Add "cur" anchor.

This commit is contained in:
2022-12-22 14:43:50 +08:00
parent 8175ca7e82
commit ec9b23f797
3 changed files with 82 additions and 53 deletions

View File

@@ -38,6 +38,7 @@ namespace Cryville.Crtr.Event {
public Transform gogroup;
public readonly Dictionary<int, Anchor> Anchors = new Dictionary<int, Anchor>();
protected Transform a_cur;
protected Transform a_head;
protected Transform a_tail;
public Vector3 Position {
@@ -76,12 +77,14 @@ namespace Cryville.Crtr.Event {
public abstract string TypeName {
get;
}
protected readonly static int _a_cur = IdentifierManager.SharedInstance.Request("cur");
protected readonly static int _a_head = IdentifierManager.SharedInstance.Request("head");
protected readonly static int _a_tail = IdentifierManager.SharedInstance.Request("tail");
public virtual void PreInit() {
gogroup = new GameObject(TypeName + ":" + Container.GetHashCode().ToString(CultureInfo.InvariantCulture)).transform;
if (cs.Parent != null)
gogroup.SetParent(cs.Parent.Handler.gogroup, false);
a_cur = RegisterAnchor(_a_cur);
a_head = RegisterAnchor(_a_head);
a_tail = RegisterAnchor(_a_tail);
}

View File

@@ -60,14 +60,24 @@ namespace Cryville.Crtr {
}
public override void Update(ContainerState s, StampedEvent ev) {
if (s.CloneType == 0) {
#if UNITY_5_6_OR_NEWER
a_cur.SetPositionAndRotation(GetFramePoint(s.Parent, s.Track), GetFrameRotation(s.Parent, s.Track));
#else
a_cur.position = GetFramePoint(s.Parent, s.Track);
a_cur.rotation = GetFrameRotation(s.Parent, s.Track);
#endif
OpenAnchor(_a_cur);
base.Update(s, ev);
if (s.CloneType == 1) {
Position = GetFramePoint(bs.Parent, bs.Track);
Rotation = GetFrameRotation(bs.Parent, bs.Track);
CloseAnchor(_a_cur);
}
else if (s.CloneType == 2) {
Position = GetFramePoint(ts.Parent, ts.Track);
Rotation = GetFrameRotation(ts.Parent, ts.Track);
else {
base.Update(s, ev);
if (s.CloneType <= 2) {
Position = GetFramePoint(s.Parent, s.Track);
Rotation = GetFrameRotation(s.Parent, s.Track);
}
if (s.CloneType == 2) {
if (!gogroup) return;
Chart.Note tev = Event;
if (tev.IsLong) {
@@ -90,6 +100,7 @@ namespace Cryville.Crtr {
}
}
}
}
public override void EndUpdate(ContainerState s) {
if (s.CloneType == 2 && gogroup) {

View File

@@ -39,7 +39,6 @@ namespace Cryville.Crtr {
#endif
}
else if (s.CloneType == 3) {
spos = Vector3.zero;
bpos = cpt;
brot = Quaternion.Euler(s.Direction);
}
@@ -61,6 +60,21 @@ namespace Cryville.Crtr {
float length;
public override void Update(ContainerState s, StampedEvent ev) {
if (s.CloneType == 0) {
pwp = Vector3.zero;
cpt = s.ScreenPoint;
spos = Vector3.zero;
#if UNITY_5_6_OR_NEWER
a_cur.SetPositionAndRotation(s.ScreenPoint, Quaternion.Euler(s.Direction));
#else
a_cur.position = s.ScreenPoint;
a_cur.rotation = Quaternion.Euler(s.Direction);
#endif
OpenAnchor(_a_cur);
base.Update(s, ev);
CloseAnchor(_a_cur);
}
else {
base.Update(s, ev);
if (s.CloneType == 2 || s.CloneType == 3) {
var tpt = s.ScreenPoint;
@@ -90,6 +104,7 @@ namespace Cryville.Crtr {
}
else UpdatePosition(s);
}
}
void UpdatePosition(ContainerState s) {
cpt = s.ScreenPoint;