|
SuperDex Physics C++ API
|
Main entry point for SuperDex Physics simulation. More...
#include <mochi_context.h>
Public Member Functions | |
| virtual void | BindThisThread ()=0 |
| Bind the calling thread to this Context. | |
| virtual void | ClearFileCache ()=0 |
| Release all shapes that are being preserved by the file cache (if any). | |
| virtual void | ClearFileFromCache (std::string_view filePath)=0 |
| Release all cached entries for a given shape file. | |
| virtual AsyncScene * | CreateAsyncScene (std::string_view name, Error &error)=0 |
| Create a new AsyncScene. | |
| virtual AsyncScene * | CreateAsyncScenePaused (std::string_view name, Error &error)=0 |
| Create a new AsyncScene that will initially be in the paused state. | |
| 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 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 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 | 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 | CreatePlaneShape (Real3 const &normal, real distance, Error &error)=0 |
| Create an implicit plane with infinite extents. | |
| virtual Scene * | CreateScene (std::string_view name)=0 |
| Create a new Scene. | |
| virtual ShapeHandle | CreateSphereShape (Real3 const ¢er, real radius, Error &error)=0 |
| Create an implicit sphere shape. | |
| virtual ShapeHandle | CreateTetMeshShape (Span< real const > coordinates, Span< int const > connectivity, Error &error)=0 |
| Create a tetrahedral mesh shape using in-memory data. | |
| virtual ShapeHandle | CreateTriMeshShape (Span< real const > coordinates, Span< int const > connectivity, Error &error)=0 |
| Create a triangle mesh shape using in-memory data. | |
| virtual void | DestroyAsyncScene (AsyncScene *scene)=0 |
| Immediately stop and destroy an AsyncScene and all its actors and constraints. | |
| virtual void | DestroyScene (Scene *scene)=0 |
| Immediately destroy a scene and all its actors and constraints. | |
| virtual void | EnableFileCache (bool enable)=0 |
| Enable or disable the file cache. | |
| virtual ArticulatedShapeInfo | GetArticulatedShapeInfo (ShapeHandle shape, Error &error) const =0 |
| Get information about an articulated shape. | |
| virtual DebugServer const & | GetDebugServer () const =0 |
| Get a const reference to the debug server for this context. | |
| virtual DebugServer & | GetDebugServer ()=0 |
| Get the debug server for this context. | |
| virtual int | GetNumShapes () const =0 |
| Get the number of shape handles that have been created/loaded and have not yet been released. | |
| virtual int | GetNumThreads () const =0 |
| Return the number of worker threads available to execute asynchronous tasks. | |
| virtual Scene const * | GetScene (SceneHandle handle) const =0 |
| Get a const pointer to a scene by its handle. | |
| virtual Scene * | GetScene (SceneHandle handle)=0 |
| Get a pointer to a scene by its handle. | |
| 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 MeshDataView | GetShapeMesh (ShapeHandle shape, Error &error) const =0 |
| Get a view of the shape's main mesh data. | |
| virtual MeshDataView | GetShapeSurfaceMesh (ShapeHandle shape, Error &error) const =0 |
| Get a view of the shape's surface mesh data. | |
| virtual MeshDataView | GetShapeVisualMesh (ShapeHandle shape, Error &error) const =0 |
| Get a view of the shape's visual mesh data, including skinning data if available. | |
| virtual bool | IsFileCacheEnabled () const =0 |
| Return true if the file cache feature is enabled. | |
| virtual bool | IsSingleThreaded () const =0 |
| Return true if running in single-threaded mode. | |
| virtual bool | IsValidAsyncScene (AsyncScene const *scene) const =0 |
| Check if an AsyncScene is valid (not destroyed), and belongs to this Context. | |
| virtual bool | IsValidScene (Scene const *scene) const =0 |
| Check if a scene is valid (not destroyed), and belongs to this Context. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory. | |
| 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, with an explicit mesh format hint. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, MeshFileType format, Real3 const &bakeScale, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint, and baking in some scale. | |
| 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, with an explicit mesh format hint, and baking in some scale, rotation, and translation. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, MeshFileType format, TransformRT const &bakeTransform, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint, and baking in rotation and translation. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, Real3 const &bakeScale, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in some scale. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, Real3 const &bakeScale, TransformRT const &bakeTransform, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in some scale, rotation, and translation. | |
| ShapeHandle | LoadShapeFromBytes (Span< char const > fileData, TransformRT const &bakeTransform, Error &error) |
| Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in rotation and translation. | |
| virtual ShapeHandle | LoadShapeFromFile (std::string_view filePath, Error &error)=0 |
| Load a shape from a file of supported format. | |
| ShapeHandle | LoadShapeFromFile (std::string_view filePath, Real3 const &bakeScale, Error &error) |
| Load a shape from a file of supported format, and bake in some scale. | |
| 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. | |
| ShapeHandle | LoadShapeFromFile (std::string_view filePath, TransformRT const &bakeTransform, Error &error) |
| Load a shape from a file of supported format, and bake in rotation and translation. | |
| virtual void | ReleaseShape (ShapeHandle shape)=0 |
| Release a shape handle. | |
| virtual void | SetIsSingleThreaded (bool isSingleThreaded)=0 |
| Enable or disable single-threaded mode. | |
| virtual void | UnbindThisThread ()=0 |
| Unbind the calling thread from this Context. | |
Static Public Member Functions | |
| static void | EnableLogChannel (LogChannel channel, bool enable) |
| Enable or disable log messages on the specified channel. | |
| static OnAssertFn | GetAssertionFailureCallback () |
| Get the function currently being used to report assertion failures. | |
| static LogFn | GetLogCallback () |
| Get the function currently being used to output logging. | |
| static bool | IsLogChannelEnabled (LogChannel channel) |
| Return true if messages on the specified log channel are enabled. | |
| static void | SetAssertionFailureCallback (OnAssertFn callback) |
| Optionally provide a callback function to customize the way in which assertion failures are reported. | |
| static void | SetLogCallback (LogFn callback) |
| Optionally provide a callback function to redirect SuperDex Physics logging. | |
Protected Member Functions | |
| virtual | ~Context ()=default |
Static Protected Member Functions | |
| static void | EnableLogChannelInternal (LogChannel channel, bool enable) |
| static void | SetLogCallbackInternal (LogFn callback) |
Main entry point for SuperDex Physics simulation.
A Context owns all global state for SuperDex Physics: scenes, shapes, threading, and shared resources. Create exactly one per process with CreateContext, and destroy it with DestroyContext. Shapes are reference-counted and can be shared between actors.
Definition at line 47 of file mochi_context.h.
|
protectedvirtualdefault |
|
pure virtual |
Bind the calling thread to this Context.
Required before using any Context, Scene, Actor, or another part of the SuperDex Physics API from a thread that did not create the Context. The thread that called CreateContext is bound automatically. Each call must be matched by a call to UnbindThisThread before the thread exits. The binding is reference-counted, so redundant calls from the same thread are safe as long as they are balanced.
|
pure virtual |
Release all shapes that are being preserved by the file cache (if any).
Use this to free up memory, or to force subsequent file requests to be loaded from disk, in case those files had been modified.
|
pure virtual |
Release all cached entries for a given shape file.
Use this to free up memory, or to force the next file request to be loaded from disk, in case the file had been modified. All entries for filePath are removed, including every variant produced by different bake scale/transform combinations.
| [in] | filePath | Path to a file that may have been loaded. The match is case-sensitive and must equal the path used at load time exactly. |
|
nodiscardpure virtual |
Create a new AsyncScene.
The returned AsyncScene owns a synchronous Scene and automatically steps it using a long-lived simulation task executed by the SuperDex Physics worker pool. This type of scene is often used for real-time interactive simulations where the physics rate is independent of the render rate.
| [in] | name | Name of the scene to create (for debugging). |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a new AsyncScene that will initially be in the paused state.
The returned AsyncScene owns a synchronous Scene and steps it using a long-lived simulation task executed by the SuperDex Physics worker pool. The scene starts paused but processes queued commands. It does not step the scene until unpaused.
| [in] | name | Name of the scene to create (for debugging). |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a shape using in-memory mesh data, so that it can be used to create actors.
| [in] | mesh | The mesh data, which SuperDex Physics copies. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a shape using in-memory mesh data, so that it can be used to create actors.
| [in] | mesh | A non-owning view of the mesh data, which SuperDex Physics copies. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a shape using in-memory model data, so that it can be used to create actors.
| [in] | model | The model data, which SuperDex Physics copies. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a shape using in-memory model data, so that it can be used to create actors.
| [in] | model | A non-owning view of the model data, which SuperDex Physics copies. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create an implicit plane with infinite extents.
| [in] | normal | Normal vector of the plane, in the shape's local frame. Need not be unit length; it is normalized internally. |
| [in] | distance | Signed offset [m] from the origin to the plane, measured along the (normalized) normal. The plane equation is dot(normalize(normal), x) = distance. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a new Scene.
A scene is a collection of actors and constraints, which can be stepped to advance the simulation. Each scene is independent. Actors from one scene cannot affect another scene.
You can create a new scene on any thread, but that scene must only be accessed from one thread at a time. All reads and writes to the scene must be synchronous and well ordered. However, if you have multiple scenes, then it is safe to step them concurrently.
| [in] | name | Name of the new scene (for debugging). |
|
nodiscardpure virtual |
Create an implicit sphere shape.
| [in] | center | Center of the sphere [m], in the shape's local frame. |
| [in] | radius | Radius of the sphere [m] |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a tetrahedral mesh shape using in-memory data.
| [in] | coordinates | Node positions [m] (3 values per node) |
| [in] | connectivity | Node indices (4 values per tetrahedron). |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Create a triangle mesh shape using in-memory data.
| [in] | coordinates | Node positions [m] (3 values per node). |
| [in] | connectivity | Node indices (3 values per triangle). |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
pure virtual |
Immediately stop and destroy an AsyncScene and all its actors and constraints.
| [in] | Scene | Pointer to the scene to destroy |
scene is null or unknown to this Context. scene. scene, such as queued commands, pre/post-step callbacks, or AsyncStepParams::timeStepCallback. Destroying an AsyncScene is synchronous: if called from code already running on the target scene's simulation task, it can deadlock during destruction.
|
pure virtual |
Immediately destroy a scene and all its actors and constraints.
| [in] | Scene | Pointer to the scene to destroy. |
scene is null or unknown to this Context. scene is owned by an AsyncScene, the call is a no-op (a warning is logged). Call DestroyAsyncScene instead.
|
pure virtual |
Enable or disable the file cache.
When enabled, shape memory will be preserved even after the ShapeHandle has been released. Subsequent requests for the same file (with the same baked-in scale and transform) will be fast because the data will already be loaded. This can be an important optimization, but beware that it could waste memory if it preserves shapes that are no longer needed.
| [in] | enable | True to enable, false to disable the feature. |
|
inlinestatic |
Enable or disable log messages on the specified channel.
When a channel is disabled, messages on that channel are discarded before reaching the logging callback (see SetLogCallback).
| [in] | channel | The log channel to enable or disable. |
| [in] | enable | True to enable the channel, false to disable it. |
Definition at line 77 of file mochi_context_inl.h.
|
staticprotected |
|
nodiscardpure virtual |
Get information about an articulated shape.
| [in] | shape | Handle to an articulated shape. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
staticnodiscard |
Get the function currently being used to report assertion failures.
|
pure virtual |
Get a const reference to the debug server for this context.
|
pure virtual |
Get the debug server for this context.
|
staticnodiscard |
Get the function currently being used to output logging.
|
nodiscardpure virtual |
Get the number of shape handles that have been created/loaded and have not yet been released.
|
nodiscardpure virtual |
Return the number of worker threads available to execute asynchronous tasks.
|
pure virtual |
Get a const pointer to a scene by its handle.
| [in] | handle | Handle to the scene. |
|
pure virtual |
Get a pointer to a scene by its handle.
| [in] | handle | Handle to the scene. |
|
nodiscardpure virtual |
Get an axis-aligned bounding box (AABB) that contains the shape, in its local coordinate frame.
| [in] | shape | Handle to a valid shape. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get a view of the shape's main mesh data.
For tetrahedral mesh shapes, returns the volume mesh (4 nodes per element). For triangular mesh shapes, returns the surface mesh (3 nodes per element). For polyline shapes, returns the polyline mesh (2 nodes per element). For shapes without a main mesh, including implicit shapes such as spheres and planes, returns an empty view.
| [in] | shape | Handle to a valid shape. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get a view of the shape's surface mesh data.
Returns a triangle mesh (3 nodes per element) representing the shape's surface. The coordinate array contains exactly the surface nodes referenced by the returned connectivity; nodes present in the underlying main mesh but not referenced by any surface triangle are omitted. Connectivity values are indices into this returned coordinate array. For shapes without a surface mesh, returns an empty view.
| [in] | shape | Handle to a valid shape. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Get a view of the shape's visual mesh data, including skinning data if available.
Returns a triangle mesh (3 nodes per element) intended for visual rendering. Coordinates and connectivity are returned in visual-mesh node-index space, including any visual mesh nodes not referenced by the visual connectivity. The mesh may include linear skinning data for deformation. For shapes without a visual mesh, returns an empty view.
| [in] | shape | Handle to a valid shape. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
nodiscardpure virtual |
Return true if the file cache feature is enabled.
|
staticnodiscard |
Return true if messages on the specified log channel are enabled.
| [in] | channel | The log channel to query. |
|
nodiscardpure virtual |
Return true if running in single-threaded mode.
Returns true when the Context was created with zero worker threads (see CreateContext) or when single-threaded mode has been explicitly enabled via SetIsSingleThreaded.
|
nodiscardpure virtual |
Check if an AsyncScene is valid (not destroyed), and belongs to this Context.
| [in] | Scene | Pointer to the AsyncScene to check |
|
nodiscardpure virtual |
Check if a scene is valid (not destroyed), and belongs to this Context.
| [in] | Scene | Pointer to the scene to check. |
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory.
Supported formats: JSON (.mochi.json) and HDF5 (.mochi.h5), auto-detected from header bytes. To load a surface mesh format (OBJ, PLY, OFF, STL) from memory, use the overload that takes an explicit MeshFileType.
| [in] | fileData | File contents as an in-memory byte array. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
Definition at line 51 of file mochi_context_inl.h.
|
nodiscardpure virtual |
Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | format | Mesh file format hint. When MeshFileType::Legacy, auto-detects between HDF5 and JSON via header bytes. When a surface mesh format (MeshFileType::PLY, MeshFileType::OFF, MeshFileType::STL, MeshFileType::OBJ), dispatches directly to that reader. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint, and baking in some scale.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | format | Mesh file format hint. When MeshFileType::Legacy, auto-detects between HDF5 and JSON via header bytes. When a surface mesh format (MeshFileType::PLY, MeshFileType::OFF, MeshFileType::STL, MeshFileType::OBJ), dispatches directly to that reader. |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale transforms those axes as normal directions using the inverse-transpose of the scale transform, then normalize them. Definition at line 35 of file mochi_context_inl.h.
|
nodiscardpure virtual |
Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint, and baking in some scale, rotation, and translation.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | format | Mesh file format hint. When MeshFileType::Legacy, auto-detects between HDF5 and JSON via header bytes. When a surface mesh format (MeshFileType::PLY, MeshFileType::OFF, MeshFileType::STL, MeshFileType::OBJ), dispatches directly to that reader. |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale and bakeTransform transform those axes as normal directions using the inverse-transpose of the scale-rotation transform, then normalize them.
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory, with an explicit mesh format hint, and baking in rotation and translation.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | format | Mesh file format hint. When MeshFileType::Legacy, auto-detects between HDF5 and JSON via header bytes. When a surface mesh format (MeshFileType::PLY, MeshFileType::OFF, MeshFileType::STL, MeshFileType::OBJ), dispatches directly to that reader. |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeTransform transforms those axes as normal directions using the inverse-transpose of the rotation transform, then normalize them. Definition at line 43 of file mochi_context_inl.h.
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in some scale.
Supported formats: JSON (.mochi.json) and HDF5 (.mochi.h5), auto-detected from header bytes. To load a surface mesh format (OBJ, PLY, OFF, STL) from memory, use the overload that takes an explicit MeshFileType.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale transforms those axes as normal directions using the inverse-transpose of the scale transform, then normalize them. Definition at line 56 of file mochi_context_inl.h.
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in some scale, rotation, and translation.
Supported formats: JSON (.mochi.json) and HDF5 (.mochi.h5), auto-detected from header bytes. To load a surface mesh format (OBJ, PLY, OFF, STL) from memory, use the overload that takes an explicit MeshFileType.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale and bakeTransform transform those axes as normal directions using the inverse-transpose of the scale-rotation transform, then normalize them. Definition at line 69 of file mochi_context_inl.h.
|
inlinenodiscard |
Load a shape from a file of supported format, where the file has already been loaded into memory, and baking in rotation and translation.
Supported formats: JSON (.mochi.json) and HDF5 (.mochi.h5), auto-detected from header bytes. To load a surface mesh format (OBJ, PLY, OFF, STL) from memory, use the overload that takes an explicit MeshFileType.
| [in] | fileData | File contents as an in-memory byte array. |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeTransform transforms those axes as normal directions using the inverse-transpose of the rotation transform, then normalize them. Definition at line 61 of file mochi_context_inl.h.
|
nodiscardpure virtual |
Load a shape from a file of supported format.
Supported formats: JSON (.mochi.json), HDF5 (.mochi.h5), OBJ (.obj), OFF (.off), PLY (.ply), and STL (.stl).
| [in] | filePath | File path to load (case sensitive on some filesystems). |
| [in,out] | error | Error status. Check Error::IsOK for success. |
|
inlinenodiscard |
Load a shape from a file of supported format, and bake in some scale.
Supported formats: JSON (.mochi.json), HDF5 (.mochi.h5), OBJ (.obj), OFF (.off), PLY (.ply), and STL (.stl).
| [in] | filePath | File path to load (case sensitive on some filesystems). |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale transforms those axes as normal directions using the inverse-transpose of the scale transform, then normalize them. Definition at line 24 of file mochi_context_inl.h.
|
nodiscardpure virtual |
Load a shape from a file of supported format, and bake in some scale, rotation, and translation.
Supported formats: JSON (.mochi.json), HDF5 (.mochi.h5), OBJ (.obj), OFF (.off), PLY (.ply), and STL (.stl).
| [in] | filePath | File path to load (case sensitive on some filesystems). |
| [in] | bakeScale | Scale to bake into the shape or (1, 1, 1) for no change. Negative scale results in mirroring. |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeScale is uniform by absolute value. Non-uniform scale by absolute value discards the precomputed SDF. If an SDF collider later requires SDF data, SuperDex Physics regenerates it from the transformed mesh at runtime, which may be expensive. bakeScale and bakeTransform transform those axes as normal directions using the inverse-transpose of the scale-rotation transform, then normalize them.
|
inlinenodiscard |
Load a shape from a file of supported format, and bake in rotation and translation.
Supported formats: JSON (.mochi.json), HDF5 (.mochi.h5), OBJ (.obj), OFF (.off), PLY (.ply), and STL (.stl).
| [in] | filePath | File path to load (case sensitive on some filesystems). |
| [in] | bakeTransform | Transform to bake into the shape, or the identity transform for no change. |
| [in,out] | error | Error status. Check Error::IsOK for success. |
bakeTransform transforms those axes as normal directions using the inverse-transpose of the rotation transform, then normalize them. Definition at line 28 of file mochi_context_inl.h.
|
pure virtual |
Release a shape handle.
In the C API, this must be called for every ShapeHandle when you are done with it. In C++ and Python, this is optional because ShapeHandle releases its reference automatically when destroyed. The shape memory is freed when it is no longer referenced by any handle, actor, or file cache entry.
| [in] | shape | Handle to the shape to release. |
|
inlinestatic |
Optionally provide a callback function to customize the way in which assertion failures are reported.
An assertion failure indicates a serious problem with the internal code or runtime environment. When this occurs, the default function will log a block of error text, then stop at a breakpoint (fatal if no debugger is attached).
| [in] | callback | Function to call in the event of an assertion failure, or nullptr to restore the default function. |
Definition at line 95 of file mochi_context_inl.h.
|
pure virtual |
Enable or disable single-threaded mode.
In single-threaded mode, each new task will be executed on the calling thread, even if other threads are available. This may hurt performance, but it is useful for debugging and batch simulation.
Enabling single-threaded mode does not, however, terminate tasks that are already running asynchronously. Such tasks will run to completion. For example, if you have an AsyncScene, it will continue to step asynchronously, but each step will do its work on that one thread.
| [in] | isSingleThreaded | True to enable single-threaded mode. False to disable. |
|
inlinestatic |
Optionally provide a callback function to redirect SuperDex Physics logging.
The default function outputs to stdout and to the debugger (if attached).
| [in] | callback | Function to handle logging, or nullptr to restore the default logging function. |
Definition at line 86 of file mochi_context_inl.h.
|
staticprotected |
|
pure virtual |
Unbind the calling thread from this Context.
Each call to BindThisThread must be matched by a call to UnbindThisThread before the thread exits. The binding is reference-counted, so the thread is only unbound when the number of unbind calls matches the number of bind calls.