From 180b0961a2216279024b4d35229d105d95a61878 Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 6 Feb 2026 08:29:34 +0100 Subject: docs: Update project documentation and regenerate assets Updated PROJECT_CONTEXT.md and TODO.md to include new critical tasks and reflect changes in task prioritization. Modified doc/3D.md to adjust task descriptions. Modified doc/CONTRIBUTING.md to incorporate the new in-memory replacement rule. Regenerated asset files (src/generated/assets.h, src/generated/assets_data.cc, src/generated/test_assets.h, src/generated/test_assets_data.cc) to reflect any changes in asset definitions. Removed temporary changes to GEMINI.md and HANDOFF.md. --- doc/3D.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'doc/3D.md') diff --git a/doc/3D.md b/doc/3D.md index 5bda566..59af47c 100644 --- a/doc/3D.md +++ b/doc/3D.md @@ -153,15 +153,26 @@ Instead of full SDF-on-SDF intersection (which is expensive), we approximate dyn * **Normal**: Compute gradient $N = \nabla SDF_B(P_{local})$ via central differences. Transform $N$ back to world space. * **Contact Point**: $P_{contact} = P_{world} - N * p$. -### Solver Loop (Semi-Implicit Euler) -1. **Integrate Velocity**: `vel += gravity * dt`. +### Narrow Phase & Resolution: +* If collision detected (depth $p > 0$): + * **Positional Correction**: Move object by $N * p$ (to resolve penetration). + * **Velocity Response (PBD)**: In Position Based Dynamics (PBD), the velocity is re-evaluated *after* all collisions and constraints have been resolved: `v = (p_new - p_old) / dt`. + * **Friction**: Apply tangential damping. + +### Rotation & Angular Momentum +Objects should support rotation via **Quaternions**. +* **State**: Add `quat orientation` and `vec3 angular_velocity` to `Object3D`. +* **Integration**: Update orientation using angular velocity: `q = q + 0.5 * dt * [0, w] * q`, then normalize. +* **Narrow Phase**: Proxy points must be rotated by the quaternion: `P_local = Inverse(Q) * (P_world - Position)`. +* **Collision Response**: Collision impulses should affect both linear and angular momentum. + +### Solver Loop (Position Based Dynamics) +1. **Integrate Position (Predicted)**: `p_pred = p + v * dt`. 2. **Broad Phase**: Find pairs using BVH. 3. **Narrow Phase & Resolution**: - * If collision detected (depth $p > 0$): - * **Positional Correction**: Move object by $N * p$ (to resolve penetration). - * **Velocity Response**: `vel = vel - (1 + restitution) * dot(vel, N) * N`. - * **Friction**: Apply tangential damping. -4. **Integrate Position**: `pos += vel * dt`. + * Resolve penetrations and constraints on `p_pred`. +4. **Update Velocity**: `v = (p_pred - p) / dt`. +5. **Finalize Position**: `p = p_pred`. ### Code Integration Plan @@ -183,4 +194,4 @@ our AssetManager or as c++ code directly) - **Task #36: Blender Exporter**. ## latter improvement How to handle transparency? Multi-Ray-casting? -We need to think about the lighting strategy. - **Task #40: Advanced Lighting & Transparency**. +We need to think about the lighting strategy. - **Task #40: Advanced Lighting & Transparency**. \ No newline at end of file -- cgit v1.2.3