When to use collisionObject and rigidBody?

Post Reply
LJS
Posts: 9
Joined: Mon Feb 04, 2013 12:12 pm

When to use collisionObject and rigidBody?

Post by LJS »

When making the scene one puts in all kind of objects. On one side I am tended to make all as rigidbodies and most with a mass of 0 on the other side, that's propably not the rights way.

But doesn't that make it more cpu intensive compared to collision objects, i.e. a building, bench or whatever static scenery?
Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Re: When to use collisionObject and rigidBody?

Post by Spaddlewit »

btCollisionObject is the parent class of btRigidBody. So a btCollisionObject could be a Rigid Body, a Soft Body, or Kinematic body.

I would suggest keeping track of btCollisionObject pointers and upcasting to btRigidBody when needed. Then it would be easier to add things like soft bodies to your application later. :D

For objects that are static and don't move, make them Rigid Bodies with a mass of zero.
LJS
Posts: 9
Joined: Mon Feb 04, 2013 12:12 pm

Re: When to use collisionObject and rigidBody?

Post by LJS »

Thanks Spaddlewit,

@All:
from wikipedia: "Kinematics is the branch of classical mechanics that describes the motion of points, bodies (objects) and systems of bodies (groups of objects) without consideration of the causes of motion."

Then related to bullet (or any physics library) would a kinematic object mean moved by keys, joystick, simply time or whatever you want to, a force by the physics library (which needs to be implemented ofcourse). As function like colObj.collidesWith (or something like that) how does a kinematic object registers to be able to collide with?

As I don't see a class btKinematicObject (only the btKinematicCharacterController and it doesn't inherite from btCollisionObject), what then is the difference between just a btCollisionObject?

Code: Select all

btKinematicCharacterController
  - public btCharacterControllerInterface
    - public btActionInterface
@Newbies:
For your information as newby too (like me at physics/3D rendering): where btActionInterface has a real neat function (mind the abstract nulling):

Code: Select all

void updateAction( btCollisionWorld* collisionWorld, btScalar deltaTimeStep ) = 0;
EDIT: removed some real nasty typos
Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Re: When to use collisionObject and rigidBody?

Post by Spaddlewit »

LJS wrote:Then related to bullet (or any physics library) would a kinematic object mean moved by keys, joystick, simply time or whatever you want to, a force by the physics library (which needs to be implemented ofcourse). As function like colObj.collidesWith (or something like that) how does a kinematic object registers to be able to collide with?
From some random Bullet stuff I've read, apparently a Kinematic object is just like a Rigid Body, except getTransform() of the MotionState is called before EVERY tick of the simulation, not just the creation of the body.

Kinematic objects also don't accept force from other rigid bodies bumping into it -- those bodies have no effect on the kinematic object. The kinematic object however, can knock over a rigid body if it runs into it. This is what makes this type of object good for characters you control.
LJS
Posts: 9
Joined: Mon Feb 04, 2013 12:12 pm

Re: When to use collisionObject and rigidBody?

Post by LJS »

When studying the code, the btKinematicCharacterController does implement a collision object, namely btPairCachingGhostObject which is a btCollisionObject inheritence. Now, my understanding is not quite okay about the collision object (actually physics as it is kind of hard to digest but geting there) and if I understand you correctly a kinametic object is just user (coder, not player) steared and is costly due to the every tick update of its the transform.

Better said/asked, is it only a naming convention?
MaxDZ8
Posts: 149
Joined: Fri Jun 24, 2011 8:53 am

Re: When to use collisionObject and rigidBody?

Post by MaxDZ8 »

Spaddlewit wrote:btCollisionObject is the parent class of btRigidBody. So a btCollisionObject could be a Rigid Body, a Soft Body, or Kinematic body.
It appears to me this sentence conveys plenty of potential for misunderstanding (LJS correctly nailed it). I guess the wording was not well though out. I think the most problematic thing is that kinematic objects are not a class. They are a concept. A btRigidBody is kinematic if you want it to be and it does not need to be on its own "Kinematic" class.
It is worth noticing that an object instantiated from class btCollisionObject is a btCollisionObject. btCollisionObject is a concrete class and can be instantiated. So a btCollisionObject object IS NOT something derived from it. A btCollisionObject object is a btCollisionObject. It is not a btRigidBody nor a btSoftBody.
The classes are a thing.
The objects are another.
There are relations between the two but it's not quite as the above statement seems to suggest.
A more correct wording could be "a btCollisionObject pointer can point to objects of type btRigidBody, btSoftBody or btGhostObject."

Back to kinematic object, the wiki link is irrelevant. For the purpose of Bullet, a kinematic object is an object the application logic can move. The application has full responsability of moving it.
As function like colObj.collidesWith (or something like that) how does a kinematic object registers to be able to collide with?
Kinematic objects are managed just as regular btRigidBodies/btCollisionObjects to a certain degree. They take part in manifold resolution more or less as static objects. That is, you will get manifolds involving the kinematic object. As for "instant" tests, they will work as expected, as long as the kinematic object has been added to the world.
When studying the code, the btKinematicCharacterController...
Personally I don't like btKinematicCharacterController at all. I'm not quite sure I even understand your point here but what btPairCachingGhostObject is doing is to pool all the manifolds it takes part into so they don't have to be pulled out of the manifold pool. That's supposed to be more efficient. Again, btPairCachingGhostObject can be accessed by btCollisionObject pointers so it takes part "normally" in manifold generation. Mind rewording your question?
LJS
Posts: 9
Joined: Mon Feb 04, 2013 12:12 pm

Re: When to use collisionObject and rigidBody?

Post by LJS »

My direct aim with this thread is to release myself as I am stuck in I don't know what. This is merely an SOS call. Creating a collision object succeeds but then it's there. With btRigidBody, the same. Give it a mass and it will fall, lean or whatever. To get further in understanding things I did take a look at the btKinematicCharacterController. Think I shouldn't have done that yet. Anyway, thanks for helping me untie myself, as you gave me some direction.

This and the my other thread 'Collisions, how to update...' are fragments of where I got stuck. In the other thread I quoted my XY problem.

@All: Hope you'll forgive me my vagueness, it's a temporary feature of mine.
Post Reply