I have an error (m_threadSanity, dgMemory.cpp) since I tried to create some NewtonBody in differents threads !
I can explain how my code works a little : it's about a voxel engine, and I have to load a chunk of 32x32x32 blocks, and edit it (add or delete blocks).
I have 3 threads :
- the main one (rendering, ...)
- another one is used to load the blocks (from a save file or with procedural generation)
- the last one is used to build the mesh and a NewtonTree/NewtonBody with it
At startup everything seems ok, I have my chunk and the NewtonBody associated.
I use a NewtonWorldRayCast in order to find a pointed block that I can edit.
But when I tried to delete a block, and let the last thread rebuild my mesh and the NewtonBody associated, I have an error (m_threadSanity, dgMemory.cpp, ...).
(not all the time, but at least for 1 edit/2)
I checked the forum, find some things about NewtonWorldCriticalSectionLock, but :
When I look at the wiki, it show :
- Code: Select all
void NewtonWorldCriticalSectionLock (const NewtonWorld* newtonWorld);
But in my current NewtonDynamics version (3.08), i have this :
- Code: Select all
void NewtonWorldCriticalSectionLock (const NewtonWorld* const newtonWorld, int threadIndex);
I have a NewtonMaterialSetCollisionCallback for a test, where I put the NewtonWorldCriticalSectionLock with the threadIndex, but this doesn't correct the error !
The other callback in my code is the NewtonWorldRayFilterCallback, but I don't think that I need to use NewtonWorldCriticalSectionLock with it !
Finally I don't know if the problem is about a callback and NewtonWorldCriticalSectionLock, or maybe directly in the mesh builder thread !
So thank you in advance if you can explain me how to use multithreading with Newton Dynamics !
(another problem who needs another topic ^^ : If someone know how to build the latest version of NewtonDynamics with MinGW only (without VisualStudio), this would be really helpfull for me ^^ !)