NewtonCreateHeightFieldCollision Option

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Mon Sep 22, 2008 12:49 pm

In sent you a PM with soem new powaa.

how do I reproduce the error, I only hit the arrow key and the carrier move, but I do not know what to do to reproduce the bug.
I see that the small vehicle in the water is an aphybium vehicle, am I suppose to drive it to land?

It that litle vehicle sopport to drive on the island? :mrgreen: :mrgreen:
hwo do I drive it, the controll keys move the big ship,
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Mon Sep 22, 2008 4:01 pm

Just linking in the new powah... ;)
Press 1 or 2 to take control of the two amphibious vehicles :)
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Mon Sep 22, 2008 6:41 pm

wow you are no going to veleive this, but I forgot to finish teh secung path pof the ray cast fintion, :oops: :oops:
I do not know hwo I for got to complete that. I hop wis dod not cause too much problem to oteh people. :cry:

here is the function, and as you cna see whn eteh diagonal is reverse I have and assert zero, so teh ray will return grabage.
I will fix that and send you anoeth update.
Let us take one bug at a time.

Code: Select all
inline dgFloat32 NewtonHeightFieldCollision::RayCastCell (dgInt32 xIndex0, dgInt32 zIndex0, const dgVector& p0, const dgVector& p1, dgVector& normalOut) const
{
   dgFloat32 t;
   dgInt32 base;
   dgInt32 triangle[3];
   dgVector points[4];

   // get the 3d point at the corner of the cell
   
   base = zIndex0 * m_width + xIndex0;
   
   points[0 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale, dgFloat32 (m_elevationMap[base]) * m_verticalScale,            (zIndex0 + 0) * m_horizontalScale, dgFloat32 (0.0f));
   points[0 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale, dgFloat32 (m_elevationMap[base + 1]) * m_verticalScale,           (zIndex0 + 0) * m_horizontalScale, dgFloat32 (0.0f));
   points[1 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale, dgFloat32 (m_elevationMap[base + m_width + 1]) * m_verticalScale, (zIndex0 + 1) * m_horizontalScale, dgFloat32 (0.0f));
   points[1 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale, dgFloat32 (m_elevationMap[base + m_width + 0]) * m_verticalScale, (zIndex0 + 1) * m_horizontalScale, dgFloat32 (0.0f));
   
   t = dgFloat32 (1.2f);
   if (m_diagonalMode) {

      triangle[0] = 1;
      triangle[1] = 2;
      triangle[2] = 3;
      _ASSERTE (0);
/*
      if (dgRayPolygonIntersect (p0, p1, &points[0].m_x, sizeof (dgVector), triangle, 3, t, normalOut)){
         return t;
      }

      triangle[0] = 1;
      triangle[1] = 0;
      triangle[2] = 2;
      if (dgRayPolygonIntersect (p0, p1, &points[0].m_x, sizeof (dgVector), triangle, 3, t, normalOut)){
         return t;
      }
*/
   } else {

      triangle[0] = 0;
      triangle[1] = 2;
      triangle[2] = 3;

      dgVector e10 (points[2] - points[0]);
      dgVector e20 (points[3] - points[0]);
      dgVector normal (e10 * e20);
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
         return t;
      }

      triangle[0] = 0;
      triangle[1] = 3;
      triangle[2] = 1;

//      dgVector f10 (points[3] - points[0]);
      dgVector e30 (points[1] - points[0]);
      normal = e20 * e30;
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
         return t;
      }

   }

   return t;
}
 


and you are righ the ray cast in worn, becaus eit bil dthe faces wit incorrectly
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Mon Sep 22, 2008 8:53 pm

Hi julio, has the bug been found now? Also, what word is there on supporting alternating diagonals? Seems the thread has been hijacked slightly :wink:
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Mon Sep 22, 2008 9:59 pm

was you bug reletare to ray cast, if so they you are right the ray case is incompleted, and I fixed.
send me a for and SDK replacement.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Mon Sep 22, 2008 10:27 pm

I don't think my problem is raycast related as objects would fall through on their own. I'm also asking about using alternating diagonals as oppose to having uniform diagonals. I'm also saying that the "debug view" Newton gives me is the horizontal inverse of what is actually being represented. If you could send me the new version as well I'd be grateful though.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Wed Sep 24, 2008 9:06 am

wow this is embarrasing, theey is still anoeth Bug, if you look at teh funtion you will see that it calculate teh normal in a local varible, but it never opdat the imput normal.
Also teh digonal were inverted
It is fix now, can you tyr again
also did you build the joint library with double?

Code: Select all
inline dgFloat32 NewtonHeightFieldCollision::RayCastCell (dgInt32 xIndex0, dgInt32 zIndex0, const dgVector& p0, const dgVector& p1, dgVector& normalOut) const
{
   dgFloat32 t;
   dgInt32 base;
   dgInt32 triangle[3];
   dgVector points[4];

   // get the 3d point at the corner of the cell
   
   base = zIndex0 * m_width + xIndex0;
   
   points[0 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale, dgFloat32 (m_elevationMap[base]) * m_verticalScale,            (zIndex0 + 0) * m_horizontalScale, dgFloat32 (0.0f));
   points[0 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale, dgFloat32 (m_elevationMap[base + 1]) * m_verticalScale,           (zIndex0 + 0) * m_horizontalScale, dgFloat32 (0.0f));
   points[1 * 2 + 1] = dgVector ((xIndex0 + 1) * m_horizontalScale, dgFloat32 (m_elevationMap[base + m_width + 1]) * m_verticalScale, (zIndex0 + 1) * m_horizontalScale, dgFloat32 (0.0f));
   points[1 * 2 + 0] = dgVector ((xIndex0 + 0) * m_horizontalScale, dgFloat32 (m_elevationMap[base + m_width + 0]) * m_verticalScale, (zIndex0 + 1) * m_horizontalScale, dgFloat32 (0.0f));
   
   t = dgFloat32 (1.2f);

// this test was wrong too.
   if (!m_diagonalMode) {
      triangle[0] = 1;
      triangle[1] = 2;
      triangle[2] = 3;

      dgVector e10 (points[2] - points[1]);
      dgVector e20 (points[3] - points[1]);
      dgVector normal (e10 * e20);
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
// this was the bug fo the boggus normal. I was calculatio teh normal in a local variable and never copoine back
         normalOut = normal;
         return t;
      }

      triangle[0] = 1;
      triangle[1] = 0;
      triangle[2] = 2;

      dgVector e30 (points[0] - points[1]);
      normal = e30 * e10;
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
// this was the bug fo the boggus normal. I was calculatio teh normal in a local variable and never copoine back
         normalOut = normal;
         return t;
      }

   } else {

      triangle[0] = 0;
      triangle[1] = 2;
      triangle[2] = 3;

      dgVector e10 (points[2] - points[0]);
      dgVector e20 (points[3] - points[0]);
      dgVector normal (e10 * e20);
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
// this was the bug fo the boggus normal. I was calculatio teh normal in a local variable and never copoine back
         normalOut = normal;
         return t;
      }

      triangle[0] = 0;
      triangle[1] = 3;
      triangle[2] = 1;

      dgVector e30 (points[1] - points[0]);
      normal = e20 * e30;
      t = dgRayPolygonIntersect (p0, p1, normal, &points[0].m_x, sizeof (dgVector), triangle, 3);
      if (t < dgFloat32 (1.0f)){
// this was the bug fo the boggus normal. I was calculatio teh normal in a local variable and never copoine back
         normalOut = normal;
         return t;
      }
   }

   return t;
}



andy send me a PM for teh new SDK, I do no post it yet because I am in teh middle of a featite, but this fix can help you wit teh bug you reported first.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Wed Sep 24, 2008 1:29 pm

Hi,

I told you there was something wrong with it.. I'm just sorry I can't make demos to try to help you debug. My project's pretty vast and not in a good state for releasing demos yet. Is it possible for you to add in the option of alternating diagonals? Fro example, 0,1 specify unified diagonals in either direction and 2 specifies alternating diagonals such that they make a diamond shape? It'd really help the quality of graphics for heightmaps (since I make the mesh match the physics).

I've set you a PM for the update as well.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Wed Sep 24, 2008 1:35 pm

I see what I can do,
but for the record that arrengment do not improve the quality of the graphic, in fact iit makes worse, trusth me on that.

anywat that has nothping to do with the physics so I see if I can add it on this weekend.
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Andy Price » Wed Sep 24, 2008 2:38 pm

Hi, I 'know' it doesn't make it worse and will in fact help but, I'm glad you're implementing it anyway.

I've tried the new version you sent in the PM (although it had the same link as the old one) and, it seems to have the same problem as before. Did you send the right link?
Last edited by Andy Price on Wed Sep 24, 2008 8:04 pm, edited 1 time in total.
Andy Price
 
Posts: 26
Joined: Mon Sep 18, 2006 11:45 pm

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Wed Sep 24, 2008 5:07 pm

Sorry for the tangental hijack...
Yeah I build the double precision jointLib. The rays are fixed now Julio :) but yes - I still get the bug Andy mentions when things fall into 'holes' in the heightmap.
Can you load up that demo savegame I sent? That shows precisely what happens.
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Re: NewtonCreateHeightFieldCollision Option

Postby Julio Jerez » Thu Sep 25, 2008 2:46 pm

I try to run that demo but I am having a diffcult time figuring out what is going on.
I see thr vehicle thunk on the terrain, but thr moment I touch any key thr scenr didsapesr from thr view and I can not find it.

It is possibel to make a test that is simpler to debug?
Julio Jerez
Moderator
Moderator
 
Posts: 11155
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: NewtonCreateHeightFieldCollision Option

Postby Aphex » Thu Sep 25, 2008 4:14 pm

Woah that's weird. Pressing 'p' after loading should unpause the game and show the vehicle doing strange stuff getting out of its hole. (Mouse + buttons moves camera)
I'll see if I can isolate it in one of the sdk demos, but I've never been able to build & run Newton demo's successfully before :(
Aphex
 
Posts: 144
Joined: Fri Jun 18, 2004 6:08 am
Location: UK

Previous

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests