Skip to content

refactor: eliminate global static state in Physics/Spine WASM modules #5

Description

@esengine

Problem

Physics 和 Spine 的 C++ binding 层大量使用全局静态变量:

  • PhysicsModuleEntry.cpp:25-34g_worldId, g_entityToBody, g_entityToShape, g_fixedTimestep, g_accumulator
  • SpineModuleEntry.cpp:106+g_nextSkeletonId, g_nextInstanceId
  • Renderer.cpps_current_blend_

Impact

  • 场景切换时状态残留,导致 Play Mode 退出后物理/Spine 行为异常
  • 无法支持多世界物理模拟
  • WASM 模块无法安全重载

Solution

将全局状态迁移到 EngineContext 或独立的 per-world context 结构体,通过指针传入 binding 函数。

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical - blocks stabilityc++C++ engine coreruntimeRuntime engine core

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions