From 7189f766a2e61fcf6925a65840a2ca8d1454c598 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Tue, 13 Dec 2016 20:56:41 -0800 Subject: [PATCH] more hacking --- assignment-client/src/avatars/AvatarMixer.cpp | 5 ++++- .../src/avatars/AvatarMixerClientData.cpp | 11 +++++++++-- assignment-client/src/avatars/AvatarMixerClientData.h | 5 ++--- libraries/shared/src/ViewFrustum.cpp | 2 ++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/assignment-client/src/avatars/AvatarMixer.cpp b/assignment-client/src/avatars/AvatarMixer.cpp index 36952d4fd6..5f031e537e 100644 --- a/assignment-client/src/avatars/AvatarMixer.cpp +++ b/assignment-client/src/avatars/AvatarMixer.cpp @@ -281,9 +281,12 @@ void AvatarMixer::broadcastAvatarData() { // Also check to see if the other node is in our view glm::vec3 otherNodeBoxScale = (otherData->getPosition() - otherData->getGlobalBoundingBoxCorner()) * 2.0f; AABox otherNodeBox(otherData->getGlobalBoundingBoxCorner(), otherNodeBoxScale); + if (!nodeData->otherAvatarInView(otherNodeBox)) { - qDebug() << "Avatar out of view!"; + //qDebug() << "Avatar out of view!"; return false; + } else { + //qDebug() << "Avatar in view!"; } return true; diff --git a/assignment-client/src/avatars/AvatarMixerClientData.cpp b/assignment-client/src/avatars/AvatarMixerClientData.cpp index 3773bd723f..63a1b108b8 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.cpp +++ b/assignment-client/src/avatars/AvatarMixerClientData.cpp @@ -60,10 +60,17 @@ void AvatarMixerClientData::ignoreOther(SharedNodePointer self, SharedNodePointe void AvatarMixerClientData::readViewFrustumPacket(const QByteArray& message) { _currentViewFrustumIsValid = true; _currentViewFrustum.fromByteArray(message); - qDebug() << __FUNCTION__; - _currentViewFrustum.printDebugDetails(); } +bool AvatarMixerClientData::otherAvatarInView(const glm::vec3& otherAvatar) { + return !_currentViewFrustumIsValid || _currentViewFrustum.pointIntersectsFrustum(otherAvatar); +} + +bool AvatarMixerClientData::otherAvatarInView(const AABox& otherAvatarBox) { + return !_currentViewFrustumIsValid || _currentViewFrustum.boxIntersectsKeyhole(otherAvatarBox); +} + + void AvatarMixerClientData::loadJSONStats(QJsonObject& jsonObject) const { jsonObject["display_name"] = _avatar->getDisplayName(); jsonObject["full_rate_distance"] = _fullRateDistance; diff --git a/assignment-client/src/avatars/AvatarMixerClientData.h b/assignment-client/src/avatars/AvatarMixerClientData.h index 85955804a9..b7b7b16ea1 100644 --- a/assignment-client/src/avatars/AvatarMixerClientData.h +++ b/assignment-client/src/avatars/AvatarMixerClientData.h @@ -90,9 +90,8 @@ public: void readViewFrustumPacket(const QByteArray& message); - bool otherAvatarInView(const AABox& otherAvatarBox) { - return !_currentViewFrustumIsValid || _currentViewFrustum.boxIntersectsKeyhole(otherAvatarBox); - } + bool otherAvatarInView(const AABox& otherAvatarBox); + bool otherAvatarInView(const glm::vec3& otherAvatar); private: AvatarSharedPointer _avatar { new AvatarData() }; diff --git a/libraries/shared/src/ViewFrustum.cpp b/libraries/shared/src/ViewFrustum.cpp index ead8f8634e..b4ed462639 100644 --- a/libraries/shared/src/ViewFrustum.cpp +++ b/libraries/shared/src/ViewFrustum.cpp @@ -173,6 +173,8 @@ void ViewFrustum::fromByteArray(const QByteArray& input) { cameraAspectRatio, cameraNearClip, cameraFarClip)); + + calculate(); } }