Re[2]: [ODE] Tri-collider with current ODE collision code

Nguyen Binh Nguyen Binh <ngbinh at glassegg.com>
Sun May 25 22:19:02 2003


        Phew....

        Thanks Nate to point out the little bug of tri-collider.
        I have another way to work around that just by modified
        dcTriListCollider a little.

        It works fine for me, and I'm using Opcode 1.2 :)

        Here it is:

        ---------------------------------------------------------------------
        // Begin code
        // function int dcTriListCollider::CollideBox(...)
        .....
        // Try search for this line in original code
                if (CollisionTriangles.size() != 0){
                        /* Generating contacts */
                        int OutTriCount = 0;
                        for (int i = 0; i < CollisionTriangles.size(); i++){
                                dcPlane& TriPlane = *(dcPlane*)dGeomGetClassData(Geometry);
                                TriPlane = CollisionTriangles[i].Plane;
        
            // Add these lines
            dGeomID PlaneGeom = dCreatePlane(0,TriPlane.Normal.x,TriPlane.Normal.y,
                                             TriPlane.Normal.z, TriPlane.Distance);
            // Old funcs
            //int ContactCount = dCollideBoxPlane(Box, Geometry, 3, BoxContacts, sizeof(dContactGeom));
            int ContactCount = dCollideBoxPlane(Box, PlaneGeom, 3, BoxContacts, sizeof(dContactGeom));

            dGeomDestroy( PlaneGeom );
            // End of modified code

            // Continue original code
            for (int j = 0; j < ContactCount; j++){
            ....
        ---------------------------------------------------------------------
        // End


        Note. I'm using official distribution of ODE 0.35. So if you
        get ODE from CVS, it may be a little different.

        The point is, CollideBox func pass an invalid dxPlane* to ODE
        func dCollideBoxPlane.So to work around this, I create a new
        dxPlane, set it parameter correctly and pass to
        dCollideBoxPlane.


 --
Best regards,

---------------------------------------------------------------------
   Nguyen Binh
   Software Engineer
   Glass Egg Digital Media
   
   E.Town Building  
   7th Floor, 364 CongHoa Street
   Tan Binh District,
   HoChiMinh City,
   VietNam,

   Phone : +84 8 8109018
   Fax   : +84 8 8109013

     www.glassegg.com
---------------------------------------------------------------------