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) {
|
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++) {
|
// for (int thingIx = 0; thingIx < thingArray.Length; thingIx++) {
|
||||||
RoboidControl.Thing thing = thingArray[thingIx];
|
// Thing thing = thingArray[thingIx];
|
||||||
GameObject foundObj = FindThingByName(thing, rootTransform);
|
// GameObject foundObj = FindThingByName(thing, rootTransform);
|
||||||
if (foundObj != null && foundObj != thing.component.gameObject) {
|
// if (foundObj != null && foundObj != thing.gameObject) {
|
||||||
Thing foundThing = foundObj.GetComponent<Thing>();
|
// Thing foundThing = foundObj.GetComponent<Thing>();
|
||||||
if (foundThing == null) {
|
// if (foundThing == null) {
|
||||||
Debug.Log($"move thing [{thing.owner.networkId}/{thing.id}] to {foundObj.name}");
|
// allThings.Remove(thing);
|
||||||
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);
|
|
||||||
|
|
||||||
Destroy(thing.component.gameObject);
|
// foundThing = foundObj.AddComponent<Thing>();
|
||||||
thing.component = foundThing;
|
// foundThing.networkId = thing.networkId;
|
||||||
}
|
// foundThing.objectId = thing.objectId;
|
||||||
}
|
// allThings.Add(foundThing);
|
||||||
}
|
// Destroy(thing.gameObject);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -283,11 +266,10 @@ namespace RoboidControl.Unity {
|
|||||||
/// If a velocity is not zero, the position and/or orientation update will be ignored
|
/// If a velocity is not zero, the position and/or orientation update will be ignored
|
||||||
protected virtual void HandlePose() {
|
protected virtual void HandlePose() {
|
||||||
this.transform.localRotation = core.orientation.ToQuaternion();
|
this.transform.localRotation = core.orientation.ToQuaternion();
|
||||||
this.transform.localPosition = core.position.ToVector3();
|
if (core.linearVelocity.distance == 0)
|
||||||
// if (core.linearVelocity.distance == 0)
|
this.transform.localPosition = core.position.ToVector3();
|
||||||
// this.transform.localPosition = core.position.ToVector3();
|
if (core.angularVelocity.distance == 0)
|
||||||
// if (core.angularVelocity.distance == 0)
|
this.transform.localRotation = core.orientation.ToQuaternion();
|
||||||
// this.transform.localRotation = core.orientation.ToQuaternion();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user