group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
PhysicsConstants.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
13namespace physics
14{
15
16// Gravity & jumping
17constexpr float k_gravity = 1000.0f;
19constexpr float k_playerGravity =
20 2.0f * k_gravity;
25constexpr float k_jumpSpeed = 660.0f;
27
28// Ground movement
29// Ground wish speed is stance-dependent — see tms::k_walkSpeed / k_sprintSpeed / k_crouchSpeed
30// and systems::currentWishSpeed() which selects between them.
31constexpr float k_groundAccel = 10.0f;
32
33// Air movement
34constexpr float k_airAccel =
35 700.0f;
36constexpr float k_airMaxSpeed = 30.0f;
39
40// Air wish-speed curve (lets you recover from low/zero air speed without breaking strafe-jump).
41// Per-tick gain in wishDir is bounded by wishSpeed when below it, so this also bounds the
42// initial "kick" from a stationary air state. Larger k_airMaxWishLowSpeed = stronger recovery
43// but feels more teleporty at exactly the moment you start pressing a direction in air.
44constexpr float k_airMaxWishLowSpeed = 120.0f;
45constexpr float k_airWishCurveTop = 250.0f;
47constexpr float k_airWishCurveExponent = 0.4f;
49
50// Friction
51constexpr float k_friction = 7.5f;
52constexpr float k_stopSpeed = 150.0f;
53
54// Collision
55constexpr float k_overbounceWall = 1.001f;
56constexpr float k_overbounceFloor = 1.0f;
57
58// Geometry
59constexpr float k_stepHeight = 18.0f;
60
63constexpr float k_floorAngleCos = 0.7f;
64
68constexpr float k_groundSnapDistance = 8.0f;
69
73constexpr float k_emergencyUnstickRadius = 64.0f;
74
77constexpr int k_maxDepenPasses = 6;
78
79// Gravity flip
80constexpr float k_gravityFlipCooldown = 0.5f;
81
82// Sub-stepping (Phase C of physics-future-path.md)
83//
84// The 128 Hz bump loop is conservative-advancement-via-sweep-TOI: each clip
85// iteration advances to the swept time-of-impact, never penetrating past
86// the swept-shape's safety margin. This is exact for our plane / brush
87// queries and the capsule-vs-triangle Voronoi sweep, and bounded
88// conservative for capsule-vs-box/cyl/sphere.
89//
90// At normal player speeds (≤ 800 u/s, ≤ 6.25 u/tick at 128 Hz) and a 16 u
91// capsule radius, one sweep per tick comfortably catches any thin feature.
92// The failure mode shows up at extreme velocities (grapple-hook yank,
93// explosion knockback, scripted teleports): when `|v|·dt` exceeds the
94// shape's safety margin, the sweep's per-tick swept distance can exceed
95// the size of thin geometry features, risking tunneling.
96//
97// Sub-stepping splits the tick into N equal substeps when the projected
98// motion exceeds `k_substepSafetyRatio · min_shape_radius`. Each
99// substep runs the full bump loop with `dt/N`. Determinism is preserved
100// because both client and server compute the same `N` from the same
101// inputs. Depen runs once per tick (its idempotence + the bump loop's
102// pushback handle the rest); slope-stick and ground-probe also run once
103// at the end of the tick.
104
105constexpr bool k_enableSubstepping = true;
106constexpr float k_substepSafetyRatio = 0.5f;
107constexpr int k_maxSubsteps = 8;
108
109} // namespace physics
Pure physics math — no ECS types, no registry.
Definition BroadphaseTree.cpp:11
constexpr float k_emergencyUnstickRadius
Maximum radius of the emergency-unstick free-space search.
Definition PhysicsConstants.hpp:73
constexpr float k_airMaxWishLowSpeed
Wish-speed CEILING in air (units/s) when stationary.
Definition PhysicsConstants.hpp:44
constexpr int k_maxDepenPasses
Maximum sequential passes the deepest-first capsule depen attempts before falling through to emergenc...
Definition PhysicsConstants.hpp:77
constexpr float k_stopSpeed
Friction is amplified below this speed for a crisp stop.
Definition PhysicsConstants.hpp:52
constexpr float k_airWishCurveTop
Horizontal speed (u/s) at which the curve plateaus at k_airMaxSpeed.
Definition PhysicsConstants.hpp:45
constexpr float k_airWishCurveExponent
Power-curve exponent for wish-speed falloff (<1 = sharp early drop).
Definition PhysicsConstants.hpp:47
constexpr float k_substepSafetyRatio
Sub-step when |v|·dt > min_shape_radius · this.
Definition PhysicsConstants.hpp:106
constexpr float k_groundAccel
Ground acceleration constant. Higher = reaches max speed faster.
Definition PhysicsConstants.hpp:31
constexpr float k_stepHeight
Maximum obstacle height auto-stepped over without jumping (units).
Definition PhysicsConstants.hpp:59
constexpr float k_gravity
Downward acceleration (units/s^2) for projectiles / dynamics.
Definition PhysicsConstants.hpp:17
constexpr bool k_enableSubstepping
Master toggle for Phase-C sub-stepping.
Definition PhysicsConstants.hpp:105
constexpr float k_floorAngleCos
dot(surfaceNormal, up) threshold above which a surface counts as walkable floor.
Definition PhysicsConstants.hpp:63
constexpr float k_airMaxSpeed
Wish-speed FLOOR in air (units/s).
Definition PhysicsConstants.hpp:36
constexpr float k_airAccel
Air acceleration constant. Higher than Quake (0.7) for Titanfall-style air control.
Definition PhysicsConstants.hpp:34
constexpr int k_maxSubsteps
Clamp on sub-step count to bound worst-case cost.
Definition PhysicsConstants.hpp:107
constexpr float k_gravityFlipCooldown
Minimum time between gravity flips (s).
Definition PhysicsConstants.hpp:80
constexpr float k_overbounceWall
Separation impulse for walls/ceilings; prevents corner-sticking.
Definition PhysicsConstants.hpp:55
constexpr float k_playerGravity
Player-specific gravity (units/s^2).
Definition PhysicsConstants.hpp:19
constexpr float k_jumpSpeed
Initial upward velocity on jump (units/s).
Definition PhysicsConstants.hpp:25
constexpr float k_groundSnapDistance
Distance the ground probe extends below the capsule foot to snap to descending slopes / steps.
Definition PhysicsConstants.hpp:68
constexpr float k_overbounceFloor
Floor overbounce — exactly 1.0 means no bounce.
Definition PhysicsConstants.hpp:56
constexpr float k_friction
Ground friction coefficient. Higher = crisper stops, easier-to-track movement.
Definition PhysicsConstants.hpp:51