if i make the CompoundCollision Moveable, by giving it a Mass, then i get a Segmentationfault in a function named : "CompoundContacts", this function seems to be a part in the Libnewton.so, so i'm not able to find the Error ,debugg, or fix it ..
I create my Objects with this code :
- Code: Select all
Procedure TNewtonConCaveHull.AddtoNewtonworld(Const Newtonworld: Pnewtonworld; Mass_: integer; Material: integer);
Var
Collision: Array Of PNewtonCollision;
rescollider: PNewtonCollision;
i,j, x: integer;
inertia: TVector3f;
ot: TVector3f;
Begin
//mass_ := 0; -- If i Uncomment this it works
If High(Fpoints) = -1 Then exit;
// Calculate the Center of Mass
ot := v3(0,0,0);
x := 0;
for i := 0 to High(Fpoints) do begin
x := x + high(Fpoints[i]) + 1;
for j := 0 to high(Fpoints[i]) do
ot := addv3(ot, fpoints[i, j]);
end;
ot := ScaleV3(1 / x, ot);
// Erstellen der Einzelnen Collides
Setlength(Collision, High(Fpoints) + 1);
x := 0;
while x < high(Fpoints) do begin
//for x := 0 to High(Fpoints) do begin
Collision[x] := NewtonCreateConvexHull(newtonworld, high(Fpoints[x]) + 1, @fpoints[x][0], 12, 0, Nil);
inc(x);
End;
rescollider := newtoncreateCompoundCollision(newtonworld, High(Collision) + 1, @Collision[0], 0); // What the Hell is a shape ID ?
NewtonConvexCollisionCalculateInertialMatrix(rescollider, @inertia, @OT);
fNewtonBody := NewtonCreateBody(NewtonWorld, rescollider);
// Remove the collider, we don't need it anymore
for x := 0 to High(Fpoints) do
NewtonReleaseCollision(NewtonWorld, Collision[x]);
NewtonReleaseCollision(NewtonWorld, rescollider);
Setlength(Collision, 0);
NewtonBodySetMassMatrix(fNewtonBody, Mass_, inertia.x * mass_, inertia.y * mass_, inertia.z * mass_);
// Now set the position of the body's matrix
NewtonBodyGetMatrix(fNewtonBody, @FMatrix[0, 0]);
fMatrix[3, 0] := fPosition.x ;
fMatrix[3, 1] := fPosition.y ;
fMatrix[3, 2] := fPosition.z ;
NewtonBodySetMatrix(fNewtonBody, @fMatrix[0, 0]);
// Finally set the callback in which the forces on this body will be applied
NewtonBodySetForceAndTorqueCallBack(fNewtonBody, ForceAndTorqueCallBack);
// FGroupid := CreateMaterialGroup(newtonworld);
NewtonBodySetMaterialGroupID(fnewtonbody, Material);
End;
and here is my callstack log :
#0 dgWorld::CompoundContacts at :0
#1 dgWorld::CalculateContacts at :0
#2 dgBroadPhaseCalculateContactsWorkerThread::ThreadExecute at :0
#3 dgBroadPhaseCollision::UpdateContacts at :0
#4 dgWorld::Update at :0
#5 Newton::UpdatePhysics at :0
#6 NewtonUpdate at :0
#7 TFORM1__TIMER1TIMER(0xb5f003d0, 0xb608af60) at unit1.pas:3498
#8 TCUSTOMTIMER__DOONTIMER(0xb5f003d0) at customtimer.pas:181
#9 TCUSTOMTIMER__TIMER(0xb5f003d0) at customtimer.pas:156
#10 GTKTIMERCB(0xb606c7a0) at gtkcallback.inc:2214
#11 ?? at :0
#12 g_main_context_dispatch at :0
#13 ?? at :0
#14 g_main_context_iteration at :0
#15 gtk_main_iteration_do at :0
#16 TGTKWIDGETSET__APPPROCESSMESSAGES(0xb7f4c0b0) at gtkwidgetset.inc:1225
#17 TAPPLICATION__HANDLEMESSAGE(0xb5f16010) at application.inc:1135
#18 TAPPLICATION__RUNLOOP(0xb5f16010) at application.inc:1269
#19 TWIDGETSET__APPRUN(0x8084320 <TAPPLICATION__RUNLOOP>, 0xb7f4c0b0) at interfacebase.inc:49
#20 TAPPLICATION__RUN(0xb5f16010) at application.inc:1257
#21 main at Balanced.lpr:19