102 Patches: Detours to the Rescue
C reference for DttR maintainers and modders.
Loading...
Searching...
No Matches
dttr_util_collision.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <dttr_core.h>
#include <dttr_pcdogs.h>
#include <dttr_util_mem.h>

Go to the source code of this file.

Macros

#define DTTR_UTIL_COLLISION_Q12_ONE   4096
 Collision node transform matrices use this Q12 fixed-point unit.
#define DTTR_UTIL_COLLISION_VERTEX_WORLD_SCALE   64
#define DTTR_UTIL_COLLISION_MAX_VERTICES   4096u
#define DTTR_UTIL_COLLISION_MAX_POLYGONS   8192u
#define DTTR_UTIL_COLLISION_ADJ_FACE_MIN_SIZE   0x14u
#define DTTR_UTIL_COLLISION_VERTEX_WALL_TAG_OFFSET   0x0bu

Functions

static uint32_t DTTR_Util_CollisionPolygonEdgeCount (const DTTR_PCDOGS_T_Collision_Polygon *polygon)
static bool DTTR_Util_CollisionVertexWorld (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Vertex *vertex, DTTR_PCDOGS_T_Math_Vec3I32 *out_world)
static bool DTTR_Util_CollisionPolygonInNode (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Polygon *polygon)
static DTTR_PCDOGS_T_Collision_PolygonDTTR_Util_CollisionAdjacentPolygon (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Polygon *polygon, uint32_t edge_index, int32_t *out_neighbor_edge)
static bool dttr_util_collision_edge_vertices (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Polygon *polygon, uint32_t edge_index, uint16_t *out_i0, uint16_t *out_i1)
static uint8_t dttr_util_collision_vertex_wall_tag (const DTTR_PCDOGS_T_Collision_Vertex *vertex)
static bool DTTR_Util_CollisionEdgeIsWall (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Polygon *polygon, uint32_t edge_index)
static bool DTTR_Util_CollisionWallEdgeQuad (const DTTR_PCDOGS_T_Collision_Node *node, const DTTR_PCDOGS_T_Collision_Polygon *polygon, uint32_t edge_index, int32_t height_fp, DTTR_PCDOGS_T_Math_Vec3I32 out_world[4])

Macro Definition Documentation

◆ DTTR_UTIL_COLLISION_ADJ_FACE_MIN_SIZE

#define DTTR_UTIL_COLLISION_ADJ_FACE_MIN_SIZE   0x14u

A face-plane record must be readable through at least this size, which covers the header through the adjacency words at +0xC.

Definition at line 41 of file dttr_util_collision.h.

Referenced by DTTR_Util_CollisionAdjacentPolygon().

◆ DTTR_UTIL_COLLISION_MAX_POLYGONS

#define DTTR_UTIL_COLLISION_MAX_POLYGONS   8192u

Definition at line 37 of file dttr_util_collision.h.

Referenced by DTTR_Util_CollisionPolygonInNode().

◆ DTTR_UTIL_COLLISION_MAX_VERTICES

#define DTTR_UTIL_COLLISION_MAX_VERTICES   4096u

Bounds for node array counts. Live nodes stay far below these values; larger counts usually mean a stale or misread node.

Definition at line 36 of file dttr_util_collision.h.

Referenced by DTTR_Util_CollisionPolygonInNode().

◆ DTTR_UTIL_COLLISION_Q12_ONE

#define DTTR_UTIL_COLLISION_Q12_ONE   4096

Collision node transform matrices use this Q12 fixed-point unit.

Helpers for decoding live collision nodes, polygons, edge adjacency, and wall edges.

This header is exposed through dttr_sdk.h only when DTTR_SDK_ENABLE_UNSTABLE is set. It depends on PCDOGS layouts that are still being mapped, so source and ABI details may change without notice.

Definition at line 27 of file dttr_util_collision.h.

Referenced by DTTR_Util_CollisionVertexWorld().

◆ DTTR_UTIL_COLLISION_VERTEX_WALL_TAG_OFFSET

#define DTTR_UTIL_COLLISION_VERTEX_WALL_TAG_OFFSET   0x0bu

The per-vertex wall tag sits at this byte offset within a collision vertex record.

Definition at line 45 of file dttr_util_collision.h.

Referenced by dttr_util_collision_vertex_wall_tag().

◆ DTTR_UTIL_COLLISION_VERTEX_WORLD_SCALE

#define DTTR_UTIL_COLLISION_VERTEX_WORLD_SCALE   64

Raw collision vertex components are local units at 1/64 of world fixed point, so a world position is the node origin plus the (optionally rotated) raw vertex times this scale.

Definition at line 32 of file dttr_util_collision.h.

Referenced by DTTR_Util_CollisionVertexWorld().

Function Documentation

◆ dttr_util_collision_edge_vertices()

bool dttr_util_collision_edge_vertices ( const DTTR_PCDOGS_T_Collision_Node * node,
const DTTR_PCDOGS_T_Collision_Polygon * polygon,
uint32_t edge_index,
uint16_t * out_i0,
uint16_t * out_i1 )
inlinestatic

◆ dttr_util_collision_vertex_wall_tag()

uint8_t dttr_util_collision_vertex_wall_tag ( const DTTR_PCDOGS_T_Collision_Vertex * vertex)
inlinestatic

◆ DTTR_Util_CollisionAdjacentPolygon()

DTTR_PCDOGS_T_Collision_Polygon * DTTR_Util_CollisionAdjacentPolygon ( const DTTR_PCDOGS_T_Collision_Node * node,
const DTTR_PCDOGS_T_Collision_Polygon * polygon,
uint32_t edge_index,
int32_t * out_neighbor_edge )
inlinestatic

Decode a polygon's packed edge adjacency locally and return the neighbor.

The packed words live at +0xC of the polygon's face-plane record: the low two bits hold the neighbor edge, and the rest is a one-based index into the owning node's polygon array. Local decoding avoids the native helper's stale-record crashes and leaves walkability filtering to callers.

Definition at line 164 of file dttr_util_collision.h.

References DTTR_PCDOGS_T_Collision_Polygon::adj_face_ptr, DTTR_UTIL_COLLISION_ADJ_FACE_MIN_SIZE, DTTR_Util_MemReadable(), NULL, DTTR_PCDOGS_T_Collision_Node::polygon_count, and DTTR_PCDOGS_T_Collision_Node::polygons.

Referenced by DTTR_Util_CollisionEdgeIsWall().

◆ DTTR_Util_CollisionEdgeIsWall()

bool DTTR_Util_CollisionEdgeIsWall ( const DTTR_PCDOGS_T_Collision_Node * node,
const DTTR_PCDOGS_T_Collision_Polygon * polygon,
uint32_t edge_index )
inlinestatic

Return whether a polygon edge is a wall, per the engine's rule in Collision_ProcessActorGroundCheck. Make sure you validate polygon membership with DTTR_Util_CollisionPolygonInNode first.

A wall edge belongs to a boundary polygon (flags 0x4000), has at least one endpoint with a nonzero wall tag (byte +0xB of the vertex record), and its neighbor across the edge is missing or not walkable (neighbor flags bit 0x4 clear), unless flags 0x400 plus bit 0 of the face-plane record mark it as a one-way or disabled barrier. The engine only extrudes such edges into vertical planes near a touching actor, while this predicate classifies them anywhere.

Definition at line 240 of file dttr_util_collision.h.

References dttr_util_collision_edge_vertices(), dttr_util_collision_vertex_wall_tag(), DTTR_Util_CollisionAdjacentPolygon(), DTTR_Util_CollisionPolygonEdgeCount(), DTTR_Util_MemReadable(), DTTR_PCDOGS_T_Collision_Polygon::flags, NULL, DTTR_PCDOGS_T_Collision_Polygon::plane_data, and DTTR_PCDOGS_T_Collision_Node::vertices.

◆ DTTR_Util_CollisionPolygonEdgeCount()

uint32_t DTTR_Util_CollisionPolygonEdgeCount ( const DTTR_PCDOGS_T_Collision_Polygon * polygon)
inlinestatic

Return a polygon's edge count, which is 4 unless flags bit 0x1 marks a triangle. The polygon must be readable.

Definition at line 49 of file dttr_util_collision.h.

References DTTR_PCDOGS_T_Collision_Polygon::flags.

Referenced by DTTR_Util_CollisionEdgeIsWall(), and DTTR_Util_CollisionWallEdgeQuad().

◆ DTTR_Util_CollisionPolygonInNode()

bool DTTR_Util_CollisionPolygonInNode ( const DTTR_PCDOGS_T_Collision_Node * node,
const DTTR_PCDOGS_T_Collision_Polygon * polygon )
inlinestatic

Report whether a polygon pointer belongs to a node's polygon array and the node's vertex array can satisfy the polygon's indices.

A zero polygon_count is normal on live nodes, in which case vertex_count stands in as the membership upper bound.

Definition at line 111 of file dttr_util_collision.h.

References DTTR_UTIL_COLLISION_MAX_POLYGONS, DTTR_UTIL_COLLISION_MAX_VERTICES, DTTR_Util_MemReadable(), DTTR_PCDOGS_T_Collision_Node::polygon_count, DTTR_PCDOGS_T_Collision_Node::polygons, DTTR_PCDOGS_T_Collision_Node::vertex_count, DTTR_PCDOGS_T_Collision_Polygon::vertex_indices, and DTTR_PCDOGS_T_Collision_Node::vertices.

◆ DTTR_Util_CollisionVertexWorld()

◆ DTTR_Util_CollisionWallEdgeQuad()

bool DTTR_Util_CollisionWallEdgeQuad ( const DTTR_PCDOGS_T_Collision_Node * node,
const DTTR_PCDOGS_T_Collision_Polygon * polygon,
uint32_t edge_index,
int32_t height_fp,
DTTR_PCDOGS_T_Math_Vec3I32 out_world[4] )
inlinestatic

Build a vertical world-space quad over a wall edge. The base follows the edge, and the top is height_fp world fixed-point units above it.

Definition at line 277 of file dttr_util_collision.h.

References dttr_util_collision_edge_vertices(), DTTR_Util_CollisionPolygonEdgeCount(), DTTR_Util_CollisionVertexWorld(), DTTR_PCDOGS_T_Collision_Node::vertices, DTTR_PCDOGS_T_Math_Vec3I32::x, DTTR_PCDOGS_T_Math_Vec3I32::y, and DTTR_PCDOGS_T_Math_Vec3I32::z.