erincatto / box2d

Box2D is a 2D physics engine for games
https://box2d.org
MIT License
8.09k stars 1.52k forks source link

Add userdata setters back #658

Closed thegrb93 closed 3 years ago

thegrb93 commented 3 years ago

They don't work with void though which breaks compatibility. The only solution I could think of was `body->SetUserData((b2BodyUserData)(&udata))Might just#define` the userdatas for my project void

erincatto commented 3 years ago

Setters are no longer needed. See #659

For your case do this (it seems udata is an integral value):

body->GetUserData().pointer = udata;
thegrb93 commented 3 years ago

Allright, thanks.

thegrb93 commented 3 years ago

Looks like for other types, I could do body->GetUserData() = udata as well.

thegrb93 commented 3 years ago

@erincatto there's still a signature for SetUserData in b2Body you might want to get rid of.

marauder2k7 commented 3 years ago

This doesn't seem to work anymore? are there any examples of b2_user_settings that shows how to add custom userdata?

For the time being i have modified the b2settings.h and changed all the pointers to void* but any update would mean that would need to be changed again.