Make Irrlicht identity material const

This commit is contained in:
sfan5 2025-02-26 18:06:53 +01:00
parent 2796283550
commit 7abaa8d4cd
3 changed files with 7 additions and 3 deletions

View file

@ -310,7 +310,11 @@ public:
\return The material at that index. */
virtual video::SMaterial &getMaterial(u32 num)
{
return video::IdentityMaterial;
// We return a default material since a reference can't be null,
// but note that writing to this is a mistake either by a child class
// or the caller, because getMaterialCount() is zero.
// Doing so will helpfully cause a segfault.
return const_cast<video::SMaterial&>(video::IdentityMaterial);
}
//! Get amount of materials used by this scene node.

View file

@ -472,7 +472,7 @@ public:
};
//! global const identity Material
IRRLICHT_API extern SMaterial IdentityMaterial;
IRRLICHT_API extern const SMaterial IdentityMaterial;
} // end namespace video
} // end namespace irr

View file

@ -88,7 +88,7 @@ const matrix4 IdentityMatrix(matrix4::EM4CONST_IDENTITY);
namespace video
{
SMaterial IdentityMaterial;
const SMaterial IdentityMaterial;
extern "C" IRRLICHT_API bool IRRCALLCONV isDriverSupported(E_DRIVER_TYPE driver)
{