Problem with Moveable newtoncreateCompoundCollision

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Problem with Moveable newtoncreateCompoundCollision

Postby Corpsman » Thu Aug 27, 2009 4:30 am

Hello, i try to use the libNewton.so under Linux KUbuntu Jaunty with Lazarus.

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

--
You want to Know more about me and my projects visit http://www.Corpsman.de
I use Newton in Balanced2
Corpsman
 
Posts: 38
Joined: Mon May 01, 2006 11:42 am

Re: Problem with Moveable newtoncreateCompoundCollision

Postby JernejL » Thu Aug 27, 2009 8:25 am

which version of newton, and are you using up to date delphi / pascal headers?
Help improving the Newton Game Dynamics WIKI
User avatar
JernejL
 
Posts: 1578
Joined: Mon Dec 06, 2004 2:00 pm
Location: Slovenia

Re: Problem with Moveable newtoncreateCompoundCollision

Postby Corpsman » Thu Aug 27, 2009 11:36 am

i Tried Newton 2.03, 2.07 and 2.08

and i do use the Official header Translation + the Bugfixes, i Posted here in the Forum..
--
You want to Know more about me and my projects visit http://www.Corpsman.de
I use Newton in Balanced2
Corpsman
 
Posts: 38
Joined: Mon May 01, 2006 11:42 am


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 9 guests

cron