| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- namespace BansheeEngine
- {
- /** @addtogroup Physics
- * @{
- */
- /// <summary>
- /// Collider with sphere geometry.
- /// </summary>
- public sealed class SphereCollider : Collider
- {
- [SerializeField]
- private float radius = 1.0f;
- /// <summary>
- /// Radius of the sphere.
- /// </summary>
- public float Radius
- {
- get { return radius; }
- set
- {
- value = MathEx.Max(value, 0.01f);
- if (radius == value)
- return;
- radius = value;
- if (Native != null)
- {
- Native.Radius = value;
- if (parent != null)
- parent.UpdateMassDistribution();
- }
- }
- }
- /// <summary>
- /// Position of the sphere shape, relative to the component's scene object.
- /// </summary>
- public Vector3 Center
- {
- get { return serializableData.localPosition; }
- set
- {
- if (serializableData.localPosition == value)
- return;
- serializableData.localPosition = value;
- if (Native != null)
- UpdateTransform();
- }
- }
- /// <summary>
- /// Returns the native sphere collider wrapped by this component.
- /// </summary>
- private NativeSphereCollider Native
- {
- get { return (NativeSphereCollider)native; }
- }
- /// <inheritdoc/>
- internal override NativeCollider CreateCollider()
- {
- NativeSphereCollider sphereCollider = new NativeSphereCollider();
- sphereCollider.Radius = radius;
- return sphereCollider;
- }
- }
- /** @} */
- }
|