summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rwxr-xr-xindra/llmath/llvolume.cpp11
-rwxr-xr-xindra/llmath/llvolume.h3
-rwxr-xr-xindra/llprimitive/llmodel.cpp2
-rwxr-xr-xindra/newview/llfloatermodelpreview.cpp75
-rwxr-xr-xindra/newview/llfloatermodelpreview.h7
5 files changed, 92 insertions, 6 deletions
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index ee2d57a562..8d6b3b926c 100755
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -2685,6 +2685,17 @@ void LLVolume::setMeshAssetLoaded(BOOL loaded)
mIsMeshAssetLoaded = loaded;
}
+void LLVolume::copyFacesTo(std::vector<LLVolumeFace> &faces) const
+{
+ faces = mVolumeFaces;
+}
+
+void LLVolume::copyFacesFrom(const std::vector<LLVolumeFace> &faces)
+{
+ mVolumeFaces = std::move(faces);
+ mSculptLevel = 0;
+}
+
void LLVolume::copyVolumeFaces(const LLVolume* volume)
{
mVolumeFaces = volume->mVolumeFaces;
diff --git a/indra/llmath/llvolume.h b/indra/llmath/llvolume.h
index 2f38ae7203..c8476f6897 100755
--- a/indra/llmath/llvolume.h
+++ b/indra/llmath/llvolume.h
@@ -993,6 +993,7 @@ public:
void resizePath(S32 length);
const LLAlignedArray<LLVector4a,64>& getMesh() const { return mMesh; }
const LLVector4a& getMeshPt(const U32 i) const { return mMesh[i]; }
+
void setDirty() { mPathp->setDirty(); mProfilep->setDirty(); }
@@ -1045,6 +1046,8 @@ public:
void sculpt(U16 sculpt_width, U16 sculpt_height, S8 sculpt_components, const U8* sculpt_data, S32 sculpt_level);
void copyVolumeFaces(const LLVolume* volume);
+ void copyFacesTo(std::vector<LLVolumeFace> &faces) const;
+ void copyFacesFrom(const std::vector<LLVolumeFace> &faces);
void cacheOptimize();
private:
diff --git a/indra/llprimitive/llmodel.cpp b/indra/llprimitive/llmodel.cpp
index 1f96d1557d..e0294cfd6a 100755
--- a/indra/llprimitive/llmodel.cpp
+++ b/indra/llprimitive/llmodel.cpp
@@ -2012,7 +2012,7 @@ bool LLModel::loadModel(std::istream& is)
}
}
- std::string nm[] =
+ static const std::string nm[] =
{
"lowest_lod",
"low_lod",
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();
diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h
index 6c0c60b87f..618748bd4e 100755
--- a/indra/newview/llfloatermodelpreview.h
+++ b/indra/newview/llfloatermodelpreview.h
@@ -343,6 +343,7 @@ public:
void loadModelCallback(S32 lod);
void genLODs(S32 which_lod = -1, U32 decimation = 3, bool enforce_tri_limit = false);
void generateNormals();
+ void restoreNormals();
U32 calcResourceCost();
void rebuildUploadData();
void saveUploadData(bool save_skinweights, bool save_joint_poisitions);
@@ -447,6 +448,12 @@ private:
LLModelLoader::model_list mModel[LLModel::NUM_LODS];
LLModelLoader::model_list mBaseModel;
+ typedef std::vector<LLVolumeFace> v_LLVolumeFace_t;
+ typedef std::vector<v_LLVolumeFace_t> vv_LLVolumeFace_t;
+
+ vv_LLVolumeFace_t mModelFacesCopy[LLModel::NUM_LODS];
+ vv_LLVolumeFace_t mBaseModelFacesCopy;
+
U32 mGroup;
std::map<LLPointer<LLModel>, U32> mObject;
U32 mMaxTriangleLimit;