OpenUT99-Plus
Unreal Engine 1, rebuilt from scratch
Loading...
Searching...
No Matches
collision.h
Go to the documentation of this file.
1// Collision against the level BSP: point solidity and swept boxes. Spec: docs/formats/level.md (collision)
2#pragma once
3#include "level.h"
4
5namespace ut {
6
7struct Hit {
8 bool hit = false;
9 bool start_solid = false; // the start overlaps solid; the box may still move out of it (only entering hits)
10 float time = 1; // fraction of the move done before the hit (pulled back slightly)
11 Vec3 normal{0, 0, 0}; // of the surface hit, pointing out of the solid
12};
13
14// Empty space: a node's front side is empty; its back side is empty only if the walk was in empty space and the
15// node is not CSG (node flag 0x1). Checked on retail maps: 1,283 of 1,285 player starts are empty with solid below.
16bool point_solid(const Model& m, Vec3 p);
17
18// Sweeps an axis-aligned box of half size extent (0 = a line) from start to end.
19Hit trace(const Model& m, Vec3 start, Vec3 end, Vec3 extent);
20
21// trace against a model placed in the world (a mover's brush): world = loc + R * (local - pivot), where the rows of
22// axes are R's columns X, Y, Z (unit vectors). The normal comes back in world space. The box keeps its world axes
23// (exact for rotations in steps of 90 degrees about Z).
24Hit trace_placed(const Model& m, Vec3 loc, Vec3 pivot, const float axes[3][3], Vec3 start, Vec3 end, Vec3 extent);
25
26// Segment a-b against a vertical cylinder (centre c, radius r, half height h). A segment starting inside does not
27// hit. On a hit before *t (fraction), sets *t and the surface normal *n and returns true.
28bool ray_cylinder(Vec3 a, Vec3 b, Vec3 c, float r, float h, float* t, Vec3* n);
29
30} // namespace ut
Definition collision.cpp:7
bool point_solid(const Model &m, Vec3 p)
Definition collision.cpp:159
Hit trace_placed(const Model &m, Vec3 loc, Vec3 pivot, const float axes[3][3], Vec3 start, Vec3 end, Vec3 extent)
Definition collision.cpp:188
bool ray_cylinder(Vec3 a, Vec3 b, Vec3 c, float r, float h, float *t_hit, Vec3 *normal)
Definition collision.cpp:129
Hit trace(const Model &m, Vec3 start, Vec3 end, Vec3 extent)
Definition collision.cpp:176
Definition collision.h:7
bool hit
Definition collision.h:8
float time
Definition collision.h:10
Vec3 normal
Definition collision.h:11
bool start_solid
Definition collision.h:9
Definition upkg.h:66