summaryrefslogtreecommitdiff
path: root/indra/newview/llface.cpp
diff options
context:
space:
mode:
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())