Skip to content

Commit 5036159

Browse files
author
DavidQ
committed
Normalize vector rendering/math boundaries and close physics with real reusable helpers
BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT
1 parent 60a3075 commit 5036159

23 files changed

Lines changed: 279 additions & 84 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,49 @@ MODEL: GPT-5.4
22
REASONING: high
33

44
COMMAND:
5-
- Promote collision to its own boundary
6-
- Remove physics proxy
7-
- Normalize imports
8-
- Update roadmap status only
9-
- Output zip to <project>/tmp
5+
Create `BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT`.
6+
7+
Implement this as one combined section-1 closeout PR.
8+
9+
Boundary decisions:
10+
1. `VectorDrawing` belongs in rendering.
11+
2. `VectorMath` belongs in shared math/utility.
12+
3. `src/engine/physics` must contain real reusable physics helpers, not just placeholder/barrel status.
13+
14+
Required work:
15+
1. Move/normalize vector drawing:
16+
- place `VectorDrawing` under the appropriate rendering-owned path
17+
- update imports/exports accordingly
18+
19+
2. Move/normalize vector math:
20+
- place `VectorMath` under the appropriate shared math/utility path
21+
- update imports/exports accordingly
22+
23+
3. Close physics truthfully:
24+
- extract the smallest valid set of reusable physics-domain helpers from existing games/samples into `src/engine/physics`
25+
- examples may include gravity, friction, drag, acceleration/integration, bounce/impulse if already stable
26+
- do NOT promote game-specific behavior prematurely
27+
- keep the extraction surgical
28+
29+
4. Validate:
30+
- imports remain green
31+
- post-move validation remains green
32+
- rendering no longer owns generic vector math
33+
- shared math no longer depends on rendering
34+
- `src/engine/physics` now contains real reusable physics helpers
35+
36+
5. Roadmap:
37+
- update status markers only
38+
- no roadmap text rewrite
39+
- mark `src/engine/rendering` and `src/engine/physics` complete only if truthfully supported
40+
- leave `src/engine/scene` open if it still is not done
41+
42+
6. Final packaging step is REQUIRED:
43+
- package ALL changed files into this exact repo-structured ZIP:
44+
`<project folder>/tmp/BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT.zip`
45+
46+
Hard rules:
47+
- implementation by Codex
48+
- surgical changes only
49+
- no unrelated repo changes
50+
- no missing ZIP

docs/dev/COMMIT_COMMENT.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
Collision boundary normalization
1+
Normalize vector rendering/math boundaries and close physics with real reusable helpers
2+
BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT

docs/dev/NEXT_COMMAND.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_PR_LEVEL_01_SECTION_1_CLOSEOUT_RECHECK
1+
BUILD_PR_LEVEL_01_SECTION_1_CLOSEOUT_RECHECK
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
Repack bundle
1+
- Combined vector boundary normalization with physics closeout to reduce PR count
2+
- Rendering now owns vector drawing concerns
3+
- Shared math/utils now owns generic vector math
4+
- Physics must be closed by extracting real reusable helpers from games/samples
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
Ensure collision != physics
1+
- VectorDrawing moved to rendering-owned path
2+
- VectorMath moved to shared math/utility path
3+
- imports/exports normalized and valid
4+
- src/engine/physics contains real reusable physics helpers
5+
- roadmap updated by status markers only
6+
- section 1 residue reduced or fully closed truthfully
7+
- output ZIP created at:
8+
<project folder>/tmp/BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT.zip

docs/dev/roadmaps/MASTER_ROADMAP_HIGH_LEVEL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
- [x] duplicate-helper migration map defined
107107
- [x] ambiguous-name rename map defined
108108
- [x] legacy migration map defined
109-
- [.] implementation PRs executed
109+
- [x] implementation PRs executed
110110
- [x] imports normalized after moves
111111
- [x] post-move validation complete
112112

@@ -115,7 +115,7 @@
115115
- [x] `src/engine/state`
116116
- [x] `src/engine/rendering`
117117
- [x] `src/engine/input`
118-
- [ ] `src/engine/physics`
118+
- [x] `src/engine/physics`
119119
- [x] `src/engine/audio`
120120
- [x] `src/engine/scene`
121121
- [x] `src/shared/utils`
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# BUILD_PR_LEVEL_01_RENDERING_VECTOR_BOUNDARY_AND_PHYSICS_CLOSEOUT
2+
3+
## Purpose
4+
Close the combined section-1 residue for rendering/vector boundary placement and physics boundary truthfulness.
5+
6+
## Applied Delta
7+
8+
### 1) Vector drawing moved to rendering ownership
9+
- Added canonical rendering-owned module:
10+
- `src/engine/rendering/VectorDrawing.js`
11+
- Updated rendering barrel:
12+
- `src/engine/rendering/index.js` now exports `transformPoints` and `drawVectorShape`
13+
- Kept compatibility for legacy vector boundary imports:
14+
- `src/engine/vector/VectorDrawing.js` re-exports from rendering
15+
- `src/engine/vector/index.js` now resolves drawing exports from rendering path
16+
17+
### 2) Vector math moved to shared math ownership
18+
- Added canonical shared math module:
19+
- `src/shared/math/vectorMath.js`
20+
- Updated compatibility layer:
21+
- `src/engine/vector/VectorMath.js` re-exports from shared math
22+
- `src/engine/vector/index.js` resolves `vectorFromAngle` from shared math
23+
24+
### 3) Physics boundary now contains real reusable helpers
25+
- Added reusable helpers under `src/engine/physics/`:
26+
- `drag.js` (`applyDrag`)
27+
- `arcadeBody.js` (`stepArcadeBody`)
28+
- `integration.js` (`integrateVelocity2D`)
29+
- `index.js` export surface
30+
- Normalized existing physics-system surface to use engine physics boundary:
31+
- `src/engine/systems/PhysicsSystem.js` now re-exports from `src/engine/physics`
32+
33+
### 4) Import normalization where touched
34+
- Updated representative runtime imports:
35+
- `games/GravityWell/game/GravityWellWorld.js`
36+
- `games/GravityWell/game/GravityWellScene.js`
37+
- Updated focused tests to canonical boundaries:
38+
- `tests/vector/VectorMath.test.mjs`
39+
- `tests/final/PrecisionCollisionSystems.test.mjs`
40+
- `tests/core/Section1FinalResidueStructure.test.mjs`
41+
42+
## Roadmap Status Marker Updates
43+
- `implementation PRs executed` -> `[x]`
44+
- `src/engine/physics` -> `[x]`
45+
46+
No roadmap prose text was rewritten.
47+
48+
## Validation
49+
- `node --check` on touched source/test files.
50+
- `node tests/core/Section1FinalResidueStructure.test.mjs`
51+
- `node tests/render/Renderer.test.mjs`
52+
- `node tests/scenes/SceneManager.test.mjs`
53+
- `node --input-type=module -e "import { run } from './tests/vector/VectorMath.test.mjs'; run();"`
54+
- `node --input-type=module -e "import { run } from './tests/final/PrecisionCollisionSystems.test.mjs'; run();"`
55+
- `rg -n "from '/src/engine/rendering/.*vectorMath|from '/src/shared/math/.*VectorDrawing" src shared` (boundary sanity check)
56+
57+
## Result Summary
58+
- `VectorDrawing` now lives in rendering ownership.
59+
- `VectorMath` now lives in shared math ownership.
60+
- `src/engine/physics` now contains reusable physics-domain helpers, not proxy-only exports.
61+
- Section-1 rendering/physics markers are truthfully complete for this boundary slice.
62+

games/GravityWell/game/GravityWellScene.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ GravityWellScene.js
77
import { Scene } from '/src/engine/scenes/index.js';
88
import { Theme, ThemeTokens } from '/src/engine/theme/index.js';
99
import { drawPanel } from '/src/engine/debug/index.js';
10-
import { drawVectorShape } from '/src/engine/vector/index.js';
10+
import { drawVectorShape } from '/src/engine/rendering/VectorDrawing.js';
1111
import { ReplaySystem } from '/src/engine/replay/index.js';
1212
import GravityWellWorld from './GravityWellWorld.js';
1313

games/GravityWell/game/GravityWellWorld.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ David Quesenberry
55
GravityWellWorld.js
66
*/
77
import { clamp, distance } from '/src/engine/utils/index.js';
8-
import { transformPoints, vectorFromAngle } from '/src/engine/vector/index.js';
8+
import { transformPoints } from '/src/engine/rendering/VectorDrawing.js';
9+
import { vectorFromAngle } from '/src/shared/math/vectorMath.js';
910

1011
const SHIP_SHAPE = [
1112
{ x: 0, y: -16 },

src/engine/physics/arcadeBody.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Toolbox Aid
3+
David Quesenberry
4+
04/14/2026
5+
arcadeBody.js
6+
*/
7+
import { clamp } from '../utils/math.js';
8+
import { applyDrag } from './drag.js';
9+
10+
export function stepArcadeBody(body, dt) {
11+
body.velocityX += (body.accelerationX ?? 0) * dt;
12+
body.velocityY += (body.accelerationY ?? 0) * dt;
13+
14+
const dragX = body.dragX ?? 0;
15+
const dragY = body.dragY ?? 0;
16+
17+
if (!body.accelerationX) {
18+
body.velocityX = applyDrag(body.velocityX, dragX, dt);
19+
}
20+
21+
if (!body.accelerationY) {
22+
body.velocityY = applyDrag(body.velocityY, dragY, dt);
23+
}
24+
25+
const maxSpeedX = body.maxSpeedX ?? Infinity;
26+
const maxSpeedY = body.maxSpeedY ?? Infinity;
27+
body.velocityX = clamp(body.velocityX, -maxSpeedX, maxSpeedX);
28+
body.velocityY = clamp(body.velocityY, -maxSpeedY, maxSpeedY);
29+
return body;
30+
}
31+

0 commit comments

Comments
 (0)