summaryrefslogtreecommitdiff
path: root/indra/newview/llface.cpp
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 /indra/newview/llface.cpp
parent73870cb0b41144dc9932947d13d6aa27952d8849 (diff)
Get the average normal of the face.
DRTVWR-583
Diffstat (limited to 'indra/newview/llface.cpp')
-rw-r--r--indra/newview/llface.cpp27
1 files changed, 27 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())