MAINT-3494 FIXED Generate Normals checkbox does not control generation of normals.
parent
5a1f4ac1a7
commit
b3c8a559f6
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -2012,7 +2012,7 @@ bool LLModel::loadModel(std::istream& is)
|
|||
}
|
||||
}
|
||||
|
||||
std::string nm[] =
|
||||
static const std::string nm[] =
|
||||
{
|
||||
"lowest_lod",
|
||||
"low_lod",
|
||||
|
|
|
|||
|
|
@ -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,19 +3855,80 @@ void LLModelPreview::generateNormals()
|
|||
|
||||
if (which_lod == 3 && !mBaseModel.empty())
|
||||
{
|
||||
for (LLModelLoader::model_list::iterator iter = mBaseModel.begin(); iter != mBaseModel.end(); ++iter)
|
||||
if(mBaseModelFacesCopy.empty())
|
||||
{
|
||||
(*iter)->generateNormals(angle_cutoff);
|
||||
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)
|
||||
{
|
||||
(*it)->generateNormals(angle_cutoff);
|
||||
}
|
||||
|
||||
mVertexBuffer[5].clear();
|
||||
}
|
||||
|
||||
for (LLModelLoader::model_list::iterator iter = mModel[which_lod].begin(); iter != mModel[which_lod].end(); ++iter)
|
||||
{
|
||||
(*iter)->generateNormals(angle_cutoff);
|
||||
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(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();
|
||||
updateStatusMessages();
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue