You need to subtract a little bit off the t value when a collision occurs, so the new endpoint isn't touching the triangle.
PRCL_RayIntersectTriangle ????
void SlideAlongPlane (PR_POINT *end, PR_PLANE *plane, float radius)
{
PR_REAL dist;
dist = PRCL_DistanceToPlane (end, plane);
dist = (PR_REAL)abs(dist) + radius;
end->x += plane->normal.x * dist;
end->y += plane->normal.y * dist;
end->z += plane->normal.z * dist;
}
seudo-code:
[...]
make_ray(ray, ent_location, next_entlocation)
if (ray_intersect_world(ray, &plane))
{
SlideAlongPlane(next_entlocation, plane,1.5)
}
pr_positionentity(ent, next_entlocation.x , ... )
I'm really losing my strong with this collision program, 'couse I can't fix it.
Cris, In the portal example, have you fixed the collision problems? How?
Thanks
LeO!!
[This message has been edited by LeO!! (edited November 16, 1999).]
I'm still trying this function.
I make all the steps: load a second object and entity used for collision test, transform to world coord. make a ray, test with all faces of all segments of the object, if PRCL_RayIntersectTriangle is == PRCL_TRUE I perform a SlidealongWall() and works! BUT if I try again and again it fail and the object pass trough....
I run the portal demo and it has many collison problem to.
Cris, some ideas???? At least say that PRCL_RayIntersectTriangle works fine and I'll look my code until find the bug.
Thanks in advance: LeO!!
to the end of the SlideAlongWall function:
end->x += plane->normal.x * dist;
end->y += plane->normal.y * dist;
end->z += plane->normal.z * dist;
PRCL_RayFromPoints (ray, start, end);
}