Irrlicht 1.5 issue
'ReadOnlyMaterials' is not handled properly in CAnimatedMeshSceneNode::render()
Please note that when CAnimatedMeshSceneNode::render() is called and the 'ReadOnlyMaterials' flag is true, the node's material is always used and not the material of the meshbuffer.
See the implementation of CMeshSceneNode (line 158) where this is correctly handled by:
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials;
[fixed] 'ReadOnlyMaterials' bug in CAnimatedMeshSceneNode
May I suggest the following:
Instead of:
Code: Select all
// render original meshes
if ( renderMeshes )
{
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
const video::SMaterial& material = ReadOnlyMaterials ? mb->getMaterial() : Materials[i];
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(material.MaterialType);
bool transparent = (rnd && rnd->isTransparent());
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(material);
driver->drawMeshBuffer(mb);
}
}
}
Code: Select all
// render original meshes
if ( renderMeshes )
{
for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{
video::IMaterialRenderer* rnd = driver->getMaterialRenderer(Materials[i].MaterialType);
bool transparent = (rnd && rnd->isTransparent());
// only render transparent buffer if this is the transparent render pass
// and solid only in solid pass
if (transparent == isTransparentPass)
{
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
if (RenderFromIdentity)
driver->setTransform(video::ETS_WORLD, core::matrix4() );
else if (Mesh->getMeshType() == EAMT_SKINNED)
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation * ((SSkinMeshBuffer*)mb)->Transformation);
driver->setMaterial(Materials[i]);
driver->drawMeshBuffer(mb);
}
}
}