From ad67f1899cf4452a4fcbf55cd7ecc80d3fec1856 Mon Sep 17 00:00:00 2001 From: vyacheslavsproductengine Date: Tue, 25 Aug 2015 17:24:24 +0400 Subject: MAINT-5064 FIXED (Mesh upload attempt causes viewer crash) (replacing BBox generation) --- indra/newview/llfloatermodelpreview.cpp | 149 ++++++++++++++++++++++++++++++-- 1 file changed, 143 insertions(+), 6 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 20760001fd..f889329222 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -751,6 +751,8 @@ void LLFloaterModelPreview::onExplodeCommit(LLUICtrl* ctrl, void* userdata) void LLFloaterModelPreview::onAutoFillCommit(LLUICtrl* ctrl, void* userdata) { LLFloaterModelPreview* fp = (LLFloaterModelPreview*) userdata; + if (fp->mModelPreview->mHasBrokenModel) + return; fp->mModelPreview->genLODs(); } @@ -1635,6 +1637,10 @@ bool LLModelLoader::doLoadModel() mModelList.push_back(model); mModel[mesh] = model; } + else + { + mPreview->mHasBrokenModel = true; + } } } @@ -2289,6 +2295,12 @@ void LLModelLoader::loadModelCallback() return ; } + //generate BBox here if non-valide model in scene was detected + if (mPreview->mHasBrokenModel) + { + mPreview->genModelBBox(); + } + //cleanup model loader if (mPreview) { @@ -3133,6 +3145,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) , mResetJoints( false ) , mRigParityWithScene( false ) , mLastJointUpdate( false ) +, mHasBrokenModel( false ) { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -4295,6 +4308,114 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim }*/ } +void LLModelPreview::genModelBBox() +{ + LLVector3 min, max; + min = this->mModelLoader->mExtents[0]; + max = this->mModelLoader->mExtents[1]; + + std::vector v_list; + v_list.resize(4); + std::map> face_list; + + // Face 0 + v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); + v_list[1] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); + v_list[2] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); + v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); + face_list.insert(std::pair>(0, v_list)); + + // Face 1 + v_list[0] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); + v_list[1] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); + v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); + v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); + face_list.insert(std::pair>(1, v_list)); + + // Face 2 + v_list[0] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); + v_list[1] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); + v_list[2] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); + v_list[3] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); + face_list.insert(std::pair>(2, v_list)); + + // Face 3 + v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); + v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); + v_list[2] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); + v_list[3] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); + face_list.insert(std::pair>(3, v_list)); + + // Face 4 + v_list[0] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); + v_list[1] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); + v_list[2] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); + v_list[3] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); + face_list.insert(std::pair>(4, v_list)); + + // Face 5 + v_list[0] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); + v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); + v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); + v_list[3] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); + face_list.insert(std::pair>(5, v_list)); + + U16 Idx[] = { 0, 1, 2, 3, 0, 2, }; + + U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; + LLPointer buff = new LLVertexBuffer(type_mask, 0); + buff->allocateBuffer(4, 6, true); + + LLStrider pos; + LLStrider idx; + LLStrider norm; + LLStrider tc; + + buff->getVertexStrider(pos); + buff->getIndexStrider(idx); + + buff->getNormalStrider(norm); + buff->getTexCoord0Strider(tc); + + for (U32 i = 0; i < 6; ++i) + { + idx[i] = Idx[i]; + } + + LLVolumeParams volume_params; + volume_params.setType(LL_PCODE_PROFILE_SQUARE, LL_PCODE_PATH_LINE); + LLModel* mdl = new LLModel(volume_params, 0.f); + mdl->mLabel = "BBOX"; + + mdl->setNumVolumeFaces(6); + for (U8 i = 0; i < 6; ++i) + { + for (U8 j = 0; j < 4; ++j) + { + pos[j] = face_list[i][j]; + } + + mdl->setVolumeFaceData(i, pos, norm, tc, idx, buff->getNumVerts(), buff->getNumIndices()); + } + + if (validate_model(mdl)) + { + LLMatrix4 mat; + std::map materials; + std::vector instance_list; + instance_list.push_back(LLModelInstance(mdl, mdl->mLabel, mat, materials)); + + for (S32 i = LLModel::LOD_HIGH - 1; i >= 0; i--) + { + mModel[i].clear(); + mModel[i].push_back(mdl); + + mScene[i].clear(); + mScene[i].insert(std::pair>(mat, instance_list)); + } + } +} + void LLModelPreview::updateStatusMessages() { assert_main_thread(); @@ -4961,12 +5082,14 @@ void LLModelPreview::update() if (mGenLOD) { - mGenLOD = false; - genLODs(); - refresh(); - updateStatusMessages(); + if (!this->mHasBrokenModel) + { + mGenLOD = false; + genLODs(); + refresh(); + updateStatusMessages(); + } } - } //----------------------------------------------------------------------------- // getTranslationForJointOffset() @@ -5292,7 +5415,11 @@ BOOL LLModelPreview::render() } gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + LLMatrix4 mat; + if (model->getName() != "BBOX") + { + mat = instance.mTransform; + } gGL.multMatrix((GLfloat*) mat.mMatrix); @@ -5825,6 +5952,16 @@ void LLModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) { if (!mLODFrozen) { + S32 lod_mode = 0; + LLCtrlSelectionInterface* iface = this->mFMP->childGetSelectionInterface("lod_mode_" + lod_name[lod]); + if (iface) + { + lod_mode = iface->getFirstSelectedIndex(); + } + + if (lod_mode == 0 && this->mHasBrokenModel) + return; + genLODs(lod, 3, enforce_tri_limit); refresh(); } -- cgit v1.2.3 From 7215b2f2363dce115681283b22238d1b7586fabb Mon Sep 17 00:00:00 2001 From: Mnikolenko ProductEngine Date: Thu, 27 Aug 2015 16:33:09 +0300 Subject: build fix --- indra/newview/llfloatermodelpreview.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index f889329222..fea4e57d13 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -4316,49 +4316,49 @@ void LLModelPreview::genModelBBox() std::vector v_list; v_list.resize(4); - std::map> face_list; + std::map > face_list; // Face 0 v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); v_list[1] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); v_list[2] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); - face_list.insert(std::pair>(0, v_list)); + face_list.insert(std::pair >(0, v_list)); // Face 1 v_list[0] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); v_list[1] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); v_list[3] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); - face_list.insert(std::pair>(1, v_list)); + face_list.insert(std::pair >(1, v_list)); // Face 2 v_list[0] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); v_list[1] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); v_list[2] = LLVector3(max.mV[VX], max.mV[VY], max.mV[VZ]); v_list[3] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); - face_list.insert(std::pair>(2, v_list)); + face_list.insert(std::pair >(2, v_list)); // Face 3 v_list[0] = LLVector3(min.mV[VX], max.mV[VY], max.mV[VZ]); v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); v_list[2] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); v_list[3] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); - face_list.insert(std::pair>(3, v_list)); + face_list.insert(std::pair >(3, v_list)); // Face 4 v_list[0] = LLVector3(min.mV[VX], min.mV[VY], max.mV[VZ]); v_list[1] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); v_list[2] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); v_list[3] = LLVector3(max.mV[VX], min.mV[VY], max.mV[VZ]); - face_list.insert(std::pair>(4, v_list)); + face_list.insert(std::pair >(4, v_list)); // Face 5 v_list[0] = LLVector3(min.mV[VX], min.mV[VY], min.mV[VZ]); v_list[1] = LLVector3(min.mV[VX], max.mV[VY], min.mV[VZ]); v_list[2] = LLVector3(max.mV[VX], max.mV[VY], min.mV[VZ]); v_list[3] = LLVector3(max.mV[VX], min.mV[VY], min.mV[VZ]); - face_list.insert(std::pair>(5, v_list)); + face_list.insert(std::pair >(5, v_list)); U16 Idx[] = { 0, 1, 2, 3, 0, 2, }; @@ -4411,7 +4411,7 @@ void LLModelPreview::genModelBBox() mModel[i].push_back(mdl); mScene[i].clear(); - mScene[i].insert(std::pair>(mat, instance_list)); + mScene[i].insert(std::pair >(mat, instance_list)); } } } -- cgit v1.2.3 From 3607d71740eb79a123972488071ce8ac4a4cef2e Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Wed, 4 Nov 2015 08:50:19 -0500 Subject: MAINT-5807 WIP - show skin weights checkbox also not properly initialized. --- indra/newview/llfloatermodelpreview.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index b5e5157335..861dc88983 100755 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -3669,6 +3669,7 @@ BOOL LLModelPreview::render() fmp->enableViewOption("show_skin_weight"); fmp->setViewOptionEnabled("show_joint_positions", skin_weight); mFMP->childEnable("upload_skin"); + mFMP->childSetValue("show_skin_weight", skin_weight); } } else -- cgit v1.2.3