From fde77add79563ed00146c78f10a30eea1966c6ab Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Wed, 1 Aug 2018 11:49:18 -0700 Subject: [PATCH 1/2] Elbow pole vectors fixes --- libraries/animation/src/Rig.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 33f14e121e..64f4708903 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -1547,16 +1547,18 @@ bool Rig::calculateElbowPoleVector(int handIndex, int elbowIndex, int armIndex, glm::vec3 backVector = oppositeArmPose.trans() - armPose.trans(); glm::vec3 backCenter = armPose.trans() + 0.5f * backVector; - const float OVER_BACK_HEAD_PERCENTAGE = 0.2f; + glm::vec3 frontVector = glm::normalize(glm::cross(backVector, Vectors::UNIT_Y)); + glm::vec3 topVector = glm::normalize(glm::cross(frontVector, backVector)); + + glm::vec3 centerToHand = handPose.trans() - backCenter; + glm::vec3 headCenter = backCenter + glm::length(backVector) * topVector; - glm::vec3 headCenter = backCenter + glm::vec3(0, OVER_BACK_HEAD_PERCENTAGE * backVector.length(), 0); - glm::vec3 frontVector = glm::normalize(glm::cross(backVector, glm::vec3(0, 1, 0))); // Make sure is pointing forward frontVector = frontVector.z < 0 ? -frontVector : frontVector; - float horizontalModule = glm::dot(armToHand, glm::vec3(0, -1, 0)); - glm::vec3 headForward = headCenter + horizontalModule * frontVector; + float horizontalModule = glm::dot(centerToHand, -topVector); + glm::vec3 headForward = headCenter + glm::max(0.0f, horizontalModule) * frontVector; glm::vec3 armToHead = headForward - armPose.trans(); float armToHandDistance = glm::length(armToHand); @@ -1570,8 +1572,10 @@ bool Rig::calculateElbowPoleVector(int handIndex, int elbowIndex, int armIndex, // How much the hand is reaching for the opposite side float oppositeProjection = glm::dot(armToHandDir, glm::normalize(backVector)); - // Don't use pole vector when the hands are behind - if (glm::dot(frontVector, armToHand) < 0 && oppositeProjection < 0.5f * armTotalDistance) { + bool isCrossed = glm::dot(centerToHand, backVector) > 0; + bool isBehind = glm::dot(frontVector, armToHand) < 0; + // Don't use pole vector when the hands are behind the back and the arms are not crossed + if (isBehind && !isCrossed) { return false; } @@ -1585,7 +1589,7 @@ bool Rig::calculateElbowPoleVector(int handIndex, int elbowIndex, int armIndex, glm::vec3 correctionVector = glm::vec3(0, 0, 0); const float FORWARD_TRIGGER_PERCENTAGE = 0.2f; - const float FORWARD_CORRECTOR_WEIGHT = 3.0f; + const float FORWARD_CORRECTOR_WEIGHT = 2.3f; float elbowForwardTrigger = FORWARD_TRIGGER_PERCENTAGE * armToHandDistance; From 2f358f3380082a44438958c969c96b324a072d56 Mon Sep 17 00:00:00 2001 From: SamGondelman Date: Thu, 2 Aug 2018 11:33:39 -0700 Subject: [PATCH 2/2] fix shapes always drawing as transparents --- libraries/entities-renderer/src/RenderableEntityItem.cpp | 9 +++++++++ .../entities-renderer/src/RenderableShapeEntityItem.cpp | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/libraries/entities-renderer/src/RenderableEntityItem.cpp b/libraries/entities-renderer/src/RenderableEntityItem.cpp index 78801df715..f04ee28d7f 100644 --- a/libraries/entities-renderer/src/RenderableEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableEntityItem.cpp @@ -336,6 +336,11 @@ bool EntityRenderer::needsRenderUpdate() const { if (_needsRenderUpdate) { return true; } + + if (isFading()) { + return true; + } + if (_prevIsTransparent != isTransparent()) { return true; } @@ -380,6 +385,10 @@ void EntityRenderer::updateModelTransformAndBound() { void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) { DETAILED_PROFILE_RANGE(simulation_physics, __FUNCTION__); withWriteLock([&] { + if (isFading()) { + emit requestRenderUpdate(); + } + auto transparent = isTransparent(); if (_prevIsTransparent && !transparent) { _isFading = false; diff --git a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp index c50b3bd760..3fd79ffad1 100644 --- a/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableShapeEntityItem.cpp @@ -216,7 +216,14 @@ ShapeKey ShapeEntityRenderer::getShapeKey() { return builder.build(); } else { - return Parent::getShapeKey(); + ShapeKey::Builder builder; + if (_procedural.isReady()) { + builder.withOwnPipeline(); + } + if (isTransparent()) { + builder.withTranslucent(); + } + return builder.build(); } }