So the problem is, when I create one compound object it works like it should be, but when I try to create another object using compound collision, the collision data I created in the first object is transferred to the second object too. (It is layed over the second object collision, if it has any)
Here is the code for creating the first compound object, I could use same function over and over, but I created two functions for both object to narrow down the problem.
function is called by:
Body = compound(1)
second object:
Body2 = compound2(2)
- Code: Select all
function compound(Obj)
local dim compCol(4) as integer
tempObj = FreeObject()
clone object tempObj, 8
NDB_BuildMatrix 0.0, 0.0, 0.0, 0.0, 0.0, 0.0
compCol(1) = NDB_NewtonCreateConvexHull(tempObj, 1)
NDB_AddCollisionToArray compCol(1)
delete object tempObj
compCol(2) = NDB_NewtonCreateCylinder(2.0,200.0)
NDB_AddCollisionToArray compCol(2)
NDB_BuildMatrix 0.0, 0.0, 0.0, -115.0, 0.0, 0.0
compCol(3) = NDB_NewtonCreateCylinder(7.0, 40.0, 1)
NDB_AddCollisionToArray compCol(3)
playerCol = NDB_NewtonCreateCompoundCollision()
Body = NDB_NewtonCreateBody(playerCol)
` Release the collisions, no longer needed
for col = 1 to 3
NDB_NewtonReleaseCollision compCol(col)
next col
NDB_NewtonReleaseCollision playerCol
NDB_CalculateMIBoxSolid 150.0, 8, 8, 150
NDB_NewtonBodySetMassMatrix Body, 150.0
NDB_BodySetDBProData Body, PlayerObj
NDB_BuildMatrix 0.0, rx, 0.0, 0.0, 0.0, x#
NDB_NewtonBodySetMatrix Body
NDB_NewtonBodySetAutoFreeze Body, 0
NDB_NewtonBodySetDestructorCallback Body
endfunction Body
And second, I stripped it to minimal, there should be no collision data, but debug shows that it has the same collision as first object.
- Code: Select all
function compound2(Obj)
playerCol2 = NDB_NewtonCreateCompoundCollision()
Body2 = NDB_NewtonCreateBody(playerCol2)
` Release the collisions, no longer needed
NDB_NewtonReleaseCollision playerCol2
endfunction Body2
As you can see, I have tried to use "playerCol2" and "Body2" inside the object 2 function, trying to avoid them getting together somehow.
I believe some part of the compund object creation is missing, "NDB_NewtonReleaseCollision" is something I have payed attention to when I have tried to fix this.
Is it even possible to have different compund collision object in scene? I hope it is

