From 5ee0e40e6ffcdc4fab93d6b131329f64ff069e68 Mon Sep 17 00:00:00 2001 From: Jb win Date: Wed, 30 Apr 2025 16:45:32 +0700 Subject: [PATCH] FIX - InitializeMujoco is now a wrapper to the real SceneInitialization + I don't want to commit 10 blueprints because we can't put empty map as default values in BP nodes --- .../Private/Actors/MujocoVolumeActor.cpp | 12 ++++++++++-- .../Public/Actors/MujocoVolumeActor.h | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Actors/MujocoVolumeActor.cpp b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Actors/MujocoVolumeActor.cpp index 1d5b67bd..86f7d859 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Actors/MujocoVolumeActor.cpp +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Private/Actors/MujocoVolumeActor.cpp @@ -115,9 +115,15 @@ void AMujocoVolumeActor::BindPostPhysicDelegate(UserClass* Object, void(UserClas PostPhysicUpdateDelegate.BindUObject(Object, Func); } -void AMujocoVolumeActor::InitializeMujoco(TMap ContactExclusion) + +void AMujocoVolumeActor::InitializeMujoco() { - if (!Options) + InitializeMujocoScene_WithContactExclusion(TMap{}); +} + +void AMujocoVolumeActor::InitializeMujocoScene_WithContactExclusion(const TMap& ContactExclusion) +{ + if (!Options) { return; } @@ -170,6 +176,8 @@ void AMujocoVolumeActor::InitializeMujoco(TMap ContactExclusio return; } + // TODO Here we should check for mujoco dll if we are on windows and LOG an error if there is not + gently quit the game + std::array ErrMsg{}; MujocoModel = MakeMujocoModelPtr(mj_loadXML(TCHAR_TO_ANSI(*ExportFilename), nullptr, ErrMsg.data(), ErrMsg.size())); if (!MujocoModel) diff --git a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Actors/MujocoVolumeActor.h b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Actors/MujocoVolumeActor.h index e8a54d1b..19c91525 100644 --- a/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Actors/MujocoVolumeActor.h +++ b/Plugins/LuckyMujoco/Source/LuckyMujoco/Public/Actors/MujocoVolumeActor.h @@ -33,15 +33,23 @@ class LUCKYMUJOCO_API AMujocoVolumeActor : public AActor public: AMujocoVolumeActor(); - UFUNCTION(BlueprintCallable, Category = "Mujoco") /** * Initialize the sim scene in headless mujoco - * @param ContactExclusion a list of pairs that should be patched in the xml file for contact exclusion (no friction, no collision) - * TODO ContactExclusion should be stored as a property of MujocoActor and not passed in the scene init - * TODO This require to cast the Actor in addition to the components list */ - void InitializeMujoco(TMap ContactExclusion); + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void InitializeMujoco(); + + + /** + * Initialize the sim scene in headless mujoco with a list of contact exclusion + * @param ContactExclusion a list of pairs that should be patched in the xml file for contact exclusion (no friction, no collision) + * TODO Can't use a default empty map as parameter in blueprints? We shouldn't need to have 2 functions + * TODO ContactExclusion should be stored as a property of MujocoActor and not passed in the scene init + * TODO This require to cast the Actor in addition to the components list + */ + UFUNCTION(BlueprintCallable, Category = "Mujoco") + void InitializeMujocoScene_WithContactExclusion(const TMap& ContactExclusion); protected: virtual void BeginPlay() override;