92 std::string_view filePath,
93 Real3 const& bakeScale,
103 Real3 const& bakeScale,
115 Real3 const& bakeScale,
129 Real3 const& bakeScale,
161 Error& error)
const = 0;
Represents a simulated body (actor) in a scene.
Manages a simulation scene that steps asynchronously using the SuperDex Physics worker pool.
Main entry point for SuperDex Physics simulation.
virtual ~Context()=default
static bool IsLogChannelEnabled(LogChannel channel)
Return true if messages on the specified log channel are enabled.
virtual MeshDataView GetShapeSurfaceMesh(ShapeHandle shape, Error &error) const =0
Get a view of the shape's surface mesh data.
virtual void ClearFileCache()=0
Release all shapes that are being preserved by the file cache (if any).
virtual MeshDataView GetShapeMesh(ShapeHandle shape, Error &error) const =0
Get a view of the shape's main mesh data.
virtual ShapeHandle CreateMeshShape(MeshData const &mesh, Error &error)=0
Create a shape using in-memory mesh data, so that it can be used to create actors.
virtual AsyncScene * CreateAsyncScenePaused(std::string_view name, Error &error)=0
Create a new AsyncScene that will initially be in the paused state.
static void EnableLogChannel(LogChannel channel, bool enable)
Enable or disable log messages on the specified channel.
static void EnableLogChannelInternal(LogChannel channel, bool enable)
virtual ShapeHandle LoadShapeFromBytes(Span< char const > fileData, MeshFileType format, Error &error)=0
Load a shape from a file of supported format, where the file has already been loaded into memory,...
virtual bool IsValidScene(Scene const *scene) const =0
Check if a scene is valid (not destroyed), and belongs to this Context.
virtual AsyncScene * CreateAsyncScene(std::string_view name, Error &error)=0
Create a new AsyncScene.
virtual DebugServer & GetDebugServer()=0
Get the debug server for this context.
static OnAssertFn GetAssertionFailureCallback()
Get the function currently being used to report assertion failures.
virtual bool IsValidAsyncScene(AsyncScene const *scene) const =0
Check if an AsyncScene is valid (not destroyed), and belongs to this Context.
virtual void ClearFileFromCache(std::string_view filePath)=0
Release all cached entries for a given shape file.
virtual bool IsSingleThreaded() const =0
Return true if running in single-threaded mode.
virtual void ReleaseShape(ShapeHandle shape)=0
Release a shape handle.
virtual ShapeHandle CreateSphereShape(Real3 const ¢er, real radius, Error &error)=0
Create an implicit sphere shape.
virtual ShapeHandle CreatePlaneShape(Real3 const &normal, real distance, Error &error)=0
Create an implicit plane with infinite extents.
virtual void DestroyAsyncScene(AsyncScene *scene)=0
Immediately stop and destroy an AsyncScene and all its actors and constraints.
virtual ShapeHandle CreateMeshShape(MeshDataView const &mesh, Error &error)=0
Create a shape using in-memory mesh data, so that it can be used to create actors.
virtual Scene * GetScene(SceneHandle handle)=0
Get a pointer to a scene by its handle.
virtual void SetIsSingleThreaded(bool isSingleThreaded)=0
Enable or disable single-threaded mode.
virtual ShapeHandle LoadShapeFromFile(std::string_view filePath, Real3 const &bakeScale, TransformRT const &bakeTransform, Error &error)=0
Load a shape from a file of supported format, and bake in some scale, rotation, and translation.
virtual int GetNumShapes() const =0
Get the number of shape handles that have been created/loaded and have not yet been released.
virtual Aabb GetShapeAabb(ShapeHandle shape, Error &error) const =0
Get an axis-aligned bounding box (AABB) that contains the shape, in its local coordinate frame.
virtual bool IsFileCacheEnabled() const =0
Return true if the file cache feature is enabled.
virtual void UnbindThisThread()=0
Unbind the calling thread from this Context.
static void SetLogCallbackInternal(LogFn callback)
virtual Scene const * GetScene(SceneHandle handle) const =0
Get a const pointer to a scene by its handle.
virtual void BindThisThread()=0
Bind the calling thread to this Context.
virtual void DestroyScene(Scene *scene)=0
Immediately destroy a scene and all its actors and constraints.
virtual ArticulatedShapeInfo GetArticulatedShapeInfo(ShapeHandle shape, Error &error) const =0
Get information about an articulated shape.
static void SetLogCallback(LogFn callback)
Optionally provide a callback function to redirect SuperDex Physics logging.
virtual ShapeHandle LoadShapeFromBytes(Span< char const > fileData, MeshFileType format, Real3 const &bakeScale, TransformRT const &bakeTransform, Error &error)=0
Load a shape from a file of supported format, where the file has already been loaded into memory,...
virtual ShapeHandle CreateModelShape(ModelDataView const &model, Error &error)=0
Create a shape using in-memory model data, so that it can be used to create actors.
virtual ShapeHandle CreateTetMeshShape(Span< real const > coordinates, Span< int const > connectivity, Error &error)=0
Create a tetrahedral mesh shape using in-memory data.
static void SetAssertionFailureCallback(OnAssertFn callback)
Optionally provide a callback function to customize the way in which assertion failures are reported.
virtual int GetNumThreads() const =0
Return the number of worker threads available to execute asynchronous tasks.
virtual ShapeHandle CreateTriMeshShape(Span< real const > coordinates, Span< int const > connectivity, Error &error)=0
Create a triangle mesh shape using in-memory data.
virtual Scene * CreateScene(std::string_view name)=0
Create a new Scene.
virtual DebugServer const & GetDebugServer() const =0
Get a const reference to the debug server for this context.
virtual void EnableFileCache(bool enable)=0
Enable or disable the file cache.
virtual MeshDataView GetShapeVisualMesh(ShapeHandle shape, Error &error) const =0
Get a view of the shape's visual mesh data, including skinning data if available.
static LogFn GetLogCallback()
Get the function currently being used to output logging.
virtual ShapeHandle CreateModelShape(ModelData const &model, Error &error)=0
Create a shape using in-memory model data, so that it can be used to create actors.
virtual ShapeHandle LoadShapeFromFile(std::string_view filePath, Error &error)=0
Load a shape from a file of supported format.
Server API to enable remote debugging and visualization.
Represents a simulation scene.
Context * CreateContext(int numWorkerThreads=-1)
Initialize SuperDex Physics by creating a Context object.
void DestroyContext(Context *context)
Shut down SuperDex Physics by destroying the Context object.
std::function< void(LogChannel, char const *message, char const *file, int line)> LogFn
MeshFileType
Mesh file format hint for Context::LoadShapeFromBytes and model-loading APIs that read from byte buff...
std::function< bool(char const *condition, char const *message, char const *file, int line)> OnAssertFn
Callback invoked when an assertion fails.
Information describing an articulated shape's kinematic structure.
A non-owning view of the mesh data for a Mochi actor or model file.
Mesh data for a Mochi actor or model file.
A non-owning view of the contents of a Mochi model file.
The contents of a Mochi model file.
Unique identifier for a Scene within a Context.
Handle to a shape (mesh, sphere, plane, etc.) within a Context.