Skip to content

EntropyCanvas::UsdSyncService

Service for USD scene serialization and synchronization. More…

#include <UsdSyncService.h>

Inherits from EntropyEngine::Core::EntropyService, EntropyEngine::Core::EntropyObject

Name
~UsdSyncService() override =default
virtual voidunload() override
virtual EntropyEngine::Core::TypeSystem::TypeIDtypeId() const override
voidsyncWorldToStage(flecs::world & world, pxr::UsdStageRefPtr stage)
Synchronize transforms from Flecs world to USD stage.
virtual voidstop() override
virtual voidstart() override
virtual const char *name() const override
virtual voidload() override
boolimportUsdIntoWorld(flecs::world & world, pxr::UsdStageRefPtr stage, const std::string & usdData)
Import USD data into Flecs world.
virtual const char *id() const override
std::stringexportWorldToUsd(flecs::world & world, pxr::UsdStageRefPtr stage)
Export Flecs world to USD string format.
virtual std::vector< EntropyEngine::Core::TypeSystem::TypeID >dependsOnTypes() const override
UsdSyncService() =default

Public Functions inherited from EntropyEngine::Core::EntropyService

Name
~EntropyService() override =default
virtual const char *version() const
ServiceStatestate() const
virtual std::vector< std::string >dependsOn() const
virtual const char *className() const override
Runtime class name for diagnostics and reflection.

Protected Functions inherited from EntropyEngine::Core::EntropyService

Name
voidsetState(ServiceState s)

Friends inherited from EntropyEngine::Core::EntropyService

Name
classEntropyServiceRegistry

Protected Classes inherited from EntropyEngine::Core::EntropyObject

Name
structHandleCore
Optional handle identity stamped by an owner/registry.

Public Functions inherited from EntropyEngine::Core::EntropyObject

Name
virtual~EntropyObject() =default
virtual const TypeSystem::TypeInfo *typeInfo() const
Optional richer type information; may be null.
booltryRetain() const
Attempts to retain only if the object is still alive.
virtual std::stringtoString() const
Human-readable short string (class@ptr by default).
voidretain() const
Increments the reference count.
voidrelease() const
Decrements the reference count and deletes when it reaches zero.
uint32_trefCount() const
Current reference count (approximate under contention).
EntropyObject &operator=(const EntropyObject & ) =delete
EntropyObject &operator=(EntropyObject && ) =delete
boolhasHandle() const
template <class OwnerT >
OwnerT *
handleOwnerAs() const
Returns the stamped owner pointer cast to the requested type.
const void *handleOwner() const
uint32_thandleIndex() const
uint64_thandleId() const
uint32_thandleGeneration() const
WeakControlBlock *getWeakControlBlock() const
Lazily retrieves or creates the weak control block.
virtual std::stringdescription() const
Long-form description; defaults to toString().
virtual std::stringdebugString() const
Debug-oriented string including refcount and handle when present.
virtual const char *className() const
Runtime class name for diagnostics and reflection.
virtual uint64_tclassHash() const
Stable type hash for cross-language identification.
EntropyObject() =default
EntropyObject(EntropyObject && ) =delete
EntropyObject(const EntropyObject & ) =delete

Protected Functions inherited from EntropyEngine::Core::EntropyObject

Name
void_setHandleIdentity(void * owner, uint32_t index, uint32_t generation)
void_clearHandleIdentity()

Protected Attributes inherited from EntropyEngine::Core::EntropyObject

Name
std::atomic< WeakControlBlock * >_weakBlock
Lazily allocated control block for weak refs.
std::atomic< uint32_t >_refCount
Thread-safe retain/release counter.
struct EntropyEngine::Core::EntropyObject::HandleCore_handle

Friends inherited from EntropyEngine::Core::EntropyObject

Name
structHandleAccess
class EntropyCanvas::UsdSyncService;

Service for USD scene serialization and synchronization.

UsdSyncService handles bidirectional conversion between Flecs entities and USD prims. It provides clean serialization for persistence without requiring direct stage access.

Responsibilities:

  • Export Flecs world state to USD string format (USDA)
  • Import USD data into Flecs world
  • Synchronize entity transforms to USD XformOps
  • Handle hierarchy preservation during import/export

NOT Responsibilities:

  • Stage ownership (caller owns the USD stage)
  • File I/O (caller handles disk operations)
  • Encryption (caller handles that)
~UsdSyncService() override =default
virtual void unload() override

Reimplements: EntropyEngine::Core::EntropyService::unload

virtual EntropyEngine::Core::TypeSystem::TypeID typeId() const override

Reimplements: EntropyEngine::Core::EntropyService::typeId

void syncWorldToStage(
flecs::world & world,
pxr::UsdStageRefPtr stage
)

Synchronize transforms from Flecs world to USD stage.

Parameters:

  • world Flecs world with entities
  • stage USD stage to update

Updates USD prims to match current Flecs entity transforms.

virtual void stop() override

Reimplements: EntropyEngine::Core::EntropyService::stop

virtual void start() override

Reimplements: EntropyEngine::Core::EntropyService::start

inline virtual const char * name() const override

Reimplements: EntropyEngine::Core::EntropyService::name

virtual void load() override

Reimplements: EntropyEngine::Core::EntropyService::load

bool importUsdIntoWorld(
flecs::world & world,
pxr::UsdStageRefPtr stage,
const std::string & usdData
)

Import USD data into Flecs world.

Parameters:

  • world Target Flecs world to populate
  • stage USD stage containing the data
  • usdData USD file content as string (USDA format)

Return: True if import succeeded, false otherwise

Creates entities from USD prims. Restores hierarchy and transforms. Must be called on main thread.

inline virtual const char * id() const override

Reimplements: EntropyEngine::Core::EntropyService::id

std::string exportWorldToUsd(
flecs::world & world,
pxr::UsdStageRefPtr stage
)

Export Flecs world to USD string format.

Parameters:

  • world Flecs world to export
  • stage USD stage to export to

Return: USD file content as string (USDA format), empty on failure

Serializes all entities with Transform components into USD prims. Preserves hierarchy via USD prim paths. Thread-safe (read-only operation).

virtual std::vector< EntropyEngine::Core::TypeSystem::TypeID > dependsOnTypes() const override

Reimplements: EntropyEngine::Core::EntropyService::dependsOnTypes

UsdSyncService() =default

Updated on 2026-01-26 at 17:14:35 -0500