chore: improject documentation for IntersectSegment

- change return of IntersectRayDisk to bool
- change return of IntersectRayBox to bool
- move [out] after @param

Signed-off-by: Michael Pollind <mpollind@gmail.com>
monroegm-disable-blank-issue-2
Michael Pollind 4 years ago
parent 1c3b293cd3
commit 02d8596d87

@ -352,9 +352,6 @@ AZ::Intersect::IntersectRayAABB(
return ISECT_RAY_AABB_ISECT; return ISECT_RAY_AABB_ISECT;
} }
//========================================================================= //=========================================================================
// IntersectRayAABB2 // IntersectRayAABB2
// [2/18/2011] // [2/18/2011]
@ -411,7 +408,7 @@ AZ::Intersect::IntersectRayAABB2(const Vector3& rayStart, const Vector3& dirRCP,
return ISECT_RAY_AABB_ISECT; return ISECT_RAY_AABB_ISECT;
} }
int AZ::Intersect::IntersectRayDisk( bool AZ::Intersect::IntersectRayDisk(
const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& diskCenter, const float diskRadius, const Vector3& diskNormal, float& t) const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& diskCenter, const float diskRadius, const Vector3& diskNormal, float& t)
{ {
// First intersect with the plane of the disk // First intersect with the plane of the disk
@ -424,10 +421,10 @@ int AZ::Intersect::IntersectRayDisk(
if (pointOnPlane.GetDistance(diskCenter) < diskRadius) if (pointOnPlane.GetDistance(diskCenter) < diskRadius)
{ {
t = planeIntersectionDistance; t = planeIntersectionDistance;
return 1; return true;
} }
} }
return 0; return false;
} }
// Reference: Real-Time Collision Detection - 5.3.7 Intersecting Ray or Segment Against Cylinder, and the book's errata. // Reference: Real-Time Collision Detection - 5.3.7 Intersecting Ray or Segment Against Cylinder, and the book's errata.
@ -1015,7 +1012,7 @@ int AZ::Intersect::IntersectRayQuad(
} }
// reference: Real-Time Collision Detection, 5.3.3 Intersecting Ray or Segment Against Box // reference: Real-Time Collision Detection, 5.3.3 Intersecting Ray or Segment Against Box
int AZ::Intersect::IntersectRayBox( bool AZ::Intersect::IntersectRayBox(
const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& boxCenter, const Vector3& boxAxis1, const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& boxCenter, const Vector3& boxAxis1,
const Vector3& boxAxis2, const Vector3& boxAxis3, float boxHalfExtent1, float boxHalfExtent2, float boxHalfExtent3, float& t) const Vector3& boxAxis2, const Vector3& boxAxis3, float boxHalfExtent1, float boxHalfExtent2, float boxHalfExtent3, float& t)
{ {
@ -1047,7 +1044,7 @@ int AZ::Intersect::IntersectRayBox(
// If the ray is parallel to the slab and the ray origin is outside, return no intersection. // If the ray is parallel to the slab and the ray origin is outside, return no intersection.
if (tp < 0.0f || tn < 0.0f) if (tp < 0.0f || tn < 0.0f)
{ {
return 0; return false;
} }
} }
else else
@ -1068,7 +1065,7 @@ int AZ::Intersect::IntersectRayBox(
tmax = AZ::GetMin(tmax, t2); tmax = AZ::GetMin(tmax, t2);
if (tmin > tmax) if (tmin > tmax)
{ {
return 0; return false;
} }
} }
@ -1088,7 +1085,7 @@ int AZ::Intersect::IntersectRayBox(
// If the ray is parallel to the slab and the ray origin is outside, return no intersection. // If the ray is parallel to the slab and the ray origin is outside, return no intersection.
if (tp < 0.0f || tn < 0.0f) if (tp < 0.0f || tn < 0.0f)
{ {
return 0; return false;
} }
} }
else else
@ -1109,7 +1106,7 @@ int AZ::Intersect::IntersectRayBox(
tmax = AZ::GetMin(tmax, t2); tmax = AZ::GetMin(tmax, t2);
if (tmin > tmax) if (tmin > tmax)
{ {
return 0; return false;
} }
} }
@ -1129,7 +1126,7 @@ int AZ::Intersect::IntersectRayBox(
// If the ray is parallel to the slab and the ray origin is outside, return no intersection. // If the ray is parallel to the slab and the ray origin is outside, return no intersection.
if (tp < 0.0f || tn < 0.0f) if (tp < 0.0f || tn < 0.0f)
{ {
return 0; return false;
} }
} }
else else
@ -1150,15 +1147,15 @@ int AZ::Intersect::IntersectRayBox(
tmax = AZ::GetMin(tmax, t2); tmax = AZ::GetMin(tmax, t2);
if (tmin > tmax) if (tmin > tmax)
{ {
return 0; return false;
} }
} }
t = (isRayOriginInsideBox ? tmax : tmin); t = (isRayOriginInsideBox ? tmax : tmin);
return 1; return true;
} }
int AZ::Intersect::IntersectRayObb(const Vector3& rayOrigin, const Vector3& rayDir, const Obb& obb, float& t) bool AZ::Intersect::IntersectRayObb(const Vector3& rayOrigin, const Vector3& rayDir, const Obb& obb, float& t)
{ {
return AZ::Intersect::IntersectRayBox(rayOrigin, rayDir, obb.GetPosition(), return AZ::Intersect::IntersectRayBox(rayOrigin, rayDir, obb.GetPosition(),
obb.GetAxisX(), obb.GetAxisY(), obb.GetAxisZ(), obb.GetAxisX(), obb.GetAxisY(), obb.GetAxisZ(),
@ -1366,11 +1363,11 @@ AZ::Intersect::IntersectSegmentCapsule(const Vector3& sa, const Vector3& dir, co
//========================================================================= //=========================================================================
bool bool
AZ::Intersect::IntersectSegmentPolyhedron( AZ::Intersect::IntersectSegmentPolyhedron(
const Vector3& sa, const Vector3& sBA, const Plane p[], int numPlanes, const Vector3& sa, const Vector3& dir, const Plane p[], int numPlanes,
float& tfirst, float& tlast, int& iFirstPlane, int& iLastPlane) float& tfirst, float& tlast, int& iFirstPlane, int& iLastPlane)
{ {
// Compute direction vector for the segment // Compute direction vector for the segment
Vector3 d = /*b - a*/ sBA; Vector3 d = /*b - a*/ dir;
// Set initial interval to being the whole segment. For a ray, tlast should be // Set initial interval to being the whole segment. For a ray, tlast should be
// set to +RR_FLT_MAX. For a line, additionally tfirst should be set to -RR_FLT_MAX // set to +RR_FLT_MAX. For a line, additionally tfirst should be set to -RR_FLT_MAX
tfirst = 0.0f; tfirst = 0.0f;

@ -36,7 +36,6 @@ namespace AZ
//! Given segment pq and triangle abc (CCW), returns whether segment intersects //! Given segment pq and triangle abc (CCW), returns whether segment intersects
//! triangle and if so, also returns the barycentric coordinates (u,v,w) //! triangle and if so, also returns the barycentric coordinates (u,v,w)
//! of the intersection point. //! of the intersection point.
//!
//! @param p segment start point //! @param p segment start point
//! @param q segment end point //! @param q segment end point
//! @param a triangle point 1 //! @param a triangle point 1
@ -49,7 +48,7 @@ namespace AZ
const Vector3& p, const Vector3& q, const Vector3& a, const Vector3& b, const Vector3& c, Vector3& normal, float& t); const Vector3& p, const Vector3& q, const Vector3& a, const Vector3& b, const Vector3& c, Vector3& normal, float& t);
//! Same as \ref IntersectSegmentTriangleCCW without respecting the triangle (a,b,c) vertex order (double sided). //! Same as \ref IntersectSegmentTriangleCCW without respecting the triangle (a,b,c) vertex order (double sided).
//! //! @param p segment start point //! @param p segment start point
//! @param q segment end point //! @param q segment end point
//! @param a triangle point 1 //! @param a triangle point 1
//! @param b triangle point 2 //! @param b triangle point 2
@ -86,41 +85,38 @@ namespace AZ
const Aabb& aabb, const Aabb& aabb,
float& tStart, float& tStart,
float& tEnd, float& tEnd,
Vector3& startNormal /*, Vector3& inter*/); Vector3& startNormal);
//! Intersect ray against AABB. //! Intersect ray against AABB.
//!
//! @param rayStart ray starting point. //! @param rayStart ray starting point.
//! @param dir ray reciprocal direction. //! @param dir ray reciprocal direction.
//! @param aabb Axis aligned bounding box to intersect against. //! @param aabb Axis aligned bounding box to intersect against.
//! @param start length on ray of the first intersection. //! @param start length on ray of the first intersection.
//! @param end length of the of the second intersection. //! @param end length of the of the second intersection.
//! @return \ref RayAABBIsectTypes In this faster version than IntersectRayAABB we return only ISECT_RAY_AABB_NONE and ISECT_RAY_AABB_ISECT. You can check yourself for that case. //! @return \ref RayAABBIsectTypes In this faster version than IntersectRayAABB we return only ISECT_RAY_AABB_NONE and
//! ISECT_RAY_AABB_ISECT. You can check yourself for that case.
RayAABBIsectTypes IntersectRayAABB2(const Vector3& rayStart, const Vector3& dirRCP, const Aabb& aabb, float& start, float& end); RayAABBIsectTypes IntersectRayAABB2(const Vector3& rayStart, const Vector3& dirRCP, const Aabb& aabb, float& start, float& end);
//! Clip a ray to an aabb. return true if ray was clipped. The ray //! Clip a ray to an aabb. return true if ray was clipped. The ray
//! can be inside so don't use the result if the ray intersect the box. //! can be inside so don't use the result if the ray intersect the box.
//!
//! @param aabb bounds //! @param aabb bounds
//! @param rayStart the start of the ray //! @param rayStart the start of the ray
//! @param rayEnd the end of the ray //! @param rayEnd the end of the ray
//! @param tClipStart[out] The proportion where the ray enterts the aabb //! @param[out] tClipStart The proportion where the ray enterts the aabb
//! @param tClipEnd[out] The proportion where the ray exits the aabb //! @param[out] tClipEnd The proportion where the ray exits the aabb
//! @return true ray was clipped else false //! @return true ray was clipped else false
bool ClipRayWithAabb(const Aabb& aabb, Vector3& rayStart, Vector3& rayEnd, float& tClipStart, float& tClipEnd); bool ClipRayWithAabb(const Aabb& aabb, Vector3& rayStart, Vector3& rayEnd, float& tClipStart, float& tClipEnd);
//! Test segment and aabb where the segment is defined by midpoint //! Test segment and aabb where the segment is defined by midpoint
//! midPoint = (p1-p0) * 0.5f and half vector halfVector = p1 - midPoint. //! midPoint = (p1-p0) * 0.5f and half vector halfVector = p1 - midPoint.
//! the aabb is at the origin and defined by half extents only. //! the aabb is at the origin and defined by half extents only.
//!
//! @param midPoint midpoint of a line segment //! @param midPoint midpoint of a line segment
//! @param halfVector half vector of an aabb //! @param halfVector half vector of an aabb
//! @param aabbExtends the extends of a bounded box //! @param aabbExtends the extends of a bounded box
//! @return 1 if the intersect, otherwise 0. //! @return true if the intersect, otherwise false.
bool TestSegmentAABBOrigin(const Vector3& midPoint, const Vector3& halfVector, const Vector3& aabbExtends); bool TestSegmentAABBOrigin(const Vector3& midPoint, const Vector3& halfVector, const Vector3& aabbExtends);
//! Test if segment specified by points p0 and p1 intersects AABB. \ref TestSegmentAABBOrigin //! Test if segment specified by points p0 and p1 intersects AABB. \ref TestSegmentAABBOrigin
//!
//! @param p0 point 1 //! @param p0 point 1
//! @param p1 point 2 //! @param p1 point 2
//! @param aabb bounded box //! @param aabb bounded box
@ -130,9 +126,9 @@ namespace AZ
//! Ray sphere intersection result types. //! Ray sphere intersection result types.
enum SphereIsectTypes : AZ::s32 enum SphereIsectTypes : AZ::s32
{ {
ISECT_RAY_SPHERE_SA_INSIDE = -1, // the ray starts inside the cylinder ISECT_RAY_SPHERE_SA_INSIDE = -1, //!< the ray starts inside the cylinder
ISECT_RAY_SPHERE_NONE, // no intersection ISECT_RAY_SPHERE_NONE, //!< no intersection
ISECT_RAY_SPHERE_ISECT, // along the PQ segment ISECT_RAY_SPHERE_ISECT, //!< along the PQ segment
}; };
//! IntersectRaySphereOrigin //! IntersectRaySphereOrigin
@ -147,16 +143,17 @@ namespace AZ
const Vector3& rayStart, const Vector3& rayDirNormalized, const float sphereRadius, float& t); const Vector3& rayStart, const Vector3& rayDirNormalized, const float sphereRadius, float& t);
//! Intersect ray (rayStart,rayDirNormalized) and sphere (sphereCenter,sphereRadius) \ref IntersectRaySphereOrigin //! Intersect ray (rayStart,rayDirNormalized) and sphere (sphereCenter,sphereRadius) \ref IntersectRaySphereOrigin
//! //! @param rayStart the start of the ray
//! @param rayStart //! @param rayDirNormalized the direction of the ray normalized
//! @param rayDirNormalized //! @param sphereCenter the center of the sphere
//! @param sphereCenter //! @param sphereRadius radius of the sphere
//! @param sphereRadius //! @param[out] t coefficient in the ray's explicit equation from which an
//! @param t //! intersecting point is calculated as "rayOrigin + t1 * rayDir".
//! @return SphereIsectTypes //! @return SphereIsectTypes
SphereIsectTypes IntersectRaySphere( SphereIsectTypes IntersectRaySphere(
const Vector3& rayStart, const Vector3& rayDirNormalized, const Vector3& sphereCenter, const float sphereRadius, float& t); const Vector3& rayStart, const Vector3& rayDirNormalized, const Vector3& sphereCenter, const float sphereRadius, float& t);
//! Intersect ray (rayStarty, rayDirNormalized) and disk (center, radius, normal)
//! @param rayOrigin The origin of the ray to test. //! @param rayOrigin The origin of the ray to test.
//! @param rayDir The direction of the ray to test. It has to be unit length. //! @param rayDir The direction of the ray to test. It has to be unit length.
//! @param diskCenter Center point of the disk //! @param diskCenter Center point of the disk
@ -164,8 +161,8 @@ namespace AZ
//! @param diskNormal A normal perpendicular to the disk //! @param diskNormal A normal perpendicular to the disk
//! @param[out] t If returning 1 (indicating a hit), this contains distance from rayOrigin along the normalized rayDir //! @param[out] t If returning 1 (indicating a hit), this contains distance from rayOrigin along the normalized rayDir
//! that the hit occured at. //! that the hit occured at.
//! @return The number of intersecting points. //! @return false if not interesecting and true if intersecting
int IntersectRayDisk( bool IntersectRayDisk(
const Vector3& rayOrigin, const Vector3& rayOrigin,
const Vector3& rayDir, const Vector3& rayDir,
const Vector3& diskCenter, const Vector3& diskCenter,
@ -177,13 +174,10 @@ namespace AZ
//! @param rayOrigin The origin of the ray to test. //! @param rayOrigin The origin of the ray to test.
//! @param rayDir The direction of the ray to test. It has to be unit length. //! @param rayDir The direction of the ray to test. It has to be unit length.
//! @param cylinderEnd1 The center of the circle on one end of the cylinder. //! @param cylinderEnd1 The center of the circle on one end of the cylinder.
//! @param cylinderDir The direction pointing from \ref cylinderEnd1 to the other end of the cylinder. It has to be unit //! @param cylinderDir The direction pointing from \ref cylinderEnd1 to the other end of the cylinder. It has to be unit length.
//! length.
//! @param cylinderHeight The distance between two centers of the circles on two ends of the cylinder respectively. //! @param cylinderHeight The distance between two centers of the circles on two ends of the cylinder respectively.
//! @param[out] t1 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated //! @param[out] t1 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t1 * rayDir".
//! as "rayOrigin + t1 * rayDir". //! @param[out] t2 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t2 * rayDir".
//! @param[out] t2 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated
//! as "rayOrigin + t2 * rayDir".
//! @return The number of intersecting points. //! @return The number of intersecting points.
int IntersectRayCappedCylinder( int IntersectRayCappedCylinder(
const Vector3& rayOrigin, const Vector3& rayOrigin,
@ -202,10 +196,8 @@ namespace AZ
//! @param coneDir The unit-length direction from the apex to the base. //! @param coneDir The unit-length direction from the apex to the base.
//! @param coneHeight The height of the cone, from the apex to the base. //! @param coneHeight The height of the cone, from the apex to the base.
//! @param coneBaseRadius The radius of the cone base circle. //! @param coneBaseRadius The radius of the cone base circle.
//! @param[out] t1 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated //! @param[out] t1 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t1 * rayDir".
//! as "rayOrigin + t1 * rayDir". //! @param[out] t2 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated as "rayOrigin + t2 * rayDir".
//! @param[out] t2 A possible coefficient in the ray's explicit equation from which an intersecting point is calculated
//! as "rayOrigin + t2 * rayDir".
//! @return The number of intersecting points. //! @return The number of intersecting points.
int IntersectRayCone( int IntersectRayCone(
const Vector3& rayOrigin, const Vector3& rayOrigin,
@ -222,7 +214,7 @@ namespace AZ
//! @param rayDir The direction of the ray to test intersection with. //! @param rayDir The direction of the ray to test intersection with.
//! @param planePos A point on the plane to test intersection with. //! @param planePos A point on the plane to test intersection with.
//! @param planeNormal The normal of the plane to test intersection with. //! @param planeNormal The normal of the plane to test intersection with.
//! @param t[out] The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection". //! @param[out] t The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
//! @return The number of intersection point. //! @return The number of intersection point.
int IntersectRayPlane( int IntersectRayPlane(
const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& planePos, const Vector3& planeNormal, float& t); const Vector3& rayOrigin, const Vector3& rayDir, const Vector3& planePos, const Vector3& planeNormal, float& t);
@ -236,7 +228,8 @@ namespace AZ
//! @param vertexB One of the four points that define the quadrilateral. //! @param vertexB One of the four points that define the quadrilateral.
//! @param vertexC One of the four points that define the quadrilateral. //! @param vertexC One of the four points that define the quadrilateral.
//! @param vertexD One of the four points that define the quadrilateral. //! @param vertexD One of the four points that define the quadrilateral.
//! @param t[out] The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection". //! @param[out] t The coefficient in the ray's explicit equation from which the
//! intersecting point is calculated as "rayOrigin + t * rayDirection".
//! @return The number of intersection point. //! @return The number of intersection point.
int IntersectRayQuad( int IntersectRayQuad(
const Vector3& rayOrigin, const Vector3& rayOrigin,
@ -248,7 +241,6 @@ namespace AZ
float& t); float& t);
//! Test intersection between a ray and an oriented box in 3D. //! Test intersection between a ray and an oriented box in 3D.
//!
//! @param rayOrigin The origin of the ray to test intersection with. //! @param rayOrigin The origin of the ray to test intersection with.
//! @param rayDir The direction of the ray to test intersection with. //! @param rayDir The direction of the ray to test intersection with.
//! @param boxCenter The position of the center of the box. //! @param boxCenter The position of the center of the box.
@ -258,9 +250,9 @@ namespace AZ
//! @param boxHalfExtent1 The half extent of the box on the dimension of \ref boxAxis1. //! @param boxHalfExtent1 The half extent of the box on the dimension of \ref boxAxis1.
//! @param boxHalfExtent2 The half extent of the box on the dimension of \ref boxAxis2. //! @param boxHalfExtent2 The half extent of the box on the dimension of \ref boxAxis2.
//! @param boxHalfExtent3 The half extent of the box on the dimension of \ref boxAxis3. //! @param boxHalfExtent3 The half extent of the box on the dimension of \ref boxAxis3.
//! @param t[out] The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection". //! @param[out] t The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
//! @return 1 if there is an intersection, 0 otherwise. //! @return true if there is an intersection, false otherwise.
int IntersectRayBox( bool IntersectRayBox(
const Vector3& rayOrigin, const Vector3& rayOrigin,
const Vector3& rayDir, const Vector3& rayDir,
const Vector3& boxCenter, const Vector3& boxCenter,
@ -273,23 +265,21 @@ namespace AZ
float& t); float& t);
//! Test intersection between a ray and an OBB. //! Test intersection between a ray and an OBB.
//!
//! @param rayOrigin The origin of the ray to test intersection with. //! @param rayOrigin The origin of the ray to test intersection with.
//! @param rayDir The direction of the ray to test intersection with. //! @param rayDir The direction of the ray to test intersection with.
//! @param obb The OBB to test for intersection with the ray. //! @param obb The OBB to test for intersection with the ray.
//! @param t[out] The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * //! @param[out] t The coefficient in the ray's explicit equation from which the intersecting point is calculated as "rayOrigin + t * rayDirection".
//! rayDirection". //! @return true if there is an intersection, false otherwise.
//! @return 1 if there is an intersection, 0 otherwise. bool IntersectRayObb(const Vector3& rayOrigin, const Vector3& rayDir, const Obb& obb, float& t);
int IntersectRayObb(const Vector3& rayOrigin, const Vector3& rayDir, const Obb& obb, float& t);
//! Ray cylinder intersection types. //! Ray cylinder intersection types.
enum CylinderIsectTypes : AZ::s32 enum CylinderIsectTypes : AZ::s32
{ {
RR_ISECT_RAY_CYL_SA_INSIDE = -1, // the ray starts inside the cylinder RR_ISECT_RAY_CYL_SA_INSIDE = -1, //!< the ray starts inside the cylinder
RR_ISECT_RAY_CYL_NONE, // no intersection RR_ISECT_RAY_CYL_NONE, //!< no intersection
RR_ISECT_RAY_CYL_PQ, // along the PQ segment RR_ISECT_RAY_CYL_PQ, //!< along the PQ segment
RR_ISECT_RAY_CYL_P_SIDE, // on the P side RR_ISECT_RAY_CYL_P_SIDE, //!< on the P side
RR_ISECT_RAY_CYL_Q_SIDE, // on the Q side RR_ISECT_RAY_CYL_Q_SIDE, //!< on the Q side
}; };
//! Reference: Real-Time Collision Detection - 5.3.7 Intersecting Ray or Segment Against Cylinder //! Reference: Real-Time Collision Detection - 5.3.7 Intersecting Ray or Segment Against Cylinder
@ -300,7 +290,7 @@ namespace AZ
//! @param p center point of side 1 cylinder //! @param p center point of side 1 cylinder
//! @param q center point of side 2 cylinder //! @param q center point of side 2 cylinder
//! @param r radius of cylinder //! @param r radius of cylinder
//! @param t[out] proporition along line semgnet //! @param[out] t proporition along line segment
//! @return CylinderIsectTypes //! @return CylinderIsectTypes
CylinderIsectTypes IntersectSegmentCylinder( CylinderIsectTypes IntersectSegmentCylinder(
const Vector3& sa, const Vector3& dir, const Vector3& p, const Vector3& q, const float r, float& t); const Vector3& sa, const Vector3& dir, const Vector3& p, const Vector3& q, const float r, float& t);
@ -308,26 +298,41 @@ namespace AZ
//! Capsule ray intersect types. //! Capsule ray intersect types.
enum CapsuleIsectTypes enum CapsuleIsectTypes
{ {
ISECT_RAY_CAPSULE_SA_INSIDE = -1, // the ray starts inside the cylinder ISECT_RAY_CAPSULE_SA_INSIDE = -1, //!< the ray starts inside the cylinder
ISECT_RAY_CAPSULE_NONE, // no intersection ISECT_RAY_CAPSULE_NONE, //!< no intersection
ISECT_RAY_CAPSULE_PQ, // along the PQ segment ISECT_RAY_CAPSULE_PQ, //!< along the PQ segment
ISECT_RAY_CAPSULE_P_SIDE, // on the P side ISECT_RAY_CAPSULE_P_SIDE, //!< on the P side
ISECT_RAY_CAPSULE_Q_SIDE, // on the Q side ISECT_RAY_CAPSULE_Q_SIDE, //!< on the Q side
}; };
//! This is a quick implementation of segment capsule based on segment cylinder \ref IntersectSegmentCylinder //! This is a quick implementation of segment capsule based on segment cylinder \ref IntersectSegmentCylinder
//! segment sphere intersection. We can optimize it a lot once we fix the ray //! segment sphere intersection. We can optimize it a lot once we fix the ray
//! cylinder intersection. //! cylinder intersection.
//! //! @param sa the beginning of the line segment
//! @param dir the direction and length of the segment
//! @param p center point of side 1 capsule
//! @param q center point of side 1 capsule
//! @param r the radius of the capsule
//! @param[out] t proporition along line segment
//! @return CapsuleIsectTypes
CapsuleIsectTypes IntersectSegmentCapsule( CapsuleIsectTypes IntersectSegmentCapsule(
const Vector3& sa, const Vector3& dir, const Vector3& p, const Vector3& q, const float r, float& t); const Vector3& sa, const Vector3& dir, const Vector3& p, const Vector3& q, const float r, float& t);
//! Intersect segment S(t)=A+t(B-A), 0<=t<=1 against convex polyhedron specified //! Intersect segment S(t)=A+t(B-A), 0<=t<=1 against convex polyhedron specified
//! by the n halfspaces defined by the planes p[]. On exit tfirst and tlast //! by the n halfspaces defined by the planes p[]. On exit tfirst and tlast
//! define the intersection, if any. //! define the intersection, if any.
//! @param sa the beggining of the line segment
//! @param dir the direction and length of the segment
//! @param p planes that compose a convex ponvex polyhedron
//! @param numPlanes number of planes
//! @param[out] tfirst proportion along the line segment where the line enters
//! @param[out] tlast proportion along the line segment where the line exits
//! @param[out] iFirstPlane the plane where the line enters
//! @param[out] iLastPlane the plane where the line exits
//! @return true if intersects else false
bool IntersectSegmentPolyhedron( bool IntersectSegmentPolyhedron(
const Vector3& sa, const Vector3& sa,
const Vector3& sBA, const Vector3& dir,
const Plane p[], const Plane p[],
int numPlanes, int numPlanes,
float& tfirst, float& tfirst,
@ -344,10 +349,10 @@ namespace AZ
//! @param segment1End end of segment 1. //! @param segment1End end of segment 1.
//! @param segment2Start start of segment 2. //! @param segment2Start start of segment 2.
//! @param segment2End end of segment 2. //! @param segment2End end of segment 2.
//! @param segment1Proportion[out] the proporition along segment 1 [0..1] //! @param[out] segment1Proportion the proporition along segment 1 [0..1]
//! @param segment2Proportion[out] the proporition along segment 2 [0..1] //! @param[out] segment2Proportion the proporition along segment 2 [0..1]
//! @param closestPointSegment1[out] closest point on segment 1. //! @param[out] closestPointSegment1 closest point on segment 1.
//! @param closestPointSegment2[out] closest point on segment 2. //! @param[out] closestPointSegment2 closest point on segment 2.
//! @param epsilon the minimum square distance where a line segment can be treated as a single point. //! @param epsilon the minimum square distance where a line segment can be treated as a single point.
void ClosestSegmentSegment( void ClosestSegmentSegment(
const Vector3& segment1Start, const Vector3& segment1Start,
@ -363,13 +368,12 @@ namespace AZ
//! Calculate the line segment closestPointSegment1<->closestPointSegment2 that is the shortest route between //! Calculate the line segment closestPointSegment1<->closestPointSegment2 that is the shortest route between
//! two segments segment1Start<->segment1End and segment2Start<->segment2End. //! two segments segment1Start<->segment1End and segment2Start<->segment2End.
//! If segments are parallel returns a solution. //! If segments are parallel returns a solution.
//!
//! @param segment1Start start of segment 1. //! @param segment1Start start of segment 1.
//! @param segment1End end of segment 1. //! @param segment1End end of segment 1.
//! @param segment2Start start of segment 2. //! @param segment2Start start of segment 2.
//! @param segment2End end of segment 2. //! @param segment2End end of segment 2.
//! @param closestPointSegment1[out] closest point on segment 1. //! @param[out] closestPointSegment1 closest point on segment 1.
//! @param closestPointSegment2[out] closest point on segment 2. //! @param[out] closestPointSegment2 closest point on segment 2.
//! @param epsilon the minimum square distance where a line segment can be treated as a single point. //! @param epsilon the minimum square distance where a line segment can be treated as a single point.
void ClosestSegmentSegment( void ClosestSegmentSegment(
const Vector3& segment1Start, const Vector3& segment1Start,
@ -383,12 +387,11 @@ namespace AZ
//! Calculate the point (closestPointOnSegment) that is the closest point on //! Calculate the point (closestPointOnSegment) that is the closest point on
//! segment segmentStart/segmentEnd to point. Also calculate the value of proportion where //! segment segmentStart/segmentEnd to point. Also calculate the value of proportion where
//! closestPointOnSegment = segmentStart + (proportion * (segmentEnd - segmentStart)) //! closestPointOnSegment = segmentStart + (proportion * (segmentEnd - segmentStart))
//!
//! @param point the point to test //! @param point the point to test
//! @param segmentStart the start of the segment //! @param segmentStart the start of the segment
//! @param segmentEnd the end of the segment //! @param segmentEnd the end of the segment
//! @param proportion[out] the proportion of the segment L(t) = (end - start) * t //! @param[out] proportion the proportion of the segment L(t) = (end - start) * t
//! @param closestPointOnSegment[out] the point along the line segment //! @param[out] closestPointOnSegment the point along the line segment
void ClosestPointSegment( void ClosestPointSegment(
const Vector3& point, const Vector3& point,
const Vector3& segmentStart, const Vector3& segmentStart,

Loading…
Cancel
Save