mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
some fixes to spherical positioning, changed strategies for the feature to use xen's suggestion
This commit is contained in:
parent
756a08d342
commit
4a20b22859
@ -114,6 +114,7 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
|
||||
Vector3 latestPropPosDelta = VectorInput(_dpp.mostRecentlyPlacedPropGO.transform.localPosition, propPosDelta, out propPosDelta, "x", "y", "z");
|
||||
_dpp.mostRecentlyPlacedPropGO.transform.localPosition += latestPropPosDelta;
|
||||
if (latestPropPosDelta != Vector3.zero) mostRecentlyPlacedPropSphericalPos = DeltaSphericalPosition(mostRecentlyPlacedProp, Vector3.zero);
|
||||
|
||||
GUILayout.Space(5);
|
||||
|
||||
@ -125,30 +126,44 @@ namespace NewHorizons.Utility.DebugMenu
|
||||
}
|
||||
|
||||
Vector3 latestPropSphericalPosDelta = VectorInput(mostRecentlyPlacedPropSphericalPos, propSphericalPosDelta, out propSphericalPosDelta, "lat ", "lon ", "height");
|
||||
if (latestPropPosDelta != Vector3.zero)
|
||||
if (latestPropSphericalPosDelta != Vector3.zero)
|
||||
{
|
||||
mostRecentlyPlacedPropSphericalPos = DeltaSphericalPosition(mostRecentlyPlacedProp, latestPropSphericalPosDelta);
|
||||
Logger.Log("Prop pos delta "+latestPropSphericalPosDelta);
|
||||
mostRecentlyPlacedPropSphericalPos = DeltaSphericalPosition(mostRecentlyPlacedProp, mostRecentlyPlacedPropSphericalPos+latestPropSphericalPosDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3 DeltaSphericalPosition(GameObject go, Vector3 deltaSpherical)
|
||||
private Vector3 DeltaSphericalPosition(GameObject prop, Vector3 deltaSpherical)
|
||||
{
|
||||
sphericalPlacer.transform.parent = _dpp.mostRecentlyPlacedPropGO.transform.parent;
|
||||
sphericalPlacer.transform.localPosition = Vector3.zero;
|
||||
sphericalPlacer.transform.LookAt(_dpp.mostRecentlyPlacedPropGO.transform.localPosition);
|
||||
sphericalPlacer.transform.localEulerAngles = new Vector3(sphericalPlacer.transform.localEulerAngles.x, sphericalPlacer.transform.localEulerAngles.y, 0);
|
||||
// note: prop was originally named go
|
||||
//sphericalPlacer.transform.parent = go.transform.parent;
|
||||
//sphericalPlacer.transform.localPosition = Vector3.zero;
|
||||
//sphericalPlacer.transform.LookAt(go.transform.localPosition);
|
||||
//sphericalPlacer.transform.localEulerAngles = new Vector3(sphericalPlacer.transform.localEulerAngles.x, sphericalPlacer.transform.localEulerAngles.y, 0);
|
||||
|
||||
go.transform.parent = sphericalPlacer.transform;
|
||||
//go.transform.parent = sphericalPlacer.transform;
|
||||
|
||||
Vector3 currentSpherical = sphericalPlacer.transform.localEulerAngles + new Vector3(0,0, go.transform.localPosition.z); // lat, lon, height
|
||||
//Vector3 currentSpherical = sphericalPlacer.transform.localEulerAngles + new Vector3(0,0, go.transform.localPosition.z); // lat, lon, height
|
||||
|
||||
sphericalPlacer.transform.localEulerAngles += new Vector3(deltaSpherical.x, deltaSpherical.y, 0);
|
||||
_dpp.mostRecentlyPlacedPropGO.transform.localPosition += new Vector3(0, 0, deltaSpherical.z);
|
||||
//sphericalPlacer.transform.localEulerAngles += new Vector3(deltaSpherical.x, deltaSpherical.y, 0);
|
||||
//go.transform.localPosition += new Vector3(0, 0, deltaSpherical.z);
|
||||
|
||||
_dpp.mostRecentlyPlacedPropGO.transform.parent = sphericalPlacer.transform.parent;
|
||||
//go.transform.parent = sphericalPlacer.transform.parent;
|
||||
|
||||
return currentSpherical+deltaSpherical;
|
||||
//return currentSpherical+deltaSpherical;
|
||||
|
||||
Vector3 originalLocalPos = prop.transform.parent.InverseTransformPoint(prop.transform.position); // parent is the sector, this gives localPos relative to the astroobject
|
||||
Vector3 sphericalPos = CoordinateUtilities.CartesianToSpherical(originalLocalPos);
|
||||
Vector3 finalLocalPosition = CoordinateUtilities.SphericalToCartesian(sphericalPos+deltaSpherical);
|
||||
|
||||
if (deltaSpherical == Vector3.zero) return sphericalPos;
|
||||
|
||||
Vector3 finalAbsolutePosition = prop.transform.parent.TransformPoint(finalLocalPosition);
|
||||
prop.transform.localPosition = prop.transform.InverseTransformPoint(finalAbsolutePosition);
|
||||
prop.transform.rotation = prop.transform.rotation * Quaternion.FromToRotation(originalLocalPos.normalized, finalLocalPosition.normalized);
|
||||
|
||||
return sphericalPos+deltaSpherical;
|
||||
}
|
||||
|
||||
private Vector3 VectorInput(Vector3 input, Vector3 deltaControls, out Vector3 deltaControlsOut, string labelX, string labelY, string labelZ)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user