From 19cd4648adfd8216cc30f71e42a295a407bede03 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Wed, 24 Aug 2016 11:21:47 -0700 Subject: [PATCH] scale collision render mesh correctly --- libraries/entities/src/EntityItem.cpp | 2 +- libraries/physics/src/CollisionRenderMeshCache.cpp | 4 ---- libraries/render-utils/src/Model.cpp | 9 +++++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 29cbfd79e6..68636415f8 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2213,4 +2213,4 @@ void EntityItem::globalizeProperties(EntityItemProperties& properties, const QSt } QUuid empty; properties.setParentID(empty); -} \ No newline at end of file +} diff --git a/libraries/physics/src/CollisionRenderMeshCache.cpp b/libraries/physics/src/CollisionRenderMeshCache.cpp index bd6b761f4e..517e25e1c4 100644 --- a/libraries/physics/src/CollisionRenderMeshCache.cpp +++ b/libraries/physics/src/CollisionRenderMeshCache.cpp @@ -190,10 +190,6 @@ bool CollisionRenderMeshCache::releaseMesh(CollisionRenderMeshCache::Key key) { } CollisionMeshMap::const_iterator itr = _meshMap.find(key); if (itr != _meshMap.end()) { - // we hold at least one reference, and the outer scope also holds at least one - // so we assert that the reference count is not 1 - assert((*itr).second.use_count() != 1); - _pendingGarbage.push_back(key); return true; } diff --git a/libraries/render-utils/src/Model.cpp b/libraries/render-utils/src/Model.cpp index ca0994b837..6f435b2c8d 100644 --- a/libraries/render-utils/src/Model.cpp +++ b/libraries/render-utils/src/Model.cpp @@ -166,6 +166,11 @@ void Model::updateRenderItems() { return; } + glm::vec3 scale = getScale(); + if (_collisionGeometry) { + // _collisionGeometry is already scaled + scale = glm::vec3(1.0f); + } _needsUpdateClusterMatrices = true; _renderItemsNeedUpdate = false; @@ -173,7 +178,7 @@ void Model::updateRenderItems() { // the application will ensure only the last lambda is actually invoked. void* key = (void*)this; std::weak_ptr weakSelf = shared_from_this(); - AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [weakSelf]() { + AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [weakSelf, scale]() { // do nothing, if the model has already been destroyed. auto self = weakSelf.lock(); @@ -184,7 +189,7 @@ void Model::updateRenderItems() { render::ScenePointer scene = AbstractViewStateInterface::instance()->getMain3DScene(); Transform modelTransform; - modelTransform.setScale(self->_scale); + modelTransform.setScale(scale); modelTransform.setTranslation(self->_translation); modelTransform.setRotation(self->_rotation);