Skip to content

Resources

Alan Jefferson edited this page Jan 23, 2020 · 1 revision

Sometimes your data needs to stay in sync with an externally managed resource, like a mesh or texture uploaded to the GPU or a rigid body managed by a simulation framework like PhysX.

WIP

Procedure

  1. Assign component, e.g. `registry.assign(entity);
  2. Observe construction
  3. Defer initialisation in PhysX, e.g. for (auto entity: in observer) {}
  4. Store handle to initialised rigid body, e.g. `registry.assign<PxRigidDynamic*>(entity, handle);
  5. Associate registry.remove<PxRigidDynamic*> with handle->release(); using on_construct

Advantages

  1. Clear registry along with PhysX with registry.reset();
  2. Clear single entity with registry.destroy(entity);
  3. Clear PhysX, but leave your data, with registry.reset<PxDynamicRigid*>();