JigLibJS2
JigLibJS2 copied to clipboard
JTriangleMesh misses some collisions
It looks like not all potential triangles are found during collision detection. If the whole mesh is put in a single cell, physics works perfectly but it is obviously very slow. Smaller the cells make the bug occur more frequently.
A quick hack to alleviate the problem is to relax the criterion to include a triangle in an octtree cell to consider only the bounding box of the triangle for overlap:
JOctree.prototype.doesTriangleIntersectCell = function(triangle, cell)
{
return triangle.get_boundingBox().overlapTest(cell.AABox);
}
Note that this does not get rid of the bug entirely, but at least gives some hints about its origins.
A question regarding TriangleMesh collisions: Is it supported to have 2 triangle meshes to collide with each other?
I've found this in the code which made me assume it's not supported, but I just want to confirm:
JigLib.RigidBody.prototype.set_movable = function(mov)
{
if (this._type == "PLANE" || this._type == "TERRAIN" || this._type == "TRIANGLEMESH")
return;
...
So if I'm right dynamic objects can collide with them, but their position will always be fixed.
My other small issue was that in the combined js file the implementations for JMatrix3D and JVector3D seem to be missing (they are there in their own js files)