Merge pull request #2893 from joanllobera:fix/passive-attribute-droped
PiperOrigin-RevId: 878958794 Change-Id: I2d1fe080bd02b5c3e685cefbf36d45821cdfb46d
This commit is contained in:
@@ -327,7 +327,7 @@ public class MjGlobalSettings : MonoBehaviour {
|
|||||||
public static MjGlobalSettings Instance {
|
public static MjGlobalSettings Instance {
|
||||||
get {
|
get {
|
||||||
if (_instance == null) {
|
if (_instance == null) {
|
||||||
var instances = FindObjectsOfType<MjGlobalSettings>();
|
var instances = FindObjectsByType<MjGlobalSettings>(FindObjectsSortMode.None);
|
||||||
if (instances.Length > 1) {
|
if (instances.Length > 1) {
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"Only one MjGlobalSettings instance is allowed - please resolve manually.");
|
"Only one MjGlobalSettings instance is allowed - please resolve manually.");
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public class MjScene : MonoBehaviour {
|
|||||||
public static MjScene Instance {
|
public static MjScene Instance {
|
||||||
get {
|
get {
|
||||||
if (_instance == null) {
|
if (_instance == null) {
|
||||||
var instances = FindObjectsOfType<MjScene>();
|
var instances = FindObjectsByType<MjScene>(FindObjectsSortMode.None);
|
||||||
if (instances.Length >= 1) { // even one is too much - _instance shouldn't have been null.
|
if (instances.Length >= 1) { // even one is too much - _instance shouldn't have been null.
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"A MjScene singleton is created automatically, yet multiple instances exist.");
|
"A MjScene singleton is created automatically, yet multiple instances exist.");
|
||||||
@@ -135,7 +135,7 @@ public class MjScene : MonoBehaviour {
|
|||||||
// I briefly explored that approach, but decided against it. It increases the amount of code
|
// I briefly explored that approach, but decided against it. It increases the amount of code
|
||||||
// on the side of the individual components. This solution allows to restrict the code in the
|
// on the side of the individual components. This solution allows to restrict the code in the
|
||||||
// components to a bare minimum, at the expense of one extra method here.
|
// components to a bare minimum, at the expense of one extra method here.
|
||||||
var hierarchyRoots = FindObjectsOfType<MjComponent>()
|
var hierarchyRoots = FindObjectsByType<MjComponent>(FindObjectsSortMode.None)
|
||||||
.Where(component => MjHierarchyTool.FindParentComponent(component) == null)
|
.Where(component => MjHierarchyTool.FindParentComponent(component) == null)
|
||||||
.Select(component => component.transform)
|
.Select(component => component.transform)
|
||||||
.Distinct();
|
.Distinct();
|
||||||
@@ -209,7 +209,7 @@ public class MjScene : MonoBehaviour {
|
|||||||
// 4. rehydrate the physics scene, and sync the Unity scene to it.
|
// 4. rehydrate the physics scene, and sync the Unity scene to it.
|
||||||
public unsafe void RecreateScene() {
|
public unsafe void RecreateScene() {
|
||||||
// cache joint states in order to re-apply it to the new scene
|
// cache joint states in order to re-apply it to the new scene
|
||||||
var joints = FindObjectsOfType<MjBaseJoint>();
|
var joints = FindObjectsByType<MjBaseJoint>(FindObjectsSortMode.None);
|
||||||
var positions = new Dictionary<MjBaseJoint, double[]>();
|
var positions = new Dictionary<MjBaseJoint, double[]>();
|
||||||
var velocities = new Dictionary<MjBaseJoint, double[]>();
|
var velocities = new Dictionary<MjBaseJoint, double[]>();
|
||||||
foreach (var joint in joints) {
|
foreach (var joint in joints) {
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public static class ConvertMj2Rca {
|
|||||||
private static MjActuator[] _actuators;
|
private static MjActuator[] _actuators;
|
||||||
private static MjExclude[] _excludes;
|
private static MjExclude[] _excludes;
|
||||||
public static GameObject ConvertTree(MjBody mjRoot) {
|
public static GameObject ConvertTree(MjBody mjRoot) {
|
||||||
_excludes = GameObject.FindObjectsOfType<MjExclude>();
|
_excludes = GameObject.FindObjectsByType<MjExclude>(FindObjectsSortMode.None);
|
||||||
_actuators = GameObject.FindObjectsOfType<MjActuator>();
|
_actuators = GameObject.FindObjectsByType<MjActuator>(FindObjectsSortMode.None);
|
||||||
// does it have joints with its parent?
|
// does it have joints with its parent?
|
||||||
bool jointFound = false;
|
bool jointFound = false;
|
||||||
foreach (Transform mjChild in mjRoot.transform) {
|
foreach (Transform mjChild in mjRoot.transform) {
|
||||||
@@ -283,7 +283,7 @@ public static class ConvertMj2Rca {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The list of available ArticulationBodies changes as the recursion advances
|
// The list of available ArticulationBodies changes as the recursion advances
|
||||||
foreach (var rcOther in GameObject.FindObjectsOfType<ArticulationBody>()) {
|
foreach (var rcOther in GameObject.FindObjectsByType<ArticulationBody>(FindObjectsSortMode.None)) {
|
||||||
// don't add explicit exclusion to immediate parent (no children yet)
|
// don't add explicit exclusion to immediate parent (no children yet)
|
||||||
if (rcParentParent != rcOther && rcOther.gameObject.name == other) {
|
if (rcParentParent != rcOther && rcOther.gameObject.name == other) {
|
||||||
// MISSING: Physics.IgnoreCollision statements between all colliders of rcParent
|
// MISSING: Physics.IgnoreCollision statements between all colliders of rcParent
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public static class MjHierarchyTool {
|
|||||||
|
|
||||||
// Finds a single component that matches both the type and the name criteria.
|
// Finds a single component that matches both the type and the name criteria.
|
||||||
public static T FindComponentOfTypeAndName<T>(string name) where T : MjComponent {
|
public static T FindComponentOfTypeAndName<T>(string name) where T : MjComponent {
|
||||||
var components = UnityEngine.Object.FindObjectsOfType<T>().Where(
|
var components = UnityEngine.Object.FindObjectsByType<T>(FindObjectsSortMode.None).Where(
|
||||||
component => component.gameObject.name == name);
|
component => component.gameObject.name == name);
|
||||||
var numComponents = components.Count();
|
var numComponents = components.Count();
|
||||||
if (components == null || numComponents == 0) {
|
if (components == null || numComponents == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user