ThreadIndex

From Newton Wiki
Jump to: navigation, search

Purpose

The thread index parameter in callbacks is the thread index of the thread that executed the callback. This value should be sent as a parameter to newton functions that are optimized to be called within a callback if the function you are calling has a threadindex parameter (such as for example: NewtonWorldConvexCast ).

If you are calling a function outside a newton update, the thread index is not important, you can pass zero.

In-depth explanation

But if you are calling a function during a newton callback (a collsion callback for example), since newton can be set to work in mutithreaded more, it is possible that one callback is action on one body, and another in another body at the same time.

In that case, send the function you are calling the same threadindex value as you received in the callback itself.

You can see an example of that in the raycast car, when the car is working with multitreaded mode. Up to 4 cars can be solved at the same time without having to complicate the code with extra local data in each car for collectiong the convex cast information.