SpringBone gizmo

This commit is contained in:
ousttrue
2022-01-11 14:27:15 +09:00
parent 2ae25adde5
commit 3ef65aab5a
5 changed files with 48 additions and 10 deletions

2
.gitignore vendored
View File

@@ -61,4 +61,4 @@ Assets/_Private.meta
# sphinx build
public
*.pyc
.venv

View File

@@ -26,5 +26,19 @@ namespace UniVRM10
public static int SelectedGuid;
public bool IsSelected => GetInstanceID() == SelectedGuid;
private void OnDrawGizmos()
{
Gizmos.matrix = transform.localToWorldMatrix;
switch (ColliderType)
{
case VRM10SpringBoneColliderTypes.Sphere:
Gizmos.DrawWireSphere(Offset, Radius);
break;
case VRM10SpringBoneColliderTypes.Capsule:
break;
}
}
}
}

View File

@@ -27,14 +27,5 @@ namespace UniVRM10
[SerializeField, Range(0, 0.5f), Header("Collision")]
public float m_jointRadius = 0.02f;
public void DrawGizmo(Transform center, Color color)
{
#if UNITY_EDITOR
// Gizmos.matrix = Transform.localToWorldMatrix;
Gizmos.color = color;
Gizmos.DrawSphere(transform.position, m_jointRadius);
#endif
}
}
}

View File

@@ -103,5 +103,17 @@ namespace UniVRM10
{
Runtime.Dispose();
}
private void OnDrawGizmos()
{
foreach (var spring in SpringBone.Springs)
{
foreach (var (head, tail) in spring.EnumHeadTail())
{
Gizmos.DrawLine(head.transform.position, tail.transform.position);
Gizmos.DrawSphere(tail.transform.position, head.m_jointRadius);
}
}
}
}
}

View File

@@ -37,6 +37,27 @@ namespace UniVRM10
{
Name = name;
}
public IEnumerable<(VRM10SpringBoneJoint, Transform)> EnumHeadTail()
{
for (int i = 0; i < Joints.Count; ++i)
{
var head = Joints[i];
if (head == null)
{
continue;
}
for (int j = i + 1; j < Joints.Count; ++j)
{
var tail = Joints[j];
if (tail != null)
{
yield return (head, tail.transform);
break;
}
}
}
}
}
[SerializeField]