summaryrefslogtreecommitdiff
path: root/Runtime/Dynamics/SphereCollider.h
blob: 1a3f779e6794234a4ffcf56d23da51af19eb7949 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SPHERECOLLIDER_H
#define SPHERECOLLIDER_H

#include "Collider.h"
#include "Runtime/Math/Vector3.h"


class SphereCollider : public Collider
{
 public:	
	REGISTER_DERIVED_CLASS (SphereCollider, Collider)
	DECLARE_OBJECT_SERIALIZE (SphereCollider)
	
	SphereCollider (MemLabelId label, ObjectCreationMode mode);
	
	virtual void Reset ();
	virtual void SmartReset ();
	virtual void AwakeFromLoad(AwakeFromLoadMode mode);
	
	void SetRadius (float r);
	float GetRadius () const { return m_Radius; }

	float GetScaledRadius () const;

	void SetCenter (const Vector3f& center);
	Vector3f GetCenter () { return m_Center; }

	Vector3f GetGlobalCenter () const;

	void TransformChanged (int changeMask);
	
	virtual AABB GetBounds ();
	
	protected:
	
	virtual void Create (const Rigidbody* ignoreAttachRigidbody);
	virtual void FetchPoseFromTransform ();
	virtual bool GetRelativeToParentPositionAndRotation (Transform& transform, Transform& anyParent, Matrix4x4f& matrix);

	virtual NxCCDSkeleton* CreateCCDSkeleton(float scale);
	
	void ScaleChanged ();
	
	/// The radius of the sphere. range { 0.00001, infinity }
	float m_Radius;
	Vector3f m_Center;

	#if UNITY_EDITOR
	/// In unity version 1.0 sphere radius did not change with scale.
	/// This was fixed with version 1.1
	/// In the transfer function we check if we should up to account for the now introduced scale.
	bool fixupSphereColliderBackwardsCompatibility;
	#endif
};

#endif