×
Menu

How Intersection Points are Calculated (EN)

Выдержка из оригинальной справки. (NDL Gamebryo 1.1)(С)
Для МВ (вероятно) не сильно актуально, но для общего ознакомления с вопросом работы системы коллизий, может быть будет интересно.
 
Примечание.
В МВ режим Капсулы - не упоминается в коде.

The text below explains how the intersection point is calculated for different combinations of two intersecting objects. Note that these calculations are simple approximations (for speed), and that an application may need to take these considerations into account for the desired effect:
 
Triangle vs. Triangle
The intersection point of two triangles is returned as the centroid of the smaller area triangle.
 
Triangle vs. Box
The intersection point of a triangle and box is the midpoint of the segment joining the box center and triangle centroid.
 
Triangle vs. Sphere
The intersection point is the spot where the shortest distance segment from the sphere center to the triangle touches the triangle.
 
Box vs. Box
When a collision has been detected for box vs. box, using the first moment of collision, the system calculates the intersection point based on the midpoint of the segment connecting the closest points of the boxes.
 
Box vs. Lozenge
The intersection point in a box vs. lozenge collision is determined as the midpoint of the segment joining the closest points between the two objects.
 
Box vs. Sphere
When a collision between box and sphere is detected, the intersection point is found through a process involving backtracking in time using the objects' velocities to find the first time of intersection. From that first collision moment, the intersection point is calculated by multiplying the unit collision vector and the radius of the sphere.
 
Sphere vs. Sphere
When two spheres are found to intersect, the intersection point is found through a process involving backtracking in time using the objects' velocities to find the first time of intersection. Once this time is found, the intersection point is the center of the slower sphere plus the length of its radius multiplied by the unit normal collision vector.
 
Capsule vs. Sphere
Capsule vs. sphere intersection points are determined similarly to the sphere vs. sphere combination because capsules can be treated as spheres swept along a line.
 
Capsule vs. Capsule
Capsule vs. capsule intersection points are determined similarly to the capsule vs. sphere (and therefore sphere vs. sphere) combination because capsules can be treated as spheres swept along a line.
 
Capsule vs. Lozenge
The intersection point between a capsule and lozenge collision is calculated as the midpoint of the segment joining the closest points of the objects.
 
Capsule vs. Triangle
The intersection point between a capsule and triangle is determined as the triangle origin when it first collides with the capsule.
 
Lozenge vs. Lozenge
The intersection point between lozenges is calculated as the midpoint of the segment joining the closest points of the objects.
 
Lozenge vs. Sphere
The intersection point between lozenge and sphere is the midpoint of the segment joining the closest points of the objects.
 
Lozenge vs. Triangle
The intersection point between lozenge and triangle is the point of the triangle that first collides with the lozenge.
 
Halfspace vs. Halfspace
The intersection point of two halfspaces is the point halfway between the regions defining overlap.
 
Halfspace vs. Sphere
The intersection point of a halfspace and sphere is the point on the sphere closest to the halfspace plane.
 
Halfspace vs. Box
The intersection point of a halfspace and box is the box vertex that comes into contact with the halfspace plane first.
 
Halfspace vs. Capsule
The intersection point between halfspace and capsule is calculated as the point on the capsule closest to the halfspace plane.
 
Halfspace vs. Lozenge
The intersection point of a halfspace and lozenge is the point on the lozenge closest to the halfspace plane.
 
Halfspace vs. Triangle
The intersection point between halfspace and triangle is the triangle vertex that comes into contact with the halfspace plane first.
 
How Normals are Calculated
In general, collision normals are not guaranteed to be unit vectors.
 
OBB vs. OBB
When OBBs collide, the resulting normals are calculated as though the OBBs were ellipsoids.
 
Box vs. Box
The collision normals for box vs. box intersection are calculated from summing the projections of a box's center-to-intersection vector onto the other box's axes. Velocity is taken in indirectly by the fact that the intersection point was calculated after backtracking to the earliest collision. If the box centers are coincident and the velocity is zero, then the unit Z vector is returned. A normalized center-to-intersection point vector will be returned as the collision normal if for some reason the calculation of the normal had resulted in a zero vector.
 
Box vs. Lozenge
Normals are taken by normalizing the segment connecting the closest points between the objects.
 
Box vs. Sphere
The collision normals for a box vs. sphere intersection are calculated using the sphere's radius, the box's extent, and both velocities. If there is no relative velocity between the objects, then the intersection is the midpoint of the segment connecting the closest points, and the normals will be the directions between the centers to the point of intersection. Otherwise, for the sphere, the normal is the normalized center-to-intersect vector. For the box, the normal is calculated by summing the projections of the sphere's center-to-intersect vector onto the box axes and normalizing the result.
 
Sphere vs. Sphere
The collision normals for sphere vs. sphere are found using the sphere's center, radius, and velocity parameters. If there is no relative velocity between the spheres, the best that can be done is to give the direction between the centers of the two spheres. If the spheres also happen to be coincident, then the unit Z vector is returned as a normal. Otherwise, an approximation to the exact normal is calculated.
 
Capsule vs. Sphere
Normals are calculated by normalizing the segment connecting the closest points of the objects.
 
Capsule vs. Capsule
Normals are calculated by normalizing the segment connecting the closest points of the objects.
 
Capsule vs. Lozenge
Normals are calculated by normalizing the segment connecting the closest points of the objects.
 
Capsule vs. Tri
The returned normals are set from the normal of the triangle.
Lozenge vs. Lozenge
Normals are calculated by normalizing the segment connecting the closest points of the objects.
Lozenge vs. Sphere
Normals are calculated by normalizing the segment connecting the closest points of the objects.
Lozenge vs. Triangle
The returned normals are set from the normal of the triangle.
 
Halfspace vs. Halfspace
The returned normals are taken as the normal of the halfspace plane.
 
Halfspace vs. Sphere
The returned normals are taken from the normal of the halfspace plane.
 
Halfspace vs. Box
The halfspace normal comes from the normal of the halfspace plane. The box normal is the normalized vector from the center of the box to the intersection point of the objects.
 
Halfspace vs. Capsule
The returned normals are taken from the normal of the halfspace plane.
 
Halfspace vs. Lozenge
The returned normals are taken from the normal of the halfspace plane.
 
Halfspace vs. Tri
The returned normals are taken from the normal of the halfspace plane.