Skip to content

Help updating graphical representation of physics bodies after physics simulation #1382

Answered by jrouwe
a1M322 asked this question in Q&A
Discussion options

You must be logged in to vote

I would suggest to use Body::Get/SetUserData. You can store a 64-bit number, so that's plenty for a pointer to an Entity or perhaps something like:

class GameObjectInterface
{
    virtual void SetWorldTransform(...) = 0;
}

class Entity : public GameObjectInterface
{
    virtual void SetWorldTransform(...) override { ... }
}

class NotAnEntity : public GameObjectInterface
{
    virtual void SetWorldTransform(...) override { ... }
}

If that's not possible then at least the lower 3 bits of any pointer will be zero (allocations are usually 8 byte aligned on 32-bit platforms, 16 byte aligned on 64-bit platforms), so you could use those bits to store the type of object that you're pointing at.

A…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by a1M322
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants