> Are there any model traces that give the actual point of
> collision, instead of just the 0.0f-1.0f value in a trace_t?
> IPhysicsCollision::TraceCollide() seems like a good
> candidate, but not quite, as it doesn't give me the point of
> intersection.

If you're talking about a ray trace, then the point of collision is
trace.endpos.  If you're talking about a swept collide or bbox, then
there isn't necessarily a single point of contact.  You can have face
vs. edge and face vs. face contacts.  So really it's a point, line
segment, or polygon of contact.

You can get a vertex that is nearest the plane of contact by taking the
support map of the swept object in the opposite direction of the contact
normal (trace.plane.normal).  For a bbox, the support map is the corner
of the box that has the same component-wise signs as the normal.  For a
collide, you can call physcollide->CollideGetExtent().

so something like:

Vector contactPoint = physcollide->CollideGetExtent(
pSweptPhysics->GetCollide(), trace.endpos, pSweptEntity->GetAbsAngles(),
-trace.plane.normal );

would work for swept collides and

// mins, maxs are the bbox passed to TraceRay()
Vector contactPoint = trace.endpos;
contactPoint.x += ( trace.plane.normal.x > 0 ) ? mins.x : maxs.x; //
note > 0 because we want the -normal
contactPoint.y += ( trace.plane.normal.y > 0 ) ? mins.y : maxs.y;
contactPoint.z += ( trace.plane.normal.z > 0 ) ? mins.z : maxs.z;

for a bbox.  But remember, this will give you a vertex on the box even
when it's a face of the box in contact with the other object (even if
some sub-section of the face that doesn't include the vertex is the only
contact).

Also in case you can use this, if you have physics objects that are
actually in contact (i.e. not just traces), you can use
CreateFrictionSnapshot() to get a list of contacts and those can return
a point actually on the contact manifold.

Jay

_______________________________________________
To unsubscribe, edit your list preferences, or view the list archives, please 
visit:
http://list.valvesoftware.com/mailman/listinfo/hlcoders

Reply via email to