Browse Source

Added Box/Sphere/Plane/Capsule colliders and general collider implementation

BearishSun 10 years ago
parent
commit
5ce5f5d41c
39 changed files with 875 additions and 50 deletions
  1. 10 0
      BansheeCore/BansheeCore.vcxproj
  2. 30 0
      BansheeCore/BansheeCore.vcxproj.filters
  3. 20 0
      BansheeCore/Include/BsBoxCollider.h
  4. 20 0
      BansheeCore/Include/BsCapsuleCollider.h
  5. 23 20
      BansheeCore/Include/BsCollider.h
  6. 5 0
      BansheeCore/Include/BsCorePrerequisites.h
  7. 47 0
      BansheeCore/Include/BsFCollider.h
  8. 9 2
      BansheeCore/Include/BsPhysics.h
  9. 20 0
      BansheeCore/Include/BsPlaneCollider.h
  10. 6 5
      BansheeCore/Include/BsRigidbody.h
  11. 20 0
      BansheeCore/Include/BsSphereCollider.h
  12. 14 0
      BansheeCore/Source/BsBoxCollider.cpp
  13. 14 0
      BansheeCore/Source/BsCapsuleCollider.cpp
  14. 65 15
      BansheeCore/Source/BsCollider.cpp
  15. 40 0
      BansheeCore/Source/BsFCollider.cpp
  16. 1 0
      BansheeCore/Source/BsPhysics.cpp
  17. 13 0
      BansheeCore/Source/BsPlaneCollider.cpp
  18. 2 2
      BansheeCore/Source/BsRigidbody.cpp
  19. 13 0
      BansheeCore/Source/BsSphereCollider.cpp
  20. 0 1
      BansheeD3D11RenderAPI/Source/BsD3D11GpuProgram.cpp
  21. 10 0
      BansheePhysX/BansheePhysX.vcxproj
  22. 30 0
      BansheePhysX/BansheePhysX.vcxproj.filters
  23. 41 0
      BansheePhysX/Include/BsFPhysXCollider.h
  24. 17 0
      BansheePhysX/Include/BsPhysX.h
  25. 21 0
      BansheePhysX/Include/BsPhysXBoxCollider.h
  26. 21 0
      BansheePhysX/Include/BsPhysXCapsuleCollider.h
  27. 2 0
      BansheePhysX/Include/BsPhysXMaterial.h
  28. 20 0
      BansheePhysX/Include/BsPhysXPlaneCollider.h
  29. 7 0
      BansheePhysX/Include/BsPhysXPrerequisites.h
  30. 1 1
      BansheePhysX/Include/BsPhysXRigidbody.h
  31. 20 0
      BansheePhysX/Include/BsPhysXSphereCollider.h
  32. 152 0
      BansheePhysX/Source/BsFPhysXCollider.cpp
  33. 34 1
      BansheePhysX/Source/BsPhysX.cpp
  34. 30 0
      BansheePhysX/Source/BsPhysXBoxCollider.cpp
  35. 30 0
      BansheePhysX/Source/BsPhysXCapsuleCollider.cpp
  36. 29 0
      BansheePhysX/Source/BsPhysXPlaneCollider.cpp
  37. 5 2
      BansheePhysX/Source/BsPhysXRigidbody.cpp
  38. 30 0
      BansheePhysX/Source/BsPhysXSphereCollider.cpp
  39. 3 1
      Doxyfile

+ 10 - 0
BansheeCore/BansheeCore.vcxproj

@@ -296,9 +296,12 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClInclude Include="Include\BsBoxCollider.h" />
+    <ClInclude Include="Include\BsCapsuleCollider.h" />
     <ClInclude Include="Include\BsCollider.h" />
     <ClInclude Include="Include\BsCollision.h" />
     <ClInclude Include="Include\BsCoreObjectCore.h" />
+    <ClInclude Include="Include\BsFCollider.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsIconUtility.h" />
     <ClInclude Include="Include\BsMaterialParams.h" />
@@ -311,6 +314,7 @@
     <ClInclude Include="Include\BsPhysics.h" />
     <ClInclude Include="Include\BsPhysicsMaterial.h" />
     <ClInclude Include="Include\BsPhysicsMaterialRTTI.h" />
+    <ClInclude Include="Include\BsPlaneCollider.h" />
     <ClInclude Include="Include\BsPrefab.h" />
     <ClInclude Include="Include\BsPrefabDiff.h" />
     <ClInclude Include="Include\BsPrefabDiffRTTI.h" />
@@ -392,6 +396,7 @@
     <ClInclude Include="Include\BsPixelBuffer.h" />
     <ClInclude Include="Include\BsShaderIncludeImporter.h" />
     <ClInclude Include="Include\BsShaderManager.h" />
+    <ClInclude Include="Include\BsSphereCollider.h" />
     <ClInclude Include="Include\BsStringTable.h" />
     <ClInclude Include="Include\BsStringTableManager.h" />
     <ClInclude Include="Include\BsStringTableRTTI.h" />
@@ -467,9 +472,12 @@
     <ClInclude Include="Include\Win32\BSWin32PlatformData.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="Source\BsBoxCollider.cpp" />
+    <ClCompile Include="Source\BsCapsuleCollider.cpp" />
     <ClCompile Include="Source\BsCollider.cpp" />
     <ClCompile Include="Source\BsCoreObjectCore.cpp" />
     <ClCompile Include="Source\BsCoreThread.cpp" />
+    <ClCompile Include="Source\BsFCollider.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
     <ClCompile Include="Source\BsIconUtility.cpp" />
     <ClCompile Include="Source\BsIResourceListener.cpp" />
@@ -479,6 +487,7 @@
     <ClCompile Include="Source\BsPhysics.cpp" />
     <ClCompile Include="Source\BsPhysicsManager.cpp" />
     <ClCompile Include="Source\BsPhysicsMaterial.cpp" />
+    <ClCompile Include="Source\BsPlaneCollider.cpp" />
     <ClCompile Include="Source\BsPrefab.cpp" />
     <ClCompile Include="Source\BsPrefabDiff.cpp" />
     <ClCompile Include="Source\BsPrefabUtility.cpp" />
@@ -532,6 +541,7 @@
     <ClCompile Include="Source\BsResourceManifest.cpp" />
     <ClCompile Include="Source\BsResourceMetaData.cpp" />
     <ClCompile Include="Source\BsShaderManager.cpp" />
+    <ClCompile Include="Source\BsSphereCollider.cpp" />
     <ClCompile Include="Source\BsStringTable.cpp" />
     <ClCompile Include="Source\BsStringTableManager.cpp" />
     <ClCompile Include="Source\BsTextureImportOptions.cpp" />

+ 30 - 0
BansheeCore/BansheeCore.vcxproj.filters

@@ -608,6 +608,21 @@
     <ClInclude Include="Include\BsCollision.h">
       <Filter>Header Files\Physics</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsBoxCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsSphereCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsCapsuleCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPlaneCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFCollider.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCoreApplication.cpp">
@@ -955,5 +970,20 @@
     <ClCompile Include="Source\BsRigidbody.cpp">
       <Filter>Source Files\Physics</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsBoxCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsSphereCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPlaneCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsCapsuleCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFCollider.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 20 - 0
BansheeCore/Include/BsBoxCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollider.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT BoxCollider : public Collider
+	{
+	public:
+		BoxCollider();
+
+		static SPtr<BoxCollider> create(float extentX = 0.0f, float extentY = 0.0f, float extentZ = 0.0f, 
+			const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
+	};
+}

+ 20 - 0
BansheeCore/Include/BsCapsuleCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollider.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT CapsuleCollider : public Collider
+	{
+	public:
+		CapsuleCollider();
+
+		static SPtr<CapsuleCollider> create(float radius = 0.0f, float halfHeight = 0.0f, 
+			const Vector3& position = Vector3::ZERO, const Quaternion& rotation = Quaternion::IDENTITY);
+	};
+}

+ 23 - 20
BansheeCore/Include/BsCollider.h

@@ -4,43 +4,46 @@
 
 #include "BsCorePrerequisites.h"
 #include "BsCollision.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
 
 namespace BansheeEngine
 {
 	class BS_CORE_EXPORT Collider
 	{
 	public:
-		virtual ~Collider();
+		virtual ~Collider() { }
 
-		virtual void setIsTrigger(bool value) = 0;
-		virtual bool getIsTrigger() const = 0;
+		inline Vector3 getPosition() const;
+		inline Quaternion getRotation() const;
+		inline void setTransform(const Vector3& pos, const Quaternion& rot);
 
-		virtual void setRigidbody(const SPtr<Rigidbody>& rigidbody);
-		virtual SPtr<Rigidbody> getRigidbody() const { return mRigidbody; }
+		inline void setIsTrigger(bool value);
+		inline bool getIsTrigger() const;
 
-		virtual void setMaterial(const HPhysicsMaterial& material);
-		virtual HPhysicsMaterial getMaterial() const { return mMaterial; }
+		inline void setRigidbody(const SPtr<Rigidbody>& rigidbody);
+		inline SPtr<Rigidbody> getRigidbody() const;
 
-		virtual void setIsActive(bool value);
-		virtual bool getIsActive() const { return mIsActive; }
+		inline void setMaterial(const HPhysicsMaterial& material);
+		inline HPhysicsMaterial getMaterial() const;
 
-		virtual void setContactOffset(float value) = 0;
-		virtual float getContactOffset() = 0;
+		inline void setIsActive(bool value);
+		inline bool getIsActive() const;
 
-		virtual void setRestOffset(float value) = 0;
-		virtual float getRestOffset() = 0;
+		inline void setContactOffset(float value);
+		inline float getContactOffset();
 
-		virtual void setLayer(UINT64 layer);
-		virtual UINT64 getLayer() const { return mLayer; }
+		inline void setRestOffset(float value);
+		inline float getRestOffset();
+
+		inline void setLayer(UINT64 layer);
+		inline UINT64 getLayer() const;
 
 		Event<void(const CollisionData&)> onCollisionStart;
 		Event<void(const CollisionData&)> onCollisionStay;
 		Event<void(const CollisionData&)> onCollisionEnd;
-	protected:
-		bool mIsActive = true;
-		UINT64 mLayer = 1;
 
-		SPtr<Rigidbody> mRigidbody;
-		HPhysicsMaterial mMaterial;
+	protected:
+		FCollider* mInternal = nullptr;
 	};
 }

+ 5 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -232,9 +232,14 @@ namespace BansheeEngine
 	class RenderAPIFactory;
 	class PhysicsManager;
 	class Physics;
+	class FCollider;
 	class Collider;
 	class Rigidbody;
 	class PhysicsMaterial;
+	class BoxCollider;
+	class SphereCollider;
+	class PlaneCollider;
+	class CapsuleCollider;
 	// Asset import
 	class SpecificImporter;
 	class Importer;

+ 47 - 0
BansheeCore/Include/BsFCollider.h

@@ -0,0 +1,47 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT FCollider
+	{
+	public:
+		virtual ~FCollider();
+
+		virtual Vector3 getPosition() const = 0;
+		virtual Quaternion getRotation() const = 0;
+		virtual void setTransform(const Vector3& pos, const Quaternion& rotation) = 0;
+
+		virtual void setIsTrigger(bool value) = 0;
+		virtual bool getIsTrigger() const = 0;
+
+		virtual void setRigidbody(const SPtr<Rigidbody>& rigidbody);
+		virtual SPtr<Rigidbody> getRigidbody() const { return mRigidbody; }
+
+		virtual void setMaterial(const HPhysicsMaterial& material);
+		virtual HPhysicsMaterial getMaterial() const { return mMaterial; }
+
+		virtual void setIsActive(bool value);
+		virtual bool getIsActive() const { return mIsActive; }
+
+		virtual void setContactOffset(float value) = 0;
+		virtual float getContactOffset() = 0;
+
+		virtual void setRestOffset(float value) = 0;
+		virtual float getRestOffset() = 0;
+
+		virtual void setLayer(UINT64 layer);
+		virtual UINT64 getLayer() const { return mLayer; }
+	protected:
+		bool mIsActive = true;
+		UINT64 mLayer = 1;
+
+		SPtr<Rigidbody> mRigidbody;
+		HPhysicsMaterial mMaterial;
+	};
+}

+ 9 - 2
BansheeCore/Include/BsPhysics.h

@@ -18,8 +18,15 @@ namespace BansheeEngine
 		virtual void update() = 0;
 
 		virtual SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) = 0;
-		virtual SPtr<Rigidbody> createRigidbody(const Vector3& position = Vector3::ZERO, 
-			const Quaternion& rotation = Quaternion::IDENTITY) = 0;
+		virtual SPtr<Rigidbody> createRigidbody(const Vector3& position, const Quaternion& rotation) = 0;
+
+		virtual SPtr<BoxCollider> createBoxCollider(float extentX, float extentY, float extentZ,
+			const Vector3& position, const Quaternion& rotation) = 0;
+		virtual SPtr<SphereCollider> createSphereCollider(float radius,
+			const Vector3& position, const Quaternion& rotation) = 0;
+		virtual SPtr<PlaneCollider> createPlaneCollider(const Vector3& position, const Quaternion& rotation) = 0;
+		virtual SPtr<CapsuleCollider> createCapsuleCollider(float radius, float halfHeight,
+			const Vector3& position, const Quaternion& rotation) = 0;
 
 		void toggleCollision(UINT64 groupA, UINT64 groupB, bool enabled);
 		bool isCollisionEnabled(UINT64 groupA, UINT64 groupB) const;

+ 20 - 0
BansheeCore/Include/BsPlaneCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollider.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT PlaneCollider : public Collider
+	{
+	public:
+		PlaneCollider();
+
+		static SPtr<PlaneCollider> create(const Vector3& position = Vector3::ZERO, 
+			const Quaternion& rotation = Quaternion::IDENTITY);
+	};
+}

+ 6 - 5
BansheeCore/Include/BsRigidbody.h

@@ -14,9 +14,6 @@ namespace BansheeEngine
 
 		// TODO
 
-		virtual void addCollider(Collider* collider);
-		virtual void removeCollider(Collider* collider);
-
 		virtual void setIsActive(bool value);
 		virtual bool getIsActive() const { return mIsActive; }
 
@@ -26,8 +23,12 @@ namespace BansheeEngine
 		Event<void(const CollisionData&)> onCollisionStay;
 		Event<void(const CollisionData&)> onCollisionEnd;
 	protected:
-		bool mIsActive = true;
+		friend class FCollider;
 
-		Vector<Collider*> mColliders;
+		virtual void addCollider(FCollider* collider);
+		virtual void removeCollider(FCollider* collider);
+
+		bool mIsActive = true;
+		Vector<FCollider*> mColliders;
 	};
 }

+ 20 - 0
BansheeCore/Include/BsSphereCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCollider.h"
+#include "BsVector3.h"
+#include "BsQuaternion.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT SphereCollider : public Collider
+	{
+	public:
+		SphereCollider();
+
+		static SPtr<SphereCollider> create(float radius = 0.0f, const Vector3& position = Vector3::ZERO, 
+			const Quaternion& rotation = Quaternion::IDENTITY);
+	};
+}

+ 14 - 0
BansheeCore/Source/BsBoxCollider.cpp

@@ -0,0 +1,14 @@
+#include "BsBoxCollider.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	BoxCollider::BoxCollider()
+	{ }
+
+	SPtr<BoxCollider> BoxCollider::create(float extentX, float extentY, float extentZ, 
+		const Vector3& position, const Quaternion& rotation)
+	{
+		return Physics::instance().createBoxCollider(extentX, extentY, extentZ, position, rotation);
+	}
+}

+ 14 - 0
BansheeCore/Source/BsCapsuleCollider.cpp

@@ -0,0 +1,14 @@
+#include "BsCapsuleCollider.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	CapsuleCollider::CapsuleCollider()
+	{ }
+
+	SPtr<CapsuleCollider> CapsuleCollider::create(float radius, float halfHeight, 
+		const Vector3& position, const Quaternion& rotation)
+	{
+		return Physics::instance().createCapsuleCollider(radius, halfHeight, position, rotation);
+	}
+}

+ 65 - 15
BansheeCore/Source/BsCollider.cpp

@@ -1,40 +1,90 @@
 #include "BsCollider.h"
-#include "BsRigidbody.h"
+#include "BsFCollider.h"
 
 namespace BansheeEngine
 {
-	Collider::~Collider()
+	Vector3 Collider::getPosition() const
 	{
-		if (mRigidbody != nullptr)
-			mRigidbody->removeCollider(this);
+		return mInternal->getPosition();
 	}
 
-	void Collider::setRigidbody(const SPtr<Rigidbody>& rigidbody)
+	Quaternion Collider::getRotation() const
 	{
-		if (mRigidbody == rigidbody)
-			return;
+		return mInternal->getRotation();
+	}
+
+	void Collider::setTransform(const Vector3& pos, const Quaternion& rot)
+	{
+		mInternal->setTransform(pos, rot);
+	}
 
-		if (mRigidbody != nullptr)
-			mRigidbody->removeCollider(this);
+	void Collider::setIsTrigger(bool value)
+	{
+		mInternal->setIsTrigger(value);
+	}
+
+	bool Collider::getIsTrigger() const
+	{
+		return mInternal->getIsTrigger();
+	}
 
-		mRigidbody = rigidbody;
+	void Collider::setRigidbody(const SPtr<Rigidbody>& rigidbody)
+	{
+		mInternal->setRigidbody(rigidbody);
+	}
 
-		if(mRigidbody != nullptr)
-			mRigidbody->addCollider(this);
+	SPtr<Rigidbody> Collider::getRigidbody() const
+	{
+		return mInternal->getRigidbody();
 	}
 
 	void Collider::setMaterial(const HPhysicsMaterial& material)
 	{
-		mMaterial = material;
+		mInternal->setMaterial(material);
+	}
+
+	HPhysicsMaterial Collider::getMaterial() const
+	{
+		return mInternal->getMaterial();
 	}
 
 	void Collider::setIsActive(bool value)
 	{
-		mIsActive = value;
+		mInternal->setIsActive(value);
+	}
+
+	bool Collider::getIsActive() const
+	{
+		return mInternal->getIsActive();
+	}
+
+	void Collider::setContactOffset(float value)
+	{
+		mInternal->setContactOffset(value);
+	}
+
+	float Collider::getContactOffset()
+	{
+		return mInternal->getContactOffset();
+	}
+
+	void Collider::setRestOffset(float value)
+	{
+		mInternal->setRestOffset(value);
+	}
+
+	float Collider::getRestOffset()
+	{
+		return mInternal->getRestOffset();
 	}
 
 	void Collider::setLayer(UINT64 layer)
 	{
-		mLayer = layer;
+		mInternal->setLayer(layer);
+	}
+
+	UINT64 Collider::getLayer() const
+	{
+		return mInternal->getLayer();
 	}
 }

+ 40 - 0
BansheeCore/Source/BsFCollider.cpp

@@ -0,0 +1,40 @@
+#include "BsFCollider.h"
+#include "BsRigidbody.h"
+
+namespace BansheeEngine
+{
+	FCollider::~FCollider()
+	{
+		if (mRigidbody != nullptr)
+			mRigidbody->removeCollider(this);
+	}
+
+	void FCollider::setRigidbody(const SPtr<Rigidbody>& rigidbody)
+	{
+		if (mRigidbody == rigidbody)
+			return;
+
+		if (mRigidbody != nullptr)
+			mRigidbody->removeCollider(this);
+
+		mRigidbody = rigidbody;
+
+		if (mRigidbody != nullptr)
+			mRigidbody->addCollider(this);
+	}
+
+	void FCollider::setMaterial(const HPhysicsMaterial& material)
+	{
+		mMaterial = material;
+	}
+
+	void FCollider::setIsActive(bool value)
+	{
+		mIsActive = value;
+	}
+
+	void FCollider::setLayer(UINT64 layer)
+	{
+		mLayer = layer;
+	}
+}

+ 1 - 0
BansheeCore/Source/BsPhysics.cpp

@@ -1,4 +1,5 @@
 #include "BsPhysics.h"
+#include "BsPhysicsMaterial.h"
 
 namespace BansheeEngine
 {

+ 13 - 0
BansheeCore/Source/BsPlaneCollider.cpp

@@ -0,0 +1,13 @@
+#include "BsPlaneCollider.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	PlaneCollider::PlaneCollider()
+	{ }
+
+	SPtr<PlaneCollider> PlaneCollider::create(const Vector3& position, const Quaternion& rotation)
+	{
+		return Physics::instance().createPlaneCollider(position, rotation);
+	}
+}

+ 2 - 2
BansheeCore/Source/BsRigidbody.cpp

@@ -8,12 +8,12 @@ namespace BansheeEngine
 		// It is assumed that child colliders will keep the parent Rigidbody alive, so we don't need to clear their parents
 	}
 
-	void Rigidbody::addCollider(Collider* collider)
+	void Rigidbody::addCollider(FCollider* collider)
 	{
 		mColliders.push_back(collider);
 	}
 
-	void Rigidbody::removeCollider(Collider* collider)
+	void Rigidbody::removeCollider(FCollider* collider)
 	{
 		auto iterFind = std::find(mColliders.begin(), mColliders.end(), collider);
 		if (iterFind != mColliders.end())

+ 13 - 0
BansheeCore/Source/BsSphereCollider.cpp

@@ -0,0 +1,13 @@
+#include "BsSphereCollider.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	SphereCollider::SphereCollider()
+	{ }
+
+	SPtr<SphereCollider> SphereCollider::create(float radius, const Vector3& position, const Quaternion& rotation)
+	{
+		return Physics::instance().createSphereCollider(radius, position, rotation);
+	}
+}

+ 0 - 1
BansheeD3D11RenderAPI/Source/BsD3D11GpuProgram.cpp

@@ -317,7 +317,6 @@ namespace BansheeEngine
 		}
 	}
 
-
 	ID3D11ComputeShader* D3D11GpuComputeProgramCore::getComputeShader() const
 	{
 		return mComputeShader;

+ 10 - 0
BansheePhysX/BansheePhysX.vcxproj

@@ -245,16 +245,26 @@
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
+    <ClCompile Include="Source\BsFPhysXCollider.cpp" />
     <ClCompile Include="Source\BsPhysX.cpp" />
+    <ClCompile Include="Source\BsPhysXBoxCollider.cpp" />
+    <ClCompile Include="Source\BsPhysXCapsuleCollider.cpp" />
     <ClCompile Include="Source\BsPhysXMaterial.cpp" />
+    <ClCompile Include="Source\BsPhysXPlaneCollider.cpp" />
     <ClCompile Include="Source\BsPhysXPlugin.cpp" />
     <ClCompile Include="Source\BsPhysXRigidbody.cpp" />
+    <ClCompile Include="Source\BsPhysXSphereCollider.cpp" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPhysX.h" />
+    <ClInclude Include="Include\BsPhysXBoxCollider.h" />
+    <ClInclude Include="Include\BsFPhysXCollider.h" />
+    <ClInclude Include="Include\BsPhysXCapsuleCollider.h" />
     <ClInclude Include="Include\BsPhysXMaterial.h" />
+    <ClInclude Include="Include\BsPhysXPlaneCollider.h" />
     <ClInclude Include="Include\BsPhysXPrerequisites.h" />
     <ClInclude Include="Include\BsPhysXRigidbody.h" />
+    <ClInclude Include="Include\BsPhysXSphereCollider.h" />
   </ItemGroup>
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">

+ 30 - 0
BansheePhysX/BansheePhysX.vcxproj.filters

@@ -23,6 +23,21 @@
     <ClCompile Include="Source\BsPhysXRigidbody.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="Source\BsPhysXBoxCollider.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFPhysXCollider.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXSphereCollider.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXPlaneCollider.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXCapsuleCollider.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPhysXPrerequisites.h">
@@ -37,5 +52,20 @@
     <ClInclude Include="Include\BsPhysXRigidbody.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="Include\BsPhysXBoxCollider.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFPhysXCollider.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXSphereCollider.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXPlaneCollider.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXCapsuleCollider.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>

+ 41 - 0
BansheePhysX/Include/BsFPhysXCollider.h

@@ -0,0 +1,41 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsCollision.h"
+#include "BsFCollider.h"
+#include "PxRigidStatic.h"
+
+namespace BansheeEngine
+{
+	class FPhysXCollider : public FCollider
+	{
+	public:
+		explicit FPhysXCollider(physx::PxShape* shape);
+		~FPhysXCollider();
+
+		Vector3 getPosition() const override;
+		Quaternion getRotation() const override;
+		void setTransform(const Vector3& pos, const Quaternion& rotation) override;
+
+		void setIsTrigger(bool value) override;
+		bool getIsTrigger() const override;
+
+		void setContactOffset(float value) override;
+		float getContactOffset() override;
+
+		void setRestOffset(float value) override;
+		float getRestOffset() override;
+
+		void setRigidbody(const SPtr<Rigidbody>& rigidbody) override;
+		void setMaterial(const HPhysicsMaterial& material) override;
+		void setIsActive(bool value) override;
+		void setLayer(UINT64 layer) override;
+
+	protected:
+		physx::PxShape* mShape;
+		physx::PxRigidStatic* mStaticBody;
+		bool mIsTrigger;
+	};
+}

+ 17 - 0
BansheePhysX/Include/BsPhysX.h

@@ -21,6 +21,18 @@ namespace BansheeEngine
 		SPtr<PhysicsMaterial> createMaterial(float staticFriction, float dynamicFriction, float restitution) override;
 		SPtr<Rigidbody> createRigidbody(const Vector3& position = Vector3::ZERO,
 			const Quaternion& rotation = Quaternion::IDENTITY) override;
+
+		SPtr<BoxCollider> createBoxCollider(float extentX, float extentY, float extentZ, const Vector3& position, 
+			const Quaternion& rotation) override;
+		SPtr<SphereCollider> createSphereCollider(float radius, const Vector3& position, const Quaternion& rotation) override;
+		SPtr<PlaneCollider> createPlaneCollider(const Vector3& position, const Quaternion& rotation) override;
+		SPtr<CapsuleCollider> createCapsuleCollider(float radius, float halfHeight, const Vector3& position, 
+			const Quaternion& rotation) override;
+
+		physx::PxMaterial* getDefaultMaterial() const { return mDefaultMaterial; }
+		physx::PxPhysics* getPhysX() const { return mPhysics; }
+		physx::PxScene* getScene() const { return mScene; }
+
 	private:
 		float mSimulationStep = 1.0f/60.0f;
 		float mLastSimulationTime = 0.0f;
@@ -29,5 +41,10 @@ namespace BansheeEngine
 		physx::PxPhysics* mPhysics = nullptr;
 		physx::PxCooking* mCooking = nullptr;
 		physx::PxScene* mScene = nullptr;
+
+		physx::PxMaterial* mDefaultMaterial = nullptr;
 	};
+
+	/** Provides easier access to PhysX. */
+	PhysX& gPhysX();
 }

+ 21 - 0
BansheePhysX/Include/BsPhysXBoxCollider.h

@@ -0,0 +1,21 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsBoxCollider.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class PhysXBoxCollider : public BoxCollider
+	{
+	public:
+		PhysXBoxCollider(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation, 
+			float extentX, float extentY, float extentZ);
+		~PhysXBoxCollider();
+
+	private:
+		FPhysXCollider* getInternal() const;
+	};
+}

+ 21 - 0
BansheePhysX/Include/BsPhysXCapsuleCollider.h

@@ -0,0 +1,21 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsCapsuleCollider.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class PhysXCapsuleCollider : public CapsuleCollider
+	{
+	public:
+		PhysXCapsuleCollider(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation, 
+			float radius, float halfHeight);
+		~PhysXCapsuleCollider();
+
+	private:
+		FPhysXCollider* getInternal() const;
+	};
+}

+ 2 - 0
BansheePhysX/Include/BsPhysXMaterial.h

@@ -23,6 +23,8 @@ namespace BansheeEngine
 		void setRestitutionCoefficient(float value) override;
 		float getRestitutionCoefficient() const override;
 
+		physx::PxMaterial* _getInternal() const { return mInternal; }
+
 	private:
 		physx::PxMaterial* mInternal;
 	};

+ 20 - 0
BansheePhysX/Include/BsPhysXPlaneCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsPlaneCollider.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class PhysXPlaneCollider : public PlaneCollider
+	{
+	public:
+		PhysXPlaneCollider(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation);
+		~PhysXPlaneCollider();
+
+	private:
+		FPhysXCollider* getInternal() const;
+	};
+}

+ 7 - 0
BansheePhysX/Include/BsPhysXPrerequisites.h

@@ -6,6 +6,7 @@
 #include "foundation\PxVec3.h"
 #include "foundation\PxVec4.h"
 #include "foundation\PxQuat.h"
+#include "foundation\PxTransform.h"
 
 namespace BansheeEngine
 {
@@ -25,6 +26,7 @@ namespace BansheeEngine
 
 	class PhysXRigidbody;
 	class PhsyXMaterial;
+	class FPhysXCollider;
 
 	inline const physx::PxVec3& toPxVector(const Vector3& input)
 	{
@@ -41,6 +43,11 @@ namespace BansheeEngine
 		return *(physx::PxQuat*)&input;
 	}
 
+	inline physx::PxTransform toPxTransform(const Vector3& pos, const Quaternion& rot)
+	{
+		return physx::PxTransform(toPxVector(pos), toPxQuaternion(rot));
+	}
+
 	inline const Vector3& fromPxVector(const physx::PxVec3& input)
 	{
 		return *(Vector3*)&input;

+ 1 - 1
BansheePhysX/Include/BsPhysXRigidbody.h

@@ -11,7 +11,7 @@ namespace BansheeEngine
 	class PhysXRigidbody : public Rigidbody
 	{
 	public:
-		PhysXRigidbody(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation);
+		PhysXRigidbody(physx::PxPhysics* physx, physx::PxScene* scene, const Vector3& position, const Quaternion& rotation);
 		~PhysXRigidbody();
 
 		// TODO

+ 20 - 0
BansheePhysX/Include/BsPhysXSphereCollider.h

@@ -0,0 +1,20 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsSphereCollider.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class PhysXSphereCollider : public SphereCollider
+	{
+	public:
+		PhysXSphereCollider(physx::PxPhysics* physx, const Vector3& position, const Quaternion& rotation, float radius);
+		~PhysXSphereCollider();
+
+	private:
+		FPhysXCollider* getInternal() const;
+	};
+}

+ 152 - 0
BansheePhysX/Source/BsFPhysXCollider.cpp

@@ -0,0 +1,152 @@
+#include "BsFPhysXCollider.h"
+#include "BsPhysX.h"
+#include "BsPhysXRigidbody.h"
+#include "BsPhysXMaterial.h"
+#include "PxScene.h"
+#include "PxShape.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	FPhysXCollider::FPhysXCollider(physx::PxShape* shape)
+		:mShape(shape), mStaticBody(nullptr), mIsTrigger(false)
+	{
+		mStaticBody = gPhysX().getPhysX()->createRigidStatic(PxTransform());
+		mStaticBody->attachShape(*mShape);
+
+		PxScene* scene = gPhysX().getScene();
+		scene->addActor(*mStaticBody);
+	}
+
+	FPhysXCollider::~FPhysXCollider()
+	{
+		if (mStaticBody != nullptr)
+			mStaticBody->release();
+
+		mShape->release();
+	}
+
+	Vector3 FPhysXCollider::getPosition() const
+	{
+		return fromPxVector(mShape->getLocalPose().p);
+	}
+
+	Quaternion FPhysXCollider::getRotation() const
+	{
+		return fromPxQuaternion(mShape->getLocalPose().q);
+	}
+
+	void FPhysXCollider::setTransform(const Vector3& pos, const Quaternion& rotation)
+	{
+		mShape->setLocalPose(toPxTransform(pos, rotation));
+	}
+
+	void FPhysXCollider::setIsTrigger(bool value)
+	{
+		if(value)
+		{
+			mShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, false);
+			mShape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, true);
+
+			mIsTrigger = true;
+		}
+		else
+		{
+			mShape->setFlag(PxShapeFlag::eTRIGGER_SHAPE, false);
+			mShape->setFlag(PxShapeFlag::eSIMULATION_SHAPE, true);
+
+			mIsTrigger = false;
+		}		
+	}
+
+	bool FPhysXCollider::getIsTrigger() const
+	{
+		return (UINT32)(mShape->getFlags() & PxShapeFlag::eTRIGGER_SHAPE) != 0;
+	}
+
+	void FPhysXCollider::setContactOffset(float value)
+	{
+		mShape->setContactOffset(value);
+	}
+
+	float FPhysXCollider::getContactOffset()
+	{
+		return mShape->getContactOffset();
+	}
+
+	void FPhysXCollider::setRestOffset(float value)
+	{
+		mShape->setRestOffset(value);
+	}
+
+	float FPhysXCollider::getRestOffset()
+	{
+		return mShape->getRestOffset();
+	}
+
+	void FPhysXCollider::setRigidbody(const SPtr<Rigidbody>& rigidbody)
+	{
+		if (mRigidbody == rigidbody)
+			return;
+
+		if(mStaticBody != nullptr)
+		{
+			mStaticBody->detachShape(*mShape);
+
+			mStaticBody->release();
+			mStaticBody = nullptr;
+		}
+
+		FCollider::setRigidbody(rigidbody);
+
+		if(rigidbody == nullptr)
+		{
+			mStaticBody = gPhysX().getPhysX()->createRigidStatic(PxTransform());
+			mStaticBody->attachShape(*mShape);
+
+			PxScene* scene = gPhysX().getScene();
+			scene->addActor(*mStaticBody);
+		}
+	}
+
+	void FPhysXCollider::setMaterial(const HPhysicsMaterial& material)
+	{
+		FCollider::setMaterial(material);
+
+		PhysXMaterial* physXmaterial = nullptr;
+		if(material.isLoaded())
+			physXmaterial = static_cast<PhysXMaterial*>(material.get());
+
+		PxMaterial* materials[1];
+		if (physXmaterial != nullptr)
+			materials[0] = physXmaterial->_getInternal();
+		else
+			materials[0] = nullptr;
+
+		mShape->setMaterials(materials, sizeof(materials));
+	}
+
+	void FPhysXCollider::setIsActive(bool value)
+	{
+		// Note: A different option might be just to fully destroy the shape & actor when disabled (might result in better
+		//       performance if a lot of disabled actors in scene).
+
+		if (!value)
+			mShape->setFlags((PxShapeFlags)0);
+		else
+		{
+			mShape->setFlag(PxShapeFlag::eSCENE_QUERY_SHAPE, true);
+			setIsTrigger(mIsTrigger);
+		}
+
+		FCollider::setIsActive(value);
+	}
+
+	void FPhysXCollider::setLayer(UINT64 layer)
+	{
+		PxFilterData data;
+		memcpy(&data.word0, &layer, sizeof(layer));
+		mShape->setSimulationFilterData(data);
+	}
+}

+ 34 - 1
BansheePhysX/Source/BsPhysX.cpp

@@ -2,6 +2,10 @@
 #include "PxPhysicsAPI.h"
 #include "BsPhysXMaterial.h"
 #include "BsPhysXRigidbody.h"
+#include "BsPhysXBoxCollider.h"
+#include "BsPhysXSphereCollider.h"
+#include "BsPhysXPlaneCollider.h"
+#include "BsPhysXCapsuleCollider.h"
 #include "BsTaskScheduler.h"
 #include "BsTime.h"
 #include "Bsvector3.h"
@@ -186,6 +190,8 @@ namespace BansheeEngine
 
 		mScene = mPhysics->createScene(sceneDesc);
 		mSimulationStep = input.timeStep;
+
+		mDefaultMaterial = mPhysics->createMaterial(0.0f, 0.0f, 0.0f);
 	}
 
 	PhysX::~PhysX()
@@ -236,6 +242,33 @@ namespace BansheeEngine
 
 	SPtr<Rigidbody> PhysX::createRigidbody(const Vector3& position, const Quaternion& rotation)
 	{
-		return bs_shared_ptr_new<PhysXRigidbody>(mPhysics, position, rotation);
+		return bs_shared_ptr_new<PhysXRigidbody>(mPhysics, mScene, position, rotation);
+	}
+
+	SPtr<BoxCollider> PhysX::createBoxCollider(float extentX, float extentY, float extentZ, const Vector3& position, 
+		const Quaternion& rotation)
+	{
+		return bs_shared_ptr_new<PhysXBoxCollider>(mPhysics, position, rotation, extentX, extentY, extentZ);
+	}
+
+	SPtr<SphereCollider> PhysX::createSphereCollider(float radius, const Vector3& position, const Quaternion& rotation)
+	{
+		return bs_shared_ptr_new<PhysXSphereCollider>(mPhysics, position, rotation, radius);
+	}
+
+	SPtr<PlaneCollider> PhysX::createPlaneCollider(const Vector3& position, const Quaternion& rotation)
+	{
+		return bs_shared_ptr_new<PhysXPlaneCollider>(mPhysics, position, rotation);
+	}
+
+	SPtr<CapsuleCollider> PhysX::createCapsuleCollider(float radius, float halfHeight, const Vector3& position, 
+		const Quaternion& rotation)
+	{
+		return bs_shared_ptr_new<PhysXCapsuleCollider>(mPhysics, position, rotation, radius, halfHeight);
+	}
+
+	PhysX& gPhysX()
+	{
+		return static_cast<PhysX&>(PhysX::instance());
 	}
 }

+ 30 - 0
BansheePhysX/Source/BsPhysXBoxCollider.cpp

@@ -0,0 +1,30 @@
+#include "BsPhysXBoxCollider.h"
+#include "BsPhysX.h"
+#include "PxPhysics.h"
+#include "BsFPhysXCollider.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXBoxCollider::PhysXBoxCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation, 
+		float extentX, float extentY, float extentZ)
+	{
+		PxBoxGeometry geometry(extentX, extentY, extentZ);
+
+		PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true);
+		shape->setLocalPose(toPxTransform(position, rotation));
+
+		mInternal = bs_new<FPhysXCollider>(shape);
+	}
+
+	PhysXBoxCollider::~PhysXBoxCollider()
+	{
+		bs_delete(mInternal);
+	}
+
+	FPhysXCollider* PhysXBoxCollider::getInternal() const
+	{
+		return static_cast<FPhysXCollider*>(mInternal);
+	}
+}

+ 30 - 0
BansheePhysX/Source/BsPhysXCapsuleCollider.cpp

@@ -0,0 +1,30 @@
+#include "BsPhysXCapsuleCollider.h"
+#include "BsPhysX.h"
+#include "PxPhysics.h"
+#include "BsFPhysXCollider.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXCapsuleCollider::PhysXCapsuleCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation,
+		float radius, float halfHeight)
+	{
+		PxCapsuleGeometry geometry(radius, halfHeight);
+
+		PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true);
+		shape->setLocalPose(toPxTransform(position, rotation));
+
+		mInternal = bs_new<FPhysXCollider>(shape);
+	}
+
+	PhysXCapsuleCollider::~PhysXCapsuleCollider()
+	{
+		bs_delete(mInternal);
+	}
+
+	FPhysXCollider* PhysXCapsuleCollider::getInternal() const
+	{
+		return static_cast<FPhysXCollider*>(mInternal);
+	}
+}

+ 29 - 0
BansheePhysX/Source/BsPhysXPlaneCollider.cpp

@@ -0,0 +1,29 @@
+#include "BsPhysXPlaneCollider.h"
+#include "BsPhysX.h"
+#include "PxPhysics.h"
+#include "BsFPhysXCollider.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXPlaneCollider::PhysXPlaneCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation)
+	{
+		PxPlaneGeometry geometry;
+
+		PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true);
+		shape->setLocalPose(toPxTransform(position, rotation));
+
+		mInternal = bs_new<FPhysXCollider>(shape);
+	}
+
+	PhysXPlaneCollider::~PhysXPlaneCollider()
+	{
+		bs_delete(mInternal);
+	}
+
+	FPhysXCollider* PhysXPlaneCollider::getInternal() const
+	{
+		return static_cast<FPhysXCollider*>(mInternal);
+	}
+}

+ 5 - 2
BansheePhysX/Source/BsPhysXRigidbody.cpp

@@ -1,19 +1,22 @@
 #include "BsPhysXRigidbody.h"
 #include "PxRigidDynamic.h"
+#include "PxScene.h"
 
 using namespace physx;
 
 namespace BansheeEngine
 {
-	PhysXRigidbody::PhysXRigidbody(PxPhysics* physx, const Vector3& position, const Quaternion& rotation)
+	PhysXRigidbody::PhysXRigidbody(PxPhysics* physx, PxScene* scene, const Vector3& position, const Quaternion& rotation)
 	{
-		PxTransform tfrm(toPxVector(position), toPxQuaternion(rotation));
+		PxTransform tfrm = toPxTransform(position, rotation);
 
 		mInternal = physx->createRigidDynamic(tfrm);
+		scene->addActor(*mInternal);
 	}
 
 	PhysXRigidbody::~PhysXRigidbody()
 	{
+		// TODO - Remove from scene? Or is that part of release()?
 		mInternal->release();
 	}
 }

+ 30 - 0
BansheePhysX/Source/BsPhysXSphereCollider.cpp

@@ -0,0 +1,30 @@
+#include "BsPhysXSphereCollider.h"
+#include "BsPhysX.h"
+#include "PxPhysics.h"
+#include "BsFPhysXCollider.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXSphereCollider::PhysXSphereCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation,
+		float radius)
+	{
+		PxSphereGeometry geometry(radius);
+
+		PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true);
+		shape->setLocalPose(toPxTransform(position, rotation));
+
+		mInternal = bs_new<FPhysXCollider>(shape);
+	}
+
+	PhysXSphereCollider::~PhysXSphereCollider()
+	{
+		bs_delete(mInternal);
+	}
+
+	FPhysXCollider* PhysXSphereCollider::getInternal() const
+	{
+		return static_cast<FPhysXCollider*>(mInternal);
+	}
+}

+ 3 - 1
Doxyfile

@@ -778,7 +778,9 @@ WARN_LOGFILE           =
 INPUT                  = C:\Projects\BansheeEngineDev\BansheeEngine\BansheeUtility\Include \
                          C:\Projects\BansheeEngineDev\BansheeEngine\BansheeUtility\Source \
                          BansheeCore/Include \
-                         BansheeCore/Source
+                         BansheeCore/Source \
+                         BansheeEngine/Include \
+                         BansheeEngine/Source
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses