summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelpreview.cpp
diff options
context:
space:
mode:
authorruslantproductengine <ruslantproductengine@lindenlab.com>2014-11-28 18:17:54 +0200
committerruslantproductengine <ruslantproductengine@lindenlab.com>2014-11-28 18:17:54 +0200
commitb3c8a559f6e6f340286204328e250312b2e467c5 (patch)
treef430bccbaf2e0b83e9345fcd15ad1250a9bbbd41 /indra/newview/llfloatermodelpreview.cpp
parent5a1f4ac1a71b8d604cbef5f9f42823b494f04a03 (diff)
MAINT-3494 FIXED Generate Normals checkbox does not control generation of normals.
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp75
1 files changed, 70 insertions, 5 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index 73bf7f3e23..f0c580c8ee 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -738,6 +738,11 @@ void LLFloaterModelPreview::toggleGenarateNormals()
{
bool enabled = childGetValue("gen_normals").asBoolean();
childSetEnabled("crease_angle", enabled);
+ if(enabled) {
+ mModelPreview->generateNormals();
+ } else {
+ mModelPreview->restoreNormals();
+ }
}
//static
@@ -3836,7 +3841,6 @@ void LLModelPreview::generateNormals()
S32 which_lod = mPreviewLOD;
-
if (which_lod > 4 || which_lod < 0 ||
mModel[which_lod].empty())
{
@@ -3851,18 +3855,79 @@ void LLModelPreview::generateNormals()
if (which_lod == 3 && !mBaseModel.empty())
{
- for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter)
+ if(mBaseModelFacesCopy.empty())
+ {
+ mBaseModelFacesCopy.reserve(mBaseModel.size());
+ for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it)
+ {
+ v_LLVolumeFace_t faces;
+ (*it)->copyFacesTo(faces);
+ mBaseModelFacesCopy.push_back(std::move(faces));
+ }
+ }
+
+ for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it)
{
- (*iter)->generateNormals(angle_cutoff);
+ (*it)->generateNormals(angle_cutoff);
}
mVertexBuffer[5].clear();
}
- for (LLModelLoader::model_list::iterator iter = mModel[which_lod].begin(); iter != mModel[which_lod].end(); ++iter)
+ bool perform_copy = mModelFacesCopy[which_lod].empty();
+ if(perform_copy) {
+ mModelFacesCopy[which_lod].reserve(mModel[which_lod].size());
+ }
+
+ for (LLModelLoader::model_list::iterator it = mModel[which_lod].begin(), itE = mModel[which_lod].end(); it != itE; ++it)
{
- (*iter)->generateNormals(angle_cutoff);
+ if(perform_copy)
+ {
+ v_LLVolumeFace_t faces;
+ (*it)->copyFacesTo(faces);
+ mModelFacesCopy[which_lod].push_back(std::move(faces));
+ }
+
+ (*it)->generateNormals(angle_cutoff);
+ }
+
+ mVertexBuffer[which_lod].clear();
+ refresh();
+ updateStatusMessages();
+}
+
+void LLModelPreview::restoreNormals()
+{
+ S32 which_lod = mPreviewLOD;
+
+ if (which_lod > 4 || which_lod < 0 ||
+ mModel[which_lod].empty())
+ {
+ return;
+ }
+
+ if(!mBaseModelFacesCopy.empty())
+ {
+ llassert(mBaseModelFacesCopy.size() == mBaseModel.size());
+
+ vv_LLVolumeFace_t::const_iterator itF = mBaseModelFacesCopy.begin();
+ for (LLModelLoader::model_list::iterator it = mBaseModel.begin(), itE = mBaseModel.end(); it != itE; ++it, ++itF)
+ {
+ (*it)->copyFacesFrom((*itF));
+ }
+ }
+ mBaseModelFacesCopy.clear();
+
+
+ if(!mModelFacesCopy[which_lod].empty())
+ {
+ vv_LLVolumeFace_t::const_iterator itF = mModelFacesCopy[which_lod].begin();
+ for (LLModelLoader::model_list::iterator it = mModel[which_lod].begin(), itE = mModel[which_lod].end(); it != itE; ++it, ++itF)
+ {
+ (*it)->copyFacesFrom((*itF));
+ }
}
+ mModelFacesCopy[which_lod].clear();
mVertexBuffer[which_lod].clear();
refresh();