[ODE] TriMesh Data woes

Jon Watte (ODE) hplus-ode at mindcontrol.org
Tue Aug 7 15:53:20 MST 2007


dTriMeshDataBuildSimple() is documented as taking a dVector3*, which 
actually is a 4-element vector, which I know (after all, I explain it 
often enough :-) but it still bit me the other day. Geometry that comes 
from externally is unlikely to actually be in ODE format; it's likely to 
be in packed 3-float format if it's not interleaved such that Simple 
can't be used.

I propose we change TriMeshDataBuildSimple() to take an array of real 
three-vectors. To make it clear we're changing the API, let it take a 
struct ExternalVertexPosition {} which can contain three floats. Pretty 
much everyone using the function uses type-casts anyway.

Also, here is a patch I think is necessary (also in the patch tracker). 
It makes sure that swapping trimesh data (without changing the geom in 
other ways) actually re-calculates the AABB correctly. I believe I saw 
this not happening when debugging the above problem.


Index: collision_trimesh_opcode.cpp
===================================================================
--- collision_trimesh_opcode.cpp        (revision 1199)
+++ collision_trimesh_opcode.cpp        (working copy)
@@ -698,6 +698,8 @@
 {
        dUASSERT(g && g->type == dTriMeshClass, "argument not a trimesh");
        ((dxTriMesh*)g)->Data = Data;
+       //  I changed my data -- I know nothing about my own AABB anymore.
+       ((dxTriMesh*)g)->gflags |= (GEOM_DIRTY|GEOM_AABB_BAD);
 }

 dTriMeshDataID dGeomTriMeshGetData(dGeomID g)


More information about the ODE mailing list