mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-20 09:34:42 -05:00
SpringBone gizmo
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -61,4 +61,4 @@ Assets/_Private.meta
|
||||
# sphinx build
|
||||
public
|
||||
*.pyc
|
||||
|
||||
.venv
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user