How do I get all the bodies of the world?

27 views
Skip to first unread message

Vaillancourt

unread,
Feb 8, 2021, 1:36:50 PM2/8/21
to ode-users
Hello!

I've looked at the code, and the available API functions, and it appears that it is not possible to get all dBody (or dJoint) instances currently present in the dWorld.

Have I missed something?

Also, and I'm not complaining, is there a specific reason for this?

I "need" it for debugging purposes (specifically, getting all the masses and see how homogeneous they are). (For now, I'll probably wrap the dBodyCreate and dBodyDestroy functions into their own calls, where I'll also keep track of what's created/destroyed.)

Thanks!

--
Vaillancourt

Oleh Derevenko

unread,
Feb 8, 2021, 5:38:10 PM2/8/21
to ode-...@googlegroups.com

You should use your objects and store handles to ODE bodies in them on creation. That is, you should not really work with ODE handles in your code directly – you should have wrapped them in some sort of your classes. And then you can do whatever you want: put them in collections, arrays, — whatever. And for the reverse reference if you get an ODE handle in a callback you can store a tag in each ODE object. That tag could be a pointer (or any other sort of key) for you to transit to your custom object having ODE handle.

 

Oleh Derevenko

-- Skype with underscore
GPG Key Fingerprint: 2F56 32DC DCD9 B2BB 06E9 39E8 A37E 5E60 376E C691

--
You received this message because you are subscribed to the Google Groups "ode-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ode-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ode-users/8aa3eb23-a5c6-45e8-8624-40582a2463cbn%40googlegroups.com.

openpgp-digital-signature.asc

Vaillancourt

unread,
Feb 8, 2021, 8:29:49 PM2/8/21
to ode-users
Thanks Oleh!

Our system allows multiple software parts to add bodies to our simulation, this is why it's not completely trivial to come up with all the bodies that are used, but I've been able to "add a layer" to be accessed in order to create and delete the bodies and so I've been able to keep track of what bodies are created there.

We do use the Data field in the dBody to store a pointer allowing us to find the owning object though, thanks for reminding us of it :)

Vaillancourt
Reply all
Reply to author
Forward
0 new messages