diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp index cb1015b98e..be6eb48158 100644 --- a/indra/newview/llheroprobemanager.cpp +++ b/indra/newview/llheroprobemanager.cpp @@ -140,10 +140,23 @@ void LLHeroProbeManager::update() bool visible = LLViewerCamera::instance().AABBInFrustum(center, size); + // Check if the reflection normal (Z-Up axis) is facing towards the camera + auto reflection_normal = LLVector3(0, 0, 1); + if(visible) + { + vo->mDrawable->getWorldRotation(); + reflection_normal *= vo->mDrawable->getWorldRotation(); + reflection_normal.normalize(); + LLVector3 offset = camera_pos - vo->getPositionAgent(); + visible = (reflection_normal * offset >= 0.0); + } + // + if (distance < last_distance && center_distance < camera_center_distance && visible) { probe_present = true; mNearestHero = vo; + mMirrorNormal = reflection_normal; last_distance = distance; camera_center_distance = center_distance; } @@ -161,10 +174,13 @@ void LLHeroProbeManager::update() if (mNearestHero != nullptr && !mNearestHero->isDead() && mNearestHero->mDrawable.notNull()) { LLVector3 hero_pos = mNearestHero->getPositionAgent(); - LLVector3 face_normal = LLVector3(0, 0, 1); + // let's not redo work we already did + // LLVector3 face_normal = LLVector3(0, 0, 1); - face_normal *= mNearestHero->mDrawable->getWorldRotation(); - face_normal.normalize(); + // face_normal *= mNearestHero->mDrawable->getWorldRotation(); + // face_normal.normalize(); + const LLVector3 face_normal = mMirrorNormal; // this is redundant could use mMirrorNormal but as the code following is likely to change this might make merges simpler. + // LLVector3 offset = camera_pos - hero_pos; LLVector3 project = face_normal * (offset * face_normal); @@ -173,7 +189,7 @@ void LLHeroProbeManager::update() mCurrentClipPlane.setVec(hero_pos, face_normal); mMirrorPosition = hero_pos; - mMirrorNormal = face_normal; + // mMirrorNormal = face_normal; // no need to assign back probe_pos.load3(point.mV);