Crashes when porting a newton 2.x program to 3.00

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Sun Jul 15, 2012 10:26 am

MoveTill is guilty.
Since I did not change the MoveTill-Code and it only calls NewtonWorldConvexCast, there must be some change.
The whole CharacterController modes of gwX are broken: walking, digging, climbing. All used MoveTill. Jump, rotate and throw did not use MoveTill and are working.

Here's the code of MoveTill:
Code: Select all
function MoveTill(home: PExecClass; pars:PData):TData; cdecl;
var
    matrix: TMatrix4;
    pos, force: TVec3;
    len: single;
    info: array of NewtonWorldConvexCastReturnInfo;
    param: single;
    o:TWorldObject;
    i:integer; max:single;
type pvec3=^TVec3;
begin
 result:=novalue;
 o:=GetWObject(home);
 if o<>nil then begin
  NewtonBodyGetMatrix(o.newton,@matrix[0][0]); //Matrix holen
  pos:=SetVector(pars[0].float,pars[1].float,pars[2].float); //Position holen
  len:=sqrt(sqr(pos[0])+sqr(pos[1])+sqr(pos[2]));
  if len<0.001 then exit; //Keine Bewegung
  force:=ApplyMatrixToVec3(matrix,pos); //Zielposition
  i:=128;
  setlength(info,i); //Die Kollisionsinfos anlegen
  i:=NewtonWorldConvexCast(NewtonBodyGetWorld(o.newton), @matrix[0][0], @force[0], NewtonBodyGetCollision(o.newton), @param, o, @myprefilter, @info[0], i, 0);
  setlength(info,i);
  max:=1;
  if i>0 then begin
   max:=param;
   result.int:=1;
  end;
  if max>0 then begin
   MatrixSetTransform(matrix,MatrixGetTransform(matrix) * (1-max) + force * max);
   NewtonBodySetMatrix(o.newton,@matrix[0][0]);
  end;
 end;
end;
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Sun Jul 15, 2012 11:17 am

It's true: NewtonWorldConvexCast return 0 for param in some cases.
That is the case when I use the matrix of a body "A" that has contact to some other objects.

I workarounded it by adding 0.2 to the y axis of the body matrix before I pass it to convexcast.
But that's not proper I think. Do you see a good way to solve this problem? I want to move a body up that is in contact with the ground. But ConvexCast tells mit "hit" at "0" with the original objects position.

(btw In some cases, the return parameter is 1.2, is that correct? {count is 0 in that case})
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby Julio Jerez » Sun Jul 15, 2012 12:01 pm

when it returns 1.2 it means the cast does no hit anything alone the path.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Sun Jul 15, 2012 1:33 pm

Now back to the case where it returns 0...
As you can read in MoveTill, the matrix of the object is taken and a ConvexCast is fired with a prefilter that filters out the object itself.
When the object is on contact to other objets, the return param is 0. That is really weird beacuse I cannot move the object up when the ground plate is below.
When I add a BIAS to the objects matrix, it works very weirdly but better than no movement. But the bias is a workaround that does not work well. How can I do it better?
The object should not collide with old contacted bodies, when the movement is in the opposite direction than the normal.
There must be sth that has been changed since Newton 2.xx

An other workaround would be to scale the matrix to 0.99 and ConvexCast with the scaled matrix.
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby Julio Jerez » Sun Jul 15, 2012 2:00 pm

In the sandbox demos ther sia convex cast demo, you cna pick a body witth the mouse and drag it to the object that is casting see if it does what you want.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Sun Jul 15, 2012 2:42 pm

Your demos just lift the object up and cast down. The starting position of the cast is always standing free. But that's what I not want to have/need.
I want that when a object is standing on the ground and I cast upwards, there should be no collision. That behavior was implemented in Newton 2.xx, now it's different. (could be a numerical error, too. but that should not be the case since the opposite direction means it would hit the backface of the object)
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby Julio Jerez » Sun Jul 15, 2012 3:27 pm

yes, I say maybe you can set the intial matrix to reporoduce the same thing you need. and see if it works
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Mon Jul 16, 2012 1:38 am

The problem was: there were more than one controller: walk, climb, brachiate.
While the climb controller has contact to the bottom, the brachiate controller has contact to the top. I solved this by expanding movetill by a extra parameter and let the controllers find their best initial matrix. (Which needs to implemented for other controllers than the walking now :S)
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Wed Jul 25, 2012 2:03 pm

Btw I tested my .exe in a virus scanner and Symantic seems to be the only one having a problem with my prog.
https://www.virustotal.com/file/ae5251d ... 343239115/

Here's the explaination of this warning: http://www.symantec.com/security_respon ... 08-1854-99
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby carli2 » Mon Aug 27, 2012 12:23 pm

Next errors:

Code: Select all
../../source/physics/dgCollisionConvex.cpp: In member function ‘dgVector dgCollisionConvex::ReduceTriangleLarge(dgInt32&, dgBigVector*, dgBigVector*) const’:
../../source/physics/dgCollisionConvex.cpp:2529:55: error: could not convert ‘((dgBigVector*)triangleDiff)->dgBigVector::<anonymous>.dgTemplateVector<T>::operator+ [with T = double]((*(const dgTemplateVector<double>*)(& segment.dgBigVector::<anonymous>.dgTemplateVector<T>::Scale [with T = double]((num / den)))))’ from ‘dgTemplateVector<double>’ to ‘dgVector’
../../source/physics/dgCollisionConvex.cpp:2542:70: error: could not convert ‘normal.dgBigVector::<anonymous>.dgTemplateVector<T>::Scale [with T = double]((normal.dgBigVector::<anonymous>.dgTemplateVector<T>::operator% [with T = double]((*(const dgTemplateVector<double>*)(&((dgBigVector*)triangleDiff)->dgBigVector::<anonymous>))) / normal.dgBigVector::<anonymous>.dgTemplateVector<T>::operator% [with T = double]((*(const dgTemplateVector<double>*)(& normal.dgBigVector::<anonymous>)))))’ from ‘dgTemplateVector<double>’ to ‘dgVector’
carli2
 
Posts: 157
Joined: Thu Nov 10, 2011 1:53 pm

Re: Crashes when porting a newton 2.x program to 3.00

Postby Julio Jerez » Mon Aug 27, 2012 2:22 pm

was that in linux?

there is a bad bug on that function anyway, I am fixing it tonight.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Previous

Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 8 guests

cron