瀏覽代碼

Update Box2D lib, add RigidBody2D::ApplyLinearImpulseToCenter()

Avoid requirement C++11 by Box2D lib
1vanK 8 年之前
父節點
當前提交
c5014a8399
共有 100 個文件被更改,包括 529 次插入400 次删除
  1. 28 28
      Source/ThirdParty/Box2D/Box2D/Box2D.h
  2. 14 10
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2ChainShape.cpp
  3. 4 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2ChainShape.h
  4. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2CircleShape.cpp
  5. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2CircleShape.h
  6. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2EdgeShape.cpp
  7. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2EdgeShape.h
  8. 10 2
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2PolygonShape.cpp
  9. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2PolygonShape.h
  10. 3 3
      Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2Shape.h
  11. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/b2BroadPhase.cpp
  12. 3 3
      Source/ThirdParty/Box2D/Box2D/Collision/b2BroadPhase.h
  13. 5 5
      Source/ThirdParty/Box2D/Box2D/Collision/b2CollideCircle.cpp
  14. 4 4
      Source/ThirdParty/Box2D/Box2D/Collision/b2CollideEdge.cpp
  15. 2 2
      Source/ThirdParty/Box2D/Box2D/Collision/b2CollidePolygon.cpp
  16. 2 2
      Source/ThirdParty/Box2D/Box2D/Collision/b2Collision.cpp
  17. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/b2Collision.h
  18. 6 7
      Source/ThirdParty/Box2D/Box2D/Collision/b2Distance.cpp
  19. 1 1
      Source/ThirdParty/Box2D/Box2D/Collision/b2Distance.h
  20. 4 6
      Source/ThirdParty/Box2D/Box2D/Collision/b2DynamicTree.cpp
  21. 2 2
      Source/ThirdParty/Box2D/Box2D/Collision/b2DynamicTree.h
  22. 6 6
      Source/ThirdParty/Box2D/Box2D/Collision/b2TimeOfImpact.cpp
  23. 2 2
      Source/ThirdParty/Box2D/Box2D/Collision/b2TimeOfImpact.h
  24. 2 7
      Source/ThirdParty/Box2D/Box2D/Common/b2BlockAllocator.cpp
  25. 1 1
      Source/ThirdParty/Box2D/Box2D/Common/b2BlockAllocator.h
  26. 1 1
      Source/ThirdParty/Box2D/Box2D/Common/b2Draw.cpp
  27. 15 4
      Source/ThirdParty/Box2D/Box2D/Common/b2Draw.h
  28. 2 7
      Source/ThirdParty/Box2D/Box2D/Common/b2GrowableStack.h
  29. 1 1
      Source/ThirdParty/Box2D/Box2D/Common/b2Math.cpp
  30. 8 3
      Source/ThirdParty/Box2D/Box2D/Common/b2Math.h
  31. 2 2
      Source/ThirdParty/Box2D/Box2D/Common/b2Settings.cpp
  32. 4 0
      Source/ThirdParty/Box2D/Box2D/Common/b2Settings.h
  33. 2 2
      Source/ThirdParty/Box2D/Box2D/Common/b2StackAllocator.cpp
  34. 1 1
      Source/ThirdParty/Box2D/Box2D/Common/b2StackAllocator.h
  35. 4 1
      Source/ThirdParty/Box2D/Box2D/Common/b2Timer.cpp
  36. 1 1
      Source/ThirdParty/Box2D/Box2D/Common/b2Timer.h
  37. 5 5
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp
  38. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h
  39. 5 5
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp
  40. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h
  41. 6 6
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2CircleContact.cpp
  42. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2CircleContact.h
  43. 17 17
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2Contact.cpp
  44. 4 4
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2Contact.h
  45. 31 26
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ContactSolver.cpp
  46. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ContactSolver.h
  47. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp
  48. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h
  49. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp
  50. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h
  51. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp
  52. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h
  53. 6 6
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonContact.cpp
  54. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonContact.h
  55. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.cpp
  56. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.h
  57. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2FrictionJoint.cpp
  58. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2FrictionJoint.h
  59. 5 5
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2GearJoint.cpp
  60. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2GearJoint.h
  61. 15 15
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2Joint.cpp
  62. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2Joint.h
  63. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MotorJoint.cpp
  64. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MotorJoint.h
  65. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MouseJoint.cpp
  66. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MouseJoint.h
  67. 10 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp
  68. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PrismaticJoint.h
  69. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PulleyJoint.cpp
  70. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PulleyJoint.h
  71. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp
  72. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RevoluteJoint.h
  73. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RopeJoint.cpp
  74. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RopeJoint.h
  75. 20 4
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WeldJoint.cpp
  76. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WeldJoint.h
  77. 34 6
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WheelJoint.cpp
  78. 11 6
      Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WheelJoint.h
  79. 16 14
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Body.cpp
  80. 26 9
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Body.h
  81. 5 5
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2ContactManager.cpp
  82. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2ContactManager.h
  83. 10 10
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Fixture.cpp
  84. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Fixture.h
  85. 12 12
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Island.cpp
  86. 3 3
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2Island.h
  87. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2TimeStep.h
  88. 53 35
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2World.cpp
  89. 7 7
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2World.h
  90. 2 2
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2WorldCallbacks.cpp
  91. 1 1
      Source/ThirdParty/Box2D/Box2D/Dynamics/b2WorldCallbacks.h
  92. 2 2
      Source/ThirdParty/Box2D/Box2D/Rope/b2Rope.cpp
  93. 1 1
      Source/ThirdParty/Box2D/Box2D/Rope/b2Rope.h
  94. 1 0
      Source/Urho3D/AngelScript/Urho2DAPI.cpp
  95. 1 0
      Source/Urho3D/LuaScript/pkgs/Urho2D/RigidBody2D.pkg
  96. 0 12
      Source/Urho3D/Urho2D/PhysicsUtils2D.h
  97. 7 0
      Source/Urho3D/Urho2D/PhysicsWorld2D.cpp
  98. 2 0
      Source/Urho3D/Urho2D/PhysicsWorld2D.h
  99. 6 1
      Source/Urho3D/Urho2D/RigidBody2D.cpp
  100. 2 0
      Source/Urho3D/Urho2D/RigidBody2D.h

+ 28 - 28
Source/ThirdParty/Box2D/Box2D/Box2D.h

@@ -31,38 +31,38 @@ For discussion please visit http://box2d.org/forum
 
 // These include files constitute the main Box2D API
 
-#include <Box2D/Common/b2Settings.h>
-#include <Box2D/Common/b2Draw.h>
-#include <Box2D/Common/b2Timer.h>
+#include "Box2D/Common/b2Settings.h"
+#include "Box2D/Common/b2Draw.h"
+#include "Box2D/Common/b2Timer.h"
 
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 
-#include <Box2D/Collision/b2BroadPhase.h>
-#include <Box2D/Collision/b2Distance.h>
-#include <Box2D/Collision/b2DynamicTree.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
+#include "Box2D/Collision/b2BroadPhase.h"
+#include "Box2D/Collision/b2Distance.h"
+#include "Box2D/Collision/b2DynamicTree.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
 
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
-#include <Box2D/Dynamics/b2World.h>
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
+#include "Box2D/Dynamics/b2World.h"
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
-#include <Box2D/Dynamics/Joints/b2DistanceJoint.h>
-#include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
-#include <Box2D/Dynamics/Joints/b2GearJoint.h>
-#include <Box2D/Dynamics/Joints/b2MotorJoint.h>
-#include <Box2D/Dynamics/Joints/b2MouseJoint.h>
-#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
-#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
-#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
-#include <Box2D/Dynamics/Joints/b2RopeJoint.h>
-#include <Box2D/Dynamics/Joints/b2WeldJoint.h>
-#include <Box2D/Dynamics/Joints/b2WheelJoint.h>
+#include "Box2D/Dynamics/Joints/b2DistanceJoint.h"
+#include "Box2D/Dynamics/Joints/b2FrictionJoint.h"
+#include "Box2D/Dynamics/Joints/b2GearJoint.h"
+#include "Box2D/Dynamics/Joints/b2MotorJoint.h"
+#include "Box2D/Dynamics/Joints/b2MouseJoint.h"
+#include "Box2D/Dynamics/Joints/b2PrismaticJoint.h"
+#include "Box2D/Dynamics/Joints/b2PulleyJoint.h"
+#include "Box2D/Dynamics/Joints/b2RevoluteJoint.h"
+#include "Box2D/Dynamics/Joints/b2RopeJoint.h"
+#include "Box2D/Dynamics/Joints/b2WeldJoint.h"
+#include "Box2D/Dynamics/Joints/b2WheelJoint.h"
 
 #endif

+ 14 - 10
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2ChainShape.cpp

@@ -16,16 +16,17 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
-
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
 #include <new>
-// Urho3D: replaced with cstring include for memcpy to work on Android
-// #include <memory.h>
-#include <cstring>
+#include <string.h>
 
 b2ChainShape::~b2ChainShape()
+{
+	Clear();
+}
+
+void b2ChainShape::Clear()
 {
 	b2Free(m_vertices);
 	m_vertices = NULL;
@@ -36,6 +37,11 @@ void b2ChainShape::CreateLoop(const b2Vec2* vertices, int32 count)
 {
 	b2Assert(m_vertices == NULL && m_count == 0);
 	b2Assert(count >= 3);
+	if (count < 3)
+	{
+		return;
+	}
+
 	for (int32 i = 1; i < count; ++i)
 	{
 		b2Vec2 v1 = vertices[i-1];
@@ -60,10 +66,8 @@ void b2ChainShape::CreateChain(const b2Vec2* vertices, int32 count)
 	b2Assert(count >= 2);
 	for (int32 i = 1; i < count; ++i)
 	{
-		b2Vec2 v1 = vertices[i-1];
-		b2Vec2 v2 = vertices[i];
 		// If the code crashes here, it means your vertices are too close together.
-		b2Assert(b2DistanceSquared(v1, v2) > b2_linearSlop * b2_linearSlop);
+		b2Assert(b2DistanceSquared(vertices[i-1], vertices[i]) > b2_linearSlop * b2_linearSlop);
 	}
 
 	m_count = count;

+ 4 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2ChainShape.h

@@ -19,7 +19,7 @@
 #ifndef B2_CHAIN_SHAPE_H
 #define B2_CHAIN_SHAPE_H
 
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Collision/Shapes/b2Shape.h"
 
 class b2EdgeShape;
 
@@ -37,6 +37,9 @@ public:
 	/// The destructor frees the vertices using b2Free.
 	~b2ChainShape();
 
+	/// Clear all data.
+	void Clear();
+
 	/// Create a loop. This automatically adjusts connectivity.
 	/// @param vertices an array of vertices, these are copied
 	/// @param count the vertex count

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2CircleShape.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
 #include <new>
 
 b2Shape* b2CircleShape::Clone(b2BlockAllocator* allocator) const

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2CircleShape.h

@@ -19,7 +19,7 @@
 #ifndef B2_CIRCLE_SHAPE_H
 #define B2_CIRCLE_SHAPE_H
 
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Collision/Shapes/b2Shape.h"
 
 /// A circle shape.
 class b2CircleShape : public b2Shape

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2EdgeShape.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
 #include <new>
 
 void b2EdgeShape::Set(const b2Vec2& v1, const b2Vec2& v2)

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2EdgeShape.h

@@ -19,7 +19,7 @@
 #ifndef B2_EDGE_SHAPE_H
 #define B2_EDGE_SHAPE_H
 
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Collision/Shapes/b2Shape.h"
 
 /// A line segment (edge) shape. These can be connected in chains or loops
 /// to other edge shapes. The connectivity information is used to ensure

+ 10 - 2
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2PolygonShape.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 #include <new>
 
 b2Shape* b2PolygonShape::Clone(b2BlockAllocator* allocator) const
@@ -138,7 +138,7 @@ void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
 		bool unique = true;
 		for (int32 j = 0; j < tempCount; ++j)
 		{
-			if (b2DistanceSquared(v, ps[j]) < 0.5f * b2_linearSlop)
+			if (b2DistanceSquared(v, ps[j]) < ((0.5f * b2_linearSlop) * (0.5f * b2_linearSlop)))
 			{
 				unique = false;
 				break;
@@ -217,6 +217,14 @@ void b2PolygonShape::Set(const b2Vec2* vertices, int32 count)
 		}
 	}
 	
+	if (m < 3)
+	{
+		// Polygon is degenerate.
+		b2Assert(false);
+		SetAsBox(1.0f, 1.0f);
+		return;
+	}
+
 	m_count = m;
 
 	// Copy vertices.

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2PolygonShape.h

@@ -19,7 +19,7 @@
 #ifndef B2_POLYGON_SHAPE_H
 #define B2_POLYGON_SHAPE_H
 
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Collision/Shapes/b2Shape.h"
 
 /// A convex polygon. It is assumed that the interior of the polygon is to
 /// the left of each edge.

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Collision/Shapes/b2Shape.h

@@ -19,9 +19,9 @@
 #ifndef B2_SHAPE_H
 #define B2_SHAPE_H
 
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Collision/b2Collision.h>
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Collision/b2Collision.h"
 
 /// This holds the mass data computed for a shape.
 struct b2MassData

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/b2BroadPhase.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2BroadPhase.h>
+#include "Box2D/Collision/b2BroadPhase.h"
 
 b2BroadPhase::b2BroadPhase()
 {

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Collision/b2BroadPhase.h

@@ -19,9 +19,9 @@
 #ifndef B2_BROAD_PHASE_H
 #define B2_BROAD_PHASE_H
 
-#include <Box2D/Common/b2Settings.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/b2DynamicTree.h>
+#include "Box2D/Common/b2Settings.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/b2DynamicTree.h"
 #include <algorithm>
 
 struct b2Pair

+ 5 - 5
Source/ThirdParty/Box2D/Box2D/Collision/b2CollideCircle.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 
 void b2CollideCircles(
 	b2Manifold* manifold,
@@ -138,8 +138,8 @@ void b2CollidePolygonAndCircle(
 	else
 	{
 		b2Vec2 faceCenter = 0.5f * (v1 + v2);
-		float32 separation = b2Dot(cLocal - faceCenter, normals[vertIndex1]);
-		if (separation > radius)
+		float32 s = b2Dot(cLocal - faceCenter, normals[vertIndex1]);
+		if (s > radius)
 		{
 			return;
 		}

+ 4 - 4
Source/ThirdParty/Box2D/Box2D/Collision/b2CollideEdge.cpp

@@ -16,10 +16,10 @@
  * 3. This notice may not be removed or altered from any source distribution.
  */
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 
 
 // Compute contact points for edge versus circle.

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Collision/b2CollidePolygon.cpp

@@ -16,8 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 
 // Find the max separation between poly1 and poly2 using edge normals from poly1.
 static float32 b2FindMaxSeparation(int32* edgeIndex,

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Collision/b2Collision.cpp

@@ -16,8 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/b2Distance.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/b2Distance.h"
 
 void b2WorldManifold::Initialize(const b2Manifold* manifold,
 						  const b2Transform& xfA, float32 radiusA,

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/b2Collision.h

@@ -19,7 +19,7 @@
 #ifndef B2_COLLISION_H
 #define B2_COLLISION_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 #include <limits.h>
 
 /// @file

+ 6 - 7
Source/ThirdParty/Box2D/Box2D/Collision/b2Distance.cpp

@@ -16,11 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Distance.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
+#include "Box2D/Collision/b2Distance.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
 
 // GJK using Voronoi regions (Christer Ericson) and Barycentric coordinates.
 int32 b2_gjkCalls, b2_gjkIters, b2_gjkMaxIters;
@@ -467,7 +467,6 @@ void b2Distance(b2DistanceOutput* output,
 	int32 saveCount = 0;
 
 	float32 distanceSqr1 = b2_maxFloat;
-	float32 distanceSqr2 = distanceSqr1;
 
 	// Main iteration loop.
 	int32 iter = 0;
@@ -506,7 +505,7 @@ void b2Distance(b2DistanceOutput* output,
 
 		// Compute closest point.
 		b2Vec2 p = simplex.GetClosestPoint();
-		distanceSqr2 = p.LengthSquared();
+		float32 distanceSqr2 = p.LengthSquared();
 
 		// Ensure progress
 		if (distanceSqr2 >= distanceSqr1)

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Collision/b2Distance.h

@@ -20,7 +20,7 @@
 #ifndef B2_DISTANCE_H
 #define B2_DISTANCE_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 class b2Shape;
 

+ 4 - 6
Source/ThirdParty/Box2D/Box2D/Collision/b2DynamicTree.cpp

@@ -16,12 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
-
-#include <Box2D/Collision/b2DynamicTree.h>
-// Urho3D: replaced with cstring include for memcpy to work on Android
-// #include <memory.h>
-#include <cstring>
+#include "Box2D/Collision/b2DynamicTree.h"
+#include <string.h>
 
 b2DynamicTree::b2DynamicTree()
 {
@@ -656,6 +652,7 @@ void b2DynamicTree::ValidateMetrics(int32 index) const
 
 void b2DynamicTree::Validate() const
 {
+#if defined(b2DEBUG)
 	ValidateStructure(m_root);
 	ValidateMetrics(m_root);
 
@@ -671,6 +668,7 @@ void b2DynamicTree::Validate() const
 	b2Assert(GetHeight() == ComputeHeight());
 
 	b2Assert(m_nodeCount + freeCount == m_nodeCapacity);
+#endif
 }
 
 int32 b2DynamicTree::GetMaxBalance() const

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Collision/b2DynamicTree.h

@@ -19,8 +19,8 @@
 #ifndef B2_DYNAMIC_TREE_H
 #define B2_DYNAMIC_TREE_H
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Common/b2GrowableStack.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Common/b2GrowableStack.h"
 
 #define b2_nullNode (-1)
 

+ 6 - 6
Source/ThirdParty/Box2D/Box2D/Collision/b2TimeOfImpact.cpp

@@ -16,12 +16,12 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/b2Distance.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
-#include <Box2D/Common/b2Timer.h>
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/b2Distance.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
+#include "Box2D/Common/b2Timer.h"
 
 #include <stdio.h>
 

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Collision/b2TimeOfImpact.h

@@ -19,8 +19,8 @@
 #ifndef B2_TIME_OF_IMPACT_H
 #define B2_TIME_OF_IMPACT_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Collision/b2Distance.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Collision/b2Distance.h"
 
 /// Input parameters for b2TimeOfImpact
 struct b2TOIInput

+ 2 - 7
Source/ThirdParty/Box2D/Box2D/Common/b2BlockAllocator.cpp

@@ -16,16 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
-
-#include <Box2D/Common/b2BlockAllocator.h>
+#include "Box2D/Common/b2BlockAllocator.h"
 #include <limits.h>
-// Urho3D: replaced with cstring include for memcpy to work on Android
-// #include <memory.h>
-#include <cstring>
+#include <string.h>
 #include <stddef.h>
 
-
 int32 b2BlockAllocator::s_blockSizes[b2_blockSizes] = 
 {
 	16,		// 0

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2BlockAllocator.h

@@ -19,7 +19,7 @@
 #ifndef B2_BLOCK_ALLOCATOR_H
 #define B2_BLOCK_ALLOCATOR_H
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 
 const int32 b2_chunkSize = 16 * 1024;
 const int32 b2_maxBlockSize = 640;

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2Draw.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Common/b2Draw.h>
+#include "Box2D/Common/b2Draw.h"
 
 b2Draw::b2Draw()
 {

+ 15 - 4
Source/ThirdParty/Box2D/Box2D/Common/b2Draw.h

@@ -19,15 +19,23 @@
 #ifndef B2_DRAW_H
 #define B2_DRAW_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 /// Color for debug drawing. Each value has the range [0,1].
 struct b2Color
 {
 	b2Color() {}
-	b2Color(float32 r, float32 g, float32 b) : r(r), g(g), b(b) {}
-	void Set(float32 ri, float32 gi, float32 bi) { r = ri; g = gi; b = bi; }
-	float32 r, g, b;
+	b2Color(float32 rIn, float32 gIn, float32 bIn, float32 aIn = 1.0f)
+	{
+		r = rIn; g = gIn; b = bIn; a = aIn;
+	}
+
+	void Set(float32 rIn, float32 gIn, float32 bIn, float32 aIn = 1.0f)
+	{
+		r = rIn; g = gIn; b = bIn; a = aIn;
+	}
+
+	float32 r, g, b, a;
 };
 
 /// Implement and register this class with a b2World to provide debug drawing of physics
@@ -79,6 +87,9 @@ public:
 	/// @param xf a transform.
 	virtual void DrawTransform(const b2Transform& xf) = 0;
 
+	/// Draw a point.
+	virtual void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color) = 0;
+
 protected:
 	uint32 m_drawFlags;
 };

+ 2 - 7
Source/ThirdParty/Box2D/Box2D/Common/b2GrowableStack.h

@@ -16,15 +16,10 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
-
-#include <cstring>
 #ifndef B2_GROWABLE_STACK_H
 #define B2_GROWABLE_STACK_H
-#include <Box2D/Common/b2Settings.h>
-// Urho3D: replaced with cstring include for memcpy to work on Android
-// #include <memory.h>
-#include <cstring>
+#include "Box2D/Common/b2Settings.h"
+#include <string.h>
 
 /// This is a growable LIFO stack with an initial capacity of N.
 /// If the stack size exceeds the initial capacity, the heap is used

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2Math.cpp

@@ -16,7 +16,7 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 const b2Vec2 b2Vec2_zero(0.0f, 0.0f);
 

+ 8 - 3
Source/ThirdParty/Box2D/Box2D/Common/b2Math.h

@@ -19,7 +19,7 @@
 #ifndef B2_MATH_H
 #define B2_MATH_H
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 #include <math.h>
 
 /// This function is used to ensure that a floating point number is not a NaN or infinity.
@@ -56,7 +56,7 @@ struct b2Vec2
 	b2Vec2() {}
 
 	/// Construct using coordinates.
-	b2Vec2(float32 x, float32 y) : x(x), y(y) {}
+	b2Vec2(float32 xIn, float32 yIn) : x(xIn), y(yIn) {}
 
 	/// Set this vector to all zeros.
 	void SetZero() { x = 0.0f; y = 0.0f; }
@@ -147,7 +147,7 @@ struct b2Vec3
 	b2Vec3() {}
 
 	/// Construct using coordinates.
-	b2Vec3(float32 x, float32 y, float32 z) : x(x), y(y), z(z) {}
+	b2Vec3(float32 xIn, float32 yIn, float32 zIn) : x(xIn), y(yIn), z(zIn) {}
 
 	/// Set this vector to all zeros.
 	void SetZero() { x = 0.0f; y = 0.0f; z = 0.0f; }
@@ -464,6 +464,11 @@ inline bool operator == (const b2Vec2& a, const b2Vec2& b)
 	return a.x == b.x && a.y == b.y;
 }
 
+inline bool operator != (const b2Vec2& a, const b2Vec2& b)
+{
+	return a.x != b.x || a.y != b.y;
+}
+
 inline float32 b2Distance(const b2Vec2& a, const b2Vec2& b)
 {
 	b2Vec2 c = a - b;

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Common/b2Settings.cpp

@@ -16,12 +16,12 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdlib.h>
 
-b2Version b2_version = {2, 3, 0};
+b2Version b2_version = {2, 3, 2};
 
 // Memory allocators. Modify these to use your own allocator.
 void* b2Alloc(int32 size)

+ 4 - 0
Source/ThirdParty/Box2D/Box2D/Common/b2Settings.h

@@ -23,6 +23,10 @@
 #include <assert.h>
 #include <float.h>
 
+#if !defined(NDEBUG)
+	#define b2DEBUG
+#endif
+
 #define B2_NOT_USED(x) ((void)(x))
 #define b2Assert(A) assert(A)
 

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Common/b2StackAllocator.cpp

@@ -16,8 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Common/b2StackAllocator.h>
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2StackAllocator.h"
+#include "Box2D/Common/b2Math.h"
 
 b2StackAllocator::b2StackAllocator()
 {

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2StackAllocator.h

@@ -19,7 +19,7 @@
 #ifndef B2_STACK_ALLOCATOR_H
 #define B2_STACK_ALLOCATOR_H
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 
 const int32 b2_stackSize = 100 * 1024;	// 100k
 const int32 b2_maxStackEntries = 32;

+ 4 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2Timer.cpp

@@ -16,13 +16,16 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Common/b2Timer.h>
+#include "Box2D/Common/b2Timer.h"
 
 #if defined(_WIN32)
 
 float64 b2Timer::s_invFrequency = 0.0f;
 
+#ifndef WIN32_LEAN_AND_MEAN
 #define WIN32_LEAN_AND_MEAN
+#endif
+
 #include <windows.h>
 
 b2Timer::b2Timer()

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Common/b2Timer.h

@@ -19,7 +19,7 @@
 #ifndef B2_TIMER_H
 #define B2_TIMER_H
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 
 /// Timer for profiling. This has platform specific code and may
 /// not work on every platform.

+ 5 - 5
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp

@@ -16,11 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
+#include "Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_CHAIN_AND_CIRCLE_CONTACT_H
 #define B2_CHAIN_AND_CIRCLE_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 5 - 5
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp

@@ -16,11 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
+#include "Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_CHAIN_AND_POLYGON_CONTACT_H
 #define B2_CHAIN_AND_POLYGON_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 6 - 6
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2CircleContact.cpp

@@ -16,12 +16,12 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2CircleContact.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
+#include "Box2D/Dynamics/Contacts/b2CircleContact.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2CircleContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_CIRCLE_CONTACT_H
 #define B2_CIRCLE_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 17 - 17
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2Contact.cpp

@@ -16,23 +16,23 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/Contacts/b2CircleContact.h>
-#include <Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h>
-#include <Box2D/Dynamics/Contacts/b2PolygonContact.h>
-#include <Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h>
-#include <Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h>
-#include <Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h>
-#include <Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h>
-#include <Box2D/Dynamics/Contacts/b2ContactSolver.h>
-
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
-#include <Box2D/Collision/Shapes/b2Shape.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2World.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/Contacts/b2CircleContact.h"
+#include "Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h"
+#include "Box2D/Dynamics/Contacts/b2PolygonContact.h"
+#include "Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h"
+#include "Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h"
+#include "Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h"
+#include "Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h"
+#include "Box2D/Dynamics/Contacts/b2ContactSolver.h"
+
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
+#include "Box2D/Collision/Shapes/b2Shape.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2World.h"
 
 b2ContactRegister b2Contact::s_registers[b2Shape::e_typeCount][b2Shape::e_typeCount];
 bool b2Contact::s_initialized = false;

+ 4 - 4
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2Contact.h

@@ -19,10 +19,10 @@
 #ifndef B2_CONTACT_H
 #define B2_CONTACT_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/Shapes/b2Shape.h>
-#include <Box2D/Dynamics/b2Fixture.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/Shapes/b2Shape.h"
+#include "Box2D/Dynamics/b2Fixture.h"
 
 class b2Body;
 class b2Contact;

+ 31 - 26
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ContactSolver.cpp

@@ -16,16 +16,19 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2ContactSolver.h>
+#include "Box2D/Dynamics/Contacts/b2ContactSolver.h"
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Common/b2StackAllocator.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Common/b2StackAllocator.h"
 
+// Solver debugging is normally disabled because the block solver sometimes has to deal with a poorly conditioned effective mass matrix.
 #define B2_DEBUG_SOLVER 0
 
+bool g_blockSolve = true;
+
 struct b2ContactPositionConstraint
 {
 	b2Vec2 localPoints[b2_maxManifoldPoints];
@@ -213,7 +216,7 @@ void b2ContactSolver::InitializeVelocityConstraints()
 		}
 
 		// If we have two points, then prepare the block solver.
-		if (vc->pointCount == 2)
+		if (vc->pointCount == 2 && g_blockSolve)
 		{
 			b2VelocityConstraintPoint* vcp1 = vc->points + 0;
 			b2VelocityConstraintPoint* vcp2 = vc->points + 1;
@@ -341,36 +344,39 @@ void b2ContactSolver::SolveVelocityConstraints()
 		}
 
 		// Solve normal constraints
-		if (vc->pointCount == 1)
+		if (pointCount == 1 || g_blockSolve == false)
 		{
-			b2VelocityConstraintPoint* vcp = vc->points + 0;
+			for (int32 j = 0; j < pointCount; ++j)
+			{
+				b2VelocityConstraintPoint* vcp = vc->points + j;
 
-			// Relative velocity at contact
-			b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
+				// Relative velocity at contact
+				b2Vec2 dv = vB + b2Cross(wB, vcp->rB) - vA - b2Cross(wA, vcp->rA);
 
-			// Compute normal impulse
-			float32 vn = b2Dot(dv, normal);
-			float32 lambda = -vcp->normalMass * (vn - vcp->velocityBias);
+				// Compute normal impulse
+				float32 vn = b2Dot(dv, normal);
+				float32 lambda = -vcp->normalMass * (vn - vcp->velocityBias);
 
-			// b2Clamp the accumulated impulse
-			float32 newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f);
-			lambda = newImpulse - vcp->normalImpulse;
-			vcp->normalImpulse = newImpulse;
+				// b2Clamp the accumulated impulse
+				float32 newImpulse = b2Max(vcp->normalImpulse + lambda, 0.0f);
+				lambda = newImpulse - vcp->normalImpulse;
+				vcp->normalImpulse = newImpulse;
 
-			// Apply contact impulse
-			b2Vec2 P = lambda * normal;
-			vA -= mA * P;
-			wA -= iA * b2Cross(vcp->rA, P);
+				// Apply contact impulse
+				b2Vec2 P = lambda * normal;
+				vA -= mA * P;
+				wA -= iA * b2Cross(vcp->rA, P);
 
-			vB += mB * P;
-			wB += iB * b2Cross(vcp->rB, P);
+				vB += mB * P;
+				wB += iB * b2Cross(vcp->rB, P);
+			}
 		}
 		else
 		{
 			// Block solver developed in collaboration with Dirk Gregorius (back in 01/07 on Box2D_Lite).
 			// Build the mini LCP for this contact patch
 			//
-			// vn = A * x + b, vn >= 0, , vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
+			// vn = A * x + b, vn >= 0, x >= 0 and vn_i * x_i = 0 with i = 1..2
 			//
 			// A = J * W * JT and J = ( -n, -r1 x n, n, r2 x n )
 			// b = vn0 - velocityBias
@@ -480,7 +486,6 @@ void b2ContactSolver::SolveVelocityConstraints()
 				x.y = 0.0f;
 				vn1 = 0.0f;
 				vn2 = vc->K.ex.y * x.x + b.y;
-
 				if (x.x >= 0.0f && vn2 >= 0.0f)
 				{
 					// Get the incremental impulse

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2ContactSolver.h

@@ -19,9 +19,9 @@
 #ifndef B2_CONTACT_SOLVER_H
 #define B2_CONTACT_SOLVER_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 class b2Contact;
 class b2Body;

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Fixture.h>
+#include "Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Fixture.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_EDGE_AND_CIRCLE_CONTACT_H
 #define B2_EDGE_AND_CIRCLE_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Fixture.h>
+#include "Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Fixture.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_EDGE_AND_POLYGON_CONTACT_H
 #define B2_EDGE_AND_POLYGON_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Dynamics/b2Fixture.h>
+#include "Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Dynamics/b2Fixture.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_POLYGON_AND_CIRCLE_CONTACT_H
 #define B2_POLYGON_AND_CIRCLE_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 6 - 6
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonContact.cpp

@@ -16,12 +16,12 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Contacts/b2PolygonContact.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
+#include "Box2D/Dynamics/Contacts/b2PolygonContact.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Contacts/b2PolygonContact.h

@@ -19,7 +19,7 @@
 #ifndef B2_POLYGON_CONTACT_H
 #define B2_POLYGON_CONTACT_H
 
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 class b2BlockAllocator;
 

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2DistanceJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2DistanceJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // 1-D constrained system
 // m (v2 - v1) = lambda

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2DistanceJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_DISTANCE_JOINT_H
 #define B2_DISTANCE_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Distance joint definition. This requires defining an
 /// anchor point on both bodies and the non-zero length of the

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2FrictionJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2FrictionJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Point-to-point constraint
 // Cdot = v2 - v1

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2FrictionJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_FRICTION_JOINT_H
 #define B2_FRICTION_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Friction joint definition.
 struct b2FrictionJointDef : public b2JointDef

+ 5 - 5
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2GearJoint.cpp

@@ -16,11 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2GearJoint.h>
-#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
-#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2GearJoint.h"
+#include "Box2D/Dynamics/Joints/b2RevoluteJoint.h"
+#include "Box2D/Dynamics/Joints/b2PrismaticJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Gear Joint:
 // C0 = (coordinate1 + ratio * coordinate2)_initial

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2GearJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_GEAR_JOINT_H
 #define B2_GEAR_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Gear joint definition. This definition requires two existing
 /// revolute or prismatic joints (any combination will work).

+ 15 - 15
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2Joint.cpp

@@ -16,21 +16,21 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
-#include <Box2D/Dynamics/Joints/b2DistanceJoint.h>
-#include <Box2D/Dynamics/Joints/b2WheelJoint.h>
-#include <Box2D/Dynamics/Joints/b2MouseJoint.h>
-#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
-#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
-#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
-#include <Box2D/Dynamics/Joints/b2GearJoint.h>
-#include <Box2D/Dynamics/Joints/b2WeldJoint.h>
-#include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
-#include <Box2D/Dynamics/Joints/b2RopeJoint.h>
-#include <Box2D/Dynamics/Joints/b2MotorJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Common/b2BlockAllocator.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
+#include "Box2D/Dynamics/Joints/b2DistanceJoint.h"
+#include "Box2D/Dynamics/Joints/b2WheelJoint.h"
+#include "Box2D/Dynamics/Joints/b2MouseJoint.h"
+#include "Box2D/Dynamics/Joints/b2RevoluteJoint.h"
+#include "Box2D/Dynamics/Joints/b2PrismaticJoint.h"
+#include "Box2D/Dynamics/Joints/b2PulleyJoint.h"
+#include "Box2D/Dynamics/Joints/b2GearJoint.h"
+#include "Box2D/Dynamics/Joints/b2WeldJoint.h"
+#include "Box2D/Dynamics/Joints/b2FrictionJoint.h"
+#include "Box2D/Dynamics/Joints/b2RopeJoint.h"
+#include "Box2D/Dynamics/Joints/b2MotorJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Common/b2BlockAllocator.h"
 
 #include <new>
 

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2Joint.h

@@ -19,7 +19,7 @@
 #ifndef B2_JOINT_H
 #define B2_JOINT_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 class b2Body;
 class b2Joint;

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MotorJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2MotorJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2MotorJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Point-to-point constraint
 // Cdot = v2 - v1

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MotorJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_MOTOR_JOINT_H
 #define B2_MOTOR_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Motor joint definition.
 struct b2MotorJointDef : public b2JointDef

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MouseJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2MouseJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2MouseJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // p = attached point, m = mouse point
 // C = p - m

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2MouseJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_MOUSE_JOINT_H
 #define B2_MOUSE_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Mouse joint definition. This requires a world target point,
 /// tuning parameters, and the time step.

+ 10 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2PrismaticJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2PrismaticJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Linear constraint (point-to-line)
 // d = p2 - p1 = x2 + r2 - x1 - r1
@@ -357,6 +357,13 @@ void b2PrismaticJoint::SolveVelocityConstraints(const b2SolverData& data)
 	data.velocities[m_indexB].w = wB;
 }
 
+// A velocity based solver computes reaction forces(impulses) using the velocity constraint solver.Under this context,
+// the position solver is not there to resolve forces.It is only there to cope with integration error.
+//
+// Therefore, the pseudo impulses in the position solver do not have any physical meaning.Thus it is okay if they suck.
+//
+// We could take the active state from the velocity solver.However, the joint might push past the limit when the velocity
+// solver indicates the limit is inactive.
 bool b2PrismaticJoint::SolvePositionConstraints(const b2SolverData& data)
 {
 	b2Vec2 cA = data.positions[m_indexA].c;

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PrismaticJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_PRISMATIC_JOINT_H
 #define B2_PRISMATIC_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Prismatic joint definition. This requires defining a line of
 /// motion using an axis and an anchor point. The definition uses local

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PulleyJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2PulleyJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Pulley:
 // length1 = norm(p1 - s1)

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2PulleyJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_PULLEY_JOINT_H
 #define B2_PULLEY_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 const float32 b2_minPulleyLength = 2.0f;
 

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2RevoluteJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2RevoluteJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Point-to-point constraint
 // C = p2 - p1

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RevoluteJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_REVOLUTE_JOINT_H
 #define B2_REVOLUTE_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Revolute joint definition. This requires defining an
 /// anchor point where the bodies are joined. The definition

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RopeJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2RopeJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2RopeJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 
 // Limit:

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2RopeJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_ROPE_JOINT_H
 #define B2_ROPE_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Rope joint definition. This requires two body anchor points and
 /// a maximum lengths.

+ 20 - 4
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WeldJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2WeldJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2WeldJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Point-to-point constraint
 // C = p2 - p1
@@ -129,6 +129,12 @@ void b2WeldJoint::InitVelocityConstraints(const b2SolverData& data)
 		invM += m_gamma;
 		m_mass.ez.z = invM != 0.0f ? 1.0f / invM : 0.0f;
 	}
+	else if (K.ez.z == 0.0f)
+	{
+		K.GetInverse22(&m_mass);
+		m_gamma = 0.0f;
+		m_bias = 0.0f;
+	}
 	else
 	{
 		K.GetSymInverse33(&m_mass);
@@ -271,7 +277,17 @@ bool b2WeldJoint::SolvePositionConstraints(const b2SolverData& data)
 
 		b2Vec3 C(C1.x, C1.y, C2);
 	
-		b2Vec3 impulse = -K.Solve33(C);
+		b2Vec3 impulse;
+		if (K.ez.z > 0.0f)
+		{
+			impulse = -K.Solve33(C);
+		}
+		else
+		{
+			b2Vec2 impulse2 = -K.Solve22(C1);
+			impulse.Set(impulse2.x, impulse2.y, 0.0f);
+		}
+
 		b2Vec2 P(impulse.x, impulse.y);
 
 		cA -= mA * P;

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WeldJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_WELD_JOINT_H
 #define B2_WELD_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Weld joint definition. You need to specify local anchor points
 /// where they are attached and the relative body angle. The position

+ 34 - 6
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WheelJoint.cpp

@@ -16,9 +16,9 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/Joints/b2WheelJoint.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Dynamics/Joints/b2WheelJoint.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 // Linear constraint (point-to-line)
 // d = pB - pA = xB + rB - xA - rA
@@ -141,14 +141,14 @@ void b2WheelJoint::InitVelocityConstraints(const b2SolverData& data)
 			float32 omega = 2.0f * b2_pi * m_frequencyHz;
 
 			// Damping coefficient
-			float32 d = 2.0f * m_springMass * m_dampingRatio * omega;
+			float32 damp = 2.0f * m_springMass * m_dampingRatio * omega;
 
 			// Spring stiffness
 			float32 k = m_springMass * omega * omega;
 
 			// magic formulas
 			float32 h = data.step.dt;
-			m_gamma = h * (d + h * k);
+			m_gamma = h * (damp + h * k);
 			if (m_gamma > 0.0f)
 			{
 				m_gamma = 1.0f / m_gamma;
@@ -360,7 +360,35 @@ float32 b2WheelJoint::GetJointTranslation() const
 	return translation;
 }
 
-float32 b2WheelJoint::GetJointSpeed() const
+float32 b2WheelJoint::GetJointLinearSpeed() const
+{
+	b2Body* bA = m_bodyA;
+	b2Body* bB = m_bodyB;
+
+	b2Vec2 rA = b2Mul(bA->m_xf.q, m_localAnchorA - bA->m_sweep.localCenter);
+	b2Vec2 rB = b2Mul(bB->m_xf.q, m_localAnchorB - bB->m_sweep.localCenter);
+	b2Vec2 p1 = bA->m_sweep.c + rA;
+	b2Vec2 p2 = bB->m_sweep.c + rB;
+	b2Vec2 d = p2 - p1;
+	b2Vec2 axis = b2Mul(bA->m_xf.q, m_localXAxisA);
+
+	b2Vec2 vA = bA->m_linearVelocity;
+	b2Vec2 vB = bB->m_linearVelocity;
+	float32 wA = bA->m_angularVelocity;
+	float32 wB = bB->m_angularVelocity;
+
+	float32 speed = b2Dot(d, b2Cross(wA, axis)) + b2Dot(axis, vB + b2Cross(wB, rB) - vA - b2Cross(wA, rA));
+	return speed;
+}
+
+float32 b2WheelJoint::GetJointAngle() const
+{
+	b2Body* bA = m_bodyA;
+	b2Body* bB = m_bodyB;
+	return bB->m_sweep.a - bA->m_sweep.a;
+}
+
+float32 b2WheelJoint::GetJointAngularSpeed() const
 {
 	float32 wA = m_bodyA->m_angularVelocity;
 	float32 wB = m_bodyB->m_angularVelocity;

+ 11 - 6
Source/ThirdParty/Box2D/Box2D/Dynamics/Joints/b2WheelJoint.h

@@ -19,7 +19,7 @@
 #ifndef B2_WHEEL_JOINT_H
 #define B2_WHEEL_JOINT_H
 
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 /// Wheel joint definition. This requires defining a line of
 /// motion using an axis and an anchor point. The definition uses local
@@ -72,9 +72,8 @@ struct b2WheelJointDef : public b2JointDef
 };
 
 /// A wheel joint. This joint provides two degrees of freedom: translation
-/// along an axis fixed in bodyA and rotation in the plane. You can use a
-/// joint limit to restrict the range of motion and a joint motor to drive
-/// the rotation or to model rotational friction.
+/// along an axis fixed in bodyA and rotation in the plane. In other words, it is a point to
+/// line constraint with a rotational motor and a linear spring/damper.
 /// This joint is designed for vehicle suspensions.
 class b2WheelJoint : public b2Joint
 {
@@ -97,8 +96,14 @@ public:
 	/// Get the current joint translation, usually in meters.
 	float32 GetJointTranslation() const;
 
-	/// Get the current joint translation speed, usually in meters per second.
-	float32 GetJointSpeed() const;
+	/// Get the current joint linear speed, usually in meters per second.
+	float32 GetJointLinearSpeed() const;
+
+	/// Get the current joint angle in radians.
+	float32 GetJointAngle() const;
+
+	/// Get the current joint angular speed in radians per second.
+	float32 GetJointAngularSpeed() const;
 
 	/// Is the joint motor enabled?
 	bool IsMotorEnabled() const;

+ 16 - 14
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Body.cpp

@@ -16,13 +16,13 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
+// Modified by 1vanK for Urho3D
 
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/Joints/b2Joint.h>
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/Joints/b2Joint.h"
 
 b2Body::b2Body(const b2BodyDef* bd, b2World* world)
 {
@@ -34,8 +34,6 @@ b2Body::b2Body(const b2BodyDef* bd, b2World* world)
 	b2Assert(b2IsValid(bd->linearDamping) && bd->linearDamping >= 0.0f);
 
 	m_flags = 0;
-    // Urho3D: added
-    m_useFixtureMass = true;
 
 	if (bd->bullet)
 	{
@@ -194,8 +192,7 @@ b2Fixture* b2Body::CreateFixture(const b2FixtureDef* def)
 	fixture->m_body = this;
 
 	// Adjust mass properties if needed.
-    // Urho3D: added flag check
-	if (fixture->m_density > 0.0f && m_useFixtureMass)
+	if (fixture->m_density > 0.0f)
 	{
 		ResetMassData();
 	}
@@ -218,6 +215,13 @@ b2Fixture* b2Body::CreateFixture(const b2Shape* shape, float32 density)
 
 void b2Body::DestroyFixture(b2Fixture* fixture)
 {
+	// Urho3D: avoid requirement C++11
+	//if (fixture == nullptr)
+	if (!fixture)
+	{
+		return;
+	}
+
 	b2Assert(m_world->IsLocked() == false);
 	if (m_world->IsLocked() == true)
 	{
@@ -271,18 +275,16 @@ void b2Body::DestroyFixture(b2Fixture* fixture)
 		fixture->DestroyProxies(broadPhase);
 	}
 
-	fixture->Destroy(allocator);
 	fixture->m_body = NULL;
 	fixture->m_next = NULL;
+	fixture->Destroy(allocator);
 	fixture->~b2Fixture();
 	allocator->Free(fixture, sizeof(b2Fixture));
 
 	--m_fixtureCount;
 
 	// Reset the mass data.
-    // Urho3D: added flag check
-    if (m_useFixtureMass)
-        ResetMassData();
+	ResetMassData();
 }
 
 void b2Body::ResetMassData()

+ 26 - 9
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Body.h

@@ -16,13 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-// Modified by Lasse Oorni for Urho3D
-
 #ifndef B2_BODY_H
 #define B2_BODY_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Collision/Shapes/b2Shape.h"
 #include <memory>
 
 class b2Fixture;
@@ -211,7 +209,6 @@ public:
 
 	/// Apply a torque. This affects the angular velocity
 	/// without affecting the linear velocity of the center of mass.
-	/// This wakes up the body.
 	/// @param torque about the z-axis (out of the screen), usually in N-m.
 	/// @param wake also wake up the body
 	void ApplyTorque(float32 torque, bool wake);
@@ -224,6 +221,11 @@ public:
 	/// @param wake also wake up the body
 	void ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& point, bool wake);
 
+	/// Apply an impulse to the center of mass. This immediately modifies the velocity.
+	/// @param impulse the world impulse vector, usually in N-seconds or kg-m/s.
+	/// @param wake also wake up the body
+	void ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake);
+
 	/// Apply an angular impulse.
 	/// @param impulse the angular impulse in units of kg*m*m/s
 	/// @param wake also wake up the body
@@ -466,10 +468,6 @@ private:
 	float32 m_sleepTime;
 
 	void* m_userData;
-
-public:
-    /// Urho3D: flag for using fixture mass. If false (custom set mass & inertia) prevents fixture operations resetting mass data. Default true.
-    bool m_useFixtureMass;
 };
 
 inline b2BodyType b2Body::GetType() const
@@ -818,6 +816,25 @@ inline void b2Body::ApplyLinearImpulse(const b2Vec2& impulse, const b2Vec2& poin
 	}
 }
 
+inline void b2Body::ApplyLinearImpulseToCenter(const b2Vec2& impulse, bool wake)
+{
+	if (m_type != b2_dynamicBody)
+	{
+		return;
+	}
+
+	if (wake && (m_flags & e_awakeFlag) == 0)
+	{
+		SetAwake(true);
+	}
+
+	// Don't accumulate velocity if the body is sleeping
+	if (m_flags & e_awakeFlag)
+	{
+		m_linearVelocity += m_invMass * impulse;
+	}
+}
+
 inline void b2Body::ApplyAngularImpulse(float32 impulse, bool wake)
 {
 	if (m_type != b2_dynamicBody)

+ 5 - 5
Source/ThirdParty/Box2D/Box2D/Dynamics/b2ContactManager.cpp

@@ -16,11 +16,11 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/b2ContactManager.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
+#include "Box2D/Dynamics/b2ContactManager.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
 
 b2ContactFilter b2_defaultFilter;
 b2ContactListener b2_defaultListener;

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/b2ContactManager.h

@@ -19,7 +19,7 @@
 #ifndef B2_CONTACT_MANAGER_H
 #define B2_CONTACT_MANAGER_H
 
-#include <Box2D/Collision/b2BroadPhase.h>
+#include "Box2D/Collision/b2BroadPhase.h"
 
 class b2Contact;
 class b2ContactFilter;

+ 10 - 10
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Fixture.cpp

@@ -16,16 +16,16 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/b2BroadPhase.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Common/b2BlockAllocator.h>
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/b2BroadPhase.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Common/b2BlockAllocator.h"
 
 b2Fixture::b2Fixture()
 {

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Fixture.h

@@ -19,9 +19,9 @@
 #ifndef B2_FIXTURE_H
 #define B2_FIXTURE_H
 
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/Shapes/b2Shape.h>
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/Shapes/b2Shape.h"
 
 class b2BlockAllocator;
 class b2Body;

+ 12 - 12
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Island.cpp

@@ -16,16 +16,16 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Collision/b2Distance.h>
-#include <Box2D/Dynamics/b2Island.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/Contacts/b2ContactSolver.h>
-#include <Box2D/Dynamics/Joints/b2Joint.h>
-#include <Box2D/Common/b2StackAllocator.h>
-#include <Box2D/Common/b2Timer.h>
+#include "Box2D/Collision/b2Distance.h"
+#include "Box2D/Dynamics/b2Island.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/Contacts/b2ContactSolver.h"
+#include "Box2D/Dynamics/Joints/b2Joint.h"
+#include "Box2D/Common/b2StackAllocator.h"
+#include "Box2D/Common/b2Timer.h"
 
 /*
 Position Correction Notes
@@ -312,9 +312,9 @@ void b2Island::Solve(b2Profile* profile, const b2TimeStep& step, const b2Vec2& g
 		bool contactsOkay = contactSolver.SolvePositionConstraints();
 
 		bool jointsOkay = true;
-		for (int32 i = 0; i < m_jointCount; ++i)
+		for (int32 j = 0; j < m_jointCount; ++j)
 		{
-			bool jointOkay = m_joints[i]->SolvePositionConstraints(solverData);
+			bool jointOkay = m_joints[j]->SolvePositionConstraints(solverData);
 			jointsOkay = jointsOkay && jointOkay;
 		}
 

+ 3 - 3
Source/ThirdParty/Box2D/Box2D/Dynamics/b2Island.h

@@ -19,9 +19,9 @@
 #ifndef B2_ISLAND_H
 #define B2_ISLAND_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 class b2Contact;
 class b2Joint;

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/b2TimeStep.h

@@ -19,7 +19,7 @@
 #ifndef B2_TIME_STEP_H
 #define B2_TIME_STEP_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 /// Profiling data. Times are in milliseconds.
 struct b2Profile

+ 53 - 35
Source/ThirdParty/Box2D/Box2D/Dynamics/b2World.cpp

@@ -16,28 +16,28 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/b2World.h>
-#include <Box2D/Dynamics/b2Body.h>
-#include <Box2D/Dynamics/b2Fixture.h>
-#include <Box2D/Dynamics/b2Island.h>
-#include <Box2D/Dynamics/Joints/b2PulleyJoint.h>
-#include <Box2D/Dynamics/Contacts/b2Contact.h>
-#include <Box2D/Dynamics/Contacts/b2ContactSolver.h>
-#include <Box2D/Collision/b2Collision.h>
-#include <Box2D/Collision/b2BroadPhase.h>
-#include <Box2D/Collision/Shapes/b2CircleShape.h>
-#include <Box2D/Collision/Shapes/b2EdgeShape.h>
-#include <Box2D/Collision/Shapes/b2ChainShape.h>
-#include <Box2D/Collision/Shapes/b2PolygonShape.h>
-#include <Box2D/Collision/b2TimeOfImpact.h>
-#include <Box2D/Common/b2Draw.h>
-#include <Box2D/Common/b2Timer.h>
+#include "Box2D/Dynamics/b2World.h"
+#include "Box2D/Dynamics/b2Body.h"
+#include "Box2D/Dynamics/b2Fixture.h"
+#include "Box2D/Dynamics/b2Island.h"
+#include "Box2D/Dynamics/Joints/b2PulleyJoint.h"
+#include "Box2D/Dynamics/Contacts/b2Contact.h"
+#include "Box2D/Dynamics/Contacts/b2ContactSolver.h"
+#include "Box2D/Collision/b2Collision.h"
+#include "Box2D/Collision/b2BroadPhase.h"
+#include "Box2D/Collision/Shapes/b2CircleShape.h"
+#include "Box2D/Collision/Shapes/b2EdgeShape.h"
+#include "Box2D/Collision/Shapes/b2ChainShape.h"
+#include "Box2D/Collision/Shapes/b2PolygonShape.h"
+#include "Box2D/Collision/b2TimeOfImpact.h"
+#include "Box2D/Common/b2Draw.h"
+#include "Box2D/Common/b2Timer.h"
 #include <new>
 
 b2World::b2World(const b2Vec2& gravity)
 {
 	m_destructionListener = NULL;
-	m_debugDraw = NULL;
+	g_debugDraw = NULL;
 
 	m_bodyList = NULL;
 	m_jointList = NULL;
@@ -101,7 +101,7 @@ void b2World::SetContactListener(b2ContactListener* listener)
 
 void b2World::SetDebugDraw(b2Draw* debugDraw)
 {
-	m_debugDraw = debugDraw;
+	g_debugDraw = debugDraw;
 }
 
 b2Body* b2World::CreateBody(const b2BodyDef* def)
@@ -1040,7 +1040,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
 			float32 radius = circle->m_radius;
 			b2Vec2 axis = b2Mul(xf.q, b2Vec2(1.0f, 0.0f));
 
-			m_debugDraw->DrawSolidCircle(center, radius, axis, color);
+			g_debugDraw->DrawSolidCircle(center, radius, axis, color);
 		}
 		break;
 
@@ -1049,7 +1049,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
 			b2EdgeShape* edge = (b2EdgeShape*)fixture->GetShape();
 			b2Vec2 v1 = b2Mul(xf, edge->m_vertex1);
 			b2Vec2 v2 = b2Mul(xf, edge->m_vertex2);
-			m_debugDraw->DrawSegment(v1, v2, color);
+			g_debugDraw->DrawSegment(v1, v2, color);
 		}
 		break;
 
@@ -1059,14 +1059,32 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
 			int32 count = chain->m_count;
 			const b2Vec2* vertices = chain->m_vertices;
 
+			b2Color ghostColor(0.75f * color.r, 0.75f * color.g, 0.75f * color.b, color.a);
+
 			b2Vec2 v1 = b2Mul(xf, vertices[0]);
+			g_debugDraw->DrawPoint(v1, 4.0f, color);
+
+			if (chain->m_hasPrevVertex)
+			{
+				b2Vec2 vp = b2Mul(xf, chain->m_prevVertex);
+				g_debugDraw->DrawSegment(vp, v1, ghostColor);
+				g_debugDraw->DrawCircle(vp, 0.1f, ghostColor);
+			}
+
 			for (int32 i = 1; i < count; ++i)
 			{
 				b2Vec2 v2 = b2Mul(xf, vertices[i]);
-				m_debugDraw->DrawSegment(v1, v2, color);
-				m_debugDraw->DrawCircle(v1, 0.05f, color);
+				g_debugDraw->DrawSegment(v1, v2, color);
+				g_debugDraw->DrawPoint(v2, 4.0f, color);
 				v1 = v2;
 			}
+
+			if (chain->m_hasNextVertex)
+			{
+				b2Vec2 vn = b2Mul(xf, chain->m_nextVertex);
+				g_debugDraw->DrawSegment(v1, vn, ghostColor);
+				g_debugDraw->DrawCircle(vn, 0.1f, ghostColor);
+			}
 		}
 		break;
 
@@ -1082,7 +1100,7 @@ void b2World::DrawShape(b2Fixture* fixture, const b2Transform& xf, const b2Color
 				vertices[i] = b2Mul(xf, poly->m_vertices[i]);
 			}
 
-			m_debugDraw->DrawSolidPolygon(vertices, vertexCount, color);
+			g_debugDraw->DrawSolidPolygon(vertices, vertexCount, color);
 		}
 		break;
             
@@ -1107,7 +1125,7 @@ void b2World::DrawJoint(b2Joint* joint)
 	switch (joint->GetType())
 	{
 	case e_distanceJoint:
-		m_debugDraw->DrawSegment(p1, p2, color);
+		g_debugDraw->DrawSegment(p1, p2, color);
 		break;
 
 	case e_pulleyJoint:
@@ -1115,9 +1133,9 @@ void b2World::DrawJoint(b2Joint* joint)
 			b2PulleyJoint* pulley = (b2PulleyJoint*)joint;
 			b2Vec2 s1 = pulley->GetGroundAnchorA();
 			b2Vec2 s2 = pulley->GetGroundAnchorB();
-			m_debugDraw->DrawSegment(s1, p1, color);
-			m_debugDraw->DrawSegment(s2, p2, color);
-			m_debugDraw->DrawSegment(s1, s2, color);
+			g_debugDraw->DrawSegment(s1, p1, color);
+			g_debugDraw->DrawSegment(s2, p2, color);
+			g_debugDraw->DrawSegment(s1, s2, color);
 		}
 		break;
 
@@ -1126,20 +1144,20 @@ void b2World::DrawJoint(b2Joint* joint)
 		break;
 
 	default:
-		m_debugDraw->DrawSegment(x1, p1, color);
-		m_debugDraw->DrawSegment(p1, p2, color);
-		m_debugDraw->DrawSegment(x2, p2, color);
+		g_debugDraw->DrawSegment(x1, p1, color);
+		g_debugDraw->DrawSegment(p1, p2, color);
+		g_debugDraw->DrawSegment(x2, p2, color);
 	}
 }
 
 void b2World::DrawDebugData()
 {
-	if (m_debugDraw == NULL)
+	if (g_debugDraw == NULL)
 	{
 		return;
 	}
 
-	uint32 flags = m_debugDraw->GetFlags();
+	uint32 flags = g_debugDraw->GetFlags();
 
 	if (flags & b2Draw::e_shapeBit)
 	{
@@ -1191,7 +1209,7 @@ void b2World::DrawDebugData()
 			//b2Vec2 cA = fixtureA->GetAABB().GetCenter();
 			//b2Vec2 cB = fixtureB->GetAABB().GetCenter();
 
-			//m_debugDraw->DrawSegment(cA, cB, color);
+			//g_debugDraw->DrawSegment(cA, cB, color);
 		}
 	}
 
@@ -1219,7 +1237,7 @@ void b2World::DrawDebugData()
 					vs[2].Set(aabb.upperBound.x, aabb.upperBound.y);
 					vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y);
 
-					m_debugDraw->DrawPolygon(vs, 4, color);
+					g_debugDraw->DrawPolygon(vs, 4, color);
 				}
 			}
 		}
@@ -1231,7 +1249,7 @@ void b2World::DrawDebugData()
 		{
 			b2Transform xf = b->GetTransform();
 			xf.p = b->GetWorldCenter();
-			m_debugDraw->DrawTransform(xf);
+			g_debugDraw->DrawTransform(xf);
 		}
 	}
 }

+ 7 - 7
Source/ThirdParty/Box2D/Box2D/Dynamics/b2World.h

@@ -19,12 +19,12 @@
 #ifndef B2_WORLD_H
 #define B2_WORLD_H
 
-#include <Box2D/Common/b2Math.h>
-#include <Box2D/Common/b2BlockAllocator.h>
-#include <Box2D/Common/b2StackAllocator.h>
-#include <Box2D/Dynamics/b2ContactManager.h>
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
-#include <Box2D/Dynamics/b2TimeStep.h>
+#include "Box2D/Common/b2Math.h"
+#include "Box2D/Common/b2BlockAllocator.h"
+#include "Box2D/Common/b2StackAllocator.h"
+#include "Box2D/Dynamics/b2ContactManager.h"
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
+#include "Box2D/Dynamics/b2TimeStep.h"
 
 struct b2AABB;
 struct b2BodyDef;
@@ -247,7 +247,7 @@ private:
 	bool m_allowSleep;
 
 	b2DestructionListener* m_destructionListener;
-	b2Draw* m_debugDraw;
+	b2Draw* g_debugDraw;
 
 	// This is used to compute the time step ratio to
 	// support a variable time step.

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Dynamics/b2WorldCallbacks.cpp

@@ -16,8 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Dynamics/b2WorldCallbacks.h>
-#include <Box2D/Dynamics/b2Fixture.h>
+#include "Box2D/Dynamics/b2WorldCallbacks.h"
+#include "Box2D/Dynamics/b2Fixture.h"
 
 // Return true if contact calculations should be performed between these two shapes.
 // If you implement your own collision filter you may want to build from this implementation.

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Dynamics/b2WorldCallbacks.h

@@ -19,7 +19,7 @@
 #ifndef B2_WORLD_CALLBACKS_H
 #define B2_WORLD_CALLBACKS_H
 
-#include <Box2D/Common/b2Settings.h>
+#include "Box2D/Common/b2Settings.h"
 
 struct b2Vec2;
 struct b2Transform;

+ 2 - 2
Source/ThirdParty/Box2D/Box2D/Rope/b2Rope.cpp

@@ -16,8 +16,8 @@
 * 3. This notice may not be removed or altered from any source distribution.
 */
 
-#include <Box2D/Rope/b2Rope.h>
-#include <Box2D/Common/b2Draw.h>
+#include "Box2D/Rope/b2Rope.h"
+#include "Box2D/Common/b2Draw.h"
 
 b2Rope::b2Rope()
 {

+ 1 - 1
Source/ThirdParty/Box2D/Box2D/Rope/b2Rope.h

@@ -19,7 +19,7 @@
 #ifndef B2_ROPE_H
 #define B2_ROPE_H
 
-#include <Box2D/Common/b2Math.h>
+#include "Box2D/Common/b2Math.h"
 
 class b2Draw;
 

+ 1 - 0
Source/Urho3D/AngelScript/Urho2DAPI.cpp

@@ -346,6 +346,7 @@ static void RegisterRigidBody2D(asIScriptEngine* engine)
     engine->RegisterObjectMethod("RigidBody2D", "void ApplyForceToCenter(const Vector2&in, bool)", asMETHOD(RigidBody2D, ApplyForceToCenter), asCALL_THISCALL);
     engine->RegisterObjectMethod("RigidBody2D", "void ApplyTorque(float torque, bool)", asMETHOD(RigidBody2D, ApplyTorque), asCALL_THISCALL);
     engine->RegisterObjectMethod("RigidBody2D", "void ApplyLinearImpulse(const Vector2&in, const Vector2&in, bool)", asMETHOD(RigidBody2D, ApplyLinearImpulse), asCALL_THISCALL);
+    engine->RegisterObjectMethod("RigidBody2D", "void ApplyLinearImpulseToCenter(const Vector2&in, bool)", asMETHOD(RigidBody2D, ApplyLinearImpulseToCenter), asCALL_THISCALL);
     engine->RegisterObjectMethod("RigidBody2D", "void ApplyAngularImpulse(float, bool)", asMETHOD(RigidBody2D, ApplyAngularImpulse), asCALL_THISCALL);
 }
 

+ 1 - 0
Source/Urho3D/LuaScript/pkgs/Urho2D/RigidBody2D.pkg

@@ -27,6 +27,7 @@ class RigidBody2D : Component
     void ApplyForceToCenter(const Vector2& force, bool wake);
     void ApplyTorque(float torque, bool wake);
     void ApplyLinearImpulse(const Vector2& impulse, const Vector2& point, bool wake);
+    void ApplyLinearImpulseToCenter(const Vector2& impulse, bool wake);
     void ApplyAngularImpulse(float impulse, bool wake);
 
     BodyType2D GetBodyType() const;

+ 0 - 12
Source/Urho3D/Urho2D/PhysicsUtils2D.h

@@ -56,16 +56,4 @@ inline Vector3 ToVector3(const b2Vec2& vec2)
     return Vector3(vec2.x, vec2.y, 0.0f);
 }
 
-/*
-inline bool operator == (const b2Vec2& left, const b2Vec2& right)
-{
-    return left.x == right.x && left.y == right.y;
-}
-*/
-
-inline bool operator !=(const b2Vec2& left, const b2Vec2& right)
-{
-    return left.x != right.x || left.y != right.y;
-}
-
 }

+ 7 - 0
Source/Urho3D/Urho2D/PhysicsWorld2D.cpp

@@ -176,6 +176,13 @@ void PhysicsWorld2D::DrawCircle(const b2Vec2& center, float32 radius, const b2Co
     }
 }
 
+extern URHO3D_API const float PIXEL_SIZE;
+
+void PhysicsWorld2D::DrawPoint(const b2Vec2& p, float32 size, const b2Color& color)
+{
+    DrawSolidCircle(p, size * 0.5f * PIXEL_SIZE, b2Vec2(), color);
+}
+
 void PhysicsWorld2D::DrawSolidCircle(const b2Vec2& center, float32 radius, const b2Vec2& axis, const b2Color& color)
 {
     if (!debugRenderer_)

+ 2 - 0
Source/Urho3D/Urho2D/PhysicsWorld2D.h

@@ -105,6 +105,8 @@ public:
     virtual void DrawSegment(const b2Vec2& p1, const b2Vec2& p2, const b2Color& color);
     /// Draw a transform. Choose your own length scale.
     virtual void DrawTransform(const b2Transform& xf);
+    /// Draw a point.
+    virtual void DrawPoint(const b2Vec2& p, float32 size, const b2Color& color);
 
     /// Step the simulation forward.
     void Update(float timeStep);

+ 6 - 1
Source/Urho3D/Urho2D/RigidBody2D.cpp

@@ -175,7 +175,6 @@ void RigidBody2D::SetUseFixtureMass(bool useFixtureMass)
 
     if (body_)
     {
-        body_->m_useFixtureMass = useFixtureMass;
         if (useFixtureMass_)
             body_->ResetMassData();
         else
@@ -351,6 +350,12 @@ void RigidBody2D::ApplyLinearImpulse(const Vector2& impulse, const Vector2& poin
         body_->ApplyLinearImpulse(ToB2Vec2(impulse), ToB2Vec2(point), wake);
 }
 
+void RigidBody2D::ApplyLinearImpulseToCenter(const Vector2& impulse, bool wake)
+{
+    if (body_ && impulse != Vector2::ZERO)
+        body_->ApplyLinearImpulseToCenter(ToB2Vec2(impulse), wake);
+}
+
 void RigidBody2D::ApplyAngularImpulse(float impulse, bool wake)
 {
     if (body_)

+ 2 - 0
Source/Urho3D/Urho2D/RigidBody2D.h

@@ -93,6 +93,8 @@ public:
     void ApplyTorque(float torque, bool wake);
     /// Apply linear impulse.
     void ApplyLinearImpulse(const Vector2& impulse, const Vector2& point, bool wake);
+    /// Apply linear impulse to center.
+    void ApplyLinearImpulseToCenter(const Vector2& impulse, bool wake);
     /// Apply angular impulse.
     void ApplyAngularImpulse(float impulse, bool wake);