From ae601f480f32c52ccf116a6d4084a2e3f8382275 Mon Sep 17 00:00:00 2001 From: Beq Date: Wed, 28 Nov 2018 20:16:40 +0000 Subject: [PATCH] Adding UV Guide and fix/improve error checking to avoid more MAV errors --- indra/newview/app_settings/settings.xml | 11 + indra/newview/llfloatermodelpreview.cpp | 191 +++++++++---- indra/newview/llfloatermodelpreview.h | 1 + .../default/textures/salt_and_pepper.jpg | Bin 0 -> 2441 bytes .../default/xui/en/floater_model_preview.xml | 250 ++++++++++------- .../xui/en/floater_model_preview.xml | 253 +++++++++++------- .../xui/en/floater_model_preview.xml | 253 +++++++++++------- 7 files changed, 604 insertions(+), 355 deletions(-) create mode 100644 indra/newview/skins/default/textures/salt_and_pepper.jpg diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e842633538..0b9146e344 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -9154,6 +9154,17 @@ Value 10.0 + FSMeshPreviewUVGuideFile + + Comment + filename of the texture to use as a UV guide for mesh preview. + Persist + 1 + Type + String + Value + salt_And_pepper.png + MigrateCacheDirectory Comment diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 73e70dcd99..77a68b82ba 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -336,6 +336,7 @@ BOOL LLFloaterModelPreview::postBuild() getChild("show_textures")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); getChild("show_skin_weight")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); getChild("show_joint_positions")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); + getChild("show_uv_guide")->setCommitCallback(boost::bind(&LLFloaterModelPreview::onViewOptionChecked, this, _1)); // - Add UV guide overlay to pmesh preview childDisable("upload_skin"); childDisable("upload_joints"); @@ -478,16 +479,7 @@ void LLFloaterModelPreview::onViewOptionChecked(LLUICtrl* ctrl) { if (mModelPreview) { - // only show explode when phsyics is on - // mModelPreview->mViewOption[ctrl->getName()] = !mModelPreview->mViewOption[ctrl->getName()]; - auto name = ctrl->getName(); - mModelPreview->mViewOption[name] = !mModelPreview->mViewOption[name]; - if (name == "show_physics") - { - auto enabled = mModelPreview->mViewOption[name]; - childSetEnabled("physics_explode", enabled); - childSetVisible("physics_explode", enabled); - } + mModelPreview->mViewOption[ctrl->getName()] = !mModelPreview->mViewOption[ctrl->getName()]; mModelPreview->refresh(); } } @@ -1381,6 +1373,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) mBuildQueueMode = GLOD_QUEUE_GREEDY; mBuildBorderMode = GLOD_BORDER_UNLOCK; mBuildOperator = GLOD_OPERATOR_EDGE_COLLAPSE; + mUVGuideTexture = LLViewerTextureManager::getFetchedTextureFromFile(gSavedSettings.getString("FSMeshPreviewUVGuideFile"), FTT_LOCAL_FILE, TRUE, LLGLTexture::BOOST_PREVIEW); // - Add UV guide overlay to pmesh preview for (U32 i = 0; i < LLModel::NUM_LODS; ++i) { @@ -3090,15 +3083,9 @@ void LLModelPreview::updateStatusMessages() } // flag degenerates here rather than deferring to a MAV error later - mFMP->childSetVisible("physics_status_message_text", mHasDegenerate); //display or clear - auto degenerateIcon = mFMP->getChild("physics_status_message_icon"); - degenerateIcon->setVisible(mHasDegenerate); if (mHasDegenerate) { has_physics_error |= PhysicsError::DEGENERATE; - mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_degenerate_triangles")); - LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); - degenerateIcon->setImage(img); } // @@ -3209,14 +3196,17 @@ void LLModelPreview::updateStatusMessages() //warn if hulls have more than 256 points in them BOOL physExceededVertexLimit = FALSE; - for (U32 i = 0; mModelNoErrors && i < mModel[LLModel::LOD_PHYSICS].size(); ++i) + for (U32 i = 0; mModelNoErrors && (i < mModel[LLModel::LOD_PHYSICS].size()); ++i) { LLModel* mdl = mModel[LLModel::LOD_PHYSICS][i]; if (mdl) { - for (U32 j = 0; j < mdl->mPhysics.mHull.size(); ++j) - { + // Better error handling + auto num_hulls = mdl->mPhysics.mHull.size(); + for (U32 j = 0; j < num_hulls; ++j) + { + // if (mdl->mPhysics.mHull[j].size() > 256) { physExceededVertexLimit = TRUE; @@ -3224,6 +3214,13 @@ void LLModelPreview::updateStatusMessages() break; } } + // Better error handling + if (num_hulls > 256) // decomp cannot have more than 256 hulls (http://wiki.secondlife.com/wiki/Mesh/Mesh_physics) + { + LL_INFOS() << "Physical model " << mdl->mLabel << " exceeds 256 hull limitation." << LL_ENDL; + has_physics_error |= PhysicsError::TOOMANYHULLS; + } + // } } @@ -3232,18 +3229,67 @@ void LLModelPreview::updateStatusMessages() has_physics_error |= PhysicsError::TOOMANYVERTSINHULL; } - if (!(has_physics_error & PhysicsError::DEGENERATE)){ // only update this field (incluides clearing it) if it is not already in use. - mFMP->childSetVisible("physics_status_message_text", physExceededVertexLimit); - LLIconCtrl* physStatusIcon = mFMP->getChild("physics_status_message_icon"); - physStatusIcon->setVisible(physExceededVertexLimit); - if (physExceededVertexLimit) +// standardise error handling + //if (!(has_physics_error & PhysicsError::DEGENERATE)){ // only update this field (incluides clearing it) if it is not already in use. + // mFMP->childSetVisible("physics_status_message_text", physExceededVertexLimit); + // LLIconCtrl* physStatusIcon = mFMP->getChild("physics_status_message_icon"); + // physStatusIcon->setVisible(physExceededVertexLimit); + // if (physExceededVertexLimit) + // { + // mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_vertex_limit_exceeded")); + // LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); + // physStatusIcon->setImage(img); + // } + //} +#ifdef OPENSIM + has_physics_error |= PhysicsError::NOHAVOK; +#endif + + auto physStatusIcon = mFMP->getChild("physics_status_message_icon"); + + if (has_physics_error != PhysicsError::NONE) + { + mFMP->childSetVisible("physics_status_message_text", true); //display or clear + physStatusIcon->setVisible(true); + // The order here is important. + if (has_physics_error & PhysicsError::TOOMANYHULLS) + { + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_hull_limit_exceeded")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); + physStatusIcon->setImage(img); + } + else if (has_physics_error & PhysicsError::TOOMANYVERTSINHULL) { mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_vertex_limit_exceeded")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); + physStatusIcon->setImage(img); + } + else if (has_physics_error & PhysicsError::DEGENERATE) + { + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_degenerate_triangles")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); + physStatusIcon->setImage(img); + } + else if (has_physics_error & PhysicsError::NOHAVOK) + { + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_no_havok")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); + physStatusIcon->setImage(img); + } + else + { + // This should not happen + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_unknown_error")); LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); physStatusIcon->setImage(img); } } - + else + { + mFMP->childSetVisible("physics_status_message_text", false); //display or clear + physStatusIcon->setVisible(false); + } +// if (getLoadState() >= LLModelLoader::ERROR_PARSING) { mModelNoErrors = false; @@ -3276,7 +3322,7 @@ void LLModelPreview::updateStatusMessages() //if (!mModelNoErrors || mHasDegenerate) //{ // mFMP->childDisable("ok_btn"); - if (!mModelNoErrors || mHasDegenerate) + if (!mModelNoErrors || (has_physics_error > PhysicsError::NOHAVOK)) // block for all cases of phsyics error except NOHAVOK { mFMP->childDisable("ok_btn"); mFMP->childDisable("calculate_btn"); @@ -3355,14 +3401,41 @@ void LLModelPreview::updateStatusMessages() mViewOption["show_physics"] = true; fmp->childSetValue("show_physics", true); } + // handle hiding of hull only explode slider + //else + //{ + // fmp->disableViewOption("show_physics"); + // mViewOption["show_physics"] = false; + // fmp->childSetValue("show_physics", false); + + //} + mViewOption["show_physics"] = true; + if (phys_hulls > 0) + { + fmp->enableViewOption("physics_explode"); + fmp->enableViewOption("exploder_label"); + fmp->childSetVisible("physics_explode", true); + fmp->childSetVisible("exploder_label", true); + } + else + { + fmp->disableViewOption("physics_explode"); + fmp->disableViewOption("exploder_label"); + fmp->childSetVisible("physics_explode", false); + fmp->childSetVisible("exploder_label", false); + } } else { fmp->disableViewOption("show_physics"); + fmp->childSetVisible("physics_explode", false); + fmp->disableViewOption("physics_explode"); + fmp->childSetVisible("exploder_label", false); + fmp->disableViewOption("exploder_label"); mViewOption["show_physics"] = false; fmp->childSetValue("show_physics", false); - } + // //bool use_hull = fmp->childGetValue("physics_use_hull").asBoolean(); @@ -3404,7 +3477,6 @@ void LLModelPreview::updateStatusMessages() { fmp->childEnable("Simplify"); } - // Enable mesh analysis in SL only for now //if (phys_tris || phys_hulls > 0) //{ @@ -3418,29 +3490,30 @@ void LLModelPreview::updateStatusMessages() fmp->childEnable("simplify_cancel"); fmp->childEnable("decompose_cancel"); } - } + // move the closing bracket for the if(fmp) to prevent possible crash + // } - - LLCtrlSelectionInterface* iface = fmp->childGetSelectionInterface("physics_lod_combo"); - S32 which_mode = 0; - S32 file_mode = 1; - if (iface) - { - which_mode = iface->getFirstSelectedIndex(); - file_mode = iface->getItemCount() - 1; - } + LLCtrlSelectionInterface* iface = fmp->childGetSelectionInterface("physics_lod_combo"); + S32 which_mode = 0; + S32 file_mode = 1; + if (iface) + { + which_mode = iface->getFirstSelectedIndex(); + file_mode = iface->getItemCount() - 1; + } - if (which_mode == file_mode) - { - mFMP->childEnable("physics_file"); - mFMP->childEnable("physics_browse"); + if (which_mode == file_mode) + { + mFMP->childEnable("physics_file"); + mFMP->childEnable("physics_browse"); + } + else + { + mFMP->childDisable("physics_file"); + mFMP->childDisable("physics_browse"); + } } - else - { - mFMP->childDisable("physics_file"); - mFMP->childDisable("physics_browse"); - } - + // LLSpinCtrl* crease = mFMP->getChild("crease_angle"); if (mRequestedCreaseAngle[mPreviewLOD] == -1.f) @@ -3921,6 +3994,7 @@ BOOL LLModelPreview::render() bool skin_weight = mViewOption["show_skin_weight"]; bool textures = mViewOption["show_textures"]; bool physics = mViewOption["show_physics"]; + bool uv_guide = mViewOption["show_uv_guide"]; // Add UV guide overlay in mesh preview // Extra configurability, to be exposed later as controls? static LLCachedControl canvas_col(gSavedSettings, "MeshPreviewCanvasColor"); @@ -4200,16 +4274,31 @@ BOOL LLModelPreview::render() mTextureSet.insert(tex); } } + // improved mesh uploader + // else + // { + // gGL.diffuseColor4f(1,1,1,1); + // } + } + else if (uv_guide) + { + if(mUVGuideTexture) + { + if (mUVGuideTexture->getDiscardLevel() > -1) + { + gGL.getTexUnit(0)->bind(mUVGuideTexture, true); + } + } + gGL.diffuseColor4fv(static_cast(base_col).mV); + } else { - // improved mesh uploader - // gGL.diffuseColor4f(1,1,1,1); + // gGL.diffuseColor4f(1,1,1,1); gGL.diffuseColor4fv(static_cast(base_col).mV); // } - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); // improved mesh uploader diff --git a/indra/newview/llfloatermodelpreview.h b/indra/newview/llfloatermodelpreview.h index 564f4c39de..4e9b575882 100644 --- a/indra/newview/llfloatermodelpreview.h +++ b/indra/newview/llfloatermodelpreview.h @@ -339,6 +339,7 @@ private: LLFloater* mFMP; + LLPointer mUVGuideTexture; // Add UV Guide texture overlay BOOL mNeedsUpdate; bool mDirty; bool mGenLOD; diff --git a/indra/newview/skins/default/textures/salt_and_pepper.jpg b/indra/newview/skins/default/textures/salt_and_pepper.jpg new file mode 100644 index 0000000000000000000000000000000000000000..bf439b9eeefe4c5b3af1b830c386b683154a8a01 GIT binary patch literal 2441 zcmeH|K~BRk6hy~y+_*~A^f#fcs@4&q2dKn`T^C4|;1nE%J8=OP9D>4zo0zFkBdb}l zsW%}jwb?XHQ!UzU>$YpxxYJ7%AI(PD#M+6grFQ=w{|>PU5@^*T5v4`>56p>5 z%y7n*dOf{RxfQCHYyVW~ul+)y6>YR&kK+q)_WQHJ;T%Gj05N*n^#xK4)#wr!su3hGR3rR(1i^H5iExY%Level of detail has too many vertices. Missing required level of detail. LOD materials are not a subset of reference model. - Some physical hulls exceed vertex limitations. - Physics mesh too dense; remove the small, thin triangles (see preview) - The OpenSim version is not supported for physics upload in SL. + Some physical hulls exceed the vertex limit (256); try an alternative 'Analyze Method'. + Some models exceed the hull limit (256); try 'simplify'. + Physics mesh too dense; remove the small, thin triangles (see preview.) + The OpenSim version is not recommended for physics upload in SL. Results may be unpredictable. + An unrecognised error was detected. All Analyzing... Simplifying... @@ -43,7 +46,7 @@ + + + Tip: +Multiple attachments on an attachment point increases the likelihood of disconnects during Teleports & region crossings. + +Too many items use the default (right hand) unnecessarily. + +For more reliable attachments, please consider using a different attachment point. + + @@ -1487,6 +1516,113 @@ Analysed: [PHU] --> + + + + Preview controls + + + High + Medium + Low + Lowest + + + + + + + + Explode hulls + + + + - + + - - - - - - - - - Preview Spread: - - - +/> diff --git a/indra/newview/skins/starlight/xui/en/floater_model_preview.xml b/indra/newview/skins/starlight/xui/en/floater_model_preview.xml index db607565a7..c1ad931d21 100644 --- a/indra/newview/skins/starlight/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/starlight/xui/en/floater_model_preview.xml @@ -4,9 +4,10 @@ can_drag_on_left="false" can_minimize="true" can_resize="true" - height="600" - min_height="600" + height="585" + min_height="585" width="1024" + top="0" min_width="1024" name="Model Preview" title="Upload Model" @@ -33,9 +34,11 @@ Level of detail has too many vertices. Missing required level of detail. LOD materials are not a subset of reference model. - Some physical hulls exceed vertex limitations. - Physics mesh too dense; remove the small, thin triangles (see preview) - The OpenSim version is not supported for physics upload in SL. + Some physical hulls exceed the vertex limit (256); try an alternative 'Analyze Method'. + Some models exceed the hull limit (256); try 'simplify'. + Physics mesh too dense; remove the small, thin triangles (see preview.) + The OpenSim version is not recommended for physics upload in SL. Results may be unpredictable. + An unrecognised error was detected. All Analyzing... Simplifying... @@ -43,7 +46,7 @@ + + + Tip: +Multiple attachments on an attachment point increases the likelihood of disconnects during Teleports & region crossings. + +Too many items use the default (right hand) unnecessarily. + +For more reliable attachments, please consider using a different attachment point. + + @@ -1487,6 +1516,113 @@ Analysed: [PHU] --> + + + + Preview controls + + + High + Medium + Low + Lowest + + + + + + + + Explode hulls + + + + @@ -1524,8 +1660,9 @@ Analysed: top="0" left="640" background_visible="true" - width="375"> - + + - - - - - - - - - Preview Spread: - - - +/> diff --git a/indra/newview/skins/starlightcui/xui/en/floater_model_preview.xml b/indra/newview/skins/starlightcui/xui/en/floater_model_preview.xml index db607565a7..c1ad931d21 100644 --- a/indra/newview/skins/starlightcui/xui/en/floater_model_preview.xml +++ b/indra/newview/skins/starlightcui/xui/en/floater_model_preview.xml @@ -4,9 +4,10 @@ can_drag_on_left="false" can_minimize="true" can_resize="true" - height="600" - min_height="600" + height="585" + min_height="585" width="1024" + top="0" min_width="1024" name="Model Preview" title="Upload Model" @@ -33,9 +34,11 @@ Level of detail has too many vertices. Missing required level of detail. LOD materials are not a subset of reference model. - Some physical hulls exceed vertex limitations. - Physics mesh too dense; remove the small, thin triangles (see preview) - The OpenSim version is not supported for physics upload in SL. + Some physical hulls exceed the vertex limit (256); try an alternative 'Analyze Method'. + Some models exceed the hull limit (256); try 'simplify'. + Physics mesh too dense; remove the small, thin triangles (see preview.) + The OpenSim version is not recommended for physics upload in SL. Results may be unpredictable. + An unrecognised error was detected. All Analyzing... Simplifying... @@ -43,7 +46,7 @@ + + + Tip: +Multiple attachments on an attachment point increases the likelihood of disconnects during Teleports & region crossings. + +Too many items use the default (right hand) unnecessarily. + +For more reliable attachments, please consider using a different attachment point. + + @@ -1487,6 +1516,113 @@ Analysed: [PHU] --> + + + + Preview controls + + + High + Medium + Low + Lowest + + + + + + + + Explode hulls + + + + @@ -1524,8 +1660,9 @@ Analysed: top="0" left="640" background_visible="true" - width="375"> - + + - - - - - - - - - Preview Spread: - - - +/>