Namespace P64::Coll

Classes

Functions

inline bool P64::Coll::aabbOverlap(const AABB &a, const AABB &b)

Determines if two AABBs overlap.

Parameters:
  • a

  • b

Returns:

true if they do, false if not

inline bool P64::Coll::aabbContains(const AABB &outer, const AABB &inner)

Determines if an AABB fully contains another.

Parameters:
  • outer

  • inner

Returns:

true if it does, fals if not

inline bool P64::Coll::aabbContainsPoint(const AABB &box, const fm_vec3_t &p)

Determines if an AABB contains a Point in 3D Space.

Parameters:
  • box

  • p

Returns:

inline AABB P64::Coll::aabbUnion(const AABB &a, const AABB &b)

Returns the union of two AABBs that contains them both.

Parameters:
  • a

  • b

Returns:

inline float P64::Coll::aabbArea(const AABB &box)

Calculates the Area of an AABB.

Used for efficient Leaf insertion in AABB Tree

Parameters:

box

Returns:

inline void P64::Coll::aabbExtendDirection(
const AABB &in,
const fm_vec3_t &dir,
AABB &out
)

Extends an AABB in a given direction by the magnitude of the input direction.

Parameters:
  • in

  • dir

  • out

inline bool P64::Coll::aabbIntersectsRay(const AABB &box, const Raycast &ray)

Determines if a Ray intersects an AABB.

Parameters:
  • box

  • origin

  • invDir

  • maxDist

Returns:

bool P64::Coll::capsuleSweepTriangle(
const fm_vec3_t &center,
const fm_vec3_t &axisUp,
float radius,
float innerHalfHeight,
const fm_vec3_t &displacement,
const fm_vec3_t &v0,
const fm_vec3_t &v1,
const fm_vec3_t &v2,
const fm_vec3_t &triNormal,
CapsuleSweepHit &hit
)

Tests a capsule sweep against a single world-space triangle.

Returns true and fills hit with the earliest contact (or deepest overlap when t == 0).

Parameters:
  • center – Capsule center in world space

  • axisUp – Normalized capsule-axis direction

  • radius – Capsule radius

  • innerHalfHeight – Half-length of the cylindrical section (not including sphere caps)

  • displacement – World-space displacement vector (not normalized)

  • v0/v1/v2 – World-space triangle vertices

  • triNormal – World-space outward triangle normal (should be normalized)

bool P64::Coll::collideDetectObjectToObject(
Collider *colliderA,
RigidBody *rigidBodyA,
Collider *colliderB,
RigidBody *rigidBodyB,
bool recordConstraints
)
bool P64::Coll::collideDetectObjectToMesh(
Collider *collider,
RigidBody *rigidBody,
const MeshCollider &mesh,
bool recordConstraints
)
bool P64::Coll::collideDetectObjectToTriangle(
ColliderProxy *colliderProxy,
RigidBody *rigidBody,
const MeshCollider &mesh,
int triangleIndex,
bool recordConstraints
)
ContactConstraint *P64::Coll::collideCacheContactConstraint(
RigidBody *rigidBodyA,
Collider *colliderA,
MeshCollider *meshColliderA,
Object *objectA,
RigidBody *rigidBodyB,
Collider *colliderB,
MeshCollider *meshColliderB,
Object *objectB,
const EpaResult &result,
float combinedFriction,
float combinedBounce,
bool isTrigger,
bool respondsA,
bool respondsB,
int triangleIndex = -1
)
void P64::Coll::colliderGjkSupport(
const void *data,
const fm_vec3_t &direction,
fm_vec3_t &output
)

GJK-compatible support wrapper.

CollisionScene *P64::Coll::collisionSceneGetInstance()
inline bool P64::Coll::shouldSwapColliderPairOrder(
Collider *colliderA,
Collider *colliderB
)
inline ContactConstraintKey P64::Coll::makeColliderPairConstraintKey(
Collider *colliderA,
Collider *colliderB
)
inline ContactConstraintKey P64::Coll::makeColliderMeshConstraintKey(
Collider *collider,
MeshCollider *meshCollider,
uint16_t triangleIndex
)
inline ContactConstraintKey P64::Coll::makeColliderMeshConstraintKey(
Collider *collider,
MeshCollider *meshCollider
)
inline uint32_t P64::Coll::contactTransformVersion(
const RigidBody *rigidBody,
const Collider *collider,
const MeshCollider *meshCollider
)
inline fm_vec3_t P64::Coll::contactLocalPointFromWorldPoint(
const fm_vec3_t &worldPoint,
const RigidBody *rigidBody,
const Collider *collider,
const MeshCollider *meshCollider
)
inline fm_vec3_t P64::Coll::contactWorldPointFromLocalPoint(
const fm_vec3_t &localPoint,
const RigidBody *rigidBody,
const Collider *collider,
const MeshCollider *meshCollider
)
inline fm_vec3_t P64::Coll::contactReferenceOffset(
const fm_vec3_t &worldPoint,
const RigidBody *rigidBody,
const Collider *collider,
const MeshCollider *meshCollider
)
inline void P64::Coll::refreshContactPointWorldState(
ContactPoint &point,
const ContactConstraint &constraint,
bool computeRelativeOffsets = false
)
bool P64::Coll::epaSolve(
Simplex &startingSimplex,
const void *rigidBodyA,
GjkSupportFunction rigidBodyASupport,
const void *rigidBodyB,
GjkSupportFunction rigidBodyBSupport,
EpaResult &result
)

Solves EPA to find penetration depth and contact information for overlapping rigidBodys.

float P64::Coll::getGfxScale()
float P64::Coll::getInvGfxScale()
void P64::Coll::setGfxScale(float gfxScale)
fm_vec3_t *P64::Coll::simplexAddPoint(
Simplex &simplex,
const fm_vec3_t &aPoint,
const fm_vec3_t &bPoint
)

Adds a new support point (Minkowski difference) to the simplex.

Parameters:
  • simplex

  • aPoint

  • bPoint

Returns:

pointer to the new point in the simplex, or nullptr if full

bool P64::Coll::simplexCheck(Simplex &simplex, fm_vec3_t &nextDirection)

Checks whether the given simplex encloses the origin and updates the search direction.

Parameters:
  • simplex

  • nextDirection

Returns:

bool P64::Coll::gjkCheckForOverlap(
Simplex &simplex,
const void *colliderA,
GjkSupportFunction colliderASupport,
const void *colliderB,
GjkSupportFunction colliderBSupport,
const fm_vec3_t &firstDirection,
fm_vec3_t *outSeparatingAxis = nullptr
)

Performs GJK overlap test between two convex rigidBodys.

Parameters:
  • simplex – pointer to the simplex structure to use

  • colliderA – first collider

  • colliderASupport – support function matching the first collider type

  • colliderB – second collider

  • colliderBSupport – support function matching the second collider type

  • firstDirection – initial direction to search for the origin (arbitrary)

Returns:

fm_vec3_t P64::Coll::matrix3Vec3Mul(const Matrix3x3 &mat, const fm_vec3_t &v)
float P64::Coll::matrix3Determinant(const Matrix3x3 &matrix)
Matrix3x3 P64::Coll::matrix3Inverse(const Matrix3x3 &matrix)
Matrix3x3 P64::Coll::matrix3Mul(const Matrix3x3 &a, const Matrix3x3 &b)
Matrix3x3 P64::Coll::matrix3Transpose(const Matrix3x3 &m)
Matrix3x3 P64::Coll::quatToMatrix3(const fm_quat_t &q)
inline Matrix3x3 P64::Coll::diagonalMatrix(const fm_vec3_t &diag)
void P64::Coll::meshTriangleGjkSupport(
const void *data,
const fm_vec3_t &direction,
fm_vec3_t &output
)

GJK-compatible wrapper for MeshTriangle.

inline RaycastColliderTypeFlags P64::Coll::operator|(
RaycastColliderTypeFlags a,
RaycastColliderTypeFlags b
)
inline bool P64::Coll::hasFlag(RaycastColliderTypeFlags m, RaycastColliderTypeFlags f)
bool P64::Coll::ray_collider_intersection(
const Raycast &ray,
const Collider *coll,
RaycastHit &hit
)
bool P64::Coll::ray_triangle_intersection(
const Raycast &ray,
const fm_vec3_t &v0,
const fm_vec3_t &v1,
const fm_vec3_t &v2,
const fm_vec3_t &tri_norm,
RaycastHit &hit
)
inline Constraint P64::Coll::operator|(Constraint a, Constraint b)
inline Constraint P64::Coll::operator&(Constraint a, Constraint b)
inline bool P64::Coll::hasFlag(Constraint c, Constraint flag)
inline fm_vec3_t P64::Coll::vec3ReciprocalScaleComponents(const fm_vec3_t &scale)
inline fm_vec3_t P64::Coll::vec3NormalizeOrFallback(
const fm_vec3_t &vector,
const fm_vec3_t &fallback
)
inline fm_vec3_t P64::Coll::vec3AssumeNormalized(
const fm_vec3_t &n,
const fm_vec3_t &fallback
)

Use when the vector is already known to be unit-length (e.g.

hit normals from capsule sweeps / raycasts). Only falls back for degenerate (zero) vectors.

inline fm_vec3_t P64::Coll::vec3Perpendicular(const fm_vec3_t &a)
inline fm_vec3_t P64::Coll::vec3TripleProduct(
const fm_vec3_t &a,
const fm_vec3_t &b,
const fm_vec3_t &c
)

Computes The vector triple product: (a × b) × c = b(a·c) - a(b·c)

Parameters:
  • a

  • b

  • c

Returns:

The result of the vector triple product

inline bool P64::Coll::vec3IsZero(const fm_vec3_t &v)

Checks if a vector is the zero vector (0, 0, 0).

Parameters:

v

Returns:

inline fm_vec3_t P64::Coll::vec3Min(const fm_vec3_t &a, const fm_vec3_t &b)

Returns a vector containing the component-wise minimum of two vectors.

Parameters:
  • a

  • b

Returns:

inline fm_vec3_t P64::Coll::vec3Max(const fm_vec3_t &a, const fm_vec3_t &b)

Returns a vector containing the component-wise maximum of two vectors.

Parameters:
  • a

  • b

Returns:

inline fm_vec3_t P64::Coll::vec3Project(const fm_vec3_t &v, const fm_vec3_t &onto)

Projects vector v onto vector onto.

Parameters:
  • v – The vector to be projected.

  • onto – The vector onto which v is projected.

Returns:

The projected vector.

inline fm_vec3_t P64::Coll::vec3ProjectOntoUnit(
const fm_vec3_t &v,
const fm_vec3_t &onto
)

Projects v onto an already-unit-length vector onto.

inline fm_vec3_t P64::Coll::vec3ClampMag(const fm_vec3_t &v, float maxMag)

Clamps the magnitude of a vector to a maximum value.

Parameters:
  • v – The vector to be clamped.

  • maxMag – The maximum allowed magnitude.

Returns:

The clamped vector.

inline void P64::Coll::vec3CalculateTangents(
const fm_vec3_t &normal,
fm_vec3_t &tangentU,
fm_vec3_t &tangentV
)

Calculates two tangent vectors orthogonal to a given normal vector.

Parameters:
  • normal – The normal vector.

  • tangentU – The first tangent vector (output).

  • tangentV – The second tangent vector (output).

inline float P64::Coll::calculateLerp(
const fm_vec3_t &a,
const fm_vec3_t &b,
const fm_vec3_t &point
)
inline fm_vec3_t P64::Coll::calculateBarycentricCoords(
const fm_vec3_t &a,
const fm_vec3_t &b,
const fm_vec3_t &c,
const fm_vec3_t &point
)
inline fm_vec3_t P64::Coll::evaluateBarycentricCoords(
const fm_vec3_t &a,
const fm_vec3_t &b,
const fm_vec3_t &c,
const fm_vec3_t &bary
)
inline Plane P64::Coll::planeFromNormalAndPoint(
const fm_vec3_t &normal,
const fm_vec3_t &point
)

Creates a plane from a normal vector and a point on the plane.

Parameters:
  • normal – The normal vector of the plane.

  • point – A point on the plane.

Returns:

The constructed plane.

inline float P64::Coll::planeSignedDistance(const Plane &plane, const fm_vec3_t &point)

Returns the signed distance from a point to a plane.

Parameters:
  • plane – The plane to test against.

  • point – The point to measure from.

Returns:

Positive if the point is on the side the normal points to, negative otherwise.

inline fm_vec3_t P64::Coll::planeProjectPoint(const Plane &plane, const fm_vec3_t &point)

Projects a point onto a plane.

Parameters:
  • plane – The plane to project onto.

  • point – The point to project.

Returns:

The closest point on the plane to the given point.

inline bool P64::Coll::planeRayIntersection(
const Plane &plane,
const fm_vec3_t &rayOrigin,
const fm_vec3_t &rayDir,
float &outDistance
)

Tests for intersection between a ray and a plane, returning the distance along the ray to the intersection point if it exists.

Parameters:
  • plane – The plane to test against.

  • rayOrigin – The origin of the ray.

  • rayDir – The direction of the ray.

  • outDistance – The distance along the ray to the intersection point (output).

Returns:

True if the ray intersects the plane, false otherwise.

inline fm_quat_t P64::Coll::quatConjugate(const fm_quat_t &q)

Constructs the conjugate of a quaternion, which represents the inverse rotation for unit quaternions.

Parameters:

q – The quaternion to conjugate.

Returns:

The conjugated quaternion.

inline float P64::Coll::quatDot(const fm_quat_t &a, const fm_quat_t &b)

Computes the dot product of two quaternions.

Parameters:
  • a – The first quaternion.

  • b – The second quaternion.

Returns:

The dot product of the two quaternions.

inline fm_quat_t P64::Coll::quatApplyAngularVelocity(
const fm_quat_t &q,
const fm_vec3_t &omega,
float dt
)

Apply an Angular Velocity to an existing rotation quaternion, scaled by a given scalar.

Parameters:
  • q – the input quaternion

  • omega – the angular velocity

  • dt – scalar

Returns:

inline bool P64::Coll::quatIsIdentical(const fm_quat_t *a, const fm_quat_t *b)

Checks if two quaternions are the same component-wise.

Parameters:
  • a

  • b

Returns:

Typedefs

using P64::Coll::NodeProxy = int16_t
using P64::Coll::GjkSupportFunction = void (*)(const void *data, const fm_vec3_t &direction, fm_vec3_t &output)

GJK support function: returns the furthest point on a convex shape in a given direction.

Enums

enum class P64::Coll::ContactConstraintKeyType : uint8_t

Values:

enumerator None
enumerator ColliderPair
enumerator ColliderMesh
enumerator ColliderMeshTriangle
enum class P64::Coll::RaycastColliderTypeFlags : uint8_t

Values:

enumerator MESH_COLLIDERS
enumerator COLLIDER_BODIES
enumerator ALL
enum class P64::Coll::Constraint : uint16_t

Defines the different positional and rotational constraints that can be imposed on a rigidbody.

Values:

enumerator None
enumerator FreezePosX
enumerator FreezePosY
enumerator FreezePosZ
enumerator FreezePosAll
enumerator FreezeRotX
enumerator FreezeRotY
enumerator FreezeRotZ
enumerator FreezeRotAll
enumerator All
enum class P64::Coll::ShapeType : uint8_t

Values:

enumerator Sphere
enumerator Capsule
enumerator Box
enumerator Cone
enumerator Cylinder
enumerator Pyramid

Variables

constexpr NodeProxy P64::Coll::NULL_NODE = -1
constexpr float P64::Coll::AABB_DISPLACEMENT_MULTIPLIER = 10.0f
constexpr int P64::Coll::AABB_QUERY_STACK_SIZE = 256
constexpr int P64::Coll::MAX_OBJ_COLLISION_CANDIDATES = 15
constexpr float P64::Coll::DEFAULT_FIXED_DT = 1.0f / 50.0f
constexpr fm_vec3_t P64::Coll::DEFAULT_GRAVITY = {0.0f, -9.8f, 0.0f}
constexpr uint8_t P64::Coll::DEFAULT_VELOCITY_SOLVER_ITERATIONS = 8
constexpr uint8_t P64::Coll::DEFAULT_POSITION_SOLVER_ITERATIONS = 7
constexpr float P64::Coll::WARM_STARTING_FACTOR = 0.85f
constexpr int P64::Coll::MAX_CCD_SUBSTEPS = 4
constexpr int P64::Coll::MAX_CONTACT_POINTS_PER_PAIR = 3
constexpr int P64::Coll::GJK_MAX_SIMPLEX_SIZE = 4
constexpr int P64::Coll::RAYCAST_MAX_COLLIDER_TESTS = 50
constexpr int P64::Coll::RAYCAST_MAX_TRIANGLE_TESTS = 30
constexpr float P64::Coll::TERMINAL_SPEED = 100.0f
constexpr float P64::Coll::TERMINAL_ANGULAR_SPEED = 50.0f
constexpr float P64::Coll::TERMINAL_ANGULAR_SPEED_SQ = TERMINAL_ANGULAR_SPEED * TERMINAL_ANGULAR_SPEED
constexpr float P64::Coll::POS_SLEEP_THRESHOLD = 0.01f
constexpr float P64::Coll::POS_SLEEP_THRESHOLD_SQ = POS_SLEEP_THRESHOLD * POS_SLEEP_THRESHOLD
constexpr float P64::Coll::SPEED_SLEEP_THRESHOLD = 0.8f
constexpr float P64::Coll::SPEED_SLEEP_THRESHOLD_SQ = SPEED_SLEEP_THRESHOLD * SPEED_SLEEP_THRESHOLD
constexpr float P64::Coll::ROT_SIMILARITY_SLEEP_THRESHOLD = 0.9999988f
constexpr float P64::Coll::ANGULAR_SLEEP_THRESHOLD = 1.0f
constexpr float P64::Coll::ANGULAR_SLEEP_THRESHOLD_SQ = ANGULAR_SLEEP_THRESHOLD * ANGULAR_SLEEP_THRESHOLD
constexpr float P64::Coll::AMPLIFY_ANG_DAMPING_THRESHOLD = 0.015f
constexpr float P64::Coll::AMPLIFY_ANG_DAMPING_THRESHOLD_SQ = AMPLIFY_ANG_DAMPING_THRESHOLD * AMPLIFY_ANG_DAMPING_THRESHOLD
constexpr float P64::Coll::AMPLIFY_ANG_DAMPING_THRESHOLD_SQ_INV = 1.0f / AMPLIFY_ANG_DAMPING_THRESHOLD_SQ
constexpr int P64::Coll::SLEEP_STEPS = 120