after fixing the matrix problems and other stuff, I was testing the treecollisions. The first result was very promising because they worked. But after some intensive testing I had some problems. Some coltrees works perfectly, and others really behave curious. In general the curious trees don't work at all, but on some not reproduceable times somewhere a collision is noticed.

Attached Image shows what I mean.

This is my treecollision code:

- Code: Select all
`Type TPhysicBody`

Field body:Byte Ptr

Field node:Byte Ptr

Field World:TPhysicWorld

Field matrix:Float[16]

Field Mesh:TMesh

Field Volume:Float

Field AABB:TVec3[2]

Field UpdateForce:Float[3]

Field Mass:Float

Method Setup()

Node = newtonCreateBody(World.World , Body)

NewtonBodySetMatrix(Node , Mesh.Mat.grid)

newtonBodySetUserData(node ,Self)

Volume = NewtonConvexCollisionCalculateVolume(Body)

AABB[0] = New TVec3

AABB[1] = New TVec3

NewtonBodyGetAABB(Node,AABB[0].Pointer(),AABB[1].Pointer())

UpdateForce = [0.0 , 9.81 , 0.0]

World.AddPhysicBody(Self)

End Method

Method Update()

newtonBodyGetMatrix(Node , Mesh.Mat.grid)

End Method

Method SetMass(Mass:Float = 0)

Self.Mass = Mass

Local Massp:Float[3]

Local Inertia:Float[3]

NewtonConvexCollisionCalculateInertialMatrix(body,Inertia,Massp)

NewtonBodySetCentreOfMass(Node,Massp)

newtonBodySetMassMatrix(Node , Mass , inertia[0] , inertia[1], inertia[2])

End Method

Method ApplyImpulse(impactX:Float , ImpactY:Float , ImpactZ:Float , ForceX:Float , ForceY:Float , ForceZ:Float)

NewtonBodyAddImpulse(node , [ForceX , ForceY , ForceZ] , [impactX , impactY , impactZ])

End Method

End Type

Type TPhysicBodyComplexHull Extends TPhysicBody

Function Create:TPhysicBodyComplexHull (World:TPhysicWorld,Mesh:TMesh,Optimized:Byte)

Local B:TPhysicBodyComplexHull = New TPhysicBodyComplexHull

B.Mesh = Mesh

B.World = World

B.Body = NewtonCreateTreeCollision(World.World)

NewtonTreeCollisionBeginBuild(B.Body)

Local Vector:Float[9]

For Local Surf:TSurface = EachIn Mesh.surf_List

For Local I:Int = 0 To surf.no_tris-1

Local v0=surf.TriangleVertex(i,2)

Local v1=surf.TriangleVertex(i,1)

Local v2=surf.TriangleVertex(i,0)

Vector[0] = surf.VertexX(v0)

Vector[1] = surf.VertexY(v0)

Vector[2] = -surf.VertexZ(v0)

Vector[3] = surf.VertexX(v1)

Vector[4] = surf.VertexY(v1)

Vector[5] = -surf.VertexZ(v1)

Vector[6] = surf.VertexX(v2)

Vector[7] = surf.VertexY(v2)

Vector[8] = -surf.VertexZ(v2)

NewtonTreeCollisionAddFace(B.Body,3,Vector,12,0)

Next

Next

If Optimized = True Then

NewtonTreeCollisionEndBuild(B.Body , 1)

Else

NewtonTreeCollisionEndBuild(B.Body , 0)

End If

B.Setup

Return B

End Function

End Type

another thing I've noticed: If I enable simd instructions then the NewtonUpdate function causes random crashes if I add to many bodys at the same time. Without simd it works fine.

Did I miss something?