[ODE] sphere-mesh and box-mesh crash
Patrick Enoch
Hendrix_ at gmx.net
Sat Jun 25 15:17:41 MST 2005
Hello,
Collider.GetNbTouchedPrimitives() will return the number of triangles
in the container allright.
however, i think that Collider.GetContactStatus() will make sure the
triangles are valid.
GetContactStatus will check the OPCODE flags against "collision
occured", which i think
is necessary for valid entries in the container.
Patrick
On 25. Jun 2005, at 15:01 Uhr, Adam D. Moss wrote:
> Patrick Enoch wrote:
>
>> I experienced crashes. The container with the touched primitives
>> was supposedly filled with a lot of
>> triangles. when checking the triangles, I saw there were indices
>> like "0xC0BA1234" and so on... this
>> certainly causing to crash "FetchTriangle" in the following code...
>> when testing for the status I saw that the status said "no
>> collisions", thus the indices are bogus.
>>
>
> If Collider.GetNbTouchedPrimitives()==0 then AFAICS we never execute
> the FetchTriangle path, so is GetNbTouchedPrimitives()'s return
> actually
> bogus if we didn't collide?
>
> In either case, Collider.GetContactStatus() looks like a cheap
> function
> so it doesn't hurt to be protective, but it'd be better if we were
> sure we weren't wallpapering over a different bug. We might well just
> be using OPCODE wrongly (i.e. GetNbTouchedPrimitives only works if
> there was a collision).
>
> Does this patch look okay? It tests okay. I'll apply it to the trunk
> shortly, if so.
>
> --adam
> Index: ode/src/collision_trimesh_box.cpp
> ===================================================================
> --- ode/src/collision_trimesh_box.cpp (revision 4638)
> +++ ode/src/collision_trimesh_box.cpp (working copy)
> @@ -1203,6 +1203,11 @@
> Collider.Collide(dxTriMesh::defaultBoxCache, Box, TriMesh-
> >Data->BVTree, null,
> &MakeMatrix(vPosMesh, mRotMesh, amatrix));
> }
> +
> + if (!Collider.GetContactStatus()) {
> + /* no collision occurred */
> + return 0;
> + }
>
> // Retrieve data
> int TriCount = Collider.GetNbTouchedPrimitives();
> Index: ode/src/collision_trimesh_ccylinder.cpp
> ===================================================================
> --- ode/src/collision_trimesh_ccylinder.cpp (revision 4638)
> +++ ode/src/collision_trimesh_ccylinder.cpp (working copy)
> @@ -958,6 +958,11 @@
> Collider.Collide(dxTriMesh::defaultBoxCache,
> obbCCylinder, TriMesh->Data->BVTree, null,&MeshMatrix);
> }
>
> + if (!Collider.GetContactStatus()) {
> + /* no collision occurred */
> + return 0;
> + }
> +
> // Retrieve data
> int TriCount = Collider.GetNbTouchedPrimitives();
> const int* Triangles = (const int*)
> Collider.GetTouchedPrimitives();
> Index: ode/src/collision_trimesh_sphere.cpp
> ===================================================================
> --- ode/src/collision_trimesh_sphere.cpp (revision 4638)
> +++ ode/src/collision_trimesh_sphere.cpp (working copy)
> @@ -305,6 +305,11 @@
> &MakeMatrix(TLPosition, TLRotation,
> amatrix));
> }
>
> + if (!Collider.GetContactStatus()) {
> + /* no collision occurred */
> + return 0;
> + }
> +
> // get results
> int TriCount = Collider.GetNbTouchedPrimitives();
> const int* Triangles = (const int*)
> Collider.GetTouchedPrimitives();
>
More information about the ODE
mailing list