summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan "Geenz" Goodman <geenz@geenzo.com>2023-09-25 12:18:02 -0700
committerJonathan "Geenz" Goodman <geenz@geenzo.com>2023-09-25 12:18:02 -0700
commitd092f3e1dc1c322a0c3c1e55b9b6e1792d6b0f59 (patch)
treef954603aa0d9ea64419c71e4cac05972519dea2b
parent73870cb0b41144dc9932947d13d6aa27952d8849 (diff)
Get the average normal of the face.
DRTVWR-583
-rw-r--r--indra/newview/llface.cpp27
-rw-r--r--indra/newview/llface.h5
-rw-r--r--indra/newview/llheroprobemanager.cpp10
3 files changed, 42 insertions, 0 deletions
diff --git a/indra/newview/llface.cpp b/indra/newview/llface.cpp
index c1776705f9..4dd991ee60 100644
--- a/indra/newview/llface.cpp
+++ b/indra/newview/llface.cpp
@@ -488,6 +488,33 @@ U16 LLFace::getGeometry(LLStrider<LLVector3> &vertices, LLStrider<LLVector3> &no
return mGeomIndex;
}
+LLVector3 LLFace::getAverageNormal()
+{
+ if (!mHasAverageNormal)
+ {
+ if (mVertexBuffer.notNull())
+ {
+ if (mVertexBuffer->hasDataType(LLVertexBuffer::TYPE_NORMAL))
+ {
+ LLStrider<LLVector3> normals;
+ mVertexBuffer->getNormalStrider(normals, mGeomIndex, mGeomCount);
+ LLVector3 normal_total;
+
+ for (int i = 0; i < mVertexBuffer->getNumVerts(); i++)
+ {
+ normal_total += *normals.get();
+ normals++;
+ }
+
+ mAverageNormal = normal_total / mVertexBuffer->getNumVerts();
+ mHasAverageNormal = true;
+ }
+ }
+ }
+
+ return mAverageNormal;
+}
+
void LLFace::updateCenterAgent()
{
if (mDrawablep->isActive())
diff --git a/indra/newview/llface.h b/indra/newview/llface.h
index eb3b47d6d6..d4f4313073 100644
--- a/indra/newview/llface.h
+++ b/indra/newview/llface.h
@@ -176,6 +176,8 @@ public:
LLStrider<LLVector3> &normals,
LLStrider<LLVector2> &texCoords,
LLStrider<U16> &indices);
+
+ LLVector3 getAverageNormal();
S32 getColors(LLStrider<LLColor4U> &colors);
S32 getIndices(LLStrider<U16> &indices);
@@ -278,6 +280,9 @@ private:
U32 mIndicesCount;
U32 mIndicesIndex; // index into mVertexBuffer's index array
S32 mIndexInTex[LLRender::NUM_TEXTURE_CHANNELS];
+
+ LLVector3 mAverageNormal;
+ bool mHasAverageNormal;
LLXformMatrix* mXform;
diff --git a/indra/newview/llheroprobemanager.cpp b/indra/newview/llheroprobemanager.cpp
index 687ebbf168..c3d7ce6e76 100644
--- a/indra/newview/llheroprobemanager.cpp
+++ b/indra/newview/llheroprobemanager.cpp
@@ -118,11 +118,20 @@ void LLHeroProbeManager::update()
F32 angleInRadians = 180 * DEG_TO_RAD;
LLMatrix4 rotationMatrix;
+
+ rotationMatrix.rotate(angleInRadians, LLVector4(mNearestHero->mDrawable->getFace(0)->getAverageNormal()));
LLVector3 translatedPoint;
LLVector3 rotatedTranslatedPoint;
LLVector3 rotatedPoint;
+ translatedPoint = camera_pos - hero_pos;
+ rotatedTranslatedPoint = translatedPoint * rotationMatrix;
+ rotatedPoint = rotatedTranslatedPoint + hero_pos;
+
+ probe_pos.load3(rotatedPoint.mV);
+
+ /*
switch (mNearestHero->mirrorPlacementMode()) {
case 0:
@@ -161,6 +170,7 @@ void LLHeroProbeManager::update()
probe_pos.load3(rotatedPoint.mV);
break;
}
+ */
}
mHeroProbeStrength = 1;