Physics rendering expert

From curiositech/windags-skills · View interactive version

Physics rendering expert is an AI agent skill from the GitHub repository curiositech/windags-skills. Real-time rope/cable physics using Position-Based Dynamics (PBD), Verlet integration, and constraint solvers. Expert in quaternion math, Gauss-Seidel/Jacobi solvers, and tangling detection. Activate on 'rope simulation', 'PBD', 'Position-Based Dynamics', 'Verlet', 'constraint solver', 'quaternion',

How to use this skill

Skill file

Physics & Rendering Expert: Rope Dynamics & Constraint Solving

Expert in computational physics for real-time rope/cable dynamics, constraint solving, and physically-based simulations.

Decision Points

Choosing constraint solver approach:

Input: System type & performance requirements
├─ Sequential structure (rope/chain)?
│  ├─ If single rope/chain → Gauss-Seidel (5-10 iterations)
│  └─ If multiple independent ropes → Parallel Gauss-Seidel per rope
└─ Large parallel system (cloth/1000+ particles)?
   ├─ If GPU available → Jacobi solver (compute shader)
   └─ If CPU only → Chunked Gauss-Seidel with spatial partitioning

Tangle detection decision tree:

For each rope segment pair:
├─ If rope-rope proximity < 0.1 * rope_radius AND relative velocity > 2.0
│  ├─ Calculate segment-segment distance
│  ├─ If distance < threshold → Create TangleConstraint
│  └─ Else → Continue monitoring
└─ If no proximity violation → Skip expensive distance calculation

Performance optimization decision:

Frame budget exceeded?
├─ If solver taking >50% budget
│  ├─ Reduce iterations (5 → 3)
│  ├─ Use spatial hashing for collision detection
│  └─ Consider LOD (fewer particles at distance)
└─ If rendering taking >50% budget → Delegate to metal-shader-expert

Failure Modes

Spring Force Instability

Symptoms: Rope oscillates wildly, simulation explodes at high spring constants

Detection: If particle velocity magnitude > 10x expected, you've hit this

Fix: Replace spring forces with PBD distance constraints: p.predicted = lerp(p1.predicted, p2.predicted, weight)

Gimbal Lock Rotation

Symptoms: Sudden orientation flips, rotation "jumps" at 90° angles

Detection: If rotation contains Euler angles (pitch/yaw/roll) representation

Fix: Convert to quaternions: q = normalize(vec4(sin(θ/2)*axis, cos(θ/2)))

Solver Over-Iteration

Symptoms: Performance bottleneck with minimal visual improvement after iteration 10

Detection: If solver iterations > 15 or frame time > 16ms on target hardware

Fix: Cap iterations at 5-10; if more constraint satisfaction needed, use XPBD with compliance parameters

Memory Allocation Per Frame

Symptoms: Frame rate hitches, garbage collection spikes during simulation

Detection: If new/malloc calls inside update loop or growing collections

Fix: Pre-allocate particle buffers, use object pools for constraints, fixed-size spatial grids

Ghost Collisions

Symptoms: Ropes stick together without actual contact, false tangle detection

Detection: If TangleConstraints created when visual gap exists between ropes

Fix: Implement proper segment-segment distance with parametric line equations, not bounding box overlap

Worked Examples

Example 1: Dog Leash Implementation

Scenario: Three-dog leash system with tangle detection (60 particles total)

Setup decisions:

Solver iteration walkthrough:

Frame start: Dogs pulling in different directions
Iteration 1: Distance constraints partially satisfied, 15% error remaining
Iteration 3: Error down to 3%, visual quality acceptable
Iteration 5: Error < 1%, diminishing returns beyond this point

Tangle detection triggers:

Performance result: 0.7ms total (0.4ms solver + 0.3ms tangle detection)

Example 2: Climbing Rope Under Load

Scenario: 30m dynamic climbing rope with 150 particles, climber fall simulation

Critical decisions:

Load case walkthrough:

t=0: Rope hanging freely, minimal constraints active
t=0.5s: Climber begins fall, tension propagates upward
t=1.2s: Peak load reached, rope stretches 8% (realistic for dynamic rope)
t=2.0s: Oscillations damped, stable configuration

Expert vs novice differences:

Quality Gates

NOT-FOR Boundaries

Do NOT use this skill for:

Delegate these scenarios:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.