summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatermodelpreview.cpp
diff options
context:
space:
mode:
authorBjoseph Wombat <bjoseph@vivox.com>2015-05-11 14:57:57 +0100
committerBjoseph Wombat <bjoseph@vivox.com>2015-05-11 14:57:57 +0100
commitc6650c13306b0d049ecba02710645b9ca2d90c05 (patch)
tree54932d9221df41ec9c608b70eeb5379fcb1d72c3 /indra/newview/llfloatermodelpreview.cpp
parent7ec58ee04789a8cc819d1151529d843045651bc8 (diff)
parente611e35e033e99f619b0e4938f6879c8e387efd5 (diff)
updates from bitbucket repository
Diffstat (limited to 'indra/newview/llfloatermodelpreview.cpp')
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp80
1 files changed, 73 insertions, 7 deletions
diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp
index ec905558aa..72c9170b06 100755
--- a/indra/newview/llfloatermodelpreview.cpp
+++ b/indra/newview/llfloatermodelpreview.cpp
@@ -732,6 +732,11 @@ void LLFloaterModelPreview::toggleGenarateNormals()
{
bool enabled = childGetValue("gen_normals").asBoolean();
childSetEnabled("crease_angle", enabled);
+ if(enabled) {
+ mModelPreview->generateNormals();
+ } else {
+ mModelPreview->restoreNormals();
+ }
}
//static
@@ -2155,7 +2160,7 @@ bool LLModelLoader::loadFromSLM(const std::string& filename)
S32 file_size = (S32) stat.st_size;
- llifstream ifstream(filename, std::ifstream::in | std::ifstream::binary);
+ llifstream ifstream(filename.c_str(), std::ifstream::in | std::ifstream::binary);
LLSD data;
LLSDSerialize::fromBinary(data, ifstream, file_size);
ifstream.close();
@@ -3513,7 +3518,7 @@ void LLModelPreview::saveUploadData(const std::string& filename, bool save_skinw
data["instance"][i] = instance.asLLSD();
}
- llofstream out(filename, std::ios_base::out | std::ios_base::binary);
+ llofstream out(filename.c_str(), std::ios_base::out | std::ios_base::binary);
LLSDSerialize::toBinary(data, out);
out.flush();
out.close();
@@ -3834,7 +3839,6 @@ void LLModelPreview::generateNormals()
S32 which_lod = mPreviewLOD;
-
if (which_lod > 4 || which_lod < 0 ||
mModel[which_lod].empty())
{
@@ -3849,19 +3853,81 @@ 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(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)
+ {
+ if(perform_copy)
+ {
+ v_LLVolumeFace_t faces;
+ (*it)->copyFacesTo(faces);
+ mModelFacesCopy[which_lod].push_back(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())
{
- (*iter)->generateNormals(angle_cutoff);
+ 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();
updateStatusMessages();