Allow MJB and XML content to be loaded directly.

PiperOrigin-RevId: 843180720
Change-Id: Id4f2bf81507b971dfbbf250d775d7fdfc76517df
This commit is contained in:
Haroon Qureshi
2025-12-11 05:40:36 -08:00
committed by Copybara-Service
parent 1ff74ba810
commit 87d333c64a
3 changed files with 62 additions and 40 deletions
+12 -2
View File
@@ -48,8 +48,17 @@ class App {
App(int width, int height, std::string ini_path,
const platform::LoadAssetFn& load_asset_fn);
enum ContentType {
kFilepath, // Path to a model file.
kModelXml, // XML model string.
kModelMjb, // Binary model payload.
};
// Loads a model into the simulation.
void LoadModel(std::string model_file);
//
// Note: Do not call this function from within Update() (i.e. while drawing
// the UX). Call RequestModelLoad() instead.
void LoadModel(std::string data, ContentType type);
// Processes window events and advances the state of the simulation.
bool Update();
@@ -132,6 +141,7 @@ class App {
void ClearModel();
void ProcessPendingLoad();
bool IsModelLoaded() const;
void RequestModelLoad(std::string model_file);
void ResetPhysics();
void UpdatePhysics();
@@ -164,7 +174,7 @@ class App {
std::string error_;
std::string ini_path_;
std::string model_file_;
std::string model_name_;
std::optional<std::string> pending_load_;
std::unique_ptr<platform::Window> window_;