Add/Remove improvement

Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Add/Remove improvement

Post by Jack »

I suggest to improve addRigidBody and removeRigidBody. It would be very nice to return bool result of the function. Return true, if object was actually added/removed. Return false if object already exists (for Add operation) or if object is not in scene (for Remove operation)...................................
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

:cry:
User avatar
jacmoe
Posts: 9
Joined: Fri Aug 05, 2005 2:59 pm

Post by jacmoe »

If you are keen on getting this functionality, submit a patch, Jack!
That way this doesn't get lost because Erwin didn't see it. :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

It would be better if the user doesn't try to add objects twice, or try to remove objects that are not added. But it's easy to add such feedback, so I'll add it.

Thanks for the suggestion,
Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

Erwin Coumans wrote:It would be better if the user doesn't try to add objects twice, or try to remove objects that are not added. But it's easy to add such feedback, so I'll add it.

Thanks for the suggestion,
Erwin
:cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
:cry: not added in 2.37 :cry:
:cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
User avatar
jacmoe
Posts: 9
Joined: Fri Aug 05, 2005 2:59 pm

Post by jacmoe »

It would be better if you kept track of what objects you did add, so that you can remove those.
You should do that in your physics/collision manager.
If the lack of this feature prevents you from using Bullet, you have serious issues in your coding. :wink:

If you really want this, and can't wait: Do It Yourself. :)
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

But it's easy to add such feedback, so I'll add it.
It's not that easy actually, it would make the API inconsistent:
The problem is that once you start with such 'improvement' there is no end... to be consistent, all API's should return true/false.

It's best to just do the check on the application side. Why would someone want to delete random things he doesn't know if they are already deleted?

I can help by adding a 'findRigidbody', and you just call that first.
Would that help?

Erwin
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

Erwin Coumans wrote:
But it's easy to add such feedback, so I'll add it.
It's not that easy actually, it would make the API inconsistent:
The problem is that once you start with such 'improvement' there is no end... to be consistent, all API's should return true/false.

It's best to just do the check on the application side. Why would someone want to delete random things he doesn't know if they are already deleted?

I can help by adding a 'findRigidbody', and you just call that first.
Would that help?

Erwin
Well...Let's come from other side.
It would be useful if Rigidbody could mantain IN_SCENE flag. You set/reset IN_SCENE flag on add/remove operation. And there will be new method in Rigidbody: bool isInScene(void). Like isStaticObject(), isKinematicObject()....Great?

P.S. Not only me, but you also need this flag. You need it to prevent adding body in several scenes at the same time....
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Post by Erwin Coumans »

rigidbody->getBroadphaseHandle() returns non-zero when the body is added to the dynamics/collision world, and 0 when remove/not added.
We can have some bool isInWorld() checking this getBroadphaseHandle.

Does that help?
Erwin
Jack wrote: Well...Let's come from other side.
It would be useful if Rigidbody could mantain IN_SCENE flag. You set/reset IN_SCENE flag on add/remove operation. And there will be new method in Rigidbody: bool isInScene(void). Like isStaticObject(), isKinematicObject()....Great?
Jack
Posts: 59
Joined: Thu Aug 31, 2006 11:51 am

Post by Jack »

Yes. That is OK!
Erwin Coumans wrote:rigidbody->getBroadphaseHandle() returns non-zero when the body is added to the dynamics/collision world, and 0 when remove/not added.
We can have some bool isInWorld() checking this getBroadphaseHandle.

Does that help?
Erwin
Jack wrote: Well...Let's come from other side.
It would be useful if Rigidbody could mantain IN_SCENE flag. You set/reset IN_SCENE flag on add/remove operation. And there will be new method in Rigidbody: bool isInScene(void). Like isStaticObject(), isKinematicObject()....Great?