From 0ac597d76e97878e4215b0528737f50f480b27ed Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Tue, 14 May 2019 16:14:44 -0700 Subject: [PATCH] BUGZ-87 - loading/physics stuck when entering domain A race condition was occurring when multiple entities using the same models were handed over to physics around the same time. The first model is passed to a worker thread to turn it into a shape and subsequent models note they are the same and don't create a shape or worker thread. The physics system was ignoring these, never marking them as ready for physics. --- libraries/physics/src/ShapeManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/ShapeManager.cpp b/libraries/physics/src/ShapeManager.cpp index c37f95b5f1..40ef00d10f 100644 --- a/libraries/physics/src/ShapeManager.cpp +++ b/libraries/physics/src/ShapeManager.cpp @@ -49,11 +49,15 @@ const btCollisionShape* ShapeManager::getShape(const ShapeInfo& info) { const btCollisionShape* shape = nullptr; if (info.getType() == SHAPE_TYPE_STATIC_MESH) { uint64_t hash = info.getHash(); + + // bump the request count to the caller knows we're + // starting or waiting on a thread. + ++_workRequestCount; + const auto itr = std::find(_pendingMeshShapes.begin(), _pendingMeshShapes.end(), hash); if (itr == _pendingMeshShapes.end()) { // start a worker _pendingMeshShapes.push_back(hash); - ++_workRequestCount; // try to recycle old deadWorker ShapeFactory::Worker* worker = _deadWorker; if (!worker) {