Menu

#18 Box-Ray collider returns skewed normals

0.12.0-J1.4
closed
nobody
None
1
2012-10-07
2012-09-23
No

The ray-box collider screws up the contact normals.

@Test
public void test() {
    OdeHelper.initODE2(0);

    DSpace rootSpace = OdeHelper.createHashSpace();

    final int maxContacts = 5;

    OdeHelper.createBox(rootSpace, 1, 1, 1);   //result contact - invalid normal  ([ -0.0, -0.0, -1.0 ])
    //OdeHelper.createSphere(rootSpace, 1);    //result contact - OK  normal  DVector3[ -1.0, 0.0, 0.0 ]

    DRay rayCastGeom = OdeHelper.createRay(rootSpace, 1);
    rayCastGeom.set(-10, 0, 0, 1, 0, 0);
    rayCastGeom.setLength(30);

    OdeHelper.spaceCollide(rootSpace, null, new DGeom.DNearCallback() {

        @Override
        public void call(Object data, DGeom o1, DGeom o2) {

                DContactBuffer contacts = new DContactBuffer(maxContacts);
                int numContacts = OdeHelper.collide(o1, o2, maxContacts, contacts.getGeomBuffer());
                if (numContacts == 0)
                    return;

                DContact contact = contacts.get(0);
                assertTrue(Math.abs(contact.geom.normal.get0()) > 0.99);
                assertTrue(Math.abs(contact.geom.normal.get1()) < 0.01);
                assertTrue(Math.abs(contact.geom.normal.get2()) < 0.01);
        }

    });

    OdeHelper.closeODE();
}

Discussion

  • Tilmann Zaeschke

    • status: open --> pending
     
  • Tilmann Zaeschke

    • status: pending --> closed
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.