Once any convex hulls are created, their collision test behavior is completely consistent from then on. It would seem that the point of creation (or maybe order of creation) may be where an anomaly may or may not be introduced. Somehow a convex hull may turn out slightly different given the same vertex array and arguments.
There are 2 cases being compared, A and B. They are not run in the same application session. The application is shut down and started again in between. There are differences in these two sessions, i.e. levels run in different orders.
I have extensively checked between 2 different cases to make sure of the following:
For the call to NewtonCreateConvexHull, the vertex count (=6147), vertex array, stride, tolerance and offset matrix are exactly the same. I performed diffs using output of a debugger memory window to confirm the vertex arrays and matrix were the same.
The vertex count is correct. I'm not causing Newton to overrun the array. The offset matrix is 4x4 floating point, and is an identity matrix.
for the call to NewtonCollisionCollide, maxSize=1, and the matrices are the same between case A and B (and are 4x4 floating point). The same convex hull instance is used for both colliders.
The newton world is set up the same in both cases, at launch:
- Code: Select all
m_world = NewtonCreate( NewtonAlloc, NewtonFree );
NewtonSetThreadsCount (m_world, 1);
I set up custom malloc and free callbacks, with malloc callback setting all the allocated memory to 0. I also put a call to NewtonInvalidateCache before each call to NewtonCreateConvexHull, just trying different things.
The contact, normal and depth results from the call to NewtonCollisionCollide are very slightly different in the 2 cases. It's only certain matrices that show a difference.
It will be a fatal issue for me if the computation may be affected by things such as the order that the player loads missions etc. All my data so far suggests that it's possible to create convex hulls using the exact same data, but collision tests can be slightly different, even though all data you input to these functions is exactly the same. the perturbation might be related to order of creation, or I speculate that is could depend on uninitialized variables somewhere. I'm not sure what the external influence might be. All I know is that the data I am feeding these functions is the same.
I'd appreciate any insight or suggestions. My next step would be to try and prove my case with an easy-to-compile test app, but first I want to see if there are known issues or resolutions.