Compare commits
No commits in common. "29b37d91c161d3aaefccff473ab30eac279106c1" and "7bd7931196f613dbc9e577ff57967106bdee55c0" have entirely different histories.
29b37d91c1
...
7bd7931196
@ -238,41 +238,24 @@ namespace RoboidControl.Unity {
|
||||
}
|
||||
|
||||
private void ScanForThings(Transform rootTransform) {
|
||||
RoboidControl.Thing[] thingArray = this.core.owner.things.ToArray();
|
||||
// Thing[] thingArray = allThings.ToArray();
|
||||
|
||||
for (int thingIx = 0; thingIx < thingArray.Length; thingIx++) {
|
||||
RoboidControl.Thing thing = thingArray[thingIx];
|
||||
GameObject foundObj = FindThingByName(thing, rootTransform);
|
||||
if (foundObj != null && foundObj != thing.component.gameObject) {
|
||||
Thing foundThing = foundObj.GetComponent<Thing>();
|
||||
if (foundThing == null) {
|
||||
Debug.Log($"move thing [{thing.owner.networkId}/{thing.id}] to {foundObj.name}");
|
||||
foundThing = foundObj.AddComponent<Thing>();
|
||||
foundThing.core = thing;
|
||||
foundThing.core.position = LinearAlgebra.Spherical.FromVector3(foundObj.transform.localPosition);
|
||||
foundThing.core.orientation = LinearAlgebra.SwingTwist.FromQuaternion(foundObj.transform.localRotation);
|
||||
// for (int thingIx = 0; thingIx < thingArray.Length; thingIx++) {
|
||||
// Thing thing = thingArray[thingIx];
|
||||
// GameObject foundObj = FindThingByName(thing, rootTransform);
|
||||
// if (foundObj != null && foundObj != thing.gameObject) {
|
||||
// Thing foundThing = foundObj.GetComponent<Thing>();
|
||||
// if (foundThing == null) {
|
||||
// allThings.Remove(thing);
|
||||
|
||||
Destroy(thing.component.gameObject);
|
||||
thing.component = foundThing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject FindThingByName(RoboidControl.Thing thing, Transform rootTransform) {
|
||||
if (rootTransform == null || thing == null)
|
||||
return null;
|
||||
|
||||
if (rootTransform.name == thing.name)
|
||||
return rootTransform.gameObject;
|
||||
|
||||
for (int childIx = 0; childIx < rootTransform.childCount; childIx++) {
|
||||
Transform child = rootTransform.GetChild(childIx);
|
||||
GameObject foundObj = FindThingByName(thing, child);
|
||||
if (foundObj != null)
|
||||
return foundObj;
|
||||
}
|
||||
return null;
|
||||
// foundThing = foundObj.AddComponent<Thing>();
|
||||
// foundThing.networkId = thing.networkId;
|
||||
// foundThing.objectId = thing.objectId;
|
||||
// allThings.Add(foundThing);
|
||||
// Destroy(thing.gameObject);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@ -283,11 +266,10 @@ namespace RoboidControl.Unity {
|
||||
/// If a velocity is not zero, the position and/or orientation update will be ignored
|
||||
protected virtual void HandlePose() {
|
||||
this.transform.localRotation = core.orientation.ToQuaternion();
|
||||
this.transform.localPosition = core.position.ToVector3();
|
||||
// if (core.linearVelocity.distance == 0)
|
||||
// this.transform.localPosition = core.position.ToVector3();
|
||||
// if (core.angularVelocity.distance == 0)
|
||||
// this.transform.localRotation = core.orientation.ToQuaternion();
|
||||
if (core.linearVelocity.distance == 0)
|
||||
this.transform.localPosition = core.position.ToVector3();
|
||||
if (core.angularVelocity.distance == 0)
|
||||
this.transform.localRotation = core.orientation.ToQuaternion();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user