⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 collisiondetection.h

📁 WOW 服务模拟端 支持2.4.3版本 来自开源的ASCENT 自己REPACK
💻 H
📖 第 1 页 / 共 3 页
字号:

	  @param sphere			Fixed Sphere.
	  @param box			Fixed Box.
	  @param contactPoints	Sphere point that penetrates the box. [Post Condition]
	  @param contactNormals	Normal at the penetration point. [Post Condition]

	  @return Depth of penetration.  If there is no intersection between the
	 		  objects then the depth will be a negative value.
 	 */
    static float penetrationDepthForFixedSphereFixedBox(
        const Sphere&       sphere,
        const Box&          box,
        Array<Vector3>&     contactPoints,
        Array<Vector3>&     contactNormals = ignoreArray);

	/**
	  Calculates the depth of penetration between a Fixed Sphere and a Fixed
	  Plane as well as the deepest point of the sphere that penetrates the plane
	  and the plane normal at that intersection.

	  @param sphere			Fixed Sphere.
	  @param plane			Fixed Plane.
	  @param contactPoints	Sphere point that penetrates the plane.
	 						[Post Condition]
	  @param contactNormals	Normal at penetration point. [Post Condition]

 	  @return Depth of penetration.  If there is no intersection between the
	  		 objects then the depth will be a negative value.
 	 */
    static float penetrationDepthForFixedSphereFixedPlane(
        const Sphere&       sphereA,
        const class Plane&  planeB,
        Array<Vector3>&     contactPoints,
        Array<Vector3>&     contactNormals = ignoreArray);

	/**
	  Calculates the depth of penetration between a fixed box and a fixed
	  plane as well as the vertexes of the box that penetrate the plane
	  and the plane normals at those intersections.

	  @param box			Fixed Box.
	  @param plane			Fixed Plane.
	  @param contactPoints	Box points that penetrate the plane.
	 						[Post Condition]
	  @param contactNormals	Normals at penetration points [Post Condition]

	  @return Depth of penetration.  If there is no intersection between the
	 		 objects then the depth will be a negative value.
 	*/
    static float penetrationDepthForFixedBoxFixedPlane(
        const Box&          box,
        const Plane&        plane,
        Array<Vector3>&     contactPoints,
        Array<Vector3>&     contactNormals = ignoreArray);

	/**
 	  Calculates time between the intersection of a moving point and a fixed
 	  plane.

 	  @note This is only a one sided collision test.   The side defined by
 	  the plane's surface normal is the only one tested.  For a two sided
 	  collision, call the function once for each side's surface normal.

 	  @param point		Moving point.
 	  @param velocity	Point's velocity.
 	  @param plane		Fixed plane.
 	  @param location	Location of collision. [Post Condition]
 	  					(Infinite vector on no collision)
 	  @param outNormal	Plane's surface normal. [Post Condition]

 	  @return Time til collision.  If there is no collision then the return
 	          value will be inf().
 	*/
    static float collisionTimeForMovingPointFixedPlane(
        const Vector3&			point,
        const Vector3&			velocity,
        const class Plane&		plane,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

	/**
 	  Calculates time between the intersection of a moving point and a fixed
 	  triangle.

 	  @note This is only a one sided collision test.   The side defined by
 	  the triangle's surface normal is the only one tested.  For a two sided
 	  collision, call the function once for each side's surface normal.

 	  @param orig		Moving point.
 	  @param dir		Point's velocity.
	  @param v0 		Triangle vertex 1.
	  @param v1 		Triangle vertex 2.
	  @param v2 		Triangle vertex 3
 	  @param location	Location of collision. [Post Condition]
 	  					(Infinite vector on no collision)

 	  @return Time til collision.  If there is no collision then the return
 	          value will be inf().
 	*/
    inline static float collisionTimeForMovingPointFixedTriangle(
        const Vector3& orig,
        const Vector3& dir,
        const Vector3& v0,
        const Vector3& v1,
        const Vector3& v2) {
        return Ray::fromOriginAndDirection(orig, dir).intersectionTime(v0, v1, v2);
    }

	/**
 	  Calculates time between the intersection of a moving point and a fixed
 	  triangle.

 	  @note This is only a one sided collision test.   The side defined by
 	  the triangle's surface normal is the only one tested.  For a two sided
 	  collision, call the function once for each side's surface normal.

 	  @param orig		Moving point.
 	  @param dir		Point's velocity.
	  @param v0 		Triangle vertex 1.
	  @param v1 		Triangle vertex 2.
	  @param v2 		Triangle vertex 3
 	  @param location	Location of collision. [Post Condition]
 	  					(Infinite vector on no collision)

 	  @return Time til collision.  If there is no collision then the return
 	          value will be inf().
 	*/
    inline static float collisionTimeForMovingPointFixedTriangle(
        const Vector3& orig,
        const Vector3& dir,
        const Vector3& v0,
        const Vector3& v1,
        const Vector3& v2,
        Vector3&       location) {
        float t = collisionTimeForMovingPointFixedTriangle(orig, dir, v0, v1, v2);
        if (t < inf()) {
            location = orig + dir * t;
        }
        return t;
    }

	/**
 	  Calculates time between the intersection of a moving point and a fixed
 	  triangle.

 	  @note This is only a one sided collision test.   The side defined by
 	  the triangle's surface normal is the only one tested.  For a two sided
 	  collision, call the function once for each side's surface normal.

 	  @param orig		Moving point.
 	  @param dir		Point's velocity.
 	  @param tri		Fixed triangle.
 	  @param location	Location of collision. [Post Condition]
 	  					(Infinite vector on no collision)
 	  @param normal		Triangle's surface normal. [Post Condition]

 	  @return Time til collision.  If there is no collision then the return
 	          value will be inf().
 	*/
    inline static float collisionTimeForMovingPointFixedTriangle(
        const Vector3&  orig,
        const Vector3&  dir,
        const Triangle& tri,
        Vector3&        location = ignore,
        Vector3&        normal   = ignore) {

        float t = collisionTimeForMovingPointFixedTriangle(
            orig, dir, tri.vertex(0), tri.vertex(1), tri.vertex(2));
        
        if ((t < inf()) && (&location != &ignore)) {
            location = orig + dir * t;
            normal   = tri.normal();
        }
        return t;
    }

	/**
 	  Calculates time between the intersection of a moving point and a fixed
 	  triangle.

 	  @note This is only a one sided collision test.   The side defined by
 	  the triangle's surface normal is the only one tested.  For a two sided
 	  collision, call the function once for each side's surface normal.

 	  @param orig		Moving point.
 	  @param dir		Point's velocity.
	  @param v0 		Triangle vertex 1.
	  @param v1 		Triangle vertex 2.
	  @param v2 		Triangle vertex 3
 	  @param location	Location of collision. [Post Condition]
 	  					(Infinite vector on no collision)
 	  @param normal		Triangle's surface normal. [Post Condition]

 	  @return Time til collision.  If there is no collision then the return
 	          value will be inf().
 	*/
    inline static float collisionTimeForMovingPointFixedTriangle(
        const Vector3& orig,
        const Vector3& dir,
        const Vector3& v0,
        const Vector3& v1,
        const Vector3& v2,
        Vector3&       location,
        Vector3&       normal) {
        float t = collisionTimeForMovingPointFixedTriangle(orig, dir, v0, v1, v2);
        if (t < inf()) {
            location = orig + dir * t;
            normal   = (v2 - v0).cross(v1 - v0).direction();
        }
        return t;
    }

    /**
     Unlike other methods, does not support an output normal.
     If the ray origin is inside the box, returns inf() but inside
     is set to true.
     <B>Beta API</B>

     @cite Andrew Woo, from "Graphics Gems", Academic Press, 1990
  	 @cite Optimized code by Pierre Terdiman, 2000 (~20-30% faster on my Celeron 500)
     @cite Epsilon value added by Klaus Hartmann
     @cite http://www.codercorner.com/RayAABB.cpp
     */
    static float collisionTimeForMovingPointFixedAABox(
        const Vector3&			point,
        const Vector3&			velocity,
        const class AABox&      box,
        Vector3&				outLocation,
        bool&                   inside = ignoreBool,
        Vector3&                outNormal = ignore);

    /**
	 Calculates time between the intersection of a moving point and a fixed
	 Axis-Aligned Box (AABox).

	 @note Avoids the sqrt from collisionTimeForMovingPointFixedAABox.

	 @param point		Moving point.
	 @param velocity	Sphere's velocity.
	 @param box			Fixed AAbox.
	 @param location	Location of collision. [Post Condition]
	 @param Inside		Does the ray originate inside the box? [Post Condition]
	 @param normal		Box's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
 	*/
    static bool collisionLocationForMovingPointFixedAABox(
        const Vector3&			point,
        const Vector3&			velocity,
        const class AABox&      box,
        Vector3&				outLocation,
        bool&                   inside = ignoreBool,
        Vector3&                normal = ignore);

    /**
	 Calculates time between the intersection of a moving point and a fixed
	 sphere.

	 @note When ray is starts inside the rectangle, the exiting intersection
	 is detected.

	 @param point		Moving point.
	 @param velocity	Point's velocity.
	 @param Sphere		Fixed Sphere.
	 @param location	Location of collision. [Post Condition]
	 @param outNormal	Sphere's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
 	*/
    static float collisionTimeForMovingPointFixedSphere(
        const Vector3&			point,
        const Vector3&			velocity,
        const class Sphere&		sphere,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

    /**
	 Calculates time between the intersection of a moving point and a fixed
	 box.

	 @note If the point is already inside the box, no collision: inf is returned.

	 @param point		Moving point.
	 @param velocity	Sphere's velocity.
	 @param box			Fixed box.
	 @param location	Position of collision. [Post Condition]
	 @param outNormal	Box's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
 	*/
    static float collisionTimeForMovingPointFixedBox(
        const Vector3&			point,
        const Vector3&			velocity,
        const class  Box&		box,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

	/**
	 Calculates time between the intersection of a moving point and a fixed
	 rectangle defined by the points v0, v1, v2, & v3.

	 @note This is only a one sided collision test.   The side defined by
	 the rectangle's surface normal is the only one tested.  For a two sided
	 collision, call the function once for each side's surface normal.

	 @param point		Moving point.
	 @param velocity	Sphere's velocity.
	 @param v0 			Rectangle vertex 1.
	 @param v1 			Rectangle vertex 2.
	 @param v2 			Rectangle vertex 3
	 @param v3 			Rectangle vertex 4.
	 @param location	Location of collision [Post Condition]
	 @param outNormal	Rectangle's surface normal. [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
 	*/
    static float collisionTimeForMovingPointFixedRectangle(
        const Vector3&			point,
        const Vector3&			velocity,
        const Vector3&			v0,
        const Vector3&			v1,
        const Vector3&			v2,
        const Vector3&			v3,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

	/**
	 Calculates time between the intersection of a moving point and a fixed
	 capsule.

	 @param point		Moving point.
	 @param velocity	Point's velocity.
	 @param capsule		Fixed capsule.
	 @param location	Location of collision. [Post Condition]
	 @param outNormal	Capsule's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
 	*/
	static float collisionTimeForMovingPointFixedCapsule(
		const Vector3&		    point,
		const Vector3&		    velocity,
		const class Capsule&	capsule,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

	/**
	 Calculates time between the intersection of a moving sphere and a fixed
	 triangle.

	 @param sphere		Moving sphere.
	 @param velocity	Sphere's velocity.
	 @param plane		Fixed Plane.
	 @param location	Location of collision -- not center position of sphere
	 					at the collision time. [Post Condition]
	 @param outNormal	Box's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
	 */
    static float collisionTimeForMovingSphereFixedPlane(
        const class Sphere&		sphere,
        const Vector3&	    	velocity,
        const class Plane&		plane,
        Vector3&				outLocation,
        Vector3&                outNormal = ignore);

	/**
	 Calculates time between the intersection of a moving sphere and a fixed
	 triangle.

	 @param sphere		Moving sphere.
	 @param velocity	Sphere's velocity.
	 @param triangle	Fixed Triangle.
	 @param location	Location of collision -- not center position of sphere
	 					at the collision time. [Post Condition]
	 @param outNormal	Box's surface normal to collision [Post Condition]

	 @return Time til collision.  If there is no collision then the return
	         value will be inf().
	*/
    static float collisionTimeForMovingSphereFixedTriangle(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -