Struct MeshCollider

struct MeshCollider

Public Functions

inline P64::Object *ownerObject() const
inline void setCollisionMask(uint8_t newReadMask, uint8_t newWriteMask)
inline uint8_t readMask() const
inline uint8_t writeMask() const
inline void setFriction(float newFriction)
inline float friction() const
inline void setBounce(float newBounce)
inline float bounce() const
inline uint16_t triangleCount() const
inline uint16_t vertexCount() const
inline const fm_vec3_t &vertex(uint16_t index) const
inline const MeshTriangleIndices &triangleIndices(uint16_t index) const
inline const fm_vec3_t &triangleNormal(uint16_t index) const
inline int queryTriangleNodes(
const AABB &localBounds,
NodeProxy *outCandidates,
int maxCandidates
) const
inline int queryTriangleNodes(
const Raycast &localRay,
NodeProxy *outCandidates,
int maxCandidates
) const
inline int triangleIndexForNode(NodeProxy node) const
inline const AABB &localRootAabb() const
inline const AABB &worldAabb() const
inline uint32_t worldTransformVersion() const
inline bool hasCachedOwnerTransform() const
inline bool transformChanged() const
inline const Matrix3x3 &inverseRotationMatrix() const
fm_vec3_t toWorldSpace(const fm_vec3_t &localPoint) const

Transform a local-space point to world space.

fm_vec3_t toLocalSpace(const fm_vec3_t &worldPoint) const

Transform a world-space point to local space.

fm_vec3_t rotateToWorld(const fm_vec3_t &localDir) const

Rotate a local-space direction/normal to world space (no translation)

fm_vec3_t rotateToLocal(const fm_vec3_t &worldDir) const

Rotate a world-space direction/normal to local space (no translation)

fm_vec3_t localNormalToWorld(const fm_vec3_t &localNormal) const
void localResultToWorld(EpaResult &result) const
void recalculateWorldAabb()

Recompute worldAabb from localRootAabb + current transform.

bool hasOwnerTransformChanged() const

Returns true if the owner’s transform differs from the cached transform snapshot.

void syncOwnerTransform()

Updates the cached owner transform snapshot to the current owner transform.

void computeLocalRootAabb()

Compute localRootAabb from the internal AABB tree root node.

AABB worldAabbToLocal(const AABB &worldAabb) const

Transform a world-space AABB into a conservative local-space AABB for tree queries.

bool hasTransform() const

Returns true if the mesh has a non-identity transform.

bool hasRotation() const

Returns true if the mesh has a non-identity rotation.

bool hasPosition() const

Returns true if the mesh has a non-zero position.

bool hasScale() const

Returns true if the mesh has a non-uniform (1,1,1) scale.

bool readsCollider(const Collider *other) const
bool readsMeshCollider(const MeshCollider *other) const
void destroyData()

Free owned vertex/triangle/normal arrays and destroy the AABB tree.

Public Static Functions

static MeshCollider *createFromRawData(void *rawData, Object *obj)

Create a MeshCollider directly from collision asset raw data, binding to the given Object’s transform.

The returned collider owns newly allocated arrays (vertices, triangles, normals). Call destroyData() to free them.

static MeshCollider *create(
fm_vec3_t *vertices,
uint16_t vertexCount,
MeshTriangleIndices *triangleIndices,
uint16_t triangleCount,
Object *owner = nullptr
)

Create a MeshCollider from manually defined geometry.

If a non-null owner Object is given, the MeshCollider’s transform will be synced to that of the owner. Coordinates must use internal physics scale (i.e. 1 unit = 1 meter). Ownership of the given arrays (vertices, triangleIndices) is transferred to the returned MeshCollider object; call destroyData() to free them.

static inline fm_vec3_t triangleNormalFromVertices(
const fm_vec3_t &v0,
const fm_vec3_t &v1,
const fm_vec3_t &v2
)