luis
25-01-2007 09:14:50
i'm using 0.4 RC3 and when i used this function:
there is no way to know if your attempt to delete the body was successful....
would be nice to return bool
and since mBodies.destroyBody(mBodies.find(_name)); returns true on success, the function could end like this:
Another comment: i've seen that when you create two bodys with the same name, the first one doesnt get its coordinates updated anymore(i'm talking about its Ogre's scenenode).
Seems that the first one just gets "unreferenced" in the list of bodys to be updated their visual representation. But the physics body is still alive and beeing correctly simulated (i can see them with the debug wireframe).
In my opinion it is a bit bug-prone, shouldnt be better to throw an exception telling you the name of the body duplicated when you register two bodies with the same name?
Thanks for your great work betajaen!
//////////////////////////////////////////////////////////////////////
void scene::destroyBody(Ogre::String _name) {
mBodies.destroyBody(mBodies.find(_name));
/*std::map<std::string, body*>::iterator it = mBodies.find(_name);
if (it == mBodies.end()) {
error::getSingleton().Throw("Attempting to delete a body '" + _name + "' that does not exist!",error::WARNING, _name, "scene::destroyBody");
return;
}
delete it->second;
mBodies.erase(it);*/
}
there is no way to know if your attempt to delete the body was successful....
would be nice to return bool
and since mBodies.destroyBody(mBodies.find(_name)); returns true on success, the function could end like this:
//////////////////////////////////////////////////////////////////////
bool scene::destroyBody(Ogre::String _name) {
return mBodies.destroyBody(mBodies.find(_name));
}
Another comment: i've seen that when you create two bodys with the same name, the first one doesnt get its coordinates updated anymore(i'm talking about its Ogre's scenenode).
Seems that the first one just gets "unreferenced" in the list of bodys to be updated their visual representation. But the physics body is still alive and beeing correctly simulated (i can see them with the debug wireframe).
In my opinion it is a bit bug-prone, shouldnt be better to throw an exception telling you the name of the body duplicated when you register two bodies with the same name?
Thanks for your great work betajaen!