You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm calling new Ammo... quite often. What classes should be destroyed and when?
If I pass a new vector to btRigidBody.setAngularFactor() for instance, should I Ammo.destroy(vec) right after that? Or should I wait for the rigidbody to be destroyed as well? Or do vectors not need to be destroyed?
Or what about Ammo.btRigidBodyConstructionInfo for instance? How can I know if and when to destroy an object?
The text was updated successfully, but these errors were encountered:
If you create something with a keyword new, you should destroy it when no longer needed. When you set a property, for example a velocity, from a vector, the values get copied and you no longer need that vector afterwards. Vectors are a good candidates for re-use, however. For example, instead of creating a new Ammo vector on each transform update, you can create it once and re-use it by updating its components to update the bodies in the physics world. A collision shape could be a good candidate for destruction after the body is added to the world. Basically, if you no longer need an Ammo object and have no plans on using it in the near future - destroy it. Same with btRigidBodyConstructionInfo - destroy after the body is created.
Ah thanks for the info! From what I remember I used destroy() for basically every new object. But I was still getting out of memory crashes and I couldn't seem to fix it. I ended up moving to my own physics engine in the end, since we were only using a few features.
I'm calling
new Ammo...
quite often. What classes should be destroyed and when?If I pass a new vector to
btRigidBody.setAngularFactor()
for instance, should IAmmo.destroy(vec)
right after that? Or should I wait for the rigidbody to be destroyed as well? Or do vectors not need to be destroyed?Or what about
Ammo.btRigidBodyConstructionInfo
for instance? How can I know if and when to destroy an object?The text was updated successfully, but these errors were encountered: