Separate colliders and rigidbodies?

Post Reply
woew1690
Posts: 5
Joined: Thu Dec 06, 2018 12:34 pm

Separate colliders and rigidbodies?

Post by woew1690 »

For my engine I'm trying to do something similar to what Unity does, where you have a component for the rigidbody, and another component for the collider (whether that be a sphere, box, convex hull, w\e). However, unless I'm doing something wrong, rigidbodies in Bullet seem to rely on having some sort of collision shape, I wouldn't be able to apply it separately. Is there some way this is possible, am I just doing something wrong?

Thanks!
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Separate colliders and rigidbodies?

Post by drleviathan »

I don't understand your distinctions between Unity (which is a game platform and can be configured to use Bullet for its physics engine) and Bullet (which is just a physics engine). It sounds to me like you're confusing the RigidBody (which would be your Collider) with a GameObject (which would represent your Thing in the game and would be a block of logic you would have to write yourself).

The RigidBody has: (a) transform+velocities, (b) mass properties, and (c) a shape. It IS the Collider.

The RigidBody does not necessarily have a visual aspect (like a model or mesh) unless you use its shape to generate that mesh. Normally in a game implementation that uses Bullet you would have a GameObject which has (a) a VisualModel and (b) a Collider (aka RigidBody, usually bridged by a MotionState) that represents it in the physics simulation whose shape might not use the visual model at all (maybe it collides like a Box or Sphere).
woew1690
Posts: 5
Joined: Thu Dec 06, 2018 12:34 pm

Re: Separate colliders and rigidbodies?

Post by woew1690 »

I don't understand your distinctions between Unity (which is a game platform and can be configured to use Bullet for its physics engine) and Bullet (which is just a physics engine).
There's no "distinction" I'm making here. I'm setting up my own game engine, and am trying to do something similar to how Unity does it.

In Unity, objects can have a rigidbody component, which will handle things like gravitational force upon an object, and they can have a collider object, which can be a box collision, sphere collision, convex hull, or whatever. Neither component is mutually exclusive. A rigidbody component on an object within Unity will have proper gravitation force, mass, and the like. As such, you can have a collider object or a rigidbody object on an object, with neither being required for the other. With no rigid body, no gravity.

I'm simplifying it a bit here, and maybe they separate things in their own code and I'm just being ridiculous.

Regardless, I appreciate the answer.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: Separate colliders and rigidbodies?

Post by drleviathan »

I see. Then I think the translation from Unity's component system to Bullet would go something like this:

Object with RigidBody and Collider components --> dynamic Bullet RigidBody with Shape

Object with RigidBody component --> dynamic Bullet RigidBody with Shape but set collisionless

Object with Collider component --> static RigidBody with Shape

I assume Unity has an "Animation" component that allows an Object to move along a specific path. Such an object would correspond to a kinematic Bullet RigidBody.
woew1690
Posts: 5
Joined: Thu Dec 06, 2018 12:34 pm

Re: Separate colliders and rigidbodies?

Post by woew1690 »

Alright, I have an idea of how to go about doing it now. Thanks for the help.
Post Reply