ConvexCast broken with triangle meshes.

Report any bugs here and we'll post fixes

Moderators: Sascha Willems, Thomas

ConvexCast broken with triangle meshes.

Postby marco » Tue Sep 26, 2017 4:32 am

hi,
Reposting 'https://github.com/MADEAPPS/newton-dynamics/issues/79' here.

NewtonWorldConvexCast is not returning any contacts when tracing against certain triangle meshes.
i included a simple test cast.

Code: Select all
#include <stdio.h>
#include "Newton.h"
#include "dVector.h"
#include "dMatrix.h"

using namespace std;

void test() {
   NewtonWorld *world = NewtonCreate();

   // create static body
   NewtonCollision* cs = 0;
   NewtonBody* dyn = 0;
   {
      // Dummy transform matrix.
      dMatrix tm(dGetIdentityMatrix());
      #if 0
      // WORKING simple BOX
      cs = NewtonCreateBox(world, 40., 40., 0.2, 0,0);
      #else
      // TRIANGLE MESH
      dVector verts[6] = {
         #if 1
         // FAILING,TRIANGLE MESH
         dVector(-55.12000656,-38.16000366,0.00000000),
         dVector(55.12000656,-38.16000366,0.00000000),
         dVector(-55.12000656,38.16000366,0.00000000),
         dVector(55.12000656,-38.16000366,0.00000000),
         dVector(55.12000656,38.16000366,0.00000000),
         dVector(-55.12000656,38.16000366,0.00000000)
         #else
         // WORKING,TRIANGLE MESH
         dVector(+40,+30,0),
         dVector(-40,+30,0),
         dVector(-40,-30,0),
         dVector(-40,-30,0),
         dVector(+40,-30,0),
         dVector(+40,+30,0),
         #endif
      };
      
      cs = NewtonCreateTreeCollision(world,0);
      NewtonTreeCollisionBeginBuild(cs);
      NewtonTreeCollisionAddFace(cs,3,&verts[0][0],sizeof(dVector),0);
      NewtonTreeCollisionAddFace(cs,3,&verts[3][0],sizeof(dVector),0);
      NewtonTreeCollisionEndBuild(cs,0);
      #endif
      dyn = NewtonCreateDynamicBody(world, cs, &tm[0][0]);
      NewtonDestroyCollision(cs);
   }

   // cast shape
   NewtonCollision* cast_shape = 0;
   {
      cast_shape = NewtonCreateBox(world,4,4,16,0,0);
   }

   // convex cast
   dVector start(-10,20.5,9.5);
   dVector target(-10,20.5,5);
   dMatrix start_xform(dQuaternion(),start);
   float hitParam = 0;
   NewtonWorldConvexCastReturnInfo info[16];
   int contactCount = NewtonWorldConvexCast(world,&start_xform[0][0],&target.m_x,cast_shape,
                                 &hitParam,0,0,
                                 info,sizeof(info)/sizeof(info[0]),0);

   // assert(contactCount > 0);
   // int a = sizeof(dVector);
   // dVector v;
   // int b = sizeof(v.m_x);
   // printf("%d %d ",a,b);

   printf("%f %d\n",hitParam,contactCount);

   // Tear down.
   NewtonMaterialDestroyAllGroupID(world);
   NewtonDestroyCollision(cast_shape);
   NewtonDestroyCollision(cs);
   NewtonDestroyAllBodies(world);
   NewtonDestroy(world);
}



Ill try again with new commit.

thanks.
marco
 
Posts: 2
Joined: Fri Sep 01, 2017 12:23 pm

Re: ConvexCast broken with triangle meshes.

Postby Julio Jerez » Tue Sep 26, 2017 10:14 am

the commit I said it fixes did fix that test repro but introduced a different bug when the cast was very oblique.
I just committed the general solution that should handle everything.
please sync again and try.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: ConvexCast broken with triangle meshes.

Postby marco » Wed Sep 27, 2017 5:51 am

working good now,no issues.
marco
 
Posts: 2
Joined: Fri Sep 01, 2017 12:23 pm


Return to Bugs and Fixes

Who is online

Users browsing this forum: No registered users and 13 guests