Clean-up test files.

Also, don't add a Global Settings component at import if the xml doesn't have any global settings (option/size/custom).

PiperOrigin-RevId: 495950899
Change-Id: I6599e8ea3f3a82729fc5c974fd7ced8eb93b277e
This commit is contained in:
Tom Erez
2022-12-16 13:38:54 -08:00
committed by Copybara-Service
parent 69c74f850e
commit 6a58fd1522
6 changed files with 21 additions and 14 deletions
@@ -40,6 +40,9 @@ namespace Mujoco {
if (Body1 == null || Body2 == null) {
throw new NullReferenceException($"Both bodies in connect {name} are required.");
}
if (Anchor == null) {
throw new NullReferenceException($"Anchor in connect {name} is required.");
}
mjcf.SetAttribute("body1", Body1.MujocoName);
mjcf.SetAttribute("body2", Body2.MujocoName);
mjcf.SetAttribute("anchor",
+1 -2
View File
@@ -149,8 +149,7 @@ public struct MjSizeStruct {
};
public void ParseMjcf(XmlElement mjcf) {
var localDefault = MjSizeStruct.Default;
Memory = mjcf.GetAttribute("memory", localDefault.Memory);
Memory = mjcf.GetAttribute("memory");
}
public XmlElement ToMjcf(XmlElement mjcf) {
+7 -4
View File
@@ -134,10 +134,13 @@ public class MjcfImporter {
}
protected virtual void ParseRoot(GameObject rootObject, XmlElement mujocoNode) {
var globalsObject = CreateGameObjectInParent("Global Settings", rootObject);
var settingsComponent = globalsObject.AddComponent<MjGlobalSettings>();
settingsComponent.ParseGlobalMjcfSections(mujocoNode);
if (mujocoNode.SelectSingleNode("option") != null
|| mujocoNode.SelectSingleNode("size") != null
|| mujocoNode.SelectSingleNode("custom") != null) {
var globalsObject = CreateGameObjectInParent("Global Settings", rootObject);
var settingsComponent = globalsObject.AddComponent<MjGlobalSettings>();
settingsComponent.ParseGlobalMjcfSections(mujocoNode);
}
// This makes references to assets.
var worldBodyNode = mujocoNode.SelectSingleNode("worldbody") as XmlElement;