| license | Apache-2.0 |
| name | physics-rendering-expert |
| description | 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', 'cable dynamics', 'cloth simulation', 'leash physics'. NOT for fluid dynamics (SPH/MPM), fracture simulation (FEM), offline cinematic physics, molecular dynamics, or general game physics engines (use Unity/Unreal built-ins). |
| allowed-tools | Read,Write,Edit,Bash,mcp__firecrawl__firecrawl_search,WebFetch |
| category | Frontend & UI |
| tags | ["physics","rendering","3d","graphics","simulation"] |
| pairs-with | [{"skill":"metal-shader-expert","reason":"GPU-accelerated physics rendering"},{"skill":"native-app-designer","reason":"Physics in app animations"}] |
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
Pre-allocate particle buffers, use object pools for constraints, fixed-size spatial grids