Object ownership, refcounting and memory allocations #1475
-
Hi, I'm currently looking at the code and I have a few questions to the point where I think I missing something fundamental. Jolt has the notion of refcounting for some objects. For shapes and constraints I can allocate the memory myself by bypassing Jolt's new/delete. I can just use my own memory, call placement new and finally call Another question is around the XXXSettings classes (eg Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
See the answer above. Note that you can override Jolt's
For most of the ref counted classes, the assumption is that you can share them between unrelated objects. E.g. you can do:
The end result of this is that only 1 In the case of |
Beta Was this translation helpful? Give feedback.
-
Thanks for the answers! |
Beta Was this translation helpful? Give feedback.
Body
is not refcounted because it requires very careful memory management: it is the main class that is safe to access from multiple threads. Also, internallyBody
and its(SoftBody)MotionProperties
are allocated in the same memory block so you can't just calldelete
on them. This is done for performance reasons. I think it's the only object that is special in that way.