diff options
Diffstat (limited to '')
2 files changed, 81 insertions, 0 deletions
diff --git a/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs b/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs new file mode 100644 index 00000000..1a75c320 --- /dev/null +++ b/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs @@ -0,0 +1,69 @@ +using UnityEngine; + +[AddComponentMenu("Dynamic Bone/Dynamic Bone Plane Collider")] +public class DynamicBonePlaneCollider : DynamicBoneColliderBase +{ + void OnValidate() + { + } + + public override void Collide(ref Vector3 particlePosition, float particleRadius) + { + Vector3 normal = Vector3.up; + switch (m_Direction) + { + case Direction.X: + normal = transform.right; + break; + case Direction.Y: + normal = transform.up; + break; + case Direction.Z: + normal = transform.forward; + break; + } + + Vector3 p = transform.TransformPoint(m_Center); + Plane plane = new Plane(normal, p); + float d = plane.GetDistanceToPoint(particlePosition); + + if (m_Bound == Bound.Outside) + { + if (d < 0) + particlePosition -= normal * d; + } + else + { + if (d > 0) + particlePosition -= normal * d; + } + } + + void OnDrawGizmosSelected() + { + if (!enabled) + return; + + if (m_Bound == Bound.Outside) + Gizmos.color = Color.yellow; + else + Gizmos.color = Color.magenta; + + Vector3 normal = Vector3.up; + switch (m_Direction) + { + case Direction.X: + normal = transform.right; + break; + case Direction.Y: + normal = transform.up; + break; + case Direction.Z: + normal = transform.forward; + break; + } + + Vector3 p = transform.TransformPoint(m_Center); + Gizmos.DrawLine(p, p + normal); + } +} diff --git a/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta b/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta new file mode 100644 index 00000000..4978da8e --- /dev/null +++ b/VRCSDK3AvatarsLegacy/Assets/Resources/DynamicBone/Scripts/DynamicBonePlaneCollider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4e535bdf3689369408cc4d078260ef6a +timeCreated: 1482666461 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |