Prune and clean up code.
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
public class PropItem : MonoBehaviour {
|
||||
public object Target;
|
||||
public PropertyEditor editor;
|
||||
public DirectoryInfo ContextPath;
|
||||
|
||||
public string PropertyName = "";
|
||||
InputField valueObj;
|
||||
string value;
|
||||
string desc = "";
|
||||
PropertyInfo prop;
|
||||
Type bindToType;
|
||||
TypeConverter converter;
|
||||
|
||||
bool mustExpand = false;
|
||||
bool readOnly = false;
|
||||
string[] filter = null;
|
||||
FileDialog fdialog;
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
transform.Find("Value").GetComponent<InputField>().onEndEdit.AddListener(s => OnValueChanged(s));
|
||||
var entry = new EventTrigger.Entry(){
|
||||
eventID = EventTriggerType.PointerClick,
|
||||
callback = new EventTrigger.TriggerEvent()
|
||||
};
|
||||
entry.callback.AddListener(e => OnClick(e));
|
||||
transform.Find("Value").GetComponent<EventTrigger>().triggers.Add(entry);
|
||||
}
|
||||
|
||||
void Start() {
|
||||
transform.Find("Name").GetComponent<Text>().text = PropertyName;
|
||||
valueObj = transform.Find("Value").GetComponent<InputField>();
|
||||
prop = Target.GetType().GetProperty(PropertyName);
|
||||
bindToType = prop.PropertyType;
|
||||
converter = TypeDescriptor.GetConverter(bindToType);
|
||||
|
||||
var descattr = (DescriptionAttribute[])prop.GetCustomAttributes(typeof(DescriptionAttribute), true);
|
||||
if (descattr.Length > 0) desc = descattr[0].Description;
|
||||
|
||||
var roattr = (ReadOnlyAttribute[])prop.GetCustomAttributes(typeof(ReadOnlyAttribute), true);
|
||||
if (roattr.Length > 0) if (roattr[0].IsReadOnly == true) {
|
||||
readOnly = true;
|
||||
valueObj.enabled = false;
|
||||
valueObj.transform.Find("ValueString").GetComponent<Text>().color = Color.gray;
|
||||
}
|
||||
|
||||
if (converter == null || !converter.CanConvertFrom(typeof(string)) || converter.GetPropertiesSupported()){
|
||||
mustExpand = true;
|
||||
valueObj.enabled = false;
|
||||
}
|
||||
|
||||
var fsattr = (FileStringAttribute[])prop.GetCustomAttributes(typeof(FileStringAttribute), true);
|
||||
if (fsattr.Length > 0) {
|
||||
valueObj.enabled = false;
|
||||
filter = fsattr[0].Filter;
|
||||
}
|
||||
|
||||
UpdateValue();
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
void OnFileDialogClosed() {
|
||||
var file = fdialog.GetComponent<FileDialog>().FileName;
|
||||
if (file != "") {
|
||||
var f = new FileInfo(file);
|
||||
if (f.Directory.FullName != ContextPath.FullName) {
|
||||
string targetFile = ContextPath.FullName + "\\" + f.Name;
|
||||
f.CopyTo(targetFile, true);
|
||||
}
|
||||
OnValueChanged(f.Name);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateValue() {
|
||||
object v;
|
||||
valueObj.placeholder.GetComponent<Text>().text = "";
|
||||
v = prop.GetValue(Target, new object[]{ });
|
||||
if (v == null) {
|
||||
DefaultValueAttribute[] defvattr = (DefaultValueAttribute[])prop.GetCustomAttributes(typeof(DefaultValueAttribute), true);
|
||||
if (defvattr.Length > 0) {
|
||||
v = defvattr[0].Value;
|
||||
if (v == null) {
|
||||
v = "";
|
||||
valueObj.placeholder.GetComponent<Text>().text = "null";
|
||||
}
|
||||
}
|
||||
else {
|
||||
v = "";
|
||||
valueObj.placeholder.GetComponent<Text>().text = "null";
|
||||
}
|
||||
}
|
||||
|
||||
if (mustExpand || readOnly || filter != null) {
|
||||
valueObj.transform.Find("ValueString").GetComponent<Text>().text = v.ToString();
|
||||
}
|
||||
else {
|
||||
valueObj.text = v.ToString();
|
||||
}
|
||||
value = valueObj.text;
|
||||
}
|
||||
|
||||
void OnClick(BaseEventData e) {
|
||||
if (mustExpand && !readOnly) {
|
||||
GameObject subeditor = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/PropertyEditor"));
|
||||
object obj = prop.GetValue(Target, new object[]{ });
|
||||
subeditor.GetComponent<PropertyEditor>().TargetObject = obj;
|
||||
}
|
||||
else if (filter != null && !readOnly) {
|
||||
fdialog = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/FileDialog")).GetComponent<FileDialog>();
|
||||
fdialog.Filter = filter;
|
||||
fdialog.CurrentDirectory = ContextPath;
|
||||
fdialog.OnClose += OnFileDialogClosed;
|
||||
}
|
||||
editor.SetDescription(PropertyName, desc);
|
||||
UpdateValue();
|
||||
}
|
||||
|
||||
void OnValueChanged(string s) {
|
||||
if (s == value) return;
|
||||
object v = null;
|
||||
if (!(mustExpand || readOnly)) {
|
||||
try {
|
||||
v = converter.ConvertFrom(s);
|
||||
prop.SetValue(Target, v, new object[]{ });
|
||||
}
|
||||
catch (TargetInvocationException ex) {
|
||||
// CallHelper.ShowMessageBox(ex.InnerException.Message);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// CallHelper.ShowMessageBox(ex.Message);
|
||||
}
|
||||
}
|
||||
UpdateValue();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 499dc47d3f108de4eb80b2d73e5851c5
|
||||
timeCreated: 1608801352
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,60 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Cryville.Common.Unity {
|
||||
public class PropertyEditor : MonoBehaviour {
|
||||
|
||||
private object target;
|
||||
public object TargetObject {
|
||||
get { return target; }
|
||||
set {
|
||||
target = value;
|
||||
ReloadProperties();
|
||||
}
|
||||
}
|
||||
|
||||
private Text desc;
|
||||
private Transform list;
|
||||
|
||||
public Action Callback;
|
||||
|
||||
private void ReloadProperties() {
|
||||
foreach (Transform p in list) {
|
||||
GameObject.Destroy(p.gameObject);
|
||||
}
|
||||
PropertyInfo[] props = target.GetType().GetProperties();
|
||||
foreach (PropertyInfo m in props) {
|
||||
var brattr = (BrowsableAttribute[])m.GetCustomAttributes(typeof(BrowsableAttribute), true);
|
||||
if (brattr.Length > 0)
|
||||
if (brattr[0].Browsable == false)
|
||||
continue;
|
||||
GameObject mi = GameObject.Instantiate<GameObject>(Resources.Load<GameObject>("Common/PropItem"));
|
||||
mi.transform.SetParent(list, false);
|
||||
mi.GetComponent<PropItem>().PropertyName = m.Name;
|
||||
mi.GetComponent<PropItem>().Target = target;
|
||||
mi.GetComponent<PropItem>().editor = this;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0051
|
||||
void Awake() {
|
||||
Transform panel = transform.Find("Panel");
|
||||
desc = panel.Find("Description").GetComponent<Text>();
|
||||
list = panel.Find("PropList").Find("PropListInner");
|
||||
SetDescription("(Property)", "");
|
||||
}
|
||||
#pragma warning restore IDE0051
|
||||
|
||||
public void SetDescription(string n, string d) {
|
||||
desc.text = "<b>" + n + "</b>\n" + d;
|
||||
}
|
||||
|
||||
public void Close() {
|
||||
if (Callback != null) Callback.Invoke();
|
||||
GameObject.Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de5a0d32ac5669347ac4570c014967d1
|
||||
timeCreated: 1608801356
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -352,6 +352,7 @@ namespace Cryville.Crtr {
|
||||
[JsonIgnore]
|
||||
public Identifier Name {
|
||||
get {
|
||||
if (name == default(Identifier)) throw new InvalidOperationException("Motion name not set");
|
||||
return name;
|
||||
}
|
||||
private set {
|
||||
@@ -369,9 +370,9 @@ namespace Cryville.Crtr {
|
||||
[JsonIgnore]
|
||||
public MotionNode RelativeNode;
|
||||
|
||||
[DefaultValue(TransitionType.Ease)] // TODO [Obsolete]
|
||||
[DefaultValue(TransitionType.Ease)][Obsolete]
|
||||
public TransitionType transition = TransitionType.Ease;
|
||||
[DefaultValue(1.0f)] // TODO [Obsolete]
|
||||
[DefaultValue(1.0f)][Obsolete]
|
||||
public float rate = 1.0f;
|
||||
[DefaultValue(0.0f)]
|
||||
public float sumfix = 0.0f;
|
||||
@@ -382,8 +383,8 @@ namespace Cryville.Crtr {
|
||||
SubmitPropOp("motion", new PropOp.String(v => motion = v));
|
||||
SubmitPropOp("name", new PropOp.Identifier(v => {
|
||||
var n = new Identifier(v);
|
||||
if (Name.Equals(n)) { }
|
||||
else if (Name.Equals(default(Identifier))) Name = n;
|
||||
if (name == n) { }
|
||||
else if (name == default(Identifier)) Name = n;
|
||||
else throw new RulesetViolationException(string.Format(
|
||||
"Motion name not matched, expected {0}, got {1}", n, Name
|
||||
));
|
||||
|
@@ -133,32 +133,14 @@ namespace Cryville.Crtr {
|
||||
httpscl.Request("GET", new Uri(p[1])).MessageBody.ReadToEnd();
|
||||
httpscl.Close();
|
||||
break;
|
||||
/*case "!lua":
|
||||
Logger.Log("main", 1, "Console", "{0}", Script.RunString(p[1]));
|
||||
break;*/
|
||||
/*case "!tls":
|
||||
var tlscl = new TlsTcpClient(p[1]);
|
||||
tlscl.Close();
|
||||
break;*/
|
||||
case "connect":
|
||||
Game.ConnectDatabase(p[1]);
|
||||
break;
|
||||
case "help": case "?":
|
||||
Logger.Log(
|
||||
"main", 1, "Console",
|
||||
"\n\tconnect <i>name</i>" +
|
||||
"\n\thelp" +
|
||||
"\n\tlist" +
|
||||
"\n\tplay" +
|
||||
"\n\tquit"
|
||||
);
|
||||
break;
|
||||
case "list":
|
||||
Logger.Log("main", 1, "Console", "Database list:");
|
||||
foreach (var i in Game.GetDatabaseList()) {
|
||||
Logger.Log("main", 1, "Console", "{0}", i.Name);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_fallback.Invoke(cmd);
|
||||
break;
|
||||
|
@@ -59,6 +59,7 @@ namespace Cryville.Crtr {
|
||||
_currentTarget = target;
|
||||
_ctxev = ChartPlayer.etor.ContextEvent;
|
||||
_ctxstate = ChartPlayer.etor.ContextState;
|
||||
_skinContainer.MatchDynamic(0, true);
|
||||
if (_currentStateName.Key == 0) {
|
||||
EnterState(_def.init, time, _currentTarget, true);
|
||||
}
|
||||
@@ -75,7 +76,6 @@ namespace Cryville.Crtr {
|
||||
ChartPlayer.etor.ContextCascadeInsert();
|
||||
ChartPlayer.etor.ContextCascadeUpdate(_VAR_EFFECT_INDEX, _indexSrc);
|
||||
ChartPlayer.etor.Evaluate(_durationOp, _currentState.duration);
|
||||
if (emitting) _skinContainer.MatchDynamic(0, true);
|
||||
_skinContainer.MatchDynamic(1, emitting);
|
||||
ChartPlayer.etor.ContextCascadeDiscard();
|
||||
}
|
||||
|
@@ -315,23 +315,6 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
}
|
||||
|
||||
static readonly int n_corner = IdentifierManager.SharedInstance.Request("corner");
|
||||
public bool Corner {
|
||||
get {
|
||||
return GetRawValue<VecI1>(n_corner).Value % 2 >= 1;
|
||||
}
|
||||
}
|
||||
|
||||
static readonly int n_ctrl0 = IdentifierManager.SharedInstance.Request("ctrl0");
|
||||
static readonly int n_ctrl1 = IdentifierManager.SharedInstance.Request("ctrl1");
|
||||
public Vector3 GetControlPoint(bool alt1, float deltaz) {
|
||||
var mv = GetRawValue<VecCtrl>(alt1 ? n_ctrl1 : n_ctrl0);
|
||||
if (alt1 && mv.IsZero()) {
|
||||
mv = GetRawValue<VecCtrl>(n_ctrl0);
|
||||
}
|
||||
return mv.ToVector3(ChartPlayer.hitRect, deltaz);
|
||||
}
|
||||
|
||||
static readonly int n_track = IdentifierManager.SharedInstance.Request("track");
|
||||
public float Track {
|
||||
get {
|
||||
|
@@ -14,10 +14,6 @@ using System.IO;
|
||||
using UnityEngine;
|
||||
using Logger = Cryville.Common.Logger;
|
||||
|
||||
#if UNITY_ANDROID
|
||||
using AOT;
|
||||
#endif
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
public static class Game {
|
||||
public static string GameDataPath {
|
||||
@@ -107,9 +103,6 @@ namespace Cryville.Crtr {
|
||||
{ new Identifier("sv") , new MotionRegistry(new VecPtComp(0f, 0f), new VecPtComp(0f, 1f)) },
|
||||
{ new Identifier("svm") , new MotionRegistry(new Vec1m(1f)) },
|
||||
{ new Identifier("dist") , new MotionRegistry(new VecPtComp(0f, 0f), new VecPtComp(0f, float.PositiveInfinity)) },
|
||||
{ new Identifier("corner") , new MotionRegistry(typeof(VecI1)) },
|
||||
{ new Identifier("ctrl0") , new MotionRegistry(typeof(VecCtrl)) },
|
||||
{ new Identifier("ctrl1") , new MotionRegistry(typeof(VecCtrl)) },
|
||||
{ new Identifier("track") , new MotionRegistry(typeof(Vec1)) },
|
||||
};
|
||||
|
||||
@@ -163,14 +156,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
public static DirectoryInfo[] GetDatabaseList() {
|
||||
return new DirectoryInfo(GameDataPath + "/db").GetDirectories();
|
||||
}
|
||||
public static void ConnectDatabase(string name) {
|
||||
}
|
||||
public static void DisconnectDatabase() {
|
||||
}
|
||||
|
||||
public static void LogException(string module, string prefix, Exception ex) {
|
||||
Logger.Log("main", 4, module, "{0}: {1}", prefix, ex);
|
||||
}
|
||||
|
@@ -7,9 +7,9 @@ namespace Cryville.Crtr {
|
||||
public class GroupHandler : ContainerHandler {
|
||||
public ChartHandler ch;
|
||||
|
||||
ColumnVector<float> coeffs;
|
||||
SquareMatrix matFrame;
|
||||
ContainerState[] tracks;
|
||||
public int TrackCount { get { return tracks.Length; } }
|
||||
|
||||
public GroupHandler(Chart.Group tg, ChartHandler ch) : base() {
|
||||
this.ch = ch;
|
||||
@@ -20,18 +20,21 @@ namespace Cryville.Crtr {
|
||||
public override void PreInit() {
|
||||
base.PreInit();
|
||||
tracks = cs.TypedChildren[typeof(Chart.Track)].ToArray();
|
||||
matFrame = SquareMatrix.WithPolynomialCoefficients(tracks.Length);
|
||||
frame1 = new ColumnVector<Vector3>(tracks.Length);
|
||||
frame2 = new ColumnVector<Vector3>(tracks.Length);
|
||||
int numTracks = tracks.Length;
|
||||
coeffs = new ColumnVector<float>(numTracks);
|
||||
matFrame = SquareMatrix.WithPolynomialCoefficients(numTracks);
|
||||
frame1 = new ColumnVector<Vector3>(numTracks);
|
||||
frame2 = new ColumnVector<Vector3>(numTracks);
|
||||
}
|
||||
|
||||
ColumnVector<Vector3> frame1;
|
||||
ColumnVector<Vector3> frame2;
|
||||
public ColumnVector<Vector3> GetCurrentFrame(Func<ContainerState, Vector3> func) {
|
||||
public Vector3 GetCurrentFrame(Func<ContainerState, Vector3> func, float track) {
|
||||
for (int i = 0; i < tracks.Length; i++)
|
||||
frame1[i] = func(tracks[i]);
|
||||
matFrame.Eliminate(frame1, frame2, Vector3Operator.Instance);
|
||||
return frame2;
|
||||
ColumnVector<float>.FillWithPolynomialCoefficients(coeffs, track);
|
||||
return frame2.Dot(coeffs, Vector3Operator.Instance);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cryville.Crtr {
|
||||
[Obsolete]
|
||||
public enum TransitionType : byte {
|
||||
In = 0,
|
||||
Out = 1,
|
||||
@@ -22,6 +23,7 @@ namespace Cryville.Crtr {
|
||||
Bounce = 24,
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static class MotionLerper {
|
||||
public static void Lerp<T>(double time, double tt, T tv, double ft, T fv, TransitionType type, float rate, ref T result) where T : Vector {
|
||||
if (fv == null) fv = (T)ReflectionHelper.InvokeEmptyConstructor(tv.GetType());
|
||||
@@ -35,19 +37,6 @@ namespace Cryville.Crtr {
|
||||
to.LerpWith(from, GetEaseTime(scaledTime, type, rate), ref r);
|
||||
}
|
||||
|
||||
public static double Delerp<T>(T value, double tt, T tv, double ft, T fv, TransitionType type, float rate) where T : Vector {
|
||||
if (fv == null) fv = (T)ReflectionHelper.InvokeEmptyConstructor(tv.GetType());
|
||||
var t = Delerp(value, fv, tv, type, rate);
|
||||
return ft * (1 - t) + tt * t;
|
||||
}
|
||||
|
||||
public static float Delerp<T>(T value, T from, T to, TransitionType type, float rate) where T : Vector {
|
||||
if (value.CompareTo(to) >= 0) return 1;
|
||||
if (value.CompareTo(from) < 0) return 0;
|
||||
float lerpedTime = to.DelerpWith(from, value);
|
||||
return GetUneaseTime(lerpedTime, type, rate);
|
||||
}
|
||||
|
||||
public static float GetEaseTime(float time, TransitionType type, float rate) {
|
||||
switch ((byte)type & 3) {
|
||||
case (byte)TransitionType.In:
|
||||
@@ -67,25 +56,6 @@ namespace Cryville.Crtr {
|
||||
}
|
||||
}
|
||||
|
||||
static float GetUneaseTime(float time, TransitionType type, float rate) {
|
||||
switch ((byte)type & 3) {
|
||||
case (byte)TransitionType.In:
|
||||
return 1 - GetUneaseOutTime(1 - time, type, rate);
|
||||
case (byte)TransitionType.Out:
|
||||
return GetUneaseOutTime(time, type, rate);
|
||||
case (byte)TransitionType.InOut:
|
||||
time *= 2;
|
||||
if (time <= 1) return (1 - GetUneaseOutTime(1 - time, type, rate)) / 2;
|
||||
else return (GetUneaseOutTime(time - 1, type, rate) + 1) / 2;
|
||||
case (byte)TransitionType.OutIn:
|
||||
time *= 2;
|
||||
if (time <= 1) return GetUneaseOutTime(time, type, rate) / 2;
|
||||
else return (2 - GetUneaseOutTime(2 - time, type, rate)) / 2;
|
||||
default:
|
||||
throw new ArgumentException("Unknown transition");
|
||||
}
|
||||
}
|
||||
|
||||
static float GetEaseOutTime(float p, TransitionType type, float rate) {
|
||||
switch ((byte)type & 252) {
|
||||
case (byte)TransitionType.Ease:
|
||||
@@ -123,21 +93,6 @@ namespace Cryville.Crtr {
|
||||
throw new ArgumentException("Unknown transition");
|
||||
}
|
||||
}
|
||||
|
||||
static float GetUneaseOutTime(float p, TransitionType type, float rate) {
|
||||
switch ((byte)type & 252) {
|
||||
case (byte)TransitionType.Ease:
|
||||
return 1 - Mathf.Pow(1 - p, 1 / rate);
|
||||
case (byte)TransitionType.Sine:
|
||||
return Mathf.Asin(p) / (Mathf.PI / 2);
|
||||
case (byte)TransitionType.Expo:
|
||||
return -Mathf.Log(1 - p, 2) / 10;
|
||||
case (byte)TransitionType.Circ:
|
||||
return 1 - Mathf.Sqrt(1 - p * p);
|
||||
default:
|
||||
throw new ArgumentException("Unknown transition");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public struct MotionRegistry {
|
||||
@@ -229,7 +184,7 @@ namespace Cryville.Crtr {
|
||||
public MotionNode QueryRelativeNode(ushort id) {
|
||||
int i = RelativeNodes.FindIndex(n => n.Id == id);
|
||||
MotionNode cnode;
|
||||
if (i == -1) cnode = new MotionNode() { Id = id };
|
||||
if (i == -1) cnode = new MotionNode { Id = id };
|
||||
else cnode = RelativeNodes[i];
|
||||
return cnode;
|
||||
}
|
||||
@@ -238,7 +193,7 @@ namespace Cryville.Crtr {
|
||||
int i = RelativeNodes.FindIndex(n => n.Id == node.Id);
|
||||
MotionNode cnode;
|
||||
if (i == -1) {
|
||||
cnode = new MotionNode() {
|
||||
cnode = new MotionNode {
|
||||
Id = node.Id,
|
||||
Time = new Vec1(0),
|
||||
Rate = new Vec1(1),
|
||||
@@ -304,7 +259,9 @@ namespace Cryville.Crtr {
|
||||
public ushort Id;
|
||||
public Vec1 Time;
|
||||
float CmpTime { get { return Time != null ? Time.Value : 0; } }
|
||||
[Obsolete]
|
||||
public TransitionType? Transition;
|
||||
[Obsolete]
|
||||
public Vec1 Rate;
|
||||
public Vector Value;
|
||||
|
||||
|
@@ -1,5 +1,4 @@
|
||||
using Cryville.Common;
|
||||
using Cryville.Common.Math;
|
||||
using Cryville.Crtr.Components;
|
||||
using Cryville.Crtr.Event;
|
||||
using System;
|
||||
@@ -50,7 +49,6 @@ namespace Cryville.Crtr {
|
||||
|
||||
public override void PreInit() {
|
||||
base.PreInit();
|
||||
coeffs = new ColumnVector<float>(gh.TrackCount);
|
||||
foreach (var j in Event.judges) {
|
||||
judges.Add(j, new JudgeState(this, j.Id.Key));
|
||||
}
|
||||
@@ -143,47 +141,13 @@ namespace Cryville.Crtr {
|
||||
return Quaternion.LookRotation(r, state.Normal);
|
||||
}
|
||||
|
||||
readonly List<Vector3> ctrl = new List<Vector3>(2);
|
||||
ColumnVector<float> coeffs;
|
||||
Vector3 GetFrame(ContainerState state, float track, Func<ContainerState, Vector3> func) {
|
||||
// TODO
|
||||
int id = Mathf.FloorToInt(track);
|
||||
var ts0 = state.GetChild(id, typeof(Chart.Track));
|
||||
var p1 = func(ts0);
|
||||
if (track == id)
|
||||
return p1;
|
||||
var ts1 = state.GetChild(id + 1, typeof(Chart.Track));
|
||||
var p2 = func(ts1);
|
||||
bool c0 = ts0.Corner;
|
||||
bool c1 = ts1.Corner;
|
||||
float t = track - id;
|
||||
float deltaz = p2.z - p1.z;
|
||||
float nt = 1 - t;
|
||||
if (c0 && c1)
|
||||
return (1 - t) * p1 + t * p2;
|
||||
else {
|
||||
ctrl.Clear();
|
||||
if (!c0) {
|
||||
var tp = ts0.GetControlPoint(true, deltaz);
|
||||
if (tp != Vector3.zero) ctrl.Add(tp);
|
||||
}
|
||||
if (!c1) {
|
||||
var tp = ts1.GetControlPoint(false, -deltaz);
|
||||
if (tp != Vector3.zero) ctrl.Add(tp);
|
||||
}
|
||||
if (ctrl.Count == 0) {
|
||||
var frame = gh.GetCurrentFrame(func);
|
||||
ColumnVector<float>.FillWithPolynomialCoefficients(coeffs, track);
|
||||
return frame.Dot(coeffs, Vector3Operator.Instance);
|
||||
}
|
||||
else if (ctrl.Count == 1) {
|
||||
return nt * (nt * p1 + t * (ctrl[0] + p1)) + t * t * p2;
|
||||
}
|
||||
else {
|
||||
var t2 = t * t;
|
||||
return nt * (nt * (nt * p1 + t * (ctrl[0] + p1)) + t2 * (ctrl[1] + p1)) + t2 * t * p2;
|
||||
}
|
||||
}
|
||||
if (track == id) return p1;
|
||||
return gh.GetCurrentFrame(func, track);
|
||||
}
|
||||
|
||||
public void ReportJudge(Judge.JudgeEvent ev, float time, Identifier result) {
|
||||
|
Reference in New Issue
Block a user