diff --git a/client/shaders/cloud_shader/opengl_vertex.glsl b/client/shaders/cloud_shader/opengl_vertex.glsl index 3f2e7d9b3..ebf4aae49 100644 --- a/client/shaders/cloud_shader/opengl_vertex.glsl +++ b/client/shaders/cloud_shader/opengl_vertex.glsl @@ -1,4 +1,4 @@ -uniform lowp vec4 emissiveColor; +uniform lowp vec4 materialColor; varying lowp vec4 varColor; @@ -14,7 +14,7 @@ void main(void) vec4 color = inVertexColor; #endif - color *= emissiveColor; + color *= materialColor; varColor = color; eyeVec = -(mWorldView * inVertexPosition).xyz; diff --git a/client/shaders/object_shader/opengl_vertex.glsl b/client/shaders/object_shader/opengl_vertex.glsl index 65acba92a..05134a5f6 100644 --- a/client/shaders/object_shader/opengl_vertex.glsl +++ b/client/shaders/object_shader/opengl_vertex.glsl @@ -1,7 +1,7 @@ uniform mat4 mWorld; uniform vec3 dayLight; uniform float animationTimer; -uniform lowp vec4 emissiveColor; +uniform lowp vec4 materialColor; varying vec3 vNormal; varying vec3 vPosition; @@ -115,7 +115,7 @@ void main(void) vec4 color = inVertexColor; #endif - color *= emissiveColor; + color *= materialColor; // The alpha gives the ratio of sunlight in the incoming light. nightRatio = 1.0 - color.a; diff --git a/client/shaders/stars_shader/opengl_fragment.glsl b/client/shaders/stars_shader/opengl_fragment.glsl index 224032fa3..e991e4f94 100644 --- a/client/shaders/stars_shader/opengl_fragment.glsl +++ b/client/shaders/stars_shader/opengl_fragment.glsl @@ -1,6 +1,6 @@ -uniform lowp vec4 emissiveColor; +uniform lowp vec4 materialColor; void main(void) { - gl_FragColor = emissiveColor; + gl_FragColor = materialColor; } diff --git a/irr/include/EMaterialProps.h b/irr/include/EMaterialProps.h index 6f37c95b8..765084340 100644 --- a/irr/include/EMaterialProps.h +++ b/irr/include/EMaterialProps.h @@ -18,12 +18,6 @@ enum E_MATERIAL_PROP //! Corresponds to SMaterial::PointCloud. EMP_POINTCLOUD = 0x2, - //! Corresponds to SMaterial::GouraudShading. - EMP_GOURAUD_SHADING = 0x4, - - //! Corresponds to SMaterial::Lighting. - EMP_LIGHTING = 0x8, - //! Corresponds to SMaterial::ZBuffer. EMP_ZBUFFER = 0x10, @@ -48,9 +42,6 @@ enum E_MATERIAL_PROP //! Corresponds to SMaterial::FogEnable. EMP_FOG_ENABLE = 0x800, - //! Corresponds to SMaterial::NormalizeNormals. - EMP_NORMALIZE_NORMALS = 0x1000, - //! Corresponds to SMaterialLayer::TextureWrapU, TextureWrapV and //! TextureWrapW. EMP_TEXTURE_WRAP = 0x2000, @@ -61,9 +52,6 @@ enum E_MATERIAL_PROP //! Corresponds to SMaterial::ColorMask. EMP_COLOR_MASK = 0x8000, - //! Corresponds to SMaterial::ColorMaterial. - EMP_COLOR_MATERIAL = 0x10000, - //! Corresponds to SMaterial::UseMipMaps. EMP_USE_MIP_MAPS = 0x20000, diff --git a/irr/include/SMaterial.h b/irr/include/SMaterial.h index 8f24b9984..cceccad78 100644 --- a/irr/include/SMaterial.h +++ b/irr/include/SMaterial.h @@ -194,29 +194,6 @@ enum E_ANTI_ALIASING_MODE EAAM_ALPHA_TO_COVERAGE = 4 }; -//! These flags allow to define the interpretation of vertex color when lighting is enabled -/** Without lighting being enabled the vertex color is the only value defining the fragment color. -Once lighting is enabled, the four values for diffuse, ambient, emissive, and specular take over. -With these flags it is possible to define which lighting factor shall be defined by the vertex color -instead of the lighting factor which is the same for all faces of that material. -The default is to use vertex color for the diffuse value, another pretty common value is to use -vertex color for both diffuse and ambient factor. */ -enum E_COLOR_MATERIAL -{ - //! Don't use vertex color for lighting - ECM_NONE = 0, - //! Use vertex color for diffuse light, this is default - ECM_DIFFUSE, - //! Use vertex color for ambient light - ECM_AMBIENT, - //! Use vertex color for emissive light - ECM_EMISSIVE, - //! Use vertex color for specular light - ECM_SPECULAR, - //! Use vertex color for both diffuse and ambient light - ECM_DIFFUSE_AND_AMBIENT -}; - //! Names for polygon offset direction const c8 *const PolygonOffsetDirectionNames[] = { "Back", @@ -262,16 +239,14 @@ class SMaterial public: //! Default constructor. Creates a solid, lit material with white colors SMaterial() : - MaterialType(EMT_SOLID), AmbientColor(255, 255, 255, 255), - DiffuseColor(255, 255, 255, 255), EmissiveColor(0, 0, 0, 0), - SpecularColor(255, 255, 255, 255), Shininess(0.0f), + MaterialType(EMT_SOLID), ColorParam(0, 0, 0, 0), MaterialTypeParam(0.0f), Thickness(1.0f), ZBuffer(ECFN_LESSEQUAL), - AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL), ColorMaterial(ECM_DIFFUSE), + AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL), BlendOperation(EBO_NONE), BlendFactor(0.0f), PolygonOffsetDepthBias(0.f), PolygonOffsetSlopeScale(0.f), Wireframe(false), PointCloud(false), - GouraudShading(true), Lighting(true), ZWriteEnable(EZW_AUTO), + ZWriteEnable(EZW_AUTO), BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false), - NormalizeNormals(false), UseMipMaps(true) + UseMipMaps(true) { } @@ -281,42 +256,9 @@ public: //! Type of the material. Specifies how everything is blended together E_MATERIAL_TYPE MaterialType; - //! How much ambient light (a global light) is reflected by this material. - /** The default is full white, meaning objects are completely - globally illuminated. Reduce this if you want to see diffuse - or specular light effects. */ - SColor AmbientColor; - - //! How much diffuse light coming from a light source is reflected by this material. - /** The default is full white. */ - SColor DiffuseColor; - - //! Light emitted by this material. Default is to emit no light. - SColor EmissiveColor; - - //! How much specular light (highlights from a light) is reflected. - /** The default is to reflect white specular light. See - SMaterial::Shininess on how to enable specular lights. */ - SColor SpecularColor; - - //! Value affecting the size of specular highlights. - /** A value of 20 is common. If set to 0, no specular - highlights are being used. To activate, simply set the - shininess of a material to a value in the range [0.5;128]: - \code - sceneNode->getMaterial(0).Shininess = 20.0f; - \endcode - - You can change the color of the highlights using - \code - sceneNode->getMaterial(0).SpecularColor.set(255,255,255,255); - \endcode - - The specular color of the dynamic lights - (SLight::SpecularColor) will influence the the highlight color - too, but they are set to a useful value by default when - creating the light scene node.*/ - f32 Shininess; + //! Custom color parameter, can be used by custom shader materials. + // See MainShaderConstantSetter in Minetest. + SColor ColorParam; //! Free parameter, dependent on the material type. /** Mostly ignored, used for example in @@ -344,14 +286,6 @@ public: depth or stencil buffer, or using Red and Green for Stereo rendering. */ u8 ColorMask : 4; - //! Defines the interpretation of vertex color in the lighting equation - /** Values should be chosen from E_COLOR_MATERIAL. - When lighting is enabled, vertex color can be used instead of the - material values for light modulation. This allows to easily change e.g. the - diffuse light behavior of each face. The default, ECM_DIFFUSE, will result in - a very similar rendering as with lighting turned off, just with light shading. */ - u8 ColorMaterial : 3; - //! Store the blend operation of choice /** Values to be chosen from E_BLEND_OPERATION. */ E_BLEND_OPERATION BlendOperation : 4; @@ -392,12 +326,6 @@ public: //! Draw as point cloud or filled triangles? Default: false bool PointCloud : 1; - //! Flat or Gouraud shading? Default: true - bool GouraudShading : 1; - - //! Will this material be lighted? Default: true - bool Lighting : 1; - //! Is the zbuffer writable or is it read-only. Default: EZW_AUTO. /** If this parameter is not EZW_OFF, you probably also want to set ZBuffer to values other than ECFN_DISABLED */ @@ -412,10 +340,6 @@ public: //! Is fog enabled? Default: false bool FogEnable : 1; - //! Should normals be normalized? - /** Always use this if the mesh lit and scaled. Default: false */ - bool NormalizeNormals : 1; - //! Shall mipmaps be used if available /** Sometimes, disabling mipmap usage can be useful. Default: true */ bool UseMipMaps : 1; @@ -486,26 +410,17 @@ public: { bool different = MaterialType != b.MaterialType || - AmbientColor != b.AmbientColor || - DiffuseColor != b.DiffuseColor || - EmissiveColor != b.EmissiveColor || - SpecularColor != b.SpecularColor || - Shininess != b.Shininess || MaterialTypeParam != b.MaterialTypeParam || Thickness != b.Thickness || Wireframe != b.Wireframe || PointCloud != b.PointCloud || - GouraudShading != b.GouraudShading || - Lighting != b.Lighting || ZBuffer != b.ZBuffer || ZWriteEnable != b.ZWriteEnable || BackfaceCulling != b.BackfaceCulling || FrontfaceCulling != b.FrontfaceCulling || FogEnable != b.FogEnable || - NormalizeNormals != b.NormalizeNormals || AntiAliasing != b.AntiAliasing || ColorMask != b.ColorMask || - ColorMaterial != b.ColorMaterial || BlendOperation != b.BlendOperation || BlendFactor != b.BlendFactor || PolygonOffsetDepthBias != b.PolygonOffsetDepthBias || diff --git a/irr/include/SOverrideMaterial.h b/irr/include/SOverrideMaterial.h index c52a55b55..1ae324211 100644 --- a/irr/include/SOverrideMaterial.h +++ b/irr/include/SOverrideMaterial.h @@ -98,12 +98,6 @@ struct SOverrideMaterial case EMP_POINTCLOUD: material.PointCloud = Material.PointCloud; break; - case EMP_GOURAUD_SHADING: - material.GouraudShading = Material.GouraudShading; - break; - case EMP_LIGHTING: - material.Lighting = Material.Lighting; - break; case EMP_ZBUFFER: material.ZBuffer = Material.ZBuffer; break; @@ -140,9 +134,6 @@ struct SOverrideMaterial case EMP_FOG_ENABLE: material.FogEnable = Material.FogEnable; break; - case EMP_NORMALIZE_NORMALS: - material.NormalizeNormals = Material.NormalizeNormals; - break; case EMP_TEXTURE_WRAP: for (u32 i = 0; i < MATERIAL_MAX_TEXTURES; ++i) { if (EnableLayerProps[i]) { @@ -158,9 +149,6 @@ struct SOverrideMaterial case EMP_COLOR_MASK: material.ColorMask = Material.ColorMask; break; - case EMP_COLOR_MATERIAL: - material.ColorMaterial = Material.ColorMaterial; - break; case EMP_USE_MIP_MAPS: material.UseMipMaps = Material.UseMipMaps; break; diff --git a/src/irr_ptr.h b/irr/include/irr_ptr.h similarity index 87% rename from src/irr_ptr.h rename to irr/include/irr_ptr.h index fc4a0f558..48717976b 100644 --- a/src/irr_ptr.h +++ b/irr/include/irr_ptr.h @@ -20,8 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include #include -#include "irrlichttypes.h" -#include "IReferenceCounted.h" +namespace irr { class IReferenceCounted; } /** Shared pointer for IrrLicht objects. * @@ -37,15 +36,13 @@ with this program; if not, write to the Free Software Foundation, Inc., * from such object is a bug and may lead to a crash. Indirect construction * is possible though; see the @c grab free function for details and use cases. */ -template ::value>::type> +template class irr_ptr { ReferenceCounted *value = nullptr; public: - irr_ptr() {} + irr_ptr() noexcept = default; irr_ptr(std::nullptr_t) noexcept {} @@ -53,15 +50,15 @@ public: irr_ptr(irr_ptr &&b) noexcept { reset(b.release()); } - template ::value>::type> + template , bool> = true> irr_ptr(const irr_ptr &b) noexcept { grab(b.get()); } - template ::value>::type> + template , bool> = true> irr_ptr(irr_ptr &&b) noexcept { reset(b.release()); @@ -88,16 +85,16 @@ public: return *this; } - template ::value>::type> + template , bool> = true> irr_ptr &operator=(const irr_ptr &b) noexcept { grab(b.get()); return *this; } - template ::value>::type> + template , bool> = true> irr_ptr &operator=(irr_ptr &&b) noexcept { reset(b.release()); @@ -128,6 +125,8 @@ public: */ void reset(ReferenceCounted *object = nullptr) noexcept { + static_assert(std::is_base_of_v, + "Class is not an IReferenceCounted"); if (value) value->drop(); value = object; @@ -138,6 +137,8 @@ public: */ void grab(ReferenceCounted *object) noexcept { + static_assert(std::is_base_of_v, + "Class is not an IReferenceCounted"); if (object) object->grab(); reset(object); @@ -152,6 +153,7 @@ public: * in this function and decreased when the returned pointer is destroyed. */ template +[[nodiscard]] irr_ptr grab(ReferenceCounted *object) noexcept { irr_ptr ptr; diff --git a/irr/src/CAnimatedMeshSceneNode.cpp b/irr/src/CAnimatedMeshSceneNode.cpp index c3a71f943..295d408f3 100644 --- a/irr/src/CAnimatedMeshSceneNode.cpp +++ b/irr/src/CAnimatedMeshSceneNode.cpp @@ -258,7 +258,6 @@ void CAnimatedMeshSceneNode::render() // for debug purposes only: if (DebugDataVisible && PassCount == 1) { video::SMaterial debug_mat; - debug_mat.Lighting = false; debug_mat.AntiAliasing = 0; driver->setMaterial(debug_mat); // show normals @@ -280,7 +279,6 @@ void CAnimatedMeshSceneNode::render() } debug_mat.ZBuffer = video::ECFN_DISABLED; - debug_mat.Lighting = false; driver->setMaterial(debug_mat); if (DebugDataVisible & scene::EDS_BBOX) @@ -316,7 +314,6 @@ void CAnimatedMeshSceneNode::render() // show mesh if (DebugDataVisible & scene::EDS_MESH_WIRE_OVERLAY) { - debug_mat.Lighting = false; debug_mat.Wireframe = true; debug_mat.ZBuffer = video::ECFN_DISABLED; driver->setMaterial(debug_mat); diff --git a/irr/src/CB3DMeshFileLoader.cpp b/irr/src/CB3DMeshFileLoader.cpp index 4cd7b1d82..4d78860b2 100644 --- a/irr/src/CB3DMeshFileLoader.cpp +++ b/irr/src/CB3DMeshFileLoader.cpp @@ -485,7 +485,8 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m video::S3DVertex *Vertex = meshBuffer->getVertex(meshBuffer->getVertexCount() - 1); if (!HasVertexColors) - Vertex->Color = B3dMaterial->Material.DiffuseColor; + Vertex->Color = video::SColorf(B3dMaterial->red, B3dMaterial->green, + B3dMaterial->blue, B3dMaterial->alpha).toSColor(); else if (Vertex->Color.getAlpha() == 255) Vertex->Color.setAlpha((s32)(B3dMaterial->alpha * 255.0f)); @@ -890,23 +891,8 @@ bool CB3DMeshFileLoader::readChunkBRUS() } } - B3dMaterial.Material.DiffuseColor = video::SColorf(B3dMaterial.red, B3dMaterial.green, B3dMaterial.blue, B3dMaterial.alpha).toSColor(); - B3dMaterial.Material.ColorMaterial = video::ECM_NONE; - //------ Material fx ------ - if (B3dMaterial.fx & 1) { // full-bright - B3dMaterial.Material.AmbientColor = video::SColor(255, 255, 255, 255); - B3dMaterial.Material.Lighting = false; - } else - B3dMaterial.Material.AmbientColor = B3dMaterial.Material.DiffuseColor; - - if (B3dMaterial.fx & 2) // use vertex colors instead of brush color - B3dMaterial.Material.ColorMaterial = video::ECM_DIFFUSE_AND_AMBIENT; - - if (B3dMaterial.fx & 4) // flatshaded - B3dMaterial.Material.GouraudShading = false; - if (B3dMaterial.fx & 16) // disable backface culling B3dMaterial.Material.BackfaceCulling = false; @@ -914,8 +900,6 @@ bool CB3DMeshFileLoader::readChunkBRUS() B3dMaterial.Material.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; B3dMaterial.Material.ZWriteEnable = video::EZW_OFF; } - - B3dMaterial.Material.Shininess = B3dMaterial.shininess; } B3dStack.erase(B3dStack.size() - 1); diff --git a/irr/src/CBillboardSceneNode.cpp b/irr/src/CBillboardSceneNode.cpp index db75a2af4..1c6d88dae 100644 --- a/irr/src/CBillboardSceneNode.cpp +++ b/irr/src/CBillboardSceneNode.cpp @@ -85,7 +85,6 @@ void CBillboardSceneNode::render() if (DebugDataVisible & scene::EDS_BBOX) { driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); video::SMaterial m; - m.Lighting = false; driver->setMaterial(m); driver->draw3DBox(BBoxSafe, video::SColor(0, 208, 195, 152)); } diff --git a/irr/src/CMeshSceneNode.cpp b/irr/src/CMeshSceneNode.cpp index 7ff6cad55..030e1fd15 100644 --- a/irr/src/CMeshSceneNode.cpp +++ b/irr/src/CMeshSceneNode.cpp @@ -115,7 +115,6 @@ void CMeshSceneNode::render() // for debug purposes only: if (DebugDataVisible && PassCount == 1) { video::SMaterial m; - m.Lighting = false; m.AntiAliasing = 0; driver->setMaterial(m); diff --git a/irr/src/CNullDriver.cpp b/irr/src/CNullDriver.cpp index 91f441a14..c7b296b57 100644 --- a/irr/src/CNullDriver.cpp +++ b/irr/src/CNullDriver.cpp @@ -104,7 +104,6 @@ CNullDriver::CNullDriver(io::IFileSystem *io, const core::dimension2d &scre FeatureEnabled[i] = true; InitMaterial2D.AntiAliasing = video::EAAM_OFF; - InitMaterial2D.Lighting = false; InitMaterial2D.ZWriteEnable = video::EZW_OFF; InitMaterial2D.ZBuffer = video::ECFN_DISABLED; InitMaterial2D.UseMipMaps = false; @@ -1131,15 +1130,10 @@ void CNullDriver::drawBuffers(const scene::IVertexBuffer *vb, void CNullDriver::drawMeshBufferNormals(const scene::IMeshBuffer *mb, f32 length, SColor color) { const u32 count = mb->getVertexCount(); - const bool normalize = mb->getMaterial().NormalizeNormals; - for (u32 i = 0; i < count; ++i) { - core::vector3df normalizedNormal = mb->getNormal(i); - if (normalize) - normalizedNormal.normalize(); - + core::vector3df normal = mb->getNormal(i); const core::vector3df &pos = mb->getPosition(i); - draw3DLine(pos, pos + (normalizedNormal * length), color); + draw3DLine(pos, pos + (normal * length), color); } } @@ -1306,10 +1300,8 @@ void CNullDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible) OcclusionQueries[index].Run = 0; if (!visible) { SMaterial mat; - mat.Lighting = false; mat.AntiAliasing = 0; mat.ColorMask = ECP_NONE; - mat.GouraudShading = false; mat.ZWriteEnable = EZW_OFF; setMaterial(mat); } diff --git a/irr/src/COBJMeshFileLoader.cpp b/irr/src/COBJMeshFileLoader.cpp index bceba6a90..97e90c322 100644 --- a/irr/src/COBJMeshFileLoader.cpp +++ b/irr/src/COBJMeshFileLoader.cpp @@ -182,7 +182,7 @@ IAnimatedMesh *COBJMeshFileLoader::createMesh(io::IReadFile *file) mtlChanged = false; } if (currMtl) - v.Color = currMtl->Meshbuffer->Material.DiffuseColor; + v.Color = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); // get all vertices data in this face (current line of obj file) const core::stringc wordBuffer = copyLine(bufPtr, bufEnd); diff --git a/irr/src/COBJMeshFileLoader.h b/irr/src/COBJMeshFileLoader.h index 63e768e4f..467392a3e 100644 --- a/irr/src/COBJMeshFileLoader.h +++ b/irr/src/COBJMeshFileLoader.h @@ -43,10 +43,6 @@ private: RecalculateNormals(false) { Meshbuffer = new SMeshBuffer(); - Meshbuffer->Material.Shininess = 0.0f; - Meshbuffer->Material.AmbientColor = video::SColorf(0.2f, 0.2f, 0.2f, 1.0f).toSColor(); - Meshbuffer->Material.DiffuseColor = video::SColorf(0.8f, 0.8f, 0.8f, 1.0f).toSColor(); - Meshbuffer->Material.SpecularColor = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f).toSColor(); } SObjMtl(const SObjMtl &o) : diff --git a/irr/src/COpenGLDriver.cpp b/irr/src/COpenGLDriver.cpp index 837dc05d3..e5f070f8e 100644 --- a/irr/src/COpenGLDriver.cpp +++ b/irr/src/COpenGLDriver.cpp @@ -1840,112 +1840,11 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial &material, const SMater E_OPENGL_FIXED_PIPELINE_STATE tempState = FixedPipelineState; if (resetAllRenderStates || tempState == EOFPS_ENABLE || tempState == EOFPS_DISABLE_TO_ENABLE) { - // material colors - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.ColorMaterial != material.ColorMaterial) { - switch (material.ColorMaterial) { - case ECM_NONE: - glDisable(GL_COLOR_MATERIAL); - break; - case ECM_DIFFUSE: - glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE); - break; - case ECM_AMBIENT: - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT); - break; - case ECM_EMISSIVE: - glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); - break; - case ECM_SPECULAR: - glColorMaterial(GL_FRONT_AND_BACK, GL_SPECULAR); - break; - case ECM_DIFFUSE_AND_AMBIENT: - glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); - break; - } - if (material.ColorMaterial != ECM_NONE) - glEnable(GL_COLOR_MATERIAL); - } - - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.AmbientColor != material.AmbientColor || - lastmaterial.DiffuseColor != material.DiffuseColor || - lastmaterial.EmissiveColor != material.EmissiveColor || - lastmaterial.ColorMaterial != material.ColorMaterial) { - GLfloat color[4]; - - const f32 inv = 1.0f / 255.0f; - - if ((material.ColorMaterial != video::ECM_AMBIENT) && - (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { - color[0] = material.AmbientColor.getRed() * inv; - color[1] = material.AmbientColor.getGreen() * inv; - color[2] = material.AmbientColor.getBlue() * inv; - color[3] = material.AmbientColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color); - } - - if ((material.ColorMaterial != video::ECM_DIFFUSE) && - (material.ColorMaterial != video::ECM_DIFFUSE_AND_AMBIENT)) { - color[0] = material.DiffuseColor.getRed() * inv; - color[1] = material.DiffuseColor.getGreen() * inv; - color[2] = material.DiffuseColor.getBlue() * inv; - color[3] = material.DiffuseColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, color); - } - - if (material.ColorMaterial != video::ECM_EMISSIVE) { - color[0] = material.EmissiveColor.getRed() * inv; - color[1] = material.EmissiveColor.getGreen() * inv; - color[2] = material.EmissiveColor.getBlue() * inv; - color[3] = material.EmissiveColor.getAlpha() * inv; - glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, color); - } - } - - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.SpecularColor != material.SpecularColor || - lastmaterial.Shininess != material.Shininess || - lastmaterial.ColorMaterial != material.ColorMaterial) { - GLfloat color[4] = {0.f, 0.f, 0.f, 1.f}; - const f32 inv = 1.0f / 255.0f; - - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, material.Shininess); - // disable Specular colors if no shininess is set - if ((material.Shininess != 0.0f) && - (material.ColorMaterial != video::ECM_SPECULAR)) { -#ifdef GL_EXT_separate_specular_color - if (FeatureAvailable[IRR_EXT_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); -#endif - color[0] = material.SpecularColor.getRed() * inv; - color[1] = material.SpecularColor.getGreen() * inv; - color[2] = material.SpecularColor.getBlue() * inv; - color[3] = material.SpecularColor.getAlpha() * inv; - } -#ifdef GL_EXT_separate_specular_color - else if (FeatureAvailable[IRR_EXT_separate_specular_color]) - glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); -#endif - glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, color); - } - - // shademode - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.GouraudShading != material.GouraudShading) { - if (material.GouraudShading) - glShadeModel(GL_SMOOTH); - else - glShadeModel(GL_FLAT); - } - - // lighting - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.Lighting != material.Lighting) { - if (material.Lighting) - glEnable(GL_LIGHTING); - else - glDisable(GL_LIGHTING); + if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE) { + glDisable(GL_COLOR_MATERIAL); + glDisable(GL_LIGHTING); + glShadeModel(GL_SMOOTH); + glDisable(GL_NORMALIZE); } // fog @@ -1957,15 +1856,6 @@ void COpenGLDriver::setBasicRenderStates(const SMaterial &material, const SMater glDisable(GL_FOG); } - // normalization - if (resetAllRenderStates || tempState == EOFPS_DISABLE_TO_ENABLE || - lastmaterial.NormalizeNormals != material.NormalizeNormals) { - if (material.NormalizeNormals) - glEnable(GL_NORMALIZE); - else - glDisable(GL_NORMALIZE); - } - // Set fixed pipeline as active. tempState = EOFPS_ENABLE; } else if (tempState == EOFPS_ENABLE_TO_DISABLE) { @@ -2405,7 +2295,6 @@ void COpenGLDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaCh } SMaterial currentMaterial = (!OverrideMaterial2DEnabled) ? InitMaterial2D : OverrideMaterial2D; - currentMaterial.Lighting = false; if (texture) { setTransform(ETS_TEXTURE_0, core::IdentityMatrix); diff --git a/irr/src/CXMeshFileLoader.cpp b/irr/src/CXMeshFileLoader.cpp index 483955805..fc0e6e237 100644 --- a/irr/src/CXMeshFileLoader.cpp +++ b/irr/src/CXMeshFileLoader.cpp @@ -109,10 +109,6 @@ bool CXMeshFileLoader::load(io::IReadFile *file) // default material if nothing loaded if (!mesh->Materials.size()) { mesh->Materials.push_back(video::SMaterial()); - mesh->Materials[0].DiffuseColor.set(0xff777777); - mesh->Materials[0].Shininess = 0.f; - mesh->Materials[0].SpecularColor.set(0xff777777); - mesh->Materials[0].EmissiveColor.set(0xff000000); } u32 i; @@ -142,7 +138,7 @@ bool CXMeshFileLoader::load(io::IReadFile *file) if (!mesh->HasVertexColors) { for (u32 j = 0; j < mesh->FaceMaterialIndices.size(); ++j) { for (u32 id = j * 3 + 0; id <= j * 3 + 2; ++id) { - mesh->Vertices[mesh->Indices[id]].Color = mesh->Buffers[mesh->FaceMaterialIndices[j]]->Material.DiffuseColor; + mesh->Vertices[mesh->Indices[id]].Color = 0xff777777; } } } diff --git a/irr/src/OpenGL/Driver.cpp b/irr/src/OpenGL/Driver.cpp index 3a921d104..fe9a24758 100644 --- a/irr/src/OpenGL/Driver.cpp +++ b/irr/src/OpenGL/Driver.cpp @@ -1478,10 +1478,8 @@ void COpenGL3DriverBase::chooseMaterial2D() Material = InitMaterial2D; if (OverrideMaterial2DEnabled) { - OverrideMaterial2D.Lighting = false; OverrideMaterial2D.ZWriteEnable = EZW_OFF; OverrideMaterial2D.ZBuffer = ECFN_DISABLED; // it will be ECFN_DISABLED after merge - OverrideMaterial2D.Lighting = false; Material = OverrideMaterial2D; } diff --git a/irr/src/OpenGL/FixedPipelineRenderer.cpp b/irr/src/OpenGL/FixedPipelineRenderer.cpp index f87220b39..cef446587 100644 --- a/irr/src/OpenGL/FixedPipelineRenderer.cpp +++ b/irr/src/OpenGL/FixedPipelineRenderer.cpp @@ -24,13 +24,7 @@ COpenGL3MaterialBaseCB::COpenGL3MaterialBaseCB() : void COpenGL3MaterialBaseCB::OnSetMaterial(const SMaterial &material) { -#ifdef _DEBUG - if (material.Lighting) - os::Printer::log("Lighted material not supported in unified driver.", ELL_INFORMATION); -#endif - FogEnable = material.FogEnable; - Thickness = (material.Thickness > 0.f) ? material.Thickness : 1.f; } diff --git a/src/client/camera.cpp b/src/client/camera.cpp index f13046848..bf9ec0bd5 100644 --- a/src/client/camera.cpp +++ b/src/client/camera.cpp @@ -63,7 +63,7 @@ Camera::Camera(MapDrawControl &draw_control, Client *client, RenderingEngine *re // all other 3D scene nodes and before the GUI. m_wieldmgr = smgr->createNewSceneManager(); m_wieldmgr->addCameraSceneNode(); - m_wieldnode = new WieldMeshSceneNode(m_wieldmgr, -1, false); + m_wieldnode = new WieldMeshSceneNode(m_wieldmgr, -1); m_wieldnode->setItem(ItemStack(), m_client); m_wieldnode->drop(); // m_wieldmgr grabbed it diff --git a/src/client/client.cpp b/src/client/client.cpp index dedbebbb4..b14ef7004 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -120,7 +120,7 @@ Client::Client( m_rendering_engine(rendering_engine), m_mesh_update_manager(std::make_unique(this)), m_env( - new ClientMap(this, rendering_engine, control, 666), + make_irr(this, rendering_engine, control, 666), tsrc, this ), m_particle_manager(std::make_unique(&m_env)), diff --git a/src/client/clientenvironment.cpp b/src/client/clientenvironment.cpp index f1ec14d3b..08c5586ea 100644 --- a/src/client/clientenvironment.cpp +++ b/src/client/clientenvironment.cpp @@ -43,10 +43,10 @@ with this program; if not, write to the Free Software Foundation, Inc., ClientEnvironment */ -ClientEnvironment::ClientEnvironment(ClientMap *map, +ClientEnvironment::ClientEnvironment(irr_ptr map, ITextureSource *texturesource, Client *client): Environment(client), - m_map(map), + m_map(std::move(map)), m_texturesource(texturesource), m_client(client) { @@ -60,18 +60,17 @@ ClientEnvironment::~ClientEnvironment() delete simple_object; } - // Drop/delete map - m_map->drop(); + m_map.reset(); delete m_local_player; } -Map & ClientEnvironment::getMap() +Map &ClientEnvironment::getMap() { return *m_map; } -ClientMap & ClientEnvironment::getClientMap() +ClientMap &ClientEnvironment::getClientMap() { return *m_map; } diff --git a/src/client/clientenvironment.h b/src/client/clientenvironment.h index bdb8b9726..db31e69f2 100644 --- a/src/client/clientenvironment.h +++ b/src/client/clientenvironment.h @@ -22,6 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "environment.h" #include "util/numeric.h" // IntervalLimiter #include "activeobjectmgr.h" // client::ActiveObjectMgr +#include "irr_ptr.h" #include #ifdef SERVER @@ -66,7 +67,7 @@ typedef std::unordered_map ClientActiveObjectMap; class ClientEnvironment : public Environment { public: - ClientEnvironment(ClientMap *map, ITextureSource *texturesource, Client *client); + ClientEnvironment(irr_ptr map, ITextureSource *texturesource, Client *client); ~ClientEnvironment(); Map & getMap(); @@ -151,7 +152,7 @@ public: u64 getFrameTimeDelta() const { return m_frame_dtime; } private: - ClientMap *m_map; + irr_ptr m_map; LocalPlayer *m_local_player = nullptr; ITextureSource *m_texturesource; Client *m_client; diff --git a/src/client/clientmap.cpp b/src/client/clientmap.cpp index d722aa4fb..0dffd6aa1 100644 --- a/src/client/clientmap.cpp +++ b/src/client/clientmap.cpp @@ -1232,7 +1232,6 @@ void ClientMap::renderMapShadows(video::IVideoDriver *driver, local_material.FrontfaceCulling = material.FrontfaceCulling; } local_material.BlendOperation = material.BlendOperation; - local_material.Lighting = false; driver->setMaterial(local_material); ++material_swaps; } diff --git a/src/client/clouds.cpp b/src/client/clouds.cpp index 71028768e..a7154c2c7 100644 --- a/src/client/clouds.cpp +++ b/src/client/clouds.cpp @@ -50,7 +50,6 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc, assert(ssrc); m_enable_shaders = g_settings->getBool("enable_shaders"); - m_material.Lighting = false; m_material.BackfaceCulling = true; m_material.FogEnable = true; m_material.AntiAliasing = video::EAAM_SIMPLE; @@ -139,7 +138,7 @@ void Clouds::updateMesh() video::SColorf c_side_2_f(m_color); video::SColorf c_bottom_f(m_color); if (m_enable_shaders) { - // shader mixes the base color, set via EmissiveColor + // shader mixes the base color, set via ColorParam c_top_f = c_side_1_f = c_side_2_f = c_bottom_f = video::SColorf(1.0f, 1.0f, 1.0f, 1.0f); } c_side_1_f.r *= 0.95f; @@ -364,7 +363,7 @@ void Clouds::render() m_material.BackfaceCulling = is3D(); if (m_enable_shaders) - m_material.EmissiveColor = m_color.toSColor(); + m_material.ColorParam = m_color.toSColor(); driver->setTransform(video::ETS_WORLD, AbsoluteTransformation); driver->setMaterial(m_material); diff --git a/src/client/content_cao.cpp b/src/client/content_cao.cpp index 467c74c42..adec70983 100644 --- a/src/client/content_cao.cpp +++ b/src/client/content_cao.cpp @@ -186,10 +186,10 @@ static bool logOnce(const std::ostringstream &from, std::ostream &log_to) return true; } -static void setEmissiveColor(scene::ISceneNode *node, video::SColor color) +static void setColorParam(scene::ISceneNode *node, video::SColor color) { for (u32 i = 0; i < node->getMaterialCount(); ++i) - node->getMaterial(i).EmissiveColor = color; + node->getMaterial(i).ColorParam = color; } /* @@ -261,7 +261,6 @@ void TestCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) u16 indices[] = {0,1,2,2,3,0}; buf->append(vertices, 4, indices, 6); // Set material - buf->getMaterial().Lighting = false; buf->getMaterial().BackfaceCulling = false; buf->getMaterial().TextureLayers[0].Texture = tsrc->getTextureForMesh("rat.png"); buf->getMaterial().TextureLayers[0].MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; @@ -648,12 +647,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) auto setMaterial = [this] (video::SMaterial &mat) { mat.MaterialType = m_material_type; - mat.Lighting = false; mat.FogEnable = true; - if (m_enable_shaders) { - mat.GouraudShading = false; - mat.NormalizeNormals = true; - } mat.forEachTexture([] (auto &tex) { tex.MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; tex.MagFilter = video::ETMAGF_NEAREST; @@ -710,7 +704,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) // Set material setMaterial(buf->getMaterial()); if (m_enable_shaders) { - buf->getMaterial().EmissiveColor = c; + buf->getMaterial().ColorParam = c; } // Add to mesh @@ -736,7 +730,7 @@ void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) // Set material setMaterial(buf->getMaterial()); if (m_enable_shaders) { - buf->getMaterial().EmissiveColor = c; + buf->getMaterial().ColorParam = c; } // Add to mesh @@ -936,7 +930,7 @@ void GenericCAO::setNodeLight(const video::SColor &light_color) auto *node = getSceneNode(); if (!node) return; - setEmissiveColor(node, light_color); + setColorParam(node, light_color); } else { if (m_meshnode) { setMeshColor(m_meshnode->getMesh(), light_color); @@ -1366,15 +1360,6 @@ void GenericCAO::updateTextures(std::string mod) material.MaterialTypeParam = m_material_type_param; material.setTexture(0, tsrc->getTextureForMesh(texturestring)); - // This allows setting per-material colors. However, until a real lighting - // system is added, the code below will have no effect. Once MineTest - // has directional lighting, it should work automatically. - if (!m_prop.colors.empty()) { - material.AmbientColor = m_prop.colors[0]; - material.DiffuseColor = m_prop.colors[0]; - material.SpecularColor = m_prop.colors[0]; - } - material.forEachTexture([=] (auto &tex) { setMaterialFilters(tex, use_bilinear_filter, use_trilinear_filter, use_anisotropic_filter); @@ -1417,17 +1402,6 @@ void GenericCAO::updateTextures(std::string mod) use_anisotropic_filter); }); } - for (u32 i = 0; i < m_prop.colors.size() && - i < m_animated_meshnode->getMaterialCount(); ++i) - { - video::SMaterial &material = m_animated_meshnode->getMaterial(i); - // This allows setting per-material colors. However, until a real lighting - // system is added, the code below will have no effect. Once MineTest - // has directional lighting, it should work automatically. - material.AmbientColor = m_prop.colors[i]; - material.DiffuseColor = m_prop.colors[i]; - material.SpecularColor = m_prop.colors[i]; - } } } @@ -1445,20 +1419,9 @@ void GenericCAO::updateTextures(std::string mod) video::SMaterial &material = m_meshnode->getMaterial(i); material.MaterialType = m_material_type; material.MaterialTypeParam = m_material_type_param; - material.Lighting = false; material.setTexture(0, tsrc->getTextureForMesh(texturestring)); material.getTextureMatrix(0).makeIdentity(); - // This allows setting per-material colors. However, until a real lighting - // system is added, the code below will have no effect. Once MineTest - // has directional lighting, it should work automatically. - if(m_prop.colors.size() > i) - { - material.AmbientColor = m_prop.colors[i]; - material.DiffuseColor = m_prop.colors[i]; - material.SpecularColor = m_prop.colors[i]; - } - material.forEachTexture([=] (auto &tex) { setMaterialFilters(tex, use_bilinear_filter, use_trilinear_filter, use_anisotropic_filter); @@ -1475,15 +1438,6 @@ void GenericCAO::updateTextures(std::string mod) auto &material = m_meshnode->getMaterial(0); material.setTexture(0, tsrc->getTextureForMesh(tname)); - // This allows setting per-material colors. However, until a real lighting - // system is added, the code below will have no effect. Once MineTest - // has directional lighting, it should work automatically. - if(!m_prop.colors.empty()) { - material.AmbientColor = m_prop.colors[0]; - material.DiffuseColor = m_prop.colors[0]; - material.SpecularColor = m_prop.colors[0]; - } - material.forEachTexture([=] (auto &tex) { setMaterialFilters(tex, use_bilinear_filter, use_trilinear_filter, use_anisotropic_filter); @@ -1500,19 +1454,6 @@ void GenericCAO::updateTextures(std::string mod) auto &material = m_meshnode->getMaterial(1); material.setTexture(0, tsrc->getTextureForMesh(tname)); - // This allows setting per-material colors. However, until a real lighting - // system is added, the code below will have no effect. Once MineTest - // has directional lighting, it should work automatically. - if (m_prop.colors.size() >= 2) { - material.AmbientColor = m_prop.colors[1]; - material.DiffuseColor = m_prop.colors[1]; - material.SpecularColor = m_prop.colors[1]; - } else if (!m_prop.colors.empty()) { - material.AmbientColor = m_prop.colors[0]; - material.DiffuseColor = m_prop.colors[0]; - material.SpecularColor = m_prop.colors[0]; - } - material.forEachTexture([=] (auto &tex) { setMaterialFilters(tex, use_bilinear_filter, use_trilinear_filter, use_anisotropic_filter); diff --git a/src/client/content_cso.cpp b/src/client/content_cso.cpp index 821c2507d..733044b23 100644 --- a/src/client/content_cso.cpp +++ b/src/client/content_cso.cpp @@ -40,7 +40,6 @@ public: video::ITexture *tex = env->getGameDef()->tsrc()->getTextureForMesh("smoke_puff.png"); m_spritenode->forEachMaterial([tex] (auto &mat) { mat.TextureLayers[0].Texture = tex; - mat.Lighting = false; mat.TextureLayers[0].MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; mat.TextureLayers[0].MagFilter = video::ETMAGF_NEAREST; mat.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; diff --git a/src/client/game.cpp b/src/client/game.cpp index 6e01f2ffe..33475f338 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -595,7 +595,8 @@ public: m_client(client) {} - void setSky(Sky *sky) { + void setSky(Sky *sky) + { m_sky = sky; for (GameGlobalShaderConstantSetter *ggscs : created_nosky) { ggscs->setSky(m_sky); @@ -890,11 +891,11 @@ private: QuicktuneShortcutter *quicktune = nullptr; std::unique_ptr m_game_ui; - GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop() + irr_ptr gui_chat_console; MapDrawControl *draw_control = nullptr; Camera *camera = nullptr; - Clouds *clouds = nullptr; // Free using ->Drop() - Sky *sky = nullptr; // Free using ->Drop() + irr_ptr clouds; + irr_ptr sky; Hud *hud = nullptr; Minimap *mapper = nullptr; @@ -1263,14 +1264,11 @@ void Game::shutdown() if (m_shutdown_progress == 0.0f) showOverlayMessage(N_("Shutting down..."), 0, 0); - if (clouds) - clouds->drop(); + clouds.reset(); - if (gui_chat_console) - gui_chat_console->drop(); + gui_chat_console.reset(); - if (sky) - sky->drop(); + sky.reset(); /* cleanup menus */ while (g_menumgr.menuCount() > 0) { @@ -1524,12 +1522,12 @@ bool Game::createClient(const GameStartData &start_data) /* Clouds */ if (m_cache_enable_clouds) - clouds = new Clouds(smgr, shader_src, -1, rand()); + clouds = make_irr(smgr, shader_src, -1, rand()); /* Skybox */ - sky = new Sky(-1, m_rendering_engine, texture_src, shader_src); - scsf->setSky(sky); + sky = make_irr(-1, m_rendering_engine, texture_src, shader_src); + scsf->setSky(sky.get()); /* Pre-calculated values */ @@ -1582,7 +1580,7 @@ bool Game::initGui() chat_backend->applySettings(); // Chat backend and console - gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(), + gui_chat_console = make_irr(guienv, guienv->getRootGUIElement(), -1, chat_backend, client, &g_menumgr); if (g_settings->getBool("touch_controls")) { @@ -1873,26 +1871,26 @@ inline bool Game::handleCallbacks() } if (g_gamecallback->changepassword_requested) { - (new GUIPasswordChange(guienv, guiroot, -1, - &g_menumgr, client, texture_src))->drop(); + (void)make_irr(guienv, guiroot, -1, + &g_menumgr, client, texture_src); g_gamecallback->changepassword_requested = false; } if (g_gamecallback->changevolume_requested) { - (new GUIVolumeChange(guienv, guiroot, -1, - &g_menumgr, texture_src))->drop(); + (void)make_irr(guienv, guiroot, -1, + &g_menumgr, texture_src); g_gamecallback->changevolume_requested = false; } if (g_gamecallback->keyconfig_requested) { - (new GUIKeyChangeMenu(guienv, guiroot, -1, - &g_menumgr, texture_src))->drop(); + (void)make_irr(guienv, guiroot, -1, + &g_menumgr, texture_src); g_gamecallback->keyconfig_requested = false; } if (!g_gamecallback->show_open_url_dialog.empty()) { - (new GUIOpenURLMenu(guienv, guiroot, -1, - &g_menumgr, texture_src, g_gamecallback->show_open_url_dialog))->drop(); + (void)make_irr(guienv, guiroot, -1, + &g_menumgr, texture_src, g_gamecallback->show_open_url_dialog); g_gamecallback->show_open_url_dialog.clear(); } @@ -2038,7 +2036,7 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times, void Game::processUserInput(f32 dtime) { // Reset input if window not active or some menu is active - if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) { + if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console.get())) { if (m_game_focused) { m_game_focused = false; infostream << "Game lost focus" << std::endl; @@ -2061,7 +2059,7 @@ void Game::processUserInput(f32 dtime) m_game_focused = true; } - if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen()) { + if (!guienv->hasFocus(gui_chat_console.get()) && gui_chat_console->isOpen()) { gui_chat_console->closeConsoleAtOnce(); } @@ -4218,7 +4216,8 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, updateShadows(); } - m_game_ui->update(*stats, client, draw_control, cam, runData.pointed_old, gui_chat_console, dtime); + m_game_ui->update(*stats, client, draw_control, cam, runData.pointed_old, + gui_chat_console.get(), dtime); /* make sure menu is on top diff --git a/src/client/hud.cpp b/src/client/hud.cpp index 0a5db6858..e4c06b542 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -99,7 +99,6 @@ Hud::Hud(Client *client, LocalPlayer *player, // Initialize m_selection_material - m_selection_material.Lighting = false; if (g_settings->getBool("enable_shaders")) { IShaderSource *shdrsrc = client->getShaderSource(); @@ -121,7 +120,6 @@ Hud::Hud(Client *client, LocalPlayer *player, } // Initialize m_block_bounds_material - m_block_bounds_material.Lighting = false; if (g_settings->getBool("enable_shaders")) { IShaderSource *shdrsrc = client->getShaderSource(); auto shader_id = shdrsrc->getShader("default_shader", TILE_MATERIAL_ALPHA); @@ -155,7 +153,6 @@ Hud::Hud(Client *client, LocalPlayer *player, indices[4] = 3; indices[5] = 0; - b->getMaterial().Lighting = false; b->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; b->setHardwareMappingHint(scene::EHM_STATIC); } @@ -1205,7 +1202,6 @@ void drawItemStack( video::SMaterial &material = buf->getMaterial(); material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; - material.Lighting = false; driver->setMaterial(material); driver->drawMeshBuffer(buf); } diff --git a/src/client/joystick_controller.h b/src/client/joystick_controller.h index 98486df43..d74cc3db6 100644 --- a/src/client/joystick_controller.h +++ b/src/client/joystick_controller.h @@ -155,6 +155,11 @@ public: float getMovementDirection(); float getMovementSpeed(); + u8 getJoystickId() const + { + return m_joystick_id; + } + f32 doubling_dtime; private: diff --git a/src/client/mapblock_mesh.cpp b/src/client/mapblock_mesh.cpp index 9c0caa9d0..071b03132 100644 --- a/src/client/mapblock_mesh.cpp +++ b/src/client/mapblock_mesh.cpp @@ -615,7 +615,7 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs ZoneScoped; for (auto &m : m_mesh) - m = new scene::SMesh(); + m = make_irr(); m_enable_shaders = data->m_use_shaders; auto mesh_grid = client->getMeshGrid(); @@ -663,7 +663,7 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs m_bounding_radius = std::sqrt(collector.m_bounding_radius_sq); for (int layer = 0; layer < MAX_TILE_LAYERS; layer++) { - scene::SMesh *mesh = (scene::SMesh *)m_mesh[layer]; + scene::SMesh *mesh = static_cast(m_mesh[layer].get()); for(u32 i = 0; i < collector.prebuffers[layer].size(); i++) { @@ -736,7 +736,6 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs // Create material video::SMaterial material; - material.Lighting = false; material.BackfaceCulling = true; material.FogEnable = true; material.setTexture(0, p.layer.texture); @@ -794,10 +793,10 @@ MapBlockMesh::MapBlockMesh(Client *client, MeshMakeData *data, v3s16 camera_offs MapBlockMesh::~MapBlockMesh() { size_t sz = 0; - for (scene::IMesh *m : m_mesh) { + for (auto &&m : m_mesh) { for (u32 i = 0; i < m->getMeshBufferCount(); i++) sz += m->getMeshBuffer(i)->getSize(); - m->drop(); + m.reset(); } for (MinimapMapblock *block : m_minimap_mapblocks) delete block; @@ -866,7 +865,7 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, get_sunlight_color(&day_color, daynight_ratio); for (auto &daynight_diff : m_daynight_diffs) { - auto *mesh = m_mesh[daynight_diff.first.first]; + auto *mesh = m_mesh[daynight_diff.first.first].get(); mesh->setDirty(scene::EBT_VERTEX); // force reload to VBO scene::IMeshBuffer *buf = mesh-> getMeshBuffer(daynight_diff.first.second); diff --git a/src/client/mapblock_mesh.h b/src/client/mapblock_mesh.h index d2c651525..c52df5ed3 100644 --- a/src/client/mapblock_mesh.h +++ b/src/client/mapblock_mesh.h @@ -193,12 +193,12 @@ public: scene::IMesh *getMesh() { - return m_mesh[0]; + return m_mesh[0].get(); } scene::IMesh *getMesh(u8 layer) { - return m_mesh[layer]; + return m_mesh[layer].get(); } std::vector moveMinimapMapblocks() @@ -242,7 +242,7 @@ private: TileLayer tile; }; - scene::IMesh *m_mesh[MAX_TILE_LAYERS]; + irr_ptr m_mesh[MAX_TILE_LAYERS]; std::vector m_minimap_mapblocks; ITextureSource *m_tsrc; IShaderSource *m_shdrsrc; diff --git a/src/client/mesh.cpp b/src/client/mesh.cpp index 1e32fcfd1..9e66404e3 100644 --- a/src/client/mesh.cpp +++ b/src/client/mesh.cpp @@ -99,7 +99,6 @@ scene::IAnimatedMesh* createCubeMesh(v3f scale) scene::IMeshBuffer *buf = new scene::SMeshBuffer(); buf->append(vertices + 4 * i, 4, indices, 6); // Set default material - buf->getMaterial().Lighting = false; buf->getMaterial().MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF; buf->getMaterial().forEachTexture([] (auto &tex) { tex.MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; @@ -401,7 +400,6 @@ scene::IMesh* convertNodeboxesToMesh(const std::vector &boxes, for (u16 j = 0; j < 6; j++) { scene::IMeshBuffer *buf = new scene::SMeshBuffer(); - buf->getMaterial().Lighting = false; buf->getMaterial().forEachTexture([] (auto &tex) { tex.MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; tex.MagFilter = video::ETMAGF_NEAREST; diff --git a/src/client/minimap.cpp b/src/client/minimap.cpp index b2fc0882d..13dca5fe9 100644 --- a/src/client/minimap.cpp +++ b/src/client/minimap.cpp @@ -201,7 +201,7 @@ Minimap::Minimap(Client *client) addMode(MINIMAP_TYPE_RADAR, 128); // Initialize minimap data - data = new MinimapData; + data = std::make_unique(); data->map_invalidated = true; data->minimap_shape_round = g_settings->getBool("minimap_shape_round"); @@ -209,11 +209,11 @@ Minimap::Minimap(Client *client) setModeIndex(0); // Create mesh buffer for minimap - m_meshbuffer = getMinimapMeshBuffer(); + m_meshbuffer = createMinimapMeshBuffer(); // Initialize and start thread - m_minimap_update_thread = new MinimapUpdateThread(); - m_minimap_update_thread->data = data; + m_minimap_update_thread = std::make_unique(); + m_minimap_update_thread->data = data.get(); m_minimap_update_thread->start(); } @@ -222,7 +222,7 @@ Minimap::~Minimap() m_minimap_update_thread->stop(); m_minimap_update_thread->wait(); - m_meshbuffer->drop(); + m_meshbuffer.reset(); if (data->minimap_mask_round) data->minimap_mask_round->drop(); @@ -232,12 +232,10 @@ Minimap::~Minimap() driver->removeTexture(data->texture); driver->removeTexture(data->heightmap_texture); - for (MinimapMarker *m : m_markers) - delete m; m_markers.clear(); - delete data; - delete m_minimap_update_thread; + data.reset(); + m_minimap_update_thread.reset(); } void Minimap::addBlock(v3s16 pos, MinimapMapblock *data) @@ -552,9 +550,9 @@ v3f Minimap::getYawVec() return v3f(1.0, 0.0, 1.0); } -scene::SMeshBuffer *Minimap::getMinimapMeshBuffer() +irr_ptr Minimap::createMinimapMeshBuffer() { - scene::SMeshBuffer *buf = new scene::SMeshBuffer(); + auto buf = make_irr(); auto &vertices = buf->Vertices->Data; auto &indices = buf->Indices->Data; vertices.resize(4); @@ -612,7 +610,6 @@ void Minimap::drawMinimap(core::rect rect) tex.MinFilter = video::ETMINF_LINEAR_MIPMAP_LINEAR; tex.MagFilter = video::ETMAGF_LINEAR; }); - material.Lighting = false; material.TextureLayers[0].Texture = minimap_texture; material.TextureLayers[1].Texture = data->heightmap_texture; @@ -629,7 +626,7 @@ void Minimap::drawMinimap(core::rect rect) // Draw minimap driver->setTransform(video::ETS_WORLD, matrix); driver->setMaterial(material); - driver->drawMeshBuffer(m_meshbuffer); + driver->drawMeshBuffer(m_meshbuffer.get()); // Draw overlay video::ITexture *minimap_overlay = data->minimap_shape_round ? @@ -637,7 +634,7 @@ void Minimap::drawMinimap(core::rect rect) material.TextureLayers[0].Texture = minimap_overlay; material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; driver->setMaterial(material); - driver->drawMeshBuffer(m_meshbuffer); + driver->drawMeshBuffer(m_meshbuffer.get()); // Draw player marker on minimap if (data->minimap_shape_round) { @@ -649,7 +646,7 @@ void Minimap::drawMinimap(core::rect rect) material.TextureLayers[0].Texture = data->player_marker; driver->setTransform(video::ETS_WORLD, matrix); driver->setMaterial(material); - driver->drawMeshBuffer(m_meshbuffer); + driver->drawMeshBuffer(m_meshbuffer.get()); // Reset transformations driver->setTransform(video::ETS_VIEW, oldViewMat); @@ -687,17 +684,17 @@ void Minimap::drawMinimap(core::rect rect) } } -MinimapMarker* Minimap::addMarker(scene::ISceneNode *parent_node) +MinimapMarker *Minimap::addMarker(scene::ISceneNode *parent_node) { - MinimapMarker *m = new MinimapMarker(parent_node); - m_markers.push_back(m); - return m; + auto m = std::make_unique(parent_node); + auto ret = m.get(); + m_markers.push_back(std::move(m)); + return ret; } void Minimap::removeMarker(MinimapMarker **m) { - m_markers.remove(*m); - delete *m; + m_markers.remove_if([ptr = *m](const auto &up) { return up.get() == ptr; }); *m = nullptr; } @@ -711,7 +708,7 @@ void Minimap::updateActiveMarkers() data->mode.scan_height / 2, data->mode.map_size / 2); - for (MinimapMarker *marker : m_markers) { + for (auto &&marker : m_markers) { v3s16 pos = floatToInt(marker->parent_node->getAbsolutePosition() + cam_offset, BS) - pos_offset; if (pos.X < 0 || pos.X > data->mode.map_size || diff --git a/src/client/minimap.h b/src/client/minimap.h index f819deaf4..0c419fa63 100644 --- a/src/client/minimap.h +++ b/src/client/minimap.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "../hud.h" #include "irrlichttypes_extrabloated.h" +#include "irr_ptr.h" #include "util/thread.h" #include "voxel.h" #include @@ -148,7 +149,7 @@ public: void blitMinimapPixelsToImageSurface(video::IImage *map_image, video::IImage *heightmap_image); - scene::SMeshBuffer *getMinimapMeshBuffer(); + irr_ptr createMinimapMeshBuffer(); MinimapMarker* addMarker(scene::ISceneNode *parent_node); void removeMarker(MinimapMarker **marker); @@ -158,20 +159,20 @@ public: video::IVideoDriver *driver; Client* client; - MinimapData *data; + std::unique_ptr data; private: ITextureSource *m_tsrc; IShaderSource *m_shdrsrc; const NodeDefManager *m_ndef; - MinimapUpdateThread *m_minimap_update_thread = nullptr; - scene::SMeshBuffer *m_meshbuffer; + std::unique_ptr m_minimap_update_thread; + irr_ptr m_meshbuffer; bool m_enable_shaders; std::vector m_modes; size_t m_current_mode_index; u16 m_surface_mode_scan_height; f32 m_angle; std::mutex m_mutex; - std::list m_markers; + std::list> m_markers; std::list m_active_markers; }; diff --git a/src/client/particles.cpp b/src/client/particles.cpp index c19282424..1eab93579 100644 --- a/src/client/particles.cpp +++ b/src/client/particles.cpp @@ -989,7 +989,6 @@ video::SMaterial ParticleManager::getMaterialForParticle(const ClientParticleTex video::SMaterial material; // Texture - material.Lighting = false; material.BackfaceCulling = false; material.FogEnable = true; material.forEachTexture([] (auto &tex) { diff --git a/src/client/shader.cpp b/src/client/shader.cpp index 242fda81c..f43bc27dc 100644 --- a/src/client/shader.cpp +++ b/src/client/shader.cpp @@ -218,15 +218,15 @@ class MainShaderConstantSetter : public IShaderConstantSetter CachedVertexShaderSetting m_texture{"mTexture"}; // commonly used way to pass material color to shader - video::SColor m_emissive_color; - CachedPixelShaderSetting m_emissive_color_setting{"emissiveColor"}; + video::SColor m_material_color; + CachedPixelShaderSetting m_material_color_setting{"materialColor"}; public: ~MainShaderConstantSetter() = default; virtual void onSetMaterial(const video::SMaterial& material) override { - m_emissive_color = material.EmissiveColor; + m_material_color = material.ColorParam; } virtual void onSetConstants(video::IMaterialRendererServices *services) override @@ -254,8 +254,8 @@ public: m_texture.set(texture, services); } - video::SColorf emissive_color(m_emissive_color); - m_emissive_color_setting.set(emissive_color, services); + video::SColorf colorf(m_material_color); + m_material_color_setting.set(colorf, services); } }; diff --git a/src/client/shadows/shadowsScreenQuad.cpp b/src/client/shadows/shadowsScreenQuad.cpp index f0eb9ab4a..d1713578d 100644 --- a/src/client/shadows/shadowsScreenQuad.cpp +++ b/src/client/shadows/shadowsScreenQuad.cpp @@ -23,7 +23,6 @@ with this program; if not, write to the Free Software Foundation, Inc., shadowScreenQuad::shadowScreenQuad() { Material.Wireframe = false; - Material.Lighting = false; video::SColor color(0x0); Vertices[0] = video::S3DVertex( diff --git a/src/client/sky.cpp b/src/client/sky.cpp index 50ef56498..65577418e 100644 --- a/src/client/sky.cpp +++ b/src/client/sky.cpp @@ -39,7 +39,6 @@ using namespace irr::core; static video::SMaterial baseMaterial() { video::SMaterial mat; - mat.Lighting = false; mat.ZBuffer = video::ECFN_DISABLED; mat.ZWriteEnable = video::EZW_OFF; mat.AntiAliasing = 0; @@ -95,7 +94,6 @@ Sky::Sky(s32 id, RenderingEngine *rendering_engine, ITextureSource *tsrc, IShade for (int i = 5; i < 11; i++) { m_materials[i] = baseMaterial(); - m_materials[i].Lighting = true; m_materials[i].MaterialType = video::EMT_SOLID; } @@ -169,7 +167,8 @@ void Sky::render() video::SColor texel_color (255, texel->getRed(), texel->getGreen(), texel->getBlue()); m_sun_tonemap->unlock(); - m_materials[3].EmissiveColor = texel_color; + // Only accessed by our code later, not used by a shader + m_materials[3].ColorParam = texel_color; } if (m_moon_tonemap) { @@ -178,7 +177,8 @@ void Sky::render() video::SColor texel_color (255, texel->getRed(), texel->getGreen(), texel->getBlue()); m_moon_tonemap->unlock(); - m_materials[4].EmissiveColor = texel_color; + // Only accessed by our code later, not used by a shader + m_materials[4].ColorParam = texel_color; } const f32 t = 1.0f; @@ -465,11 +465,11 @@ void Sky::update(float time_of_day, float time_brightness, // which keeps previous behavior. if (m_sun_tonemap && m_default_tint) { pointcolor_sun_f.r = pointcolor_light * - (float)m_materials[3].EmissiveColor.getRed() / 255; + (float)m_materials[3].ColorParam.getRed() / 255; pointcolor_sun_f.b = pointcolor_light * - (float)m_materials[3].EmissiveColor.getBlue() / 255; + (float)m_materials[3].ColorParam.getBlue() / 255; pointcolor_sun_f.g = pointcolor_light * - (float)m_materials[3].EmissiveColor.getGreen() / 255; + (float)m_materials[3].ColorParam.getGreen() / 255; } else if (!m_default_tint) { pointcolor_sun_f = m_sky_params.fog_sun_tint; } else { @@ -498,11 +498,11 @@ void Sky::update(float time_of_day, float time_brightness, } if (m_moon_tonemap && m_default_tint) { pointcolor_moon_f.r = pointcolor_light * - (float)m_materials[4].EmissiveColor.getRed() / 255; + (float)m_materials[4].ColorParam.getRed() / 255; pointcolor_moon_f.b = pointcolor_light * - (float)m_materials[4].EmissiveColor.getBlue() / 255; + (float)m_materials[4].ColorParam.getBlue() / 255; pointcolor_moon_f.g = pointcolor_light * - (float)m_materials[4].EmissiveColor.getGreen() / 255; + (float)m_materials[4].ColorParam.getGreen() / 255; } video::SColor pointcolor_sun = pointcolor_sun_f.toSColor(); @@ -603,11 +603,8 @@ void Sky::draw_sun(video::IVideoDriver *driver, const video::SColor &suncolor, // Another magic number that contributes to the ratio 1.57 sun/moon size // difference. float d = (sunsize * 1.7) * m_sun_params.scale; - video::SColor c; - if (m_sun_tonemap) - c = video::SColor(0, 0, 0, 0); - else - c = video::SColor(255, 255, 255, 255); + video::SColor c = m_sun_tonemap ? m_materials[3].ColorParam : + video::SColor(255, 255, 255, 255); draw_sky_body(vertices, -d, d, c); place_sky_body(vertices, 90, wicked_time_of_day * 360 - 90); driver->drawIndexedTriangleList(&vertices[0], 4, indices, 2); @@ -660,11 +657,8 @@ void Sky::draw_moon(video::IVideoDriver *driver, const video::SColor &mooncolor, // Another magic number that contributes to the ratio 1.57 sun/moon size // difference. float d = (moonsize * 1.9) * m_moon_params.scale; - video::SColor c; - if (m_moon_tonemap) - c = video::SColor(0, 0, 0, 0); - else - c = video::SColor(255, 255, 255, 255); + video::SColor c = m_sun_tonemap ? m_materials[4].ColorParam : + video::SColor(255, 255, 255, 255); draw_sky_body(vertices, -d, d, c); place_sky_body(vertices, -90, wicked_time_of_day * 360 - 90); driver->drawIndexedTriangleList(&vertices[0], 4, indices, 2); @@ -689,7 +683,7 @@ void Sky::draw_stars(video::IVideoDriver * driver, float wicked_time_of_day) if (color.a <= 0.0f) // Stars are only drawn when not fully transparent return; if (m_enable_shaders) - m_materials[0].EmissiveColor = color.toSColor(); + m_materials[0].ColorParam = color.toSColor(); else setMeshBufferColor(m_stars.get(), color.toSColor()); @@ -745,7 +739,6 @@ void Sky::setSunTexture(const std::string &sun_texture, m_sun_params.tonemap = sun_tonemap; m_sun_tonemap = tsrc->isKnownSourceImage(sun_tonemap) ? tsrc->getTexture(sun_tonemap) : nullptr; - m_materials[3].Lighting = !!m_sun_tonemap; if (m_sun_params.texture == sun_texture && !m_first_update) return; @@ -765,7 +758,6 @@ void Sky::setSunTexture(const std::string &sun_texture, m_materials[3].setTexture(0, m_sun_texture); m_materials[3].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; disableTextureFiltering(m_materials[3]); - m_materials[3].Lighting = !!m_sun_tonemap; } } @@ -789,7 +781,6 @@ void Sky::setMoonTexture(const std::string &moon_texture, m_moon_params.tonemap = moon_tonemap; m_moon_tonemap = tsrc->isKnownSourceImage(moon_tonemap) ? tsrc->getTexture(moon_tonemap) : nullptr; - m_materials[4].Lighting = !!m_moon_tonemap; if (m_moon_params.texture == moon_texture && !m_first_update) return; @@ -809,7 +800,6 @@ void Sky::setMoonTexture(const std::string &moon_texture, m_materials[4].setTexture(0, m_moon_texture); m_materials[4].MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; disableTextureFiltering(m_materials[4]); - m_materials[4].Lighting = !!m_moon_tonemap; } } diff --git a/src/client/wieldmesh.cpp b/src/client/wieldmesh.cpp index 148130606..e66214ae6 100644 --- a/src/client/wieldmesh.cpp +++ b/src/client/wieldmesh.cpp @@ -194,10 +194,9 @@ private: static ExtrusionMeshCache *g_extrusion_mesh_cache = nullptr; -WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id, bool lighting): +WieldMeshSceneNode::WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id): scene::ISceneNode(mgr->getRootSceneNode(), mgr, id), - m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF), - m_lighting(lighting) + m_material_type(video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF) { m_enable_shaders = g_settings->getBool("enable_shaders"); m_anisotropic_filter = g_settings->getBool("anisotropic_filter"); @@ -390,8 +389,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che // overlay is white, if present m_colors.emplace_back(true, video::SColor(0xFFFFFFFF)); // initialize the color - if (!m_lighting) - setColor(video::SColor(0xFFFFFFFF)); + setColor(video::SColor(0xFFFFFFFF)); return; } @@ -468,8 +466,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che } // initialize the color - if (!m_lighting) - setColor(video::SColor(0xFFFFFFFF)); + setColor(video::SColor(0xFFFFFFFF)); return; } else { const std::string inventory_image = item.getInventoryImage(idef); @@ -485,8 +482,7 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che m_colors.emplace_back(true, video::SColor(0xFFFFFFFF)); // initialize the color - if (!m_lighting) - setColor(video::SColor(0xFFFFFFFF)); + setColor(video::SColor(0xFFFFFFFF)); return; } @@ -496,7 +492,6 @@ void WieldMeshSceneNode::setItem(const ItemStack &item, Client *client, bool che void WieldMeshSceneNode::setColor(video::SColor c) { - assert(!m_lighting); scene::IMesh *mesh = m_meshnode->getMesh(); if (!mesh) return; @@ -535,7 +530,7 @@ void WieldMeshSceneNode::setNodeLightColor(video::SColor color) if (m_enable_shaders) { for (u32 i = 0; i < m_meshnode->getMaterialCount(); ++i) { video::SMaterial &material = m_meshnode->getMaterial(i); - material.EmissiveColor = color; + material.ColorParam = color; } } else { setColor(color); @@ -565,11 +560,6 @@ void WieldMeshSceneNode::changeToMesh(scene::IMesh *mesh) mesh->setHardwareMappingHint(scene::EHM_DYNAMIC); } - m_meshnode->forEachMaterial([this] (auto &mat) { - mat.Lighting = m_lighting; - // need to normalize normals when lighting is enabled (because of setScale()) - mat.NormalizeNormals = m_lighting; - }); m_meshnode->setVisible(true); } @@ -667,7 +657,6 @@ void getItemMesh(Client *client, const ItemStack &item, ItemMesh *result) tex.MagFilter = video::ETMAGF_NEAREST; }); material.BackfaceCulling = cull_backface; - material.Lighting = false; } rotateMeshXZby(mesh, -45); @@ -720,7 +709,6 @@ scene::SMesh *getExtrudedMesh(ITextureSource *tsrc, tex.MagFilter = video::ETMAGF_NEAREST; }); material.BackfaceCulling = true; - material.Lighting = false; material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; material.MaterialTypeParam = 0.5f; } diff --git a/src/client/wieldmesh.h b/src/client/wieldmesh.h index e2c6cd445..08240c8ef 100644 --- a/src/client/wieldmesh.h +++ b/src/client/wieldmesh.h @@ -104,7 +104,7 @@ struct ItemMesh class WieldMeshSceneNode : public scene::ISceneNode { public: - WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id = -1, bool lighting = false); + WieldMeshSceneNode(scene::ISceneManager *mgr, s32 id = -1); virtual ~WieldMeshSceneNode(); void setCube(const ContentFeatures &f, v3f wield_scale); @@ -132,9 +132,6 @@ private: scene::IMeshSceneNode *m_meshnode = nullptr; video::E_MATERIAL_TYPE m_material_type; - // True if SMaterial::Lighting should be enabled. - bool m_lighting; - bool m_enable_shaders; bool m_anisotropic_filter; bool m_bilinear_filter; diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 0371c26f3..40a445a0c 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -3976,10 +3976,9 @@ bool GUIFormSpecMenu::preprocessEvent(const SEvent& event) } if (event.EventType == irr::EET_JOYSTICK_INPUT_EVENT) { - /* TODO add a check like: - if (event.JoystickEvent != joystick_we_listen_for) + if (event.JoystickEvent.Joystick != m_joystick->getJoystickId()) return false; - */ + bool handled = m_joystick->handleEvent(event.JoystickEvent); if (handled) { if (m_joystick->wasKeyDown(KeyType::ESC)) { diff --git a/src/gui/guiScene.cpp b/src/gui/guiScene.cpp index a26cfa93f..9293ebe22 100644 --- a/src/gui/guiScene.cpp +++ b/src/gui/guiScene.cpp @@ -67,7 +67,6 @@ void GUIScene::setTexture(u32 idx, video::ITexture *texture) material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; material.MaterialTypeParam = 0.5f; material.TextureLayers[0].Texture = texture; - material.Lighting = false; material.FogEnable = true; material.TextureLayers[0].MinFilter = video::ETMINF_NEAREST_MIPMAP_NEAREST; material.TextureLayers[0].MagFilter = video::ETMAGF_NEAREST; diff --git a/src/irrlicht_changes/CGUITTFont.cpp b/src/irrlicht_changes/CGUITTFont.cpp index 4f5f52b4e..022ab46b0 100644 --- a/src/irrlicht_changes/CGUITTFont.cpp +++ b/src/irrlicht_changes/CGUITTFont.cpp @@ -1098,13 +1098,9 @@ core::array CGUITTFont::addTextSceneNode(const wchar_t* text // the default font material SMaterial mat; - mat.Lighting = true; mat.ZWriteEnable = video::EZW_OFF; - mat.NormalizeNormals = true; - mat.ColorMaterial = video::ECM_NONE; mat.MaterialType = use_transparency ? video::EMT_TRANSPARENT_ALPHA_CHANNEL : video::EMT_SOLID; mat.MaterialTypeParam = 0.01f; - mat.DiffuseColor = color; wchar_t current_char = 0, previous_char = 0; u32 n = 0; diff --git a/src/unittest/test_irrptr.cpp b/src/unittest/test_irrptr.cpp index befeefc73..61d1e302c 100644 --- a/src/unittest/test_irrptr.cpp +++ b/src/unittest/test_irrptr.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "exceptions.h" #include "irr_ptr.h" +#include "IReferenceCounted.h" class TestIrrPtr : public TestBase {