ITS BROKEN
This commit is contained in:
@@ -200,15 +200,16 @@ namespace SplashEdit.RuntimeCode
|
||||
else Debug.LogWarning("No active Scene View.");
|
||||
}
|
||||
}
|
||||
else if (!isUITrack && (track.TrackType == PSXTrackType.ObjectPosition || track.TrackType == PSXTrackType.ObjectRotationY))
|
||||
else if (!isUITrack && (track.TrackType == PSXTrackType.ObjectPosition || track.TrackType == PSXTrackType.ObjectRotation))
|
||||
{
|
||||
if (GUILayout.Button("From Sel.", GUILayout.Width(70)))
|
||||
// Capture from the named object in scene
|
||||
if (!string.IsNullOrEmpty(track.ObjectName) && GUILayout.Button("From Object", GUILayout.Width(85)))
|
||||
{
|
||||
var sel = Selection.activeGameObject;
|
||||
if (sel != null)
|
||||
var go = GameObject.Find(track.ObjectName);
|
||||
if (go != null)
|
||||
kf.Value = track.TrackType == PSXTrackType.ObjectPosition
|
||||
? sel.transform.position : new Vector3(0, sel.transform.eulerAngles.y, 0);
|
||||
else Debug.LogWarning("No GameObject selected.");
|
||||
? go.transform.position : go.transform.eulerAngles;
|
||||
else Debug.LogWarning($"Object '{track.ObjectName}' not found in scene.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,10 +230,10 @@ namespace SplashEdit.RuntimeCode
|
||||
kf.Value = new Vector3(active ? 1f : 0f, 0, 0);
|
||||
break;
|
||||
}
|
||||
case PSXTrackType.ObjectRotationY:
|
||||
case PSXTrackType.ObjectRotation:
|
||||
case PSXTrackType.CameraRotation:
|
||||
{
|
||||
float yRot = EditorGUILayout.FloatField("Y\u00b0", kf.Value.y);
|
||||
kf.Value = new Vector3(0, yRot, 0);
|
||||
kf.Value = EditorGUILayout.Vector3Field("Rotation\u00b0", kf.Value);
|
||||
break;
|
||||
}
|
||||
case PSXTrackType.UIProgress:
|
||||
@@ -297,17 +298,20 @@ namespace SplashEdit.RuntimeCode
|
||||
track.Keyframes.Add(new PSXKeyframe { Frame = frame, Value = val });
|
||||
}
|
||||
}
|
||||
else if (!isUITrack && (track.TrackType == PSXTrackType.ObjectPosition || track.TrackType == PSXTrackType.ObjectRotationY))
|
||||
else if (!isUITrack && (track.TrackType == PSXTrackType.ObjectPosition || track.TrackType == PSXTrackType.ObjectRotation))
|
||||
{
|
||||
if (GUILayout.Button("+ from Selected", GUILayout.Width(120)))
|
||||
if (!string.IsNullOrEmpty(track.ObjectName))
|
||||
{
|
||||
var sel = Selection.activeGameObject;
|
||||
Vector3 val = Vector3.zero;
|
||||
if (sel != null)
|
||||
val = track.TrackType == PSXTrackType.ObjectPosition
|
||||
? sel.transform.position : new Vector3(0, sel.transform.eulerAngles.y, 0);
|
||||
int frame = track.Keyframes.Count > 0 ? track.Keyframes[track.Keyframes.Count - 1].Frame + 15 : 0;
|
||||
track.Keyframes.Add(new PSXKeyframe { Frame = frame, Value = val });
|
||||
if (GUILayout.Button("+ from Object", GUILayout.Width(110)))
|
||||
{
|
||||
var go = GameObject.Find(track.ObjectName);
|
||||
Vector3 val = Vector3.zero;
|
||||
if (go != null)
|
||||
val = track.TrackType == PSXTrackType.ObjectPosition
|
||||
? go.transform.position : go.transform.eulerAngles;
|
||||
int frame = track.Keyframes.Count > 0 ? track.Keyframes[track.Keyframes.Count - 1].Frame + 15 : 0;
|
||||
track.Keyframes.Add(new PSXKeyframe { Frame = frame, Value = val });
|
||||
}
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndHorizontal();
|
||||
@@ -584,9 +588,9 @@ namespace SplashEdit.RuntimeCode
|
||||
if (_savedObjectPositions.ContainsKey(track.ObjectName ?? ""))
|
||||
initialVal = _savedObjectPositions[track.ObjectName];
|
||||
break;
|
||||
case PSXTrackType.ObjectRotationY:
|
||||
case PSXTrackType.ObjectRotation:
|
||||
if (_savedObjectRotations.ContainsKey(track.ObjectName ?? ""))
|
||||
initialVal = new Vector3(0, _savedObjectRotations[track.ObjectName].eulerAngles.y, 0);
|
||||
initialVal = _savedObjectRotations[track.ObjectName].eulerAngles;
|
||||
break;
|
||||
case PSXTrackType.ObjectActive:
|
||||
if (_savedObjectActive.ContainsKey(track.ObjectName ?? ""))
|
||||
@@ -619,10 +623,10 @@ namespace SplashEdit.RuntimeCode
|
||||
if (go != null) go.transform.position = val;
|
||||
break;
|
||||
}
|
||||
case PSXTrackType.ObjectRotationY:
|
||||
case PSXTrackType.ObjectRotation:
|
||||
{
|
||||
var go = GameObject.Find(track.ObjectName);
|
||||
if (go != null) go.transform.rotation = Quaternion.Euler(0, val.y, 0);
|
||||
if (go != null) go.transform.rotation = Quaternion.Euler(val);
|
||||
break;
|
||||
}
|
||||
case PSXTrackType.ObjectActive:
|
||||
@@ -706,16 +710,6 @@ namespace SplashEdit.RuntimeCode
|
||||
{
|
||||
float rawT = frame / after.Frame;
|
||||
float t = ApplyInterpCurve(rawT, after.Interp);
|
||||
|
||||
bool isRotation = track.TrackType == PSXTrackType.CameraRotation
|
||||
|| track.TrackType == PSXTrackType.ObjectRotationY;
|
||||
if (isRotation)
|
||||
{
|
||||
return new Vector3(
|
||||
Mathf.LerpAngle(initialValue.x, after.Value.x, t),
|
||||
Mathf.LerpAngle(initialValue.y, after.Value.y, t),
|
||||
Mathf.LerpAngle(initialValue.z, after.Value.z, t));
|
||||
}
|
||||
return Vector3.Lerp(initialValue, after.Value, t);
|
||||
}
|
||||
|
||||
@@ -727,17 +721,8 @@ namespace SplashEdit.RuntimeCode
|
||||
float rawT2 = (frame - before.Frame) / span;
|
||||
float t2 = ApplyInterpCurve(rawT2, after.Interp);
|
||||
|
||||
// Use shortest-path angle interpolation for rotation tracks
|
||||
bool isRot = track.TrackType == PSXTrackType.CameraRotation
|
||||
|| track.TrackType == PSXTrackType.ObjectRotationY;
|
||||
if (isRot)
|
||||
{
|
||||
return new Vector3(
|
||||
Mathf.LerpAngle(before.Value.x, after.Value.x, t2),
|
||||
Mathf.LerpAngle(before.Value.y, after.Value.y, t2),
|
||||
Mathf.LerpAngle(before.Value.z, after.Value.z, t2));
|
||||
}
|
||||
|
||||
// Linear interpolation for all tracks including rotation.
|
||||
// No shortest-path wrapping: a keyframe from 0 to 360 rotates the full circle.
|
||||
return Vector3.Lerp(before.Value, after.Value, t2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user