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