Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions unity/Runtime/Components/MjGlobalSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ public struct MjcfOptionFlag {
public EnableDisableFlag FrictionLoss;
public EnableDisableFlag Limit;
public EnableDisableFlag Contact;
public EnableDisableFlag Passive;
public EnableDisableFlag Spring;
public EnableDisableFlag Damper;
public EnableDisableFlag Gravity;
public EnableDisableFlag ClampCtrl;
public EnableDisableFlag WarmStart;
Expand All @@ -80,7 +81,8 @@ public struct MjcfOptionFlag {
FrictionLoss = EnableDisableFlag.enable,
Limit = EnableDisableFlag.enable,
Contact = EnableDisableFlag.enable,
Passive = EnableDisableFlag.enable,
Spring = EnableDisableFlag.enable,
Damper = EnableDisableFlag.enable,
Gravity = EnableDisableFlag.enable,
ClampCtrl = EnableDisableFlag.enable,
WarmStart = EnableDisableFlag.enable,
Expand All @@ -101,7 +103,8 @@ public void FromMjcf(XmlElement mjcf) {
localDefault.FrictionLoss);
Limit = mjcf.GetEnumAttribute<EnableDisableFlag>("limit", localDefault.Limit);
Contact = mjcf.GetEnumAttribute<EnableDisableFlag>("contact", localDefault.Contact);
Passive = mjcf.GetEnumAttribute<EnableDisableFlag>("passive", localDefault.Passive);
Spring = mjcf.GetEnumAttribute<EnableDisableFlag>("spring", localDefault.Spring);
Damper = mjcf.GetEnumAttribute<EnableDisableFlag>("damper", localDefault.Damper);
Gravity = mjcf.GetEnumAttribute<EnableDisableFlag>("gravity", localDefault.Gravity);
ClampCtrl = mjcf.GetEnumAttribute<EnableDisableFlag>("clampctrl", localDefault.ClampCtrl);
WarmStart = mjcf.GetEnumAttribute<EnableDisableFlag>("warmstart", localDefault.WarmStart);
Expand All @@ -121,7 +124,8 @@ public void ToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("frictionloss", FrictionLoss.ToString());
mjcf.SetAttribute("limit", Limit.ToString());
mjcf.SetAttribute("contact", Contact.ToString());
mjcf.SetAttribute("passive", Passive.ToString());
mjcf.SetAttribute("spring", Spring.ToString());
mjcf.SetAttribute("damper", Damper.ToString());
mjcf.SetAttribute("gravity", Gravity.ToString());
mjcf.SetAttribute("clampctrl", ClampCtrl.ToString());
mjcf.SetAttribute("warmstart", WarmStart.ToString());
Expand Down Expand Up @@ -271,10 +275,9 @@ public void ParseMjcf(XmlElement mjcf) {

public XmlElement ToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("impratio", MjEngineTool.MakeLocaleInvariant($"{ImpRatio}"));

mjcf.SetAttribute("magnetic", MjEngineTool.MakeLocaleInvariant($"{Magnetic.x} {Magnetic.y} {Magnetic.z}"));
mjcf.SetAttribute("magnetic",
MjEngineTool.MakeLocaleInvariant($"{Magnetic.x} {Magnetic.y} {Magnetic.z}"));
mjcf.SetAttribute("wind", MjEngineTool.MakeLocaleInvariant($"{Wind.x} {Wind.y} {Wind.z}"));

mjcf.SetAttribute("density", MjEngineTool.MakeLocaleInvariant($"{Density}"));
mjcf.SetAttribute("viscosity", MjEngineTool.MakeLocaleInvariant($"{Viscosity}"));
mjcf.SetAttribute("o_margin", MjEngineTool.MakeLocaleInvariant($"{OverrideMargin}"));
Expand All @@ -286,7 +289,6 @@ public XmlElement ToMjcf(XmlElement mjcf) {
mjcf.SetAttribute("cone", Cone.ToString());
mjcf.SetAttribute("jacobian", Jacobian.ToString());
mjcf.SetAttribute("solver", Solver.ToString());

mjcf.SetAttribute("iterations", MjEngineTool.MakeLocaleInvariant($"{Iterations}"));
mjcf.SetAttribute("tolerance", MjEngineTool.MakeLocaleInvariant($"{Tolerance}"));
mjcf.SetAttribute("noslip_iterations", MjEngineTool.MakeLocaleInvariant($"{NoSlipIterations}"));
Expand Down Expand Up @@ -328,7 +330,7 @@ public class MjGlobalSettings : MonoBehaviour {
public static MjGlobalSettings Instance {
get {
if (_instance == null) {
var instances = FindObjectsOfType<MjGlobalSettings>();
var instances = FindObjectsByType<MjGlobalSettings>(FindObjectsSortMode.None);
if (instances.Length > 1) {
throw new InvalidOperationException(
"Only one MjGlobalSettings instance is allowed - please resolve manually.");
Expand Down