From 7b14e13fe61abf50d7e33231ca70c53a879e09d2 Mon Sep 17 00:00:00 2001
From: Daniel Chappuis <chappuis.daniel@gmail.com>
Date: Wed, 22 Aug 2018 18:35:53 +0200
Subject: [PATCH] Fix bug with assert with joints

---
 CHANGELOG.md                 |  1 +
 src/engine/DynamicsWorld.cpp | 11 +++++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 23510726..0c667fb2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
  - Bug [#57](https://github.com/DanielChappuis/reactphysics3d/issues/57) has been fixed.
  - Bug [#37](https://github.com/DanielChappuis/reactphysics3d/issues/37) has been fixed.
  - Bug [#62](https://github.com/DanielChappuis/reactphysics3d/issues/62) has been fixed.
+ - Bug [#63](https://github.com/DanielChappuis/reactphysics3d/issues/63) has been fixed.
 
 ## Version 0.7.0 (May 1, 2018)
 
diff --git a/src/engine/DynamicsWorld.cpp b/src/engine/DynamicsWorld.cpp
index 3e5ab482..4ed879de 100644
--- a/src/engine/DynamicsWorld.cpp
+++ b/src/engine/DynamicsWorld.cpp
@@ -398,11 +398,14 @@ void DynamicsWorld::solvePositionCorrection() {
 
         // ---------- Solve the position error correction for the constraints ---------- //
 
-        // For each iteration of the position (error correction) solver
-        for (uint i=0; i<mNbPositionSolverIterations; i++) {
+        if (mIslands[islandIndex]->getNbJoints() > 0) {
 
-            // Solve the position constraints
-            mConstraintSolver.solvePositionConstraints(mIslands[islandIndex]);
+            // For each iteration of the position (error correction) solver
+            for (uint i=0; i<mNbPositionSolverIterations; i++) {
+
+                // Solve the position constraints
+                mConstraintSolver.solvePositionConstraints(mIslands[islandIndex]);
+            }
         }
     }
 }