Files
2nd/10_Wiki/Topics/Domain_General/Game_Design/Physics.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

6.9 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-physics Physics 10_Wiki/Topics verified self
Game Physics
Physics Engine
Rigid Body Simulation
none A 0.95 applied
game-design
physics
simulation
rigid-body
collision
2026-05-10 pending
language framework
cpp rigid-body-physics

Physics

매 한 줄

"매 Newtonian dynamics 의 discrete-time integration + collision detection + constraint solving 의 trinity". Game physics 매 (1) integrator (Euler, Verlet, RK4), (2) broadphase + narrowphase collision, (3) iterative constraint solver (Sequential Impulses, PGS, XPBD) 의 stack. 2026 매 Jolt (Horizon Forbidden West), Rapier (Rust ecosystem), PhysX 5, Bullet 매 dominant.

매 핵심

매 Three Pillars

  • Integration: 매 Δt 의 over forces → velocity → position.
  • Collision detection: 매 broadphase (BVH, sweep-and-prune) → narrowphase (GJK, SAT, MPR).
  • Constraint resolution: 매 contact, joints, friction 의 iterative solve.

매 Integrators

  • Explicit Euler: 매 simple, unstable, energy gain.
  • Semi-implicit Euler: 매 game default, stable for most cases.
  • Verlet: 매 position-based, energy-stable, cloth-friendly.
  • RK4: 매 accurate, expensive — 매 specialized sims.

매 Constraint solvers

  • Sequential Impulses (Erin Catto): 매 Box2D / Bullet 의 standard.
  • Projected Gauss-Seidel (PGS): 매 PhysX, ODE.
  • XPBD (Extended Position-Based Dynamics): 매 Jolt, modern soft-body.

매 응용

  1. Action games — Jolt + Havok physics for combat impact.
  2. Driving sims — multi-body vehicle constraints.
  3. Cloth / soft-body — XPBD + Verlet for hair, capes, organic deformation.

💻 패턴

Semi-implicit Euler

struct RigidBody {
    Vec3 position, velocity;
    Quat orientation; Vec3 angularVelocity;
    float invMass; Mat3 invInertia;
    Vec3 force, torque;
};

void integrate(RigidBody& b, float dt) {
    b.velocity += (b.force * b.invMass) * dt;          // 매 v_{n+1} 의 first
    b.position += b.velocity * dt;                     // 매 x_{n+1} 의 use new v
    b.angularVelocity += (b.invInertia * b.torque) * dt;
    Quat dq = 0.5f * Quat(0, b.angularVelocity) * b.orientation;
    b.orientation = normalize(b.orientation + dq * dt);
    b.force = b.torque = Vec3::Zero;
}

AABB broadphase (sweep-and-prune)

struct AABB { Vec3 min, max; int bodyId; };

std::vector<std::pair<int,int>> sap(std::vector<AABB>& boxes, int axis) {
    std::sort(boxes.begin(), boxes.end(),
        [&](auto& a, auto& b){ return a.min[axis] < b.min[axis]; });
    std::vector<std::pair<int,int>> pairs;
    for (size_t i = 0; i < boxes.size(); i++) {
        for (size_t j = i + 1; j < boxes.size(); j++) {
            if (boxes[j].min[axis] > boxes[i].max[axis]) break;
            if (overlap(boxes[i], boxes[j])) pairs.emplace_back(boxes[i].bodyId, boxes[j].bodyId);
        }
    }
    return pairs;
}

GJK narrowphase (convex overlap test)

bool gjk(const ConvexShape& A, const ConvexShape& B) {
    Vec3 d = {1, 0, 0};
    std::vector<Vec3> simplex = { support(A, B, d) };
    d = -simplex[0];
    for (int i = 0; i < 64; i++) {
        Vec3 p = support(A, B, d);
        if (dot(p, d) < 0) return false; // 매 origin 의 not contained
        simplex.push_back(p);
        if (doSimplex(simplex, d)) return true;
    }
    return false;
}

Sequential impulse contact resolution

void resolveContact(RigidBody& a, RigidBody& b, const Contact& c, float restitution, float friction) {
    Vec3 ra = c.point - a.position;
    Vec3 rb = c.point - b.position;
    Vec3 relV = (b.velocity + cross(b.angularVelocity, rb))
              - (a.velocity + cross(a.angularVelocity, ra));
    float vn = dot(relV, c.normal);
    if (vn > 0) return; // 매 separating

    float effMass = a.invMass + b.invMass
        + dot(c.normal, cross(a.invInertia * cross(ra, c.normal), ra))
        + dot(c.normal, cross(b.invInertia * cross(rb, c.normal), rb));

    float j = -(1 + restitution) * vn / effMass;
    Vec3 impulse = j * c.normal;
    a.velocity -= impulse * a.invMass;
    b.velocity += impulse * b.invMass;
    a.angularVelocity -= a.invInertia * cross(ra, impulse);
    b.angularVelocity += b.invInertia * cross(rb, impulse);
}

XPBD distance constraint

void solveDistance(RigidBody& a, RigidBody& b, float restLen, float compliance, float dt) {
    Vec3 d = b.position - a.position;
    float len = length(d);
    Vec3 n = d / len;
    float C = len - restLen;
    float wSum = a.invMass + b.invMass;
    float alpha = compliance / (dt * dt);
    float dLambda = -C / (wSum + alpha);
    a.position -= n * (dLambda * a.invMass);
    b.position += n * (dLambda * b.invMass);
}

Continuous collision (CCD)

// 매 high-velocity tunneling 의 prevent
float ccdSphereSphere(Vec3 pa, Vec3 va, float ra, Vec3 pb, Vec3 vb, float rb, float dt) {
    Vec3 dp = pb - pa;
    Vec3 dv = vb - va;
    float r = ra + rb;
    float a = dot(dv, dv);
    float b = 2 * dot(dp, dv);
    float c = dot(dp, dp) - r * r;
    float disc = b*b - 4*a*c;
    if (disc < 0 || a == 0) return -1;
    float t = (-b - std::sqrt(disc)) / (2 * a);
    return (t >= 0 && t <= dt) ? t : -1;
}

매 결정 기준

상황 Approach
Action / shooter Jolt + semi-implicit Euler + sequential impulses
Cloth / soft-body XPBD + Verlet
Driving sim Multi-body + RK4 (or sub-stepped semi-implicit)
Casual mobile Box2D / cocos2d-x physics — minimal overhead
Multiplayer rollback Deterministic fixed-point physics (Photon Quantum)

기본값: 매 semi-implicit Euler + sequential impulses + AABB broadphase + GJK narrowphase.

🔗 Graph

🤖 LLM 활용

언제: Solver boilerplate, integrator selection, debugging stuck constraint diagnosis. 언제 X: Numerical correctness verification (deterministic test 의 require), shipping-grade tuning.

안티패턴

  • Explicit Euler 의 production: 매 energy drift → instability.
  • No CCD on bullets: 매 tunneling 의 inevitable.
  • Single-axis SAP: 매 worst-case O(N²) 의 degrade.
  • Float-based deterministic netcode: 매 cross-platform desync.
  • Constraint solver 의 too-few iterations: 매 stack jitter.

🧪 검증 / 중복

  • Verified (Erin Catto GDC talks 2006-2024, Jolt physics docs 2024, "Real-Time Collision Detection" Christer Ericson, XPBD paper Macklin et al.).
  • 신뢰도 A+.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — integration, collision, constraint trinity + canonical solvers

🔗 관련 문서 (자동 연결)