From 954cac907dfa002317308d30c213860a3be249a8 Mon Sep 17 00:00:00 2001 From: luiscuenca Date: Tue, 12 Feb 2019 15:02:56 -0700 Subject: [PATCH] Other avatars after update and mod timer when active --- interface/src/avatar/AvatarManager.cpp | 11 +++------- interface/src/avatar/MyAvatar.cpp | 8 +++++++ interface/src/avatar/MyAvatar.h | 2 ++ libraries/animation/src/Flow.cpp | 30 +++++++++++--------------- libraries/animation/src/Flow.h | 1 - 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 50e8546979..d2ba7149f2 100755 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -271,14 +271,6 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { if (avatar->getSkeletonModel()->isLoaded()) { // remove the orb if it is there avatar->removeOrb(); - if (avatar->getWorkloadRegion() == workload::Region::R1) { - auto &flow = _myAvatar->getSkeletonModel()->getRig().getFlow(); - for (auto &handJointName : HAND_COLLISION_JOINTS) { - int jointIndex = avatar->getJointIndex(handJointName); - glm::vec3 position = avatar->getJointPosition(jointIndex); - flow.setOthersCollision(avatar->getID(), jointIndex, position); - } - } if (avatar->needsPhysicsUpdate()) { _avatarsToChangeInPhysics.insert(avatar); } @@ -305,6 +297,9 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { avatar->setIsNewAvatar(false); } avatar->simulate(deltaTime, inView); + if (avatar->getSkeletonModel()->isLoaded() && avatar->getWorkloadRegion() == workload::Region::R1) { + _myAvatar->addAvatarHandsToFlow(avatar); + } avatar->updateRenderItem(renderTransaction); avatar->updateSpaceProxy(workloadTransaction); avatar->setLastRenderUpdateTime(startTime); diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 92d9270d20..d5f8f8a3ec 100755 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -5312,3 +5312,11 @@ void MyAvatar::releaseGrab(const QUuid& grabID) { } } +void MyAvatar::addAvatarHandsToFlow(const std::shared_ptr& otherAvatar) { + auto &flow = _skeletonModel->getRig().getFlow(); + for (auto &handJointName : HAND_COLLISION_JOINTS) { + int jointIndex = otherAvatar->getJointIndex(handJointName); + glm::vec3 position = otherAvatar->getJointPosition(jointIndex); + flow.setOthersCollision(otherAvatar->getID(), jointIndex, position); + } +} diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 0d27988543..996abcabf2 100755 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -1182,6 +1182,8 @@ public: void updateAvatarEntity(const QUuid& entityID, const QByteArray& entityData) override; void avatarEntityDataToJson(QJsonObject& root) const override; int sendAvatarDataPacket(bool sendAll = false) override; + + void addAvatarHandsToFlow(const std::shared_ptr& otherAvatar); public slots: diff --git a/libraries/animation/src/Flow.cpp b/libraries/animation/src/Flow.cpp index 87d7155abd..8aee4dc53c 100644 --- a/libraries/animation/src/Flow.cpp +++ b/libraries/animation/src/Flow.cpp @@ -461,7 +461,6 @@ void Flow::calculateConstraints() { auto simPrefix = SIM_JOINT_PREFIX.toUpper(); auto skeleton = _rig->getAnimSkeleton(); std::vector handsIndices; - _collisionSystem.resetCollisions(); if (skeleton) { for (int i = 0; i < skeleton->getNumJoints(); i++) { auto name = skeleton->getJointName(i); @@ -517,10 +516,6 @@ void Flow::calculateConstraints() { _collisionSystem.addCollisionSphere(i, PRESET_COLLISION_DATA.at(name)); } } - if (isFlowJoint || isSimJoint) { - auto jointInfo = FlowJointInfo(i, parentIndex, -1, name); - _flowJointInfos.push_back(jointInfo); - } } } @@ -604,7 +599,9 @@ void Flow::cleanUp() { _flowJointData.clear(); _jointThreads.clear(); _flowJointKeywords.clear(); - _flowJointInfos.clear(); + _collisionSystem.resetCollisions(); + _initialized = false; + _active = false; } void Flow::setTransform(float scale, const glm::vec3& position, const glm::quat& rotation) { @@ -619,9 +616,9 @@ void Flow::setTransform(float scale, const glm::vec3& position, const glm::quat& } void Flow::update() { - QElapsedTimer _timer; - _timer.start(); if (_initialized && _active) { + QElapsedTimer _timer; + _timer.start(); updateJoints(); int count = 0; for (auto &thread : _jointThreads) { @@ -633,15 +630,14 @@ void Flow::update() { thread.apply(); } setJoints(); - } - _deltaTime += _timer.nsecsElapsed(); - _updates++; - if (_deltaTime > _deltaTimeLimit) { - qDebug() << "Flow C++ update " << _deltaTime / _updates << " nanoSeconds"; - _deltaTime = 0; - _updates = 0; - } - + _deltaTime += _timer.nsecsElapsed(); + _updates++; + if (_deltaTime > _deltaTimeLimit) { + qDebug() << "Flow C++ update " << _deltaTime / _updates << " nanoSeconds"; + _deltaTime = 0; + _updates = 0; + } + } } bool Flow::worldToJointPoint(const glm::vec3& position, const int jointIndex, glm::vec3& jointSpacePosition) const { diff --git a/libraries/animation/src/Flow.h b/libraries/animation/src/Flow.h index ec98b32265..9c088bf263 100644 --- a/libraries/animation/src/Flow.h +++ b/libraries/animation/src/Flow.h @@ -296,7 +296,6 @@ private: std::map _flowJointData; std::vector _jointThreads; std::vector _flowJointKeywords; - std::vector _flowJointInfos; FlowCollisionSystem _collisionSystem; bool _initialized { false }; bool _active { false };