From b75e053e9deb3d92d54abb719870d13d0f363bd4 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 23 Oct 2015 13:37:49 -0700 Subject: [PATCH 01/21] Add automatic CCD activation to the physics engine --- libraries/physics/src/ObjectMotionState.cpp | 18 ++++++++++++++++++ libraries/physics/src/ObjectMotionState.h | 1 + 2 files changed, 19 insertions(+) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index be0edafff5..6f1b928456 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -115,6 +115,21 @@ void ObjectMotionState::setMotionType(MotionType motionType) { _motionType = motionType; } +void ObjectMotionState::updateCCDConfiguration() { + if (_body) { + if (_shape) { + btVector3 center; + btScalar radius; + _shape->getBoundingSphere(center, radius); + _body->setCcdMotionThreshold(radius * 2.0f); + _body->setCcdSweptSphereRadius(radius); + } else { + // Disable CCD + _body->setCcdMotionThreshold(0); + } + } +} + void ObjectMotionState::setRigidBody(btRigidBody* body) { // give the body a (void*) back-pointer to this ObjectMotionState if (_body != body) { @@ -125,6 +140,7 @@ void ObjectMotionState::setRigidBody(btRigidBody* body) { if (_body) { _body->setUserPointer(this); } + updateCCDConfiguration(); } } @@ -187,6 +203,8 @@ bool ObjectMotionState::handleHardAndEasyChanges(uint32_t flags, PhysicsEngine* if (_shape != newShape) { _shape = newShape; _body->setCollisionShape(_shape); + + updateCCDConfiguration(); } else { // huh... the shape didn't actually change, so we clear the DIRTY_SHAPE flag flags &= ~Simulation::DIRTY_SHAPE; diff --git a/libraries/physics/src/ObjectMotionState.h b/libraries/physics/src/ObjectMotionState.h index 992bdd11d7..8c3f3aaca1 100644 --- a/libraries/physics/src/ObjectMotionState.h +++ b/libraries/physics/src/ObjectMotionState.h @@ -151,6 +151,7 @@ protected: virtual bool isReadyToComputeShape() = 0; virtual btCollisionShape* computeNewShape() = 0; void setMotionType(MotionType motionType); + void updateCCDConfiguration(); // clearObjectBackPointer() overrrides should call the base method, then actually clear the object back pointer. virtual void clearObjectBackPointer() { _type = MOTIONSTATE_TYPE_INVALID; } From b410604475a606a53efede906cabc22f1ddacbe1 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 3 Nov 2015 11:18:38 -0800 Subject: [PATCH 02/21] Add comments to updateCCDConfiguration --- libraries/physics/src/ObjectMotionState.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 6f1b928456..5101eabd6a 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -118,10 +118,18 @@ void ObjectMotionState::setMotionType(MotionType motionType) { void ObjectMotionState::updateCCDConfiguration() { if (_body) { if (_shape) { + // If this object moves faster than its bounding radius * RADIUS_MOTION_THRESHOLD_MULTIPLIER, + // CCD will be enabled for this object. + const auto RADIUS_MOTION_THRESHOLD_MULTIPLIER = 2.0f; + btVector3 center; btScalar radius; _shape->getBoundingSphere(center, radius); - _body->setCcdMotionThreshold(radius * 2.0f); + _body->setCcdMotionThreshold(radius * RADIUS_MOTION_THRESHOLD_MULTIPLIER); + + // TODO: Ideally the swept sphere radius would be contained by the object. Using the bounding sphere + // radius works well for spherical objects, but may cause issues with other shapes. For arbitrary + // objects we may want to consider a different approach, such as grouping rigid bodies together. _body->setCcdSweptSphereRadius(radius); } else { // Disable CCD From c0a7da0b88b8903fa1e0aedac464b7b77ac0b35b Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 3 Nov 2015 11:22:15 -0800 Subject: [PATCH 03/21] Add comment to ObjectMotionState::updateCCDConfiguration --- libraries/physics/src/ObjectMotionState.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 5101eabd6a..4f2f2b8184 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -115,6 +115,8 @@ void ObjectMotionState::setMotionType(MotionType motionType) { _motionType = motionType; } +// Update the Continuous Collision Detection (CCD) configuration settings of our RigidBody so that +// CCD will be enabled automatically when its speed surpasses a certain threshold. void ObjectMotionState::updateCCDConfiguration() { if (_body) { if (_shape) { From 7c5f0bb62058283579bfc615c4cc53b0358a6e40 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Tue, 10 Nov 2015 08:51:22 -0800 Subject: [PATCH 04/21] Update RADIUS_MOTION_THRESHOLD_MULTIPLIER --- libraries/physics/src/ObjectMotionState.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/physics/src/ObjectMotionState.cpp b/libraries/physics/src/ObjectMotionState.cpp index 4f2f2b8184..24acb3358c 100644 --- a/libraries/physics/src/ObjectMotionState.cpp +++ b/libraries/physics/src/ObjectMotionState.cpp @@ -122,7 +122,7 @@ void ObjectMotionState::updateCCDConfiguration() { if (_shape) { // If this object moves faster than its bounding radius * RADIUS_MOTION_THRESHOLD_MULTIPLIER, // CCD will be enabled for this object. - const auto RADIUS_MOTION_THRESHOLD_MULTIPLIER = 2.0f; + const auto RADIUS_MOTION_THRESHOLD_MULTIPLIER = 0.5f; btVector3 center; btScalar radius; From 784df60a9750ae2ad32ec4ae9d9d2321e5024abb Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Nov 2015 13:56:20 -0800 Subject: [PATCH 05/21] Update bullet archive to include CCD+Compound improvements --- cmake/externals/bullet/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index efe5b694fa..3322779272 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -18,8 +18,8 @@ if (WIN32) ExternalProject_Add( ${EXTERNAL_NAME} # URL https://bullet.googlecode.com/files/bullet-2.82-r2704.zip - URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-r2704.zip - URL_MD5 f5e8914fc9064ad32e0d62d19d33d977 + URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.zip + URL_MD5 d95b07eb120de7dd7786361c0b5a8d9f CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 -DUSE_DX11=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 @@ -30,8 +30,8 @@ else () ExternalProject_Add( ${EXTERNAL_NAME} #URL http://bullet.googlecode.com/files/bullet-2.82-r2704.tgz - URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-r2704.tgz - URL_MD5 70b3c8d202dee91a0854b4cbc88173e8 + URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.tgz + URL_MD5 eae10a936e100ddf9fe7b1645018f561 CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 @@ -80,4 +80,4 @@ endif () if (DEFINED ${EXTERNAL_NAME_UPPER}_DYNAMICS_LIBRARY_RELEASE) set(${EXTERNAL_NAME_UPPER}_INCLUDE_DIR ${INSTALL_DIR}/include/bullet CACHE PATH "Path to bullet include directory") -endif () \ No newline at end of file +endif () From 7e87ad5114febc0105e1155b62940271f7dff23d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Nov 2015 14:50:31 -0800 Subject: [PATCH 06/21] Update bullet tgz md5sum --- cmake/externals/bullet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index 3322779272..867ff85ea2 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -31,7 +31,7 @@ else () ${EXTERNAL_NAME} #URL http://bullet.googlecode.com/files/bullet-2.82-r2704.tgz URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.tgz - URL_MD5 eae10a936e100ddf9fe7b1645018f561 + URL_MD5 3ffdde88230ddf3c5125a6b25373a2be CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 From 67d07921736a05deb5d7be780269b00ee5ef909d Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Nov 2015 15:09:06 -0800 Subject: [PATCH 07/21] Update bullet tgz md5sum --- cmake/externals/bullet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index 867ff85ea2..402cfbb3dc 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -31,7 +31,7 @@ else () ${EXTERNAL_NAME} #URL http://bullet.googlecode.com/files/bullet-2.82-r2704.tgz URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.tgz - URL_MD5 3ffdde88230ddf3c5125a6b25373a2be + URL_MD5 8082947ba8b07480ea785e5e6b2bab23 CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 From 3aa271d688c87ba4cea77190ae9505214f33a515 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Nov 2015 15:21:53 -0800 Subject: [PATCH 08/21] Update bullet tgz md5sum --- cmake/externals/bullet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index 402cfbb3dc..8990167e1c 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -31,7 +31,7 @@ else () ${EXTERNAL_NAME} #URL http://bullet.googlecode.com/files/bullet-2.82-r2704.tgz URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.tgz - URL_MD5 8082947ba8b07480ea785e5e6b2bab23 + URL_MD5 8d9daf5a46409120fa02c77d02c23c56 CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 From d1e9e28522c2075da9bb2e8a580cc5c3859ce7d3 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 20 Nov 2015 16:11:12 -0800 Subject: [PATCH 09/21] Update bullet tgz md5sum --- cmake/externals/bullet/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/externals/bullet/CMakeLists.txt b/cmake/externals/bullet/CMakeLists.txt index 8990167e1c..ff0eb22241 100644 --- a/cmake/externals/bullet/CMakeLists.txt +++ b/cmake/externals/bullet/CMakeLists.txt @@ -31,7 +31,7 @@ else () ${EXTERNAL_NAME} #URL http://bullet.googlecode.com/files/bullet-2.82-r2704.tgz URL http://hifi-public.s3.amazonaws.com/dependencies/bullet-2.82-ccd-fix.tgz - URL_MD5 8d9daf5a46409120fa02c77d02c23c56 + URL_MD5 fb140a4983b4109aa1c825a162aa8d64 CMAKE_ARGS ${PLATFORM_CMAKE_ARGS} -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH= -DBUILD_EXTRAS=0 -DINSTALL_LIBS=1 -DBUILD_DEMOS=0 -DUSE_GLUT=0 LOG_DOWNLOAD 1 LOG_CONFIGURE 1 From 1409ed2d1892a8bd659a937efb24c0a6b9f97933 Mon Sep 17 00:00:00 2001 From: ericrius1 Date: Mon, 23 Nov 2015 12:28:44 -0800 Subject: [PATCH 10/21] moved logic to build vertices buffer to renderable class, recalculating vertices anytime any of the normals, point, or strokeWidths data changes --- .../painting/whiteboard/whiteboardSpawner.js | 2 +- .../src/RenderablePolyLineEntityItem.cpp | 49 ++++++++++++++++++- .../src/RenderablePolyLineEntityItem.h | 2 + libraries/entities/src/PolyLineEntityItem.cpp | 41 ++-------------- libraries/entities/src/PolyLineEntityItem.h | 3 +- 5 files changed, 56 insertions(+), 41 deletions(-) diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/examples/painting/whiteboard/whiteboardSpawner.js index 56ead143e4..75d5be8967 100644 --- a/examples/painting/whiteboard/whiteboardSpawner.js +++ b/examples/painting/whiteboard/whiteboardSpawner.js @@ -247,4 +247,4 @@ function cleanup() { // Uncomment this line to delete whiteboard and all associated entity on script close -// Script.scriptEnding.connect(cleanup); \ No newline at end of file +Script.scriptEnding.connect(cleanup); \ No newline at end of file diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp index 76cf4fac3d..036d37a95b 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.cpp @@ -31,6 +31,7 @@ EntityItemPointer RenderablePolyLineEntityItem::factory(const EntityItemID& enti RenderablePolyLineEntityItem::RenderablePolyLineEntityItem(const EntityItemID& entityItemID, const EntityItemProperties& properties) : PolyLineEntityItem(entityItemID, properties) { _numVertices = 0; + _vertices = QVector(0.0f); } @@ -114,13 +115,56 @@ void RenderablePolyLineEntityItem::updateGeometry() { _numVertices += 2; } _pointsChanged = false; + _normalsChanged = false; + _strokeWidthsChanged = false; +} + +void RenderablePolyLineEntityItem::updateVertices() { + // Calculate the minimum vector size out of normals, points, and stroke widths + int minVectorSize = _normals.size(); + if (_points.size() < minVectorSize) { + minVectorSize = _points.size(); + } + if (_strokeWidths.size() < minVectorSize) { + minVectorSize = _strokeWidths.size(); + } + + _vertices.clear(); + glm::vec3 v1, v2, tangent, binormal, point; + + int finalIndex = minVectorSize - 1; + for (int i = 0; i < finalIndex; i++) { + float width = _strokeWidths.at(i); + point = _points.at(i); + + tangent = _points.at(i); + + tangent = _points.at(i + 1) - point; + glm::vec3 normal = _normals.at(i); + binormal = glm::normalize(glm::cross(tangent, normal)) * width; + + // Check to make sure binormal is not a NAN. If it is, don't add to vertices vector + if (binormal.x != binormal.x) { + continue; + } + v1 = point + binormal; + v2 = point - binormal; + _vertices << v1 << v2; + } + + // For last point we can assume binormals are the same since it represents the last two vertices of quad + point = _points.at(finalIndex); + v1 = point + binormal; + v2 = point - binormal; + _vertices << v1 << v2; + } void RenderablePolyLineEntityItem::render(RenderArgs* args) { QWriteLocker lock(&_quadReadWriteLock); - if (_points.size() < 2 || _normals.size () < 2 || _vertices.size() < 2) { + if (_points.size() < 2 || _normals.size () < 2 || _strokeWidths.size() < 2) { return; } @@ -139,7 +183,8 @@ void RenderablePolyLineEntityItem::render(RenderArgs* args) { Q_ASSERT(getType() == EntityTypes::PolyLine); Q_ASSERT(args->_batch); - if (_pointsChanged) { + if (_pointsChanged || _strokeWidthsChanged || _normalsChanged) { + updateVertices(); updateGeometry(); } diff --git a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h index 618f8c66a6..c49777cfa3 100644 --- a/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h +++ b/libraries/entities-renderer/src/RenderablePolyLineEntityItem.h @@ -40,8 +40,10 @@ public: protected: void updateGeometry(); + void updateVertices(); gpu::BufferPointer _verticesBuffer; unsigned int _numVertices; + QVector _vertices; }; diff --git a/libraries/entities/src/PolyLineEntityItem.cpp b/libraries/entities/src/PolyLineEntityItem.cpp index 45c967f78d..012ec3ca4a 100644 --- a/libraries/entities/src/PolyLineEntityItem.cpp +++ b/libraries/entities/src/PolyLineEntityItem.cpp @@ -34,8 +34,9 @@ PolyLineEntityItem::PolyLineEntityItem(const EntityItemID& entityItemID, const E EntityItem(entityItemID), _lineWidth(DEFAULT_LINE_WIDTH), _pointsChanged(true), +_normalsChanged(true), +_strokeWidthsChanged(true), _points(QVector(0.0f)), -_vertices(QVector(0.0f)), _normals(QVector(0.0f)), _strokeWidths(QVector(0.0f)), _textures("") @@ -106,47 +107,13 @@ bool PolyLineEntityItem::appendPoint(const glm::vec3& point) { bool PolyLineEntityItem::setStrokeWidths(const QVector& strokeWidths) { _strokeWidths = strokeWidths; + _strokeWidthsChanged = true; return true; } bool PolyLineEntityItem::setNormals(const QVector& normals) { _normals = normals; - if (_points.size() < 2 || _normals.size() < 2 || _strokeWidths.size() < 2) { - return false; - } - - int minVectorSize = _normals.size(); - if (_points.size() < minVectorSize) { - minVectorSize = _points.size(); - } - if (_strokeWidths.size() < minVectorSize) { - minVectorSize = _strokeWidths.size(); - } - - _vertices.clear(); - glm::vec3 v1, v2, tangent, binormal, point; - - int finalIndex = minVectorSize -1; - for (int i = 0; i < finalIndex; i++) { - float width = _strokeWidths.at(i); - point = _points.at(i); - - tangent = _points.at(i + 1) - point; - glm::vec3 normal = normals.at(i); - binormal = glm::normalize(glm::cross(tangent, normal)) * width; - - //This checks to make sure binormal is not a NAN - assert(binormal.x == binormal.x); - v1 = point + binormal; - v2 = point - binormal; - _vertices << v1 << v2; - } - //for last point we can just assume binormals are same since it represents last two vertices of quad - point = _points.at(finalIndex); - v1 = point + binormal; - v2 = point - binormal; - _vertices << v1 << v2; - + _normalsChanged = true; return true; } diff --git a/libraries/entities/src/PolyLineEntityItem.h b/libraries/entities/src/PolyLineEntityItem.h index 9e9d3f9013..4da52f3f21 100644 --- a/libraries/entities/src/PolyLineEntityItem.h +++ b/libraries/entities/src/PolyLineEntityItem.h @@ -93,8 +93,9 @@ class PolyLineEntityItem : public EntityItem { rgbColor _color; float _lineWidth; bool _pointsChanged; + bool _normalsChanged; + bool _strokeWidthsChanged; QVector _points; - QVector _vertices; QVector _normals; QVector _strokeWidths; QString _textures; From 40be9ae1211409c9c34997c544c73201ab163281 Mon Sep 17 00:00:00 2001 From: Eric Levin Date: Mon, 23 Nov 2015 17:15:26 -0800 Subject: [PATCH 11/21] Commented out whiteboard cleanup --- examples/painting/whiteboard/whiteboardSpawner.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/painting/whiteboard/whiteboardSpawner.js b/examples/painting/whiteboard/whiteboardSpawner.js index 75d5be8967..f3005495ec 100644 --- a/examples/painting/whiteboard/whiteboardSpawner.js +++ b/examples/painting/whiteboard/whiteboardSpawner.js @@ -247,4 +247,4 @@ function cleanup() { // Uncomment this line to delete whiteboard and all associated entity on script close -Script.scriptEnding.connect(cleanup); \ No newline at end of file +//Script.scriptEnding.connect(cleanup); From 546f09c0b1248d909ab5e7fd46fdf2bc4fcd1a28 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Wed, 25 Nov 2015 13:30:54 -0800 Subject: [PATCH 12/21] Restore rendering of one's own avatar. --- interface/src/avatar/Avatar.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index f6d73e3beb..17ecae1330 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -96,7 +96,6 @@ Avatar::Avatar(RigPointer rig) : _moving(false), _initialized(false), _shouldRenderBillboard(true), - _shouldSkipRender(true), _voiceSphereID(GeometryCache::UNKNOWN_ID) { // we may have been created in the network thread, but we live in the main thread From 6c7099a5f7b23a0a1dbdb10cff9653de18b670d1 Mon Sep 17 00:00:00 2001 From: Howard Stearns Date: Wed, 25 Nov 2015 15:18:32 -0800 Subject: [PATCH 13/21] Coordinate with other uses of setVisibleInScene. --- interface/src/avatar/Avatar.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 17ecae1330..a52123b3d5 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -197,12 +197,14 @@ void Avatar::simulate(float deltaTime) { if (_shouldSkipRender) { if (distance < renderDistance * (1.0f - SKIP_HYSTERESIS_PROPORTION)) { _shouldSkipRender = false; + _skeletonModel.setVisibleInScene(true, qApp->getMain3DScene()); if (!isControllerLogging) { // Test for isMyAvatar is prophylactic. Never occurs in current code. qCDebug(interfaceapp) << "Rerendering" << (isMyAvatar() ? "myself" : getSessionUUID()) << "for distance" << renderDistance; } } } else if (distance > renderDistance * (1.0f + SKIP_HYSTERESIS_PROPORTION)) { _shouldSkipRender = true; + _skeletonModel.setVisibleInScene(false, qApp->getMain3DScene()); if (!isControllerLogging) { qCDebug(interfaceapp) << "Unrendering" << (isMyAvatar() ? "myself" : getSessionUUID()) << "for distance" << renderDistance; } @@ -608,10 +610,6 @@ void Avatar::fixupModelsInScene() { // check to see if when we added our models to the scene they were ready, if they were not ready, then // fix them up in the scene render::ScenePointer scene = qApp->getMain3DScene(); - _skeletonModel.setVisibleInScene(!_shouldSkipRender, scene); - if (_shouldSkipRender) { - return; - } render::PendingChanges pendingChanges; if (_skeletonModel.isRenderable() && _skeletonModel.needsFixupInScene()) { _skeletonModel.removeFromScene(scene, pendingChanges); From 9ec2a01475c60f6653c2e69dcf08f81b9e63dbe1 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Fri, 27 Nov 2015 12:13:53 -0800 Subject: [PATCH 14/21] isolate grab script changes from bow branch --- examples/controllers/handControllerGrab.js | 92 +++++++++++++--------- 1 file changed, 55 insertions(+), 37 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index f8a2eeefa5..0a6aec6e7d 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -37,6 +37,7 @@ var BUMPER_ON_VALUE = 0.5; var DISTANCE_HOLDING_RADIUS_FACTOR = 5; // multiplied by distance between hand and object var DISTANCE_HOLDING_ACTION_TIMEFRAME = 0.1; // how quickly objects move to their new position var DISTANCE_HOLDING_ROTATION_EXAGGERATION_FACTOR = 2.0; // object rotates this much more than hand did + var NO_INTERSECT_COLOR = { red: 10, green: 10, @@ -86,6 +87,7 @@ var ZERO_VEC = { y: 0, z: 0 }; + var NULL_ACTION_ID = "{00000000-0000-0000-000000000000}"; var MSEC_PER_SEC = 1000.0; @@ -95,7 +97,8 @@ var ACTION_TTL = 15; // seconds var ACTION_TTL_REFRESH = 5; var PICKS_PER_SECOND_PER_HAND = 5; var MSECS_PER_SEC = 1000.0; -var GRABBABLE_PROPERTIES = ["position", +var GRABBABLE_PROPERTIES = [ + "position", "rotation", "gravity", "ignoreForCollisions", @@ -104,17 +107,15 @@ var GRABBABLE_PROPERTIES = ["position", "name" ]; - var GRABBABLE_DATA_KEY = "grabbableKey"; // shared with grab.js var GRAB_USER_DATA_KEY = "grabKey"; // shared with grab.js +var BEAM_DISABLER_KEY = 'beamDisablerKey' var DEFAULT_GRABBABLE_DATA = { grabbable: true, invertSolidWhileHeld: false }; -var disabledHand = 'none'; - // states for the state machine var STATE_OFF = 0; @@ -307,7 +308,14 @@ function MyController(hand) { position: closePoint, linePoints: [ZERO_VEC, farPoint], color: color, - lifetime: 0.1 + lifetime: 0.1, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) }); } @@ -322,7 +330,14 @@ function MyController(hand) { position: closePoint, linePoints: [ZERO_VEC, farPoint], color: color, - lifetime: LIFETIME + lifetime: LIFETIME, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) }); } else { var age = Entities.getEntityProperties(this.pointer, "age").age; @@ -396,11 +411,6 @@ function MyController(hand) { this.search = function() { this.grabbedEntity = null; - // if this hand is the one that's disabled, we don't want to search for anything at all - if (this.hand === disabledHand) { - return; - } - if (this.state == STATE_SEARCHING ? this.triggerSmoothedReleased() : this.bumperReleased()) { this.setState(STATE_RELEASE); return; @@ -445,17 +455,7 @@ function MyController(hand) { // the ray is intersecting something we can move. var intersectionDistance = Vec3.distance(pickRay.origin, intersection.intersection); - //this code will disabled the beam for the opposite hand of the one that grabbed it if the entity says so var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, intersection.entityID, DEFAULT_GRABBABLE_DATA); - if (grabbableData["turnOffOppositeBeam"]) { - if (this.hand === RIGHT_HAND) { - disabledHand = LEFT_HAND; - } else { - disabledHand = RIGHT_HAND; - } - } else { - disabledHand = 'none'; - } if (intersection.properties.name == "Grab Debug Entity") { continue; @@ -526,7 +526,14 @@ function MyController(hand) { green: 255, blue: 0 }, - lifetime: 0.1 + lifetime: 0.1, + collisionsWillMove: false, + ignoreForCollisions: true, + userData: JSON.stringify({ + grabbableKey: { + grabbable: false + } + }) }); } @@ -540,8 +547,7 @@ function MyController(hand) { if (typeof grabbableDataForCandidate.grabbable !== 'undefined' && !grabbableDataForCandidate.grabbable) { continue; } - var propsForCandidate = - Entities.getEntityProperties(nearbyEntities[i], GRABBABLE_PROPERTIES); + var propsForCandidate = Entities.getEntityProperties(nearbyEntities[i], GRABBABLE_PROPERTIES); if (propsForCandidate.type == 'Unknown') { continue; @@ -737,15 +743,8 @@ function MyController(hand) { this.nearGrabbing = function() { var now = Date.now(); - var grabbableData = getEntityCustomData(GRABBABLE_DATA_KEY, this.grabbedEntity, DEFAULT_GRABBABLE_DATA); - var turnOffOtherHand = grabbableData["turnOffOtherHand"]; - if (turnOffOtherHand) { - //don't activate the second hand grab because the script is handling the second hand logic - return; - } - if (this.state == STATE_NEAR_GRABBING && this.triggerSmoothedReleased()) { this.setState(STATE_RELEASE); Entities.callEntityMethod(this.grabbedEntity, "releaseGrab"); @@ -1094,10 +1093,6 @@ function MyController(hand) { this.release = function() { - if (this.hand !== disabledHand) { - //release the disabled hand when we let go with the main one - disabledHand = 'none'; - } this.lineOff(); if (this.grabbedEntity !== null) { @@ -1218,12 +1213,35 @@ mapping.from([Controller.Standard.LB]).peek().to(leftController.bumperPress); Controller.enableMapping(MAPPING_NAME); +var handToDisable = 'none'; function update() { - rightController.update(); - leftController.update(); + if (handToDisable !== 0) { + leftController.update(); + } + if (handToDisable !== 1) { + rightController.update(); + } } +Messages.subscribe('Hifi-Beam-Disabler'); + +handleBeamDisablerMessages = function(channel, message, sender) { + + if (sender === MyAvatar.sessionUUID) { + handToDisable = message; + if (message === 'left') { + handToDisable = 1; + } + if (message === 'right') { + handToDisable = 0; + } + } + +} + +Messages.messageReceived.connect(handleBeamDisablerMessages); + function cleanup() { rightController.cleanup(); leftController.cleanup(); From a9e25c51e52a4f81faeadc7efde82863f795efcd Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Fri, 27 Nov 2015 19:47:12 -0800 Subject: [PATCH 15/21] Fix for linker warning LNK4075 on Windows Specifcally, this warning: LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification The fix is to set /OPT:NOREF and /OPT:NOICF on debug builds. --- cmake/macros/LinkHifiLibraries.cmake | 2 +- cmake/macros/SetupHifiProject.cmake | 7 +++++++ interface/CMakeLists.txt | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake/macros/LinkHifiLibraries.cmake b/cmake/macros/LinkHifiLibraries.cmake index 70399bedb4..ed37256b10 100644 --- a/cmake/macros/LinkHifiLibraries.cmake +++ b/cmake/macros/LinkHifiLibraries.cmake @@ -21,7 +21,7 @@ macro(LINK_HIFI_LIBRARIES) include_directories("${HIFI_LIBRARY_DIR}/${HIFI_LIBRARY}/src") add_dependencies(${TARGET_NAME} ${HIFI_LIBRARY}) - + # link the actual library - it is static so don't bubble it up target_link_libraries(${TARGET_NAME} ${HIFI_LIBRARY}) diff --git a/cmake/macros/SetupHifiProject.cmake b/cmake/macros/SetupHifiProject.cmake index 79ca0122c9..77df280d1a 100644 --- a/cmake/macros/SetupHifiProject.cmake +++ b/cmake/macros/SetupHifiProject.cmake @@ -34,6 +34,13 @@ macro(SETUP_HIFI_PROJECT) # find these Qt modules and link them to our own target find_package(Qt5 COMPONENTS ${${TARGET_NAME}_DEPENDENCY_QT_MODULES} REQUIRED) + # disable /OPT:REF and /OPT:ICF for the Debug builds + # This will prevent the following linker warnings + # LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification + if (WIN32) + set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF") + endif() + foreach(QT_MODULE ${${TARGET_NAME}_DEPENDENCY_QT_MODULES}) target_link_libraries(${TARGET_NAME} Qt5::${QT_MODULE}) endforeach() diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index 3357b57858..67ce3f3df8 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -100,6 +100,13 @@ else() add_executable(${TARGET_NAME} ${INTERFACE_SRCS} ${QM}) endif() +# disable /OPT:REF and /OPT:ICF for the Debug builds +# This will prevent the following linker warnings +# LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF' specification +if (WIN32) + set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF") +endif() + # link required hifi libraries link_hifi_libraries(shared octree environment gpu gl procedural model render recording fbx networking model-networking entities avatars From 63cef9c367eb2c2f3085b07828737a2538a0205c Mon Sep 17 00:00:00 2001 From: Anthony Thibault Date: Fri, 27 Nov 2015 20:57:35 -0800 Subject: [PATCH 16/21] Configure fix for quazip 23> CMake Warning (dev) at C:/msys64/home/Anthony/code/hifi/build/ext/vc12/quazip/project/src/quazip-stamp/quazip-configure-Debug.cmake:3 (set): 23> Syntax error in cmake code at 23> 23> C:/msys64/home/Anthony/code/hifi/build/ext/vc12/quazip/project/src/quazip-stamp/quazip-configure-Debug.cmake:3 23> 23> when parsing string 23> 23> C:/Program Files (x86)/CMake/bin/cmake.exe;-DCMAKE_INSTALL_PREFIX:PATH=C:/msys64/home/Anthony/code/hifi/build/ext/vc12/quazip/project;-DCMAKE_PREFIX_PATH=C:\Qt\Qt5.5.1\5.5\msvc2013\lib\cmake;-DCMAKE_INSTALL_NAME_DIR:PATH=C:/msys64/home/Anthony/code/hifi/build/ext/vc12/quazip/project/lib;-DZLIB_ROOT=C:/msys64/home/Anthony/code/hifi/build/ext/vc12/zlib/project;-GVisual Studio 12 2013;C:/msys64/home/Anthony/code/hifi/build/ext/vc12/quazip/project/src/quazip 23> 23> Invalid escape sequence \Q 23> 23> Policy CMP0010 is not set: Bad variable reference syntax is an error. Run 23> "cmake --help-policy CMP0010" for policy details. Use the cmake_policy 23> command to set the policy and suppress this warning. 23> This warning is for project developers. Use -Wno-dev to suppress it. By converting backslashes to slashes before using the QT_CMAKE_PREFIX_PATH environment variable on the command line. --- cmake/externals/quazip/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/externals/quazip/CMakeLists.txt b/cmake/externals/quazip/CMakeLists.txt index db0e218835..ddac942692 100644 --- a/cmake/externals/quazip/CMakeLists.txt +++ b/cmake/externals/quazip/CMakeLists.txt @@ -3,12 +3,14 @@ string(TOUPPER ${EXTERNAL_NAME} EXTERNAL_NAME_UPPER) cmake_policy(SET CMP0046 OLD) include(ExternalProject) + +string(REPLACE \\ / QT_CMAKE_PREFIX_PATH $ENV{QT_CMAKE_PREFIX_PATH}) ExternalProject_Add( ${EXTERNAL_NAME} URL http://s3-us-west-1.amazonaws.com/hifi-production/dependencies/quazip-0.6.2.zip URL_MD5 514851970f1a14d815bdc3ad6267af4d BINARY_DIR ${EXTERNAL_PROJECT_PREFIX}/build - CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=$ENV{QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH= -DCMAKE_PREFIX_PATH=${QT_CMAKE_PREFIX_PATH} -DCMAKE_INSTALL_NAME_DIR:PATH=/lib -DZLIB_ROOT=${ZLIB_ROOT} LOG_DOWNLOAD 1 LOG_CONFIGURE 1 LOG_BUILD 1 From 8f51ee6f580b65b1a5ad45cf7b2fd3311e645fcc Mon Sep 17 00:00:00 2001 From: James Pollack Date: Sat, 28 Nov 2015 22:29:12 -0800 Subject: [PATCH 17/21] rename hand disabler --- examples/controllers/handControllerGrab.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 0a6aec6e7d..158e67b5db 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -1224,17 +1224,17 @@ function update() { } } -Messages.subscribe('Hifi-Beam-Disabler'); +Messages.subscribe('Hifi-Hand-Disabler'); handleBeamDisablerMessages = function(channel, message, sender) { if (sender === MyAvatar.sessionUUID) { handToDisable = message; if (message === 'left') { - handToDisable = 1; + handToDisable = LEFT_HAND; } if (message === 'right') { - handToDisable = 0; + handToDisable = RIGHT_HAND; } } From 1315201bdcb564434ff508e6a464e3d7ca764014 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Sat, 28 Nov 2015 22:55:44 -0800 Subject: [PATCH 18/21] update name of function --- examples/controllers/handControllerGrab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index 158e67b5db..eb07ec4133 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -1226,7 +1226,7 @@ function update() { Messages.subscribe('Hifi-Hand-Disabler'); -handleBeamDisablerMessages = function(channel, message, sender) { +handleHandDisablerMessages = function(channel, message, sender) { if (sender === MyAvatar.sessionUUID) { handToDisable = message; @@ -1240,7 +1240,7 @@ handleBeamDisablerMessages = function(channel, message, sender) { } -Messages.messageReceived.connect(handleBeamDisablerMessages); +Messages.messageReceived.connect(handleHandDisablerMessages); function cleanup() { rightController.cleanup(); From 1e2398cbea6b499c56b852ad07c331b1e375a88f Mon Sep 17 00:00:00 2001 From: James Pollack Date: Sat, 28 Nov 2015 23:04:52 -0800 Subject: [PATCH 19/21] use constants --- examples/controllers/handControllerGrab.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index eb07ec4133..bd63ab55e2 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -1216,10 +1216,10 @@ Controller.enableMapping(MAPPING_NAME); var handToDisable = 'none'; function update() { - if (handToDisable !== 0) { + if (handToDisable !== LEFT_HAND) { leftController.update(); } - if (handToDisable !== 1) { + if (handToDisable !== RIGHT_HAND) { rightController.update(); } } From 55f797838f4e45004dbacebe87d9119ca98fe990 Mon Sep 17 00:00:00 2001 From: James Pollack Date: Sat, 28 Nov 2015 23:22:00 -0800 Subject: [PATCH 20/21] remove unused key --- examples/controllers/handControllerGrab.js | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/controllers/handControllerGrab.js b/examples/controllers/handControllerGrab.js index bd63ab55e2..0812dc8980 100644 --- a/examples/controllers/handControllerGrab.js +++ b/examples/controllers/handControllerGrab.js @@ -109,7 +109,6 @@ var GRABBABLE_PROPERTIES = [ var GRABBABLE_DATA_KEY = "grabbableKey"; // shared with grab.js var GRAB_USER_DATA_KEY = "grabKey"; // shared with grab.js -var BEAM_DISABLER_KEY = 'beamDisablerKey' var DEFAULT_GRABBABLE_DATA = { grabbable: true, From ce100dbbc5e6b7fd0682bddce7b1b2dcf0363bc6 Mon Sep 17 00:00:00 2001 From: David Rowe Date: Mon, 30 Nov 2015 15:10:51 +1300 Subject: [PATCH 21/21] Fix crash in WebWindowClass in debug build setTitle on open WebWindow --- interface/src/scripting/WebWindowClass.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/interface/src/scripting/WebWindowClass.cpp b/interface/src/scripting/WebWindowClass.cpp index 69523f5f9d..a5ce817f87 100644 --- a/interface/src/scripting/WebWindowClass.cpp +++ b/interface/src/scripting/WebWindowClass.cpp @@ -196,5 +196,9 @@ QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* } void WebWindowClass::setTitle(const QString& title) { + if (QThread::currentThread() != thread()) { + QMetaObject::invokeMethod(this, "setTitle", Qt::AutoConnection, Q_ARG(QString, title)); + return; + } _windowWidget->setWindowTitle(title); }