Hi!
I'm using Bullet-C API, and have a question about the type of the objects.
They type is defined as
#define PL_DECLARE_HANDLE(name) typedef struct name##__ { int unused; } *name
So, a handle to a rigid body type would be declared like this:
PL_DECLARE_HANDLE(plRigidBodyHandle);
And it's used like this:
void plSetPosition(plRigidBodyHandle object, const plVector3 position)
{
btRigidBody* body = reinterpret_cast< btRigidBody* >(object);
...
}
Why not simply use void* to hold the objects, and use static casts?
Thank you.
Jose
Understanding the internals of Bullet-C API
-
josemarin
- Posts: 38
- Joined: Fri Aug 12, 2005 5:37 pm
-
Erwin Coumans
- Site Admin
- Posts: 4221
- Joined: Sun Jun 26, 2005 6:43 pm
- Location: California, USA
Re: Understanding the internals of Bullet-C API
void* doesn't have type checking, handles do: for instance the compiler will prevent exchanging a rigidbody handle with a shape handle.josemarin wrote: Why not simply use void* to hold the objects, and use static casts?
Hope this helps,
Erwin
-
josemarin
- Posts: 38
- Joined: Fri Aug 12, 2005 5:37 pm
Re: Understanding the internals of Bullet-C API
And this is a good thing when you are hunting down a mysterious bug!
Thank you, Erwin.
Thank you, Erwin.