Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:47:58+00:00 2026-06-10T22:47:58+00:00

Box2d objects have a void* m_userData field where the user can store data. Typically

  • 0

Box2d objects have a
void* m_userData
field where the user can store data. Typically you store a pointer to another object, for instance a pointer to a sprite that shall be updated with location information every system tick.

I want to store a pointer to another object, but I would be glad if I also could store one extra bit of information. Can I do that in the most significant bit of the pointer? Could the most significant bit of an object pointer be set? I mean the internal memory is only 512 MB (I guess).

Maybe the app be rejected because of this? It’s not completely future proof, and it’s a bit of a hack…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:47:59+00:00Added an answer on June 10, 2026 at 10:47 pm

    The pointer to ‘another object’ can be whatever you like, so the typical way to do this would be to make a struct/class to hold whatever you want to store in the user data, eg:

    struct myUserData {
    
        Object* anObject;
        AnotherObject* anotherObject;
        bool oneExtraBit;//okay, 8 extra bits :)
    
    }
    

    Then you would set one of these as the user data…

    myUserData* mud = new myUserData;
    mud->anObject = ...;
    mud->oneExtraBit = ...;
    myBody->SetUserData( mud );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have an object instance and I know it is actually a boxed
Here is a utility method I have: public static Class<?>[] getTypes(Object[] objects){ Class<?>[] types
I have a problem with data binding my user control into a DGV. When
I am new to Box2d, and I have just learned that it does not
I'm using AndEngine/Box2d to develop a game. I have a ball that bounces around
I have some code that causes the box2d physics simulation to stutter forever after
I think I've configured Box2d to have some sort of maximum velocity for any
I have a method with the signature public void setFoo(int newFoo) in a model
Suppose I have the following, completely pointless code: object val1 = 1; object val2
I am using Box2d to simulate a top-down space like environment. I have an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.