Explorar o código

WIP physics joints

BearishSun %!s(int64=10) %!d(string=hai) anos
pai
achega
b4ff87e672
Modificáronse 40 ficheiros con 925 adicións e 16 borrados
  1. 10 0
      BansheeCore/BansheeCore.vcxproj
  2. 30 0
      BansheeCore/BansheeCore.vcxproj.filters
  3. 6 0
      BansheeCore/Include/BsCorePrerequisites.h
  4. 42 0
      BansheeCore/Include/BsDistanceJoint.h
  5. 16 0
      BansheeCore/Include/BsFCollider.h
  6. 34 0
      BansheeCore/Include/BsFJoint.h
  7. 17 0
      BansheeCore/Include/BsFixedJoint.h
  8. 44 0
      BansheeCore/Include/BsHingeJoint.h
  9. 98 0
      BansheeCore/Include/BsJoint.h
  10. 7 0
      BansheeCore/Include/BsPhysics.h
  11. 2 0
      BansheeCore/Source/BsBoxCollider.cpp
  12. 2 0
      BansheeCore/Source/BsCapsuleCollider.cpp
  13. 2 0
      BansheeCore/Source/BsCollider.cpp
  14. 12 0
      BansheeCore/Source/BsDistanceJoint.cpp
  15. 2 0
      BansheeCore/Source/BsFCollider.cpp
  16. 8 0
      BansheeCore/Source/BsFJoint.cpp
  17. 12 0
      BansheeCore/Source/BsFixedJoint.cpp
  18. 12 0
      BansheeCore/Source/BsHingeJoint.cpp
  19. 51 0
      BansheeCore/Source/BsJoint.cpp
  20. 2 0
      BansheeCore/Source/BsMeshCollider.cpp
  21. 2 0
      BansheeCore/Source/BsPhysics.cpp
  22. 2 0
      BansheeCore/Source/BsPhysicsManager.cpp
  23. 2 0
      BansheeCore/Source/BsPhysicsMaterial.cpp
  24. 2 0
      BansheeCore/Source/BsPhysicsMesh.cpp
  25. 2 0
      BansheeCore/Source/BsPlaneCollider.cpp
  26. 2 0
      BansheeCore/Source/BsRigidbody.cpp
  27. 2 0
      BansheeCore/Source/BsSphereCollider.cpp
  28. 8 0
      BansheePhysX/BansheePhysX.vcxproj
  29. 24 0
      BansheePhysX/BansheePhysX.vcxproj.filters
  30. 0 16
      BansheePhysX/Include/BsFPhysXCollider.h
  31. 34 0
      BansheePhysX/Include/BsFPhysXJoint.h
  32. 38 0
      BansheePhysX/Include/BsPhysXDistanceJoint.h
  33. 17 0
      BansheePhysX/Include/BsPhysXFixedJoint.h
  34. 33 0
      BansheePhysX/Include/BsPhysXHingeJoint.h
  35. 2 0
      BansheePhysX/Include/BsPhysXRigidbody.h
  36. 119 0
      BansheePhysX/Source/BsFPhysXJoint.cpp
  37. 2 0
      BansheePhysX/Source/BsPhysXBoxCollider.cpp
  38. 101 0
      BansheePhysX/Source/BsPhysXDistanceJoint.cpp
  39. 22 0
      BansheePhysX/Source/BsPhysXFixedJoint.cpp
  40. 102 0
      BansheePhysX/Source/BsPhysXHingeJoint.cpp

+ 10 - 0
BansheeCore/BansheeCore.vcxproj

@@ -315,9 +315,14 @@
     <ClInclude Include="Include\BsCRigidbodyRTTI.h" />
     <ClInclude Include="Include\BsCRigidbodyRTTI.h" />
     <ClInclude Include="Include\BsCSphereCollider.h" />
     <ClInclude Include="Include\BsCSphereCollider.h" />
     <ClInclude Include="Include\BsCSphereColliderRTTI.h" />
     <ClInclude Include="Include\BsCSphereColliderRTTI.h" />
+    <ClInclude Include="Include\BsDistanceJoint.h" />
     <ClInclude Include="Include\BsFCollider.h" />
     <ClInclude Include="Include\BsFCollider.h" />
+    <ClInclude Include="Include\BsFixedJoint.h" />
+    <ClInclude Include="Include\BsFJoint.h" />
+    <ClInclude Include="Include\BsHingeJoint.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsHString.h" />
     <ClInclude Include="Include\BsIconUtility.h" />
     <ClInclude Include="Include\BsIconUtility.h" />
+    <ClInclude Include="Include\BsJoint.h" />
     <ClInclude Include="Include\BsMaterialParams.h" />
     <ClInclude Include="Include\BsMaterialParams.h" />
     <ClInclude Include="Include\BsMaterialParamsRTTI.h" />
     <ClInclude Include="Include\BsMaterialParamsRTTI.h" />
     <ClInclude Include="Include\BsMeshCollider.h" />
     <ClInclude Include="Include\BsMeshCollider.h" />
@@ -501,10 +506,15 @@
     <ClCompile Include="Source\BsCPlaneCollider.cpp" />
     <ClCompile Include="Source\BsCPlaneCollider.cpp" />
     <ClCompile Include="Source\BsCRigidbody.cpp" />
     <ClCompile Include="Source\BsCRigidbody.cpp" />
     <ClCompile Include="Source\BsCSphereCollider.cpp" />
     <ClCompile Include="Source\BsCSphereCollider.cpp" />
+    <ClCompile Include="Source\BsDistanceJoint.cpp" />
     <ClCompile Include="Source\BsFCollider.cpp" />
     <ClCompile Include="Source\BsFCollider.cpp" />
+    <ClCompile Include="Source\BsFixedJoint.cpp" />
+    <ClCompile Include="Source\BsFJoint.cpp" />
+    <ClCompile Include="Source\BsHingeJoint.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
     <ClCompile Include="Source\BsHString.cpp" />
     <ClCompile Include="Source\BsIconUtility.cpp" />
     <ClCompile Include="Source\BsIconUtility.cpp" />
     <ClCompile Include="Source\BsIResourceListener.cpp" />
     <ClCompile Include="Source\BsIResourceListener.cpp" />
+    <ClCompile Include="Source\BsJoint.cpp" />
     <ClCompile Include="Source\BsMaterialParam.cpp" />
     <ClCompile Include="Source\BsMaterialParam.cpp" />
     <ClCompile Include="Source\BsMeshCollider.cpp" />
     <ClCompile Include="Source\BsMeshCollider.cpp" />
     <ClCompile Include="Source\BsMeshImportOptions.cpp" />
     <ClCompile Include="Source\BsMeshImportOptions.cpp" />

+ 30 - 0
BansheeCore/BansheeCore.vcxproj.filters

@@ -680,6 +680,21 @@
     <ClInclude Include="Include\BsCMeshColliderRTTI.h">
     <ClInclude Include="Include\BsCMeshColliderRTTI.h">
       <Filter>Header Files\RTTI</Filter>
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsFJoint.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsJoint.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsFixedJoint.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsDistanceJoint.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsHingeJoint.h">
+      <Filter>Header Files\Physics</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsCoreApplication.cpp">
     <ClCompile Include="Source\BsCoreApplication.cpp">
@@ -1069,5 +1084,20 @@
     <ClCompile Include="Source\BsCMeshCollider.cpp">
     <ClCompile Include="Source\BsCMeshCollider.cpp">
       <Filter>Source Files\Components</Filter>
       <Filter>Source Files\Components</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsFJoint.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsJoint.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsFixedJoint.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsDistanceJoint.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsHingeJoint.cpp">
+      <Filter>Source Files\Physics</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 6 - 0
BansheeCore/Include/BsCorePrerequisites.h

@@ -252,6 +252,12 @@ namespace BansheeEngine
 	class CPlaneCollider;
 	class CPlaneCollider;
 	class CCapsuleCollider;
 	class CCapsuleCollider;
 	class CMeshCollider;
 	class CMeshCollider;
+	class FixedJoint;
+	class DistanceJoint;
+	class HingeJoint;
+	class SphericalJoint;
+	class SliderJoint;
+	class D6Joint;
 	// Asset import
 	// Asset import
 	class SpecificImporter;
 	class SpecificImporter;
 	class Importer;
 	class Importer;

+ 42 - 0
BansheeCore/Include/BsDistanceJoint.h

@@ -0,0 +1,42 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT DistanceJoint : public Joint
+	{
+	public:
+		enum class Flag
+		{
+			MinDistance = 0x1,
+			MaxDistance = 0x2,
+			Spring = 0x4
+		};
+
+	public:
+		virtual ~DistanceJoint() { }
+
+		virtual float getDistance() const = 0;
+
+		virtual float getMinDistance() const = 0;
+		virtual void setMinDistance(float value) = 0;
+
+		virtual float getMaxDistance() const = 0;
+		virtual void setMaxDistance(float value) = 0;
+
+		virtual float getTolerance() const = 0;
+		virtual void setTolerance(float value) = 0;
+
+		virtual Spring getSpring() const = 0;
+		virtual void setSpring(const Spring& value) = 0;
+
+		virtual void setFlag(Flag flag, bool enabled) = 0;
+		virtual bool hasFlag(Flag flag) = 0;
+
+		static SPtr<DistanceJoint> create();
+	};
+}

+ 16 - 0
BansheeCore/Include/BsFCollider.h

@@ -30,10 +30,26 @@ namespace BansheeEngine
 		virtual void setMaterial(const HPhysicsMaterial& material);
 		virtual void setMaterial(const HPhysicsMaterial& material);
 		virtual HPhysicsMaterial getMaterial() const { return mMaterial; }
 		virtual HPhysicsMaterial getMaterial() const { return mMaterial; }
 
 
+		/**
+		 * Determines how far apart do two shapes need to be away from each other before the physics runtime starts 
+		 * generating repelling impulse for them. This distance will be the sum of contact offsets of the two interacting
+		 * objects. If objects are moving fast you can increase this value to start generating the impulse earlier and 
+		 * potentially prevent the objects from interpenetrating. This value is in meters.
+		 *
+		 * Also see setRestOffset().
+		 */
 		virtual void setContactOffset(float value) = 0;
 		virtual void setContactOffset(float value) = 0;
+
+		/** Returns shape's contact offset in meters. See setContactOffset() to learn contact offset is. */
 		virtual float getContactOffset() const = 0;
 		virtual float getContactOffset() const = 0;
 
 
+		/**
+		 * Sets at what distance should two objects resting on one another come to an equilibrium. The value used in the
+		 * runtime will be the sum of rest offsets for both interacting objects. This value is in meters.
+		 */
 		virtual void setRestOffset(float value) = 0;
 		virtual void setRestOffset(float value) = 0;
+
+		/** Returns shepe's rest offset in meters. See setRestOffset() to learn what contact offset is. */
 		virtual float getRestOffset() const = 0;
 		virtual float getRestOffset() const = 0;
 
 
 		virtual void setLayer(UINT64 layer);
 		virtual void setLayer(UINT64 layer);

+ 34 - 0
BansheeCore/Include/BsFJoint.h

@@ -0,0 +1,34 @@
+//********************************** 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
+{
+	enum class JointBody
+	{
+		A, B
+	};
+
+	class BS_CORE_EXPORT FJoint
+	{
+	public:
+		virtual ~FJoint() { }
+
+		virtual Rigidbody* getBody(JointBody body) const = 0;
+		virtual void setBody(JointBody body, Rigidbody* value) = 0;
+
+		virtual Vector3 getPosition(JointBody body) const = 0;
+		virtual Quaternion getRotation(JointBody body) const = 0;
+		virtual void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation) = 0;
+
+		virtual float getBreakForce() const = 0;
+		virtual void setBreakForce(float force) = 0;
+
+		virtual float getBreakTorque() const = 0;
+		virtual void setBreakToque(float torque) = 0;
+	};
+}

+ 17 - 0
BansheeCore/Include/BsFixedJoint.h

@@ -0,0 +1,17 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT FixedJoint : public Joint
+	{
+	public:
+		virtual ~FixedJoint() { }
+
+		static SPtr<FixedJoint> create();
+	};
+}

+ 44 - 0
BansheeCore/Include/BsHingeJoint.h

@@ -0,0 +1,44 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT HingeJoint : public Joint
+	{
+	public:
+		enum class Flag
+		{
+			Limit = 0x1,
+			Drive = 0x2
+		};
+
+		struct Drive
+		{
+			float speed = 0.0f;
+			float forceLimit = FLT_MAX;
+			float gearRatio = 1.0f;
+			bool freeSpin = false;
+		};
+
+	public:
+		virtual ~HingeJoint() { }
+
+		virtual Radian getAngle() const = 0;
+		virtual float getSpeed() const = 0;
+
+		virtual LimitAngular getLimit() const = 0;
+		virtual void setLimit(const LimitAngular& limit) const = 0;
+
+		virtual Drive getDrive() const = 0;
+		virtual void setDrive(const Drive& drive) const = 0;
+
+		virtual void setFlag(Flag flag, bool enabled) = 0;
+		virtual bool hasFlag(Flag flag) = 0;
+
+		static SPtr<HingeJoint> create();
+	};
+}

+ 98 - 0
BansheeCore/Include/BsJoint.h

@@ -0,0 +1,98 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsFJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_CORE_EXPORT Joint
+	{
+	public:
+		virtual ~Joint() { }
+
+		inline Rigidbody* getBody(JointBody body) const;
+		inline void setBody(JointBody body, Rigidbody* value);
+
+		inline Vector3 getPosition(JointBody body) const;
+		inline Quaternion getRotation(JointBody body) const;
+		inline void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation);
+
+		inline float getBreakForce() const;
+		inline void setBreakForce(float force);
+
+		inline float getBreakTorque() const;
+		inline void setBreakToque(float torque);
+
+	protected:
+		FJoint* mInternal = nullptr;
+	};
+
+	struct Spring
+	{
+		Spring() { }
+		Spring(float stiffness, float damping)
+			:stiffness(stiffness), damping(damping)
+		{ }
+
+		float stiffness = 0.0f;
+		float damping = 0.0f;
+	};
+
+	struct LimitLinear
+	{
+		LimitLinear()
+		{ }
+
+		LimitLinear(float extent, float contactDist = -1.0f)
+			:extent(extent), contactDist(contactDist)
+		{ }
+
+		LimitLinear(float extent, const Spring& spring)
+			:extent(extent), spring(spring)
+		{ }
+
+		float extent = FLT_MAX;
+		float contactDist = -1.0f;
+		Spring spring;
+	};
+
+	struct LimitAngular
+	{
+		LimitAngular()
+		{ }
+
+		LimitAngular(Radian lower, Radian upper, float contactDist = -1.0f)
+			:lower(lower), upper(upper), contactDist(contactDist)
+		{ }
+
+		LimitAngular(Radian lower, Radian upper, const Spring& spring)
+			:lower(lower), upper(upper), spring(spring)
+		{ }
+
+		Radian lower = Radian(0.0f);
+		Radian upper = Radian(0.0f);
+		float contactDist = -1.0f;
+		Spring spring;
+	};
+
+	struct LimitCone
+	{
+		LimitCone()
+		{ }
+
+		LimitCone(Radian yLimitAngle, Radian zLimitAngle, float contactDist = -1.0f)
+			:yLimitAngle(yLimitAngle), zLimitAngle(zLimitAngle), contactDist(contactDist)
+		{ }
+
+		LimitCone(Radian yLimitAngle, Radian zLimitAngle, const Spring& spring)
+			:yLimitAngle(yLimitAngle), zLimitAngle(zLimitAngle), spring(spring)
+		{ }
+
+		Radian yLimitAngle = Radian(Math::PI * 0.5f);
+		Radian zLimitAngle = Radian(Math::PI * 0.5f);
+		float contactDist = -1.0f;
+		Spring spring;
+	};
+}

+ 7 - 0
BansheeCore/Include/BsPhysics.h

@@ -30,6 +30,13 @@ namespace BansheeEngine
 			const Vector3& position, const Quaternion& rotation) = 0;
 			const Vector3& position, const Quaternion& rotation) = 0;
 		virtual SPtr<MeshCollider> createMeshCollider(const Vector3& position, const Quaternion& rotation) = 0;
 		virtual SPtr<MeshCollider> createMeshCollider(const Vector3& position, const Quaternion& rotation) = 0;
 
 
+		virtual SPtr<FixedJoint> createFixedJoint() = 0;
+		virtual SPtr<DistanceJoint> createDistanceJoint() = 0;
+		virtual SPtr<HingeJoint> createHingeJoint() = 0;
+		virtual SPtr<SphericalJoint> createSphericalJoint() = 0;
+		virtual SPtr<SliderJoint> createSliderJoint() = 0;
+		virtual SPtr<D6Joint> createD6Joint() = 0;
+
 		void toggleCollision(UINT64 groupA, UINT64 groupB, bool enabled);
 		void toggleCollision(UINT64 groupA, UINT64 groupB, bool enabled);
 		bool isCollisionEnabled(UINT64 groupA, UINT64 groupB) const;
 		bool isCollisionEnabled(UINT64 groupA, UINT64 groupB) const;
 
 

+ 2 - 0
BansheeCore/Source/BsBoxCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsBoxCollider.h"
 #include "BsBoxCollider.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 
 

+ 2 - 0
BansheeCore/Source/BsCapsuleCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsCapsuleCollider.h"
 #include "BsCapsuleCollider.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 
 

+ 2 - 0
BansheeCore/Source/BsCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsCollider.h"
 #include "BsCollider.h"
 #include "BsFCollider.h"
 #include "BsFCollider.h"
 
 

+ 12 - 0
BansheeCore/Source/BsDistanceJoint.cpp

@@ -0,0 +1,12 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsDistanceJoint.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	SPtr<DistanceJoint> DistanceJoint::create()
+	{
+		return gPhysics().createDistanceJoint();
+	}
+}

+ 2 - 0
BansheeCore/Source/BsFCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsFCollider.h"
 #include "BsFCollider.h"
 #include "BsRigidbody.h"
 #include "BsRigidbody.h"
 
 

+ 8 - 0
BansheeCore/Source/BsFJoint.cpp

@@ -0,0 +1,8 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFJoint.h"
+
+namespace BansheeEngine
+{
+	
+}

+ 12 - 0
BansheeCore/Source/BsFixedJoint.cpp

@@ -0,0 +1,12 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFixedJoint.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	SPtr<FixedJoint> FixedJoint::create()
+	{
+		return gPhysics().createFixedJoint();
+	}
+}

+ 12 - 0
BansheeCore/Source/BsHingeJoint.cpp

@@ -0,0 +1,12 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsHingeJoint.h"
+#include "BsPhysics.h"
+
+namespace BansheeEngine
+{
+	SPtr<HingeJoint> HingeJoint::create()
+	{
+		return gPhysics().createHingeJoint();
+	}
+}

+ 51 - 0
BansheeCore/Source/BsJoint.cpp

@@ -0,0 +1,51 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsJoint.h"
+
+namespace BansheeEngine
+{
+	Rigidbody* Joint::getBody(JointBody body) const
+	{
+		return mInternal->getBody(body);
+	}
+
+	void Joint::setBody(JointBody body, Rigidbody* value)
+	{
+		mInternal->setBody(body, value);
+	}
+
+	Vector3 Joint::getPosition(JointBody body) const
+	{
+		return mInternal->getPosition(body);
+	}
+
+	Quaternion Joint::getRotation(JointBody body) const
+	{
+		return mInternal->getRotation(body);
+	}
+
+	void Joint::setTransform(JointBody body, const Vector3& position, const Quaternion& rotation)
+	{
+		mInternal->setTransform(body, position, rotation);
+	}
+
+	float Joint::getBreakForce() const
+	{
+		return mInternal->getBreakForce();
+	}
+
+	void Joint::setBreakForce(float force)
+	{
+		mInternal->setBreakForce(force);
+	}
+
+	float Joint::getBreakTorque() const
+	{
+		return mInternal->getBreakTorque();
+	}
+
+	void Joint::setBreakToque(float torque)
+	{
+		mInternal->setBreakToque(torque);
+	}
+}

+ 2 - 0
BansheeCore/Source/BsMeshCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsMeshCollider.h"
 #include "BsMeshCollider.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 
 

+ 2 - 0
BansheeCore/Source/BsPhysics.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 #include "BsRigidbody.h"
 #include "BsRigidbody.h"
 
 

+ 2 - 0
BansheeCore/Source/BsPhysicsManager.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPhysicsManager.h"
 #include "BsPhysicsManager.h"
 #include "BsDynLibManager.h"
 #include "BsDynLibManager.h"
 #include "BsDynLib.h"
 #include "BsDynLib.h"

+ 2 - 0
BansheeCore/Source/BsPhysicsMaterial.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPhysicsMaterial.h"
 #include "BsPhysicsMaterial.h"
 #include "BsPhysicsMaterialRTTI.h"
 #include "BsPhysicsMaterialRTTI.h"
 #include "BsResources.h"
 #include "BsResources.h"

+ 2 - 0
BansheeCore/Source/BsPhysicsMesh.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPhysicsMesh.h"
 #include "BsPhysicsMesh.h"
 #include "BsPhysicsMeshRTTI.h"
 #include "BsPhysicsMeshRTTI.h"
 #include "BsResources.h"
 #include "BsResources.h"

+ 2 - 0
BansheeCore/Source/BsPlaneCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPlaneCollider.h"
 #include "BsPlaneCollider.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 
 

+ 2 - 0
BansheeCore/Source/BsRigidbody.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsRigidbody.h"
 #include "BsRigidbody.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 #include "BsFCollider.h"
 #include "BsFCollider.h"

+ 2 - 0
BansheeCore/Source/BsSphereCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsSphereCollider.h"
 #include "BsSphereCollider.h"
 #include "BsPhysics.h"
 #include "BsPhysics.h"
 
 

+ 8 - 0
BansheePhysX/BansheePhysX.vcxproj

@@ -246,9 +246,13 @@
   </ItemDefinitionGroup>
   </ItemDefinitionGroup>
   <ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\BsFPhysXCollider.cpp" />
     <ClCompile Include="Source\BsFPhysXCollider.cpp" />
+    <ClCompile Include="Source\BsFPhysXJoint.cpp" />
     <ClCompile Include="Source\BsPhysX.cpp" />
     <ClCompile Include="Source\BsPhysX.cpp" />
     <ClCompile Include="Source\BsPhysXBoxCollider.cpp" />
     <ClCompile Include="Source\BsPhysXBoxCollider.cpp" />
     <ClCompile Include="Source\BsPhysXCapsuleCollider.cpp" />
     <ClCompile Include="Source\BsPhysXCapsuleCollider.cpp" />
+    <ClCompile Include="Source\BsPhysXDistanceJoint.cpp" />
+    <ClCompile Include="Source\BsPhysXFixedJoint.cpp" />
+    <ClCompile Include="Source\BsPhysXHingeJoint.cpp" />
     <ClCompile Include="Source\BsPhysXMaterial.cpp" />
     <ClCompile Include="Source\BsPhysXMaterial.cpp" />
     <ClCompile Include="Source\BsPhysXMesh.cpp" />
     <ClCompile Include="Source\BsPhysXMesh.cpp" />
     <ClCompile Include="Source\BsPhysXMeshCollider.cpp" />
     <ClCompile Include="Source\BsPhysXMeshCollider.cpp" />
@@ -258,10 +262,14 @@
     <ClCompile Include="Source\BsPhysXSphereCollider.cpp" />
     <ClCompile Include="Source\BsPhysXSphereCollider.cpp" />
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
+    <ClInclude Include="Include\BsFPhysXJoint.h" />
     <ClInclude Include="Include\BsPhysX.h" />
     <ClInclude Include="Include\BsPhysX.h" />
     <ClInclude Include="Include\BsPhysXBoxCollider.h" />
     <ClInclude Include="Include\BsPhysXBoxCollider.h" />
     <ClInclude Include="Include\BsFPhysXCollider.h" />
     <ClInclude Include="Include\BsFPhysXCollider.h" />
     <ClInclude Include="Include\BsPhysXCapsuleCollider.h" />
     <ClInclude Include="Include\BsPhysXCapsuleCollider.h" />
+    <ClInclude Include="Include\BsPhysXDistanceJoint.h" />
+    <ClInclude Include="Include\BsPhysXFixedJoint.h" />
+    <ClInclude Include="Include\BsPhysXHingeJoint.h" />
     <ClInclude Include="Include\BsPhysXMaterial.h" />
     <ClInclude Include="Include\BsPhysXMaterial.h" />
     <ClInclude Include="Include\BsPhysXMesh.h" />
     <ClInclude Include="Include\BsPhysXMesh.h" />
     <ClInclude Include="Include\BsPhysXMeshCollider.h" />
     <ClInclude Include="Include\BsPhysXMeshCollider.h" />

+ 24 - 0
BansheePhysX/BansheePhysX.vcxproj.filters

@@ -47,6 +47,18 @@
     <ClCompile Include="Source\BsPhysXMeshCollider.cpp">
     <ClCompile Include="Source\BsPhysXMeshCollider.cpp">
       <Filter>Source Files</Filter>
       <Filter>Source Files</Filter>
     </ClCompile>
     </ClCompile>
+    <ClCompile Include="Source\BsFPhysXJoint.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXFixedJoint.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXDistanceJoint.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\BsPhysXHingeJoint.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\BsPhysXPrerequisites.h">
     <ClInclude Include="Include\BsPhysXPrerequisites.h">
@@ -85,5 +97,17 @@
     <ClInclude Include="Include\BsPhysXMeshCollider.h">
     <ClInclude Include="Include\BsPhysXMeshCollider.h">
       <Filter>Header Files</Filter>
       <Filter>Header Files</Filter>
     </ClInclude>
     </ClInclude>
+    <ClInclude Include="Include\BsFPhysXJoint.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXFixedJoint.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXDistanceJoint.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\BsPhysXHingeJoint.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   </ItemGroup>
 </Project>
 </Project>

+ 0 - 16
BansheePhysX/Include/BsFPhysXCollider.h

@@ -25,26 +25,10 @@ namespace BansheeEngine
 		void setIsStatic(bool value) override;
 		void setIsStatic(bool value) override;
 		bool getIsStatic() const override;
 		bool getIsStatic() const override;
 
 
-		/**
-		 * Determines how far apart do two shapes need to be away from each other before the physics runtime starts 
-		 * generating repelling impulse for them. This distance will be the sum of contact offsets of the two interacting
-		 * objects. If objects are moving fast you can increase this value to start generating the impulse earlier and 
-		 * potentially prevent the objects from interpenetrating. This value is in meters.
-		 *
-		 * Also see setRestOffset().
-		 */
 		void setContactOffset(float value) override;
 		void setContactOffset(float value) override;
-
-		/** Returns shape's contact offset in meters. See setContactOffset() to learn contact offset is. */
 		float getContactOffset() const override;
 		float getContactOffset() const override;
 
 
-		/**
-		 * Sets at what distance should two objects resting on one another come to an equilibrium. The value used in the
-		 * runtime will be the sum of rest offsets for both interacting objects. This value is in meters.
-		 */
 		void setRestOffset(float value) override;
 		void setRestOffset(float value) override;
-
-		/** Returns shepe's rest offset in meters. See setRestOffset() to learn what contact offset is. */
 		float getRestOffset() const override;
 		float getRestOffset() const override;
 
 
 		void setMaterial(const HPhysicsMaterial& material) override;
 		void setMaterial(const HPhysicsMaterial& material) override;

+ 34 - 0
BansheePhysX/Include/BsFPhysXJoint.h

@@ -0,0 +1,34 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsFJoint.h"
+#include "extensions\PxJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_PHYSX_EXPORT FPhysXJoint : public FJoint
+	{
+	public:
+		FPhysXJoint(physx::PxJoint* joint);
+		~FPhysXJoint();
+
+		Rigidbody* getBody(JointBody body) const override;
+		void setBody(JointBody body, Rigidbody* value) override;
+
+		Vector3 getPosition(JointBody body) const override;
+		Quaternion getRotation(JointBody body) const override;
+		void setTransform(JointBody body, const Vector3& position, const Quaternion& rotation) override;
+
+		float getBreakForce() const override;
+		void setBreakForce(float force) override;
+
+		float getBreakTorque() const override;
+		void setBreakToque(float torque) override;
+
+		physx::PxJoint* _getInternal() const { return mJoint; }
+	protected:
+		physx::PxJoint* mJoint;
+	};
+}

+ 38 - 0
BansheePhysX/Include/BsPhysXDistanceJoint.h

@@ -0,0 +1,38 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsDistanceJoint.h"
+#include "PxPhysics.h"
+#include "extensions\PxDistanceJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_PHYSX_EXPORT PhysXDistanceJoint : public DistanceJoint
+	{
+	public:
+		PhysXDistanceJoint(physx::PxPhysics* physx);
+		~PhysXDistanceJoint();
+
+		float getDistance() const override;
+
+		float getMinDistance() const override;
+		void setMinDistance(float value) override;
+
+		float getMaxDistance() const override;
+		void setMaxDistance(float value) override;
+
+		float getTolerance() const override;
+		void setTolerance(float value) override;
+
+		Spring getSpring() const override;
+		void setSpring(const Spring& value) override;
+
+		void setFlag(Flag flag, bool enabled) override;
+		bool hasFlag(Flag flag) override;
+
+	private:
+		inline physx::PxDistanceJoint* getInternal() const;
+	};
+}

+ 17 - 0
BansheePhysX/Include/BsPhysXFixedJoint.h

@@ -0,0 +1,17 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsFixedJoint.h"
+#include "PxPhysics.h"
+
+namespace BansheeEngine
+{
+	class BS_PHYSX_EXPORT PhysXFixedJoint : public FixedJoint
+	{
+	public:
+		PhysXFixedJoint(physx::PxPhysics* physx);
+		~PhysXFixedJoint();
+	};
+}

+ 33 - 0
BansheePhysX/Include/BsPhysXHingeJoint.h

@@ -0,0 +1,33 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPhysXPrerequisites.h"
+#include "BsHingeJoint.h"
+#include "PxPhysics.h"
+#include "extensions\PxRevoluteJoint.h"
+
+namespace BansheeEngine
+{
+	class BS_PHYSX_EXPORT PhysXHingeJoint : public HingeJoint
+	{
+	public:
+		PhysXHingeJoint(physx::PxPhysics* physx);
+		~PhysXHingeJoint();
+
+		Radian getAngle() const override;
+		float getSpeed() const override;
+
+		LimitAngular getLimit() const override;
+		void setLimit(const LimitAngular& limit) const override;
+
+		Drive getDrive() const override;
+		void setDrive(const Drive& drive) const override;
+
+		void setFlag(Flag flag, bool enabled) override;
+		bool hasFlag(Flag flag) override;
+
+	private:
+		inline physx::PxRevoluteJoint* getInternal() const;
+	};
+}

+ 2 - 0
BansheePhysX/Include/BsPhysXRigidbody.h

@@ -79,6 +79,8 @@ namespace BansheeEngine
 		void removeColliders() override;
 		void removeColliders() override;
 		void updateMassDistribution() override;
 		void updateMassDistribution() override;
 		
 		
+		physx::PxRigidDynamic* _getInternal() const { return mInternal; }
+
 	private:
 	private:
 		physx::PxRigidDynamic* mInternal;
 		physx::PxRigidDynamic* mInternal;
 	};
 	};

+ 119 - 0
BansheePhysX/Source/BsFPhysXJoint.cpp

@@ -0,0 +1,119 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsFPhysXJoint.h"
+#include "BsPhysXRigidbody.h"
+#include "PxRigidDynamic.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PxJointActorIndex::Enum toJointActor(JointBody body)
+	{
+		if (body == JointBody::A)
+			return PxJointActorIndex::eACTOR0;
+
+		return PxJointActorIndex::eACTOR1;
+	}
+
+	FPhysXJoint::FPhysXJoint(physx::PxJoint* joint)
+		:mJoint(joint)
+	{
+		
+	}
+
+	FPhysXJoint::~FPhysXJoint()
+	{
+		mJoint->release();
+	}
+
+	Rigidbody* FPhysXJoint::getBody(JointBody body) const
+	{
+		PxRigidActor* actorA = nullptr;
+		PxRigidActor* actorB = nullptr;
+
+		mJoint->getActors(actorA, actorB);
+
+		PxRigidActor* wantedActor = body == JointBody::A ? actorA : actorB;
+		if (wantedActor == nullptr)
+			return nullptr;
+
+		return (Rigidbody*)wantedActor->userData;
+	}
+
+	void FPhysXJoint::setBody(JointBody body, Rigidbody* value)
+	{
+		PxRigidActor* actorA = nullptr;
+		PxRigidActor* actorB = nullptr;
+
+		mJoint->getActors(actorA, actorB);
+
+		PxRigidActor* actor = nullptr;
+		if (value != nullptr)
+			actor = static_cast<PhysXRigidbody*>(value)->_getInternal();
+
+		if (body == JointBody::A)
+			actorA = actor;
+		else
+			actorB = actor;
+
+		mJoint->setActors(actorA, actorB);
+	}
+
+	Vector3 FPhysXJoint::getPosition(JointBody body) const
+	{
+		PxVec3 position = mJoint->getLocalPose(toJointActor(body)).p;
+
+		return fromPxVector(position);
+	}
+
+	Quaternion FPhysXJoint::getRotation(JointBody body) const
+	{
+		PxQuat rotation = mJoint->getLocalPose(toJointActor(body)).q;
+
+		return fromPxQuaternion(rotation);
+	}
+
+	void FPhysXJoint::setTransform(JointBody body, const Vector3& position, const Quaternion& rotation)
+	{
+		PxTransform transform = toPxTransform(position, rotation);
+
+		mJoint->setLocalPose(toJointActor(body), transform);
+	}
+
+	float FPhysXJoint::getBreakForce() const
+	{
+		float force = 0.0f;
+		float torque = 0.0f;
+
+		mJoint->getBreakForce(force, torque);
+		return force;
+	}
+
+	void FPhysXJoint::setBreakForce(float force)
+	{
+		float dummy = 0.0f;
+		float torque = 0.0f;
+
+		mJoint->getBreakForce(dummy, torque);
+		mJoint->setBreakForce(force, torque);
+	}
+
+	float FPhysXJoint::getBreakTorque() const
+	{
+		float force = 0.0f;
+		float torque = 0.0f;
+
+		mJoint->getBreakForce(force, torque);
+		return torque;
+	}
+
+	void FPhysXJoint::setBreakToque(float torque)
+	{
+		float force = 0.0f;
+		float dummy = 0.0f;
+
+		mJoint->getBreakForce(force, dummy);
+		mJoint->setBreakForce(force, torque);
+	}
+}

+ 2 - 0
BansheePhysX/Source/BsPhysXBoxCollider.cpp

@@ -1,3 +1,5 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPhysXBoxCollider.h"
 #include "BsPhysXBoxCollider.h"
 #include "BsPhysX.h"
 #include "BsPhysX.h"
 #include "PxPhysics.h"
 #include "PxPhysics.h"

+ 101 - 0
BansheePhysX/Source/BsPhysXDistanceJoint.cpp

@@ -0,0 +1,101 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPhysXDistanceJoint.h"
+#include "BsFPhysxJoint.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PxDistanceJointFlag::Enum toPxFlag(PhysXDistanceJoint::Flag flag)
+	{
+		switch (flag)
+		{
+		case PhysXDistanceJoint::Flag::MaxDistance:
+			return PxDistanceJointFlag::eMAX_DISTANCE_ENABLED;
+		case PhysXDistanceJoint::Flag::MinDistance:
+			return PxDistanceJointFlag::eMIN_DISTANCE_ENABLED;
+		default:
+		case PhysXDistanceJoint::Flag::Spring:
+			return PxDistanceJointFlag::eSPRING_ENABLED;
+		}
+	}
+
+	PhysXDistanceJoint::PhysXDistanceJoint(PxPhysics* physx)
+	{
+		PxDistanceJoint* joint = PxDistanceJointCreate(*physx, nullptr, PxTransform(), nullptr, PxTransform());
+
+		mInternal = bs_new<FPhysXJoint>(joint);
+	}
+
+	PhysXDistanceJoint::~PhysXDistanceJoint()
+	{
+		bs_delete(mInternal);
+	}
+
+	float PhysXDistanceJoint::getDistance() const
+	{
+		return getInternal()->getDistance();
+	}
+
+	float PhysXDistanceJoint::getMinDistance() const
+	{
+		return getInternal()->getMinDistance();
+	}
+
+	void PhysXDistanceJoint::setMinDistance(float value)
+	{
+		getInternal()->setMinDistance(value);
+	}
+
+	float PhysXDistanceJoint::getMaxDistance() const
+	{
+		return getInternal()->getMaxDistance();
+	}
+
+	void PhysXDistanceJoint::setMaxDistance(float value)
+	{
+		getInternal()->setMaxDistance(value);
+	}
+
+	float PhysXDistanceJoint::getTolerance() const
+	{
+		return getInternal()->getTolerance();
+	}
+
+	void PhysXDistanceJoint::setTolerance(float value)
+	{
+		getInternal()->setTolerance(value);
+	}
+
+	Spring PhysXDistanceJoint::getSpring() const
+	{
+		float damping = getInternal()->getDamping();
+		float stiffness = getInternal()->getStiffness();
+
+		return Spring(stiffness, damping);
+	}
+
+	void PhysXDistanceJoint::setSpring(const Spring& value)
+	{
+		getInternal()->setDamping(value.damping);
+		getInternal()->setStiffness(value.stiffness);
+	}
+
+	void PhysXDistanceJoint::setFlag(Flag flag, bool enabled)
+	{
+		getInternal()->setDistanceJointFlag(toPxFlag(flag), enabled);
+	}
+
+	bool PhysXDistanceJoint::hasFlag(Flag flag)
+	{
+		return getInternal()->getDistanceJointFlags() & toPxFlag(flag);
+	}
+
+	PxDistanceJoint* PhysXDistanceJoint::getInternal() const
+	{
+		FPhysXJoint* internal = static_cast<FPhysXJoint*>(mInternal);
+
+		return static_cast<PxDistanceJoint*>(internal->_getInternal());
+	}
+}

+ 22 - 0
BansheePhysX/Source/BsPhysXFixedJoint.cpp

@@ -0,0 +1,22 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPhysXFixedJoint.h"
+#include "BsFPhysxJoint.h"
+#include "extensions\PxFixedJoint.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PhysXFixedJoint::PhysXFixedJoint(PxPhysics* physx)
+	{
+		PxFixedJoint* joint = PxFixedJointCreate(*physx, nullptr, PxTransform(), nullptr, PxTransform());
+
+		mInternal = bs_new<FPhysXJoint>(joint);
+	}
+
+	PhysXFixedJoint::~PhysXFixedJoint()
+	{
+		bs_delete(mInternal);
+	}
+}

+ 102 - 0
BansheePhysX/Source/BsPhysXHingeJoint.cpp

@@ -0,0 +1,102 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPhysXHingeJoint.h"
+#include "BsFPhysxJoint.h"
+
+using namespace physx;
+
+namespace BansheeEngine
+{
+	PxRevoluteJointFlag::Enum toPxFlag(PhysXHingeJoint::Flag flag)
+	{
+		switch (flag)
+		{
+		case PhysXHingeJoint::Flag::Limit:
+			return PxRevoluteJointFlag::eLIMIT_ENABLED;
+		default:
+		case PhysXHingeJoint::Flag::Drive:
+			return PxRevoluteJointFlag::eDRIVE_ENABLED;
+		}
+	}
+
+	PhysXHingeJoint::PhysXHingeJoint(PxPhysics* physx)
+	{
+		PxRevoluteJoint* joint = PxRevoluteJointCreate(*physx, nullptr, PxTransform(), nullptr, PxTransform());
+
+		mInternal = bs_new<FPhysXJoint>(joint);
+	}
+
+	PhysXHingeJoint::~PhysXHingeJoint()
+	{
+		bs_delete(mInternal);
+	}
+
+	Radian PhysXHingeJoint::getAngle() const
+	{
+		return Radian(getInternal()->getAngle());
+	}
+
+	float PhysXHingeJoint::getSpeed() const
+	{
+		return getInternal()->getVelocity();
+	}
+
+	LimitAngular PhysXHingeJoint::getLimit() const
+	{
+		PxJointAngularLimitPair pxLimit = getInternal()->getLimit();
+
+		LimitAngular limit;
+		limit.lower = pxLimit.lower;
+		limit.upper = pxLimit.upper;
+		limit.contactDist = pxLimit.contactDistance;
+		limit.spring.stiffness = pxLimit.stiffness;
+		limit.spring.damping = pxLimit.damping;
+
+		return limit;
+	}
+
+	void PhysXHingeJoint::setLimit(const LimitAngular& limit) const
+	{
+		PxJointAngularLimitPair pxLimit(limit.lower.valueRadians(), limit.upper.valueRadians(), limit.contactDist);
+		pxLimit.stiffness = limit.spring.stiffness;
+		pxLimit.damping = limit.spring.damping;
+
+		getInternal()->setLimit(pxLimit);
+	}
+
+	PhysXHingeJoint::Drive PhysXHingeJoint::getDrive() const
+	{
+		Drive drive;
+		drive.speed = getInternal()->getDriveVelocity();
+		drive.forceLimit = getInternal()->getDriveForceLimit();
+		drive.gearRatio = getInternal()->getDriveGearRatio();
+		drive.freeSpin = getInternal()->getRevoluteJointFlags() & PxRevoluteJointFlag::eDRIVE_FREESPIN;
+
+		return drive;
+	}
+
+	void PhysXHingeJoint::setDrive(const Drive& drive) const
+	{
+		getInternal()->setDriveVelocity(drive.speed);
+		getInternal()->setDriveForceLimit(drive.forceLimit);
+		getInternal()->setDriveGearRatio(drive.gearRatio);
+		getInternal()->setRevoluteJointFlag(PxRevoluteJointFlag::eDRIVE_FREESPIN, drive.freeSpin);
+	}
+
+	void PhysXHingeJoint::setFlag(Flag flag, bool enabled)
+	{
+		getInternal()->setRevoluteJointFlag(toPxFlag(flag), enabled);
+	}
+
+	bool PhysXHingeJoint::hasFlag(Flag flag)
+	{
+		return getInternal()->getRevoluteJointFlags() & toPxFlag(flag);
+	}
+
+	PxRevoluteJoint* PhysXHingeJoint::getInternal() const
+	{
+		FPhysXJoint* internal = static_cast<FPhysXJoint*>(mInternal);
+
+		return static_cast<PxRevoluteJoint*>(internal->_getInternal());
+	}
+}