You need to sign in or sign up before continuing.
Commit 42b0b92c authored by hybrid's avatar hybrid

Two more self-assignment fixes. setMesh still resets the values, though.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2201 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 6cf999bc
...@@ -757,6 +757,9 @@ void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped) ...@@ -757,6 +757,9 @@ void CAnimatedMeshSceneNode::setLoopMode(bool playAnimationLooped)
//! playback has ended. Set this to 0 to disable the callback again. //! playback has ended. Set this to 0 to disable the callback again.
void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack* callback) void CAnimatedMeshSceneNode::setAnimationEndCallback(IAnimationEndCallBack* callback)
{ {
if (callback == LoopCallBack)
return;
if (LoopCallBack) if (LoopCallBack)
LoopCallBack->drop(); LoopCallBack->drop();
...@@ -825,11 +828,17 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) ...@@ -825,11 +828,17 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh)
if (!mesh) if (!mesh)
return; // won't set null mesh return; // won't set null mesh
if (Mesh != mesh)
{
if (Mesh) if (Mesh)
Mesh->drop(); Mesh->drop();
Mesh = mesh; Mesh = mesh;
// grab the mesh (it's non-null!)
Mesh->grab();
}
// get materials and bounding box // get materials and bounding box
Box = Mesh->getBoundingBox(); Box = Mesh->getBoundingBox();
...@@ -837,24 +846,20 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh) ...@@ -837,24 +846,20 @@ void CAnimatedMeshSceneNode::setMesh(IAnimatedMesh* mesh)
if (m) if (m)
{ {
Materials.clear(); Materials.clear();
Materials.reallocate(m->getMeshBufferCount());
video::SMaterial mat;
for (u32 i=0; i<m->getMeshBufferCount(); ++i) for (u32 i=0; i<m->getMeshBufferCount(); ++i)
{ {
IMeshBuffer* mb = m->getMeshBuffer(i); IMeshBuffer* mb = m->getMeshBuffer(i);
if (mb) if (mb)
mat = mb->getMaterial(); Materials.push_back(mb->getMaterial());
else
Materials.push_back(mat); Materials.push_back(video::SMaterial());
} }
} }
// get start and begin time // get start and begin time
setFrameLoop ( 0, Mesh->getFrameCount() ); setFrameLoop ( 0, Mesh->getFrameCount() );
// grab the mesh
if (Mesh)
Mesh->grab();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment