Accuracy of OPCODE

View previous topic View next topic Go down

Accuracy of OPCODE

Post by templar_vii on Wed Dec 09, 2015 1:21 pm

Is use OPCODE with mesh position-values up to 5000 millimeters (per example X=100, Y=4800, Z=2600).
Is it possible that the accuracy is just 5 millimeters? So I get collisions for meshes which 5mm apart?

Maybe this is due OPCODE uses float and not double precision?

Thank you very much for any help.
Manuel


Last edited by templar_vii on Fri Dec 11, 2015 12:07 pm; edited 2 times in total

templar_vii
Admin

Posts : 7
Join date : 2015-12-09

View user profile http://opcode.forumotion.net

Back to top Go down

Re: Accuracy of OPCODE

Post by templar_vii on Wed Dec 09, 2015 1:22 pm

I wrote a C++ Unit Test to reproduce behaviour above.
The two triangles don't touch each other. However OPCODE reports a collision.
Can anybody reproduce this behavior? Or explain what's wrong?


Screenshot of the thwo triangles

Code:

      TEST_METHOD(MyTest)
      {
         IceMaths::Point vertices0[] =
         {
            Point(141.288421630859, 1284.9755859375, 0),
            Point(16.0570087432861, 139.073532104492, 0),
            Point(42.5077857971191, 195.797409057617, 0),

            Point(141.288421630859, 1284.9755859375, 1.5),
            Point(16.0570087432861, 139.073532104492, 1.5),
            Point(42.5077857971191, 195.797409057617, 1.5)
         };

         IceMaths::Point vertices1[] =
         {
            Point(-1.76504766941071, 149.057647705078, 0),
            Point(136.07829284668, 1285.10754394531, 0),
            Point(122.885803222656, 1285.11926269531, 0),

            Point(-1.76504766941071, 149.057647705078, 1.5),
            Point(136.07829284668, 1285.10754394531, 1.5),
            Point(122.885803222656, 1285.11926269531, 1.5)
         };

         IndexedTriangle indices0[] =
         {
            *(new IndexedTriangle(0, 1, 2)),
            *(new IndexedTriangle(3, 4, 5))
         };

         IndexedTriangle indices1[] =
         {
            *(new IndexedTriangle(0, 1, 2)),
            *(new IndexedTriangle(3, 4, 5))
         };

         Matrix4x4* transformation = new Matrix4x4(
            0.99218028721812679,
            -0.060684346027920492,
            0.10906735443256611,
            0.0,
            0.1088639218309557,
            -0.0066584026990387044,
            -0.99403436167824744,
            0.0,
            0.061048539534856665,
            0.99813479842186692,
            0.000000000000000030743598821295616,
            0.0,
            -1261.9345667567216,
            297.90183531834396,
            1443.7096202932094,
            1.0);

         udword nrTriangles0 = sizeof(indices0) / sizeof(indices0[0]);
         udword nrVertices0 = sizeof(vertices0) / sizeof(vertices0[0]);
         udword nrTriangles1 = sizeof(indices1) / sizeof(indices1[0]);
         udword nrVertices1 = sizeof(vertices1) / sizeof(vertices1[0]);
         MeshInterface* mesh0 = GetMeshInterface(indices0, vertices0, nrTriangles0, nrVertices0);
         MeshInterface* mesh1 = GetMeshInterface(indices1, vertices1, nrTriangles1, nrVertices1);

         Model* model0 = GetModel(mesh0);
         Model* model1 = GetModel(mesh1);

         BVTCache* cache = new BVTCache();
         cache->Model0 = model0;
         cache->Model1 = model1;

         AABBTreeCollider* collider = new AABBTreeCollider();
         bool checkDone = collider->Collide(*cache, transformation, transformation);
         Assert::IsTrue(checkDone);

         bool contactFound = collider->GetContactStatus();
         Assert::IsFalse(contactFound);
      }
      
      Model* GetModel(MeshInterface* mesh)
      {
         BuildSettings* buildSettings = new BuildSettings();
         buildSettings->mLimit = 1;
         buildSettings->mRules = SPLIT_BEST_AXIS | SPLIT_SPLATTER_POINTS | SPLIT_GEOM_CENTER;

         OPCODECREATE* data = new OPCODECREATE();
         data->mCanRemap = false;
         data->mIMesh = mesh;
         data->mKeepOriginal = false;
         data->mNoLeaf = true;
         data->mQuantized = true;
         data->mSettings = *buildSettings;

         Model* model = new Model();
         bool modelCreated = model->Build(*data);
         Assert::IsTrue(modelCreated);
         
         return model;
      }

      MeshInterface* GetMeshInterface(IndexedTriangle* indices, Point* vertices, udword nrTriangles, udword nrVertices)
      {
         MeshInterface* meshInterface = new MeshInterface();

         meshInterface->SetNbTriangles(nrTriangles);
         meshInterface->SetNbVertices(nrVertices);
         
         bool pointersSet = meshInterface->SetPointers(indices, vertices);
         Assert::IsTrue(pointersSet);

         udword degeneratedFaces = meshInterface->CheckTopology();
         Assert::IsTrue(degeneratedFaces == 0);
         Assert::IsTrue(meshInterface->IsValid());

         return meshInterface;
      }

templar_vii
Admin

Posts : 7
Join date : 2015-12-09

View user profile http://opcode.forumotion.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum