Archived

This topic is now archived and is closed to further replies.

LeO!!

PRCL_RayIntersectTriangle ????

Recommended Posts

The test only works if the two ends of the ray lie on opposite sides of the triangle. If the first point lies on the triangle you'll just slip through it.

You need to subtract a little bit off the t value when a collision occurs, so the new endpoint isn't touching the triangle.

Share this post


Link to post
Share on other sites
I'm using this function to perform slide along plane.

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).]

Share this post


Link to post
Share on other sites
The fix for the portal collision is in actor.c, which has a line added
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);
}

Share this post


Link to post
Share on other sites

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!!

Share this post


Link to post
Share on other sites