From d9fdb948d9b7d7b873ec83c43332f97018573194 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Thu, 29 Nov 2018 21:04:35 +0200 Subject: SL-9747 [Mesh Uploader] Remove confusing model_metric from upload --- indra/newview/llfloatermodelpreview.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 268c646719..818d364c3e 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -1418,8 +1418,6 @@ void LLModelPreview::rebuildUploadData() std::string requested_name = mFMP->getChild("description_form")->getValue().asString(); - std::string metric = mFMP->getChild("model_category_combo")->getValue().asString(); - LLSpinCtrl* scale_spinner = mFMP->getChild("import_scale"); F32 scale = scale_spinner->getValue().asReal(); @@ -1460,7 +1458,6 @@ void LLModelPreview::rebuildUploadData() if (base_model && !requested_name.empty()) { base_model->mRequestedLabel = requested_name; - base_model->mMetric = metric; } for (int i = LLModel::NUM_LODS - 1; i >= LLModel::LOD_IMPOSTOR; i--) -- cgit v1.2.3 From efa5f24d1b00472485a3764d550882484fe5bdd5 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Thu, 3 Jan 2019 00:35:38 +0200 Subject: SL-10288 Mesh uploader changes from Firestorm --- indra/newview/llfloatermodelpreview.cpp | 527 ++++++++++++++++++++++---------- 1 file changed, 363 insertions(+), 164 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 818d364c3e..01f0a5197d 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,8 +427,11 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } - - mModelPreview = new LLModelPreview(512, 512, this ); + // mesh uploader changes to allow higher resolution render + // mModelPreview = new LLModelPreview(512, 512, this); + auto size = gSavedSettings.getS32("PreviewRenderSize"); + mModelPreview = new LLModelPreview(size, size, this ); + // mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); @@ -438,8 +441,16 @@ void LLFloaterModelPreview::onViewOptionChecked(LLUICtrl* ctrl) { if (mModelPreview) { - mModelPreview->mViewOption[ctrl->getName()] = !mModelPreview->mViewOption[ctrl->getName()]; - + // 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->refresh(); } } @@ -653,6 +664,43 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) } } +// extracted method to simplify changes in layout +void LLFloaterModelPreview::draw3dPreview() +{ + gGL.color3f(1.f, 1.f, 1.f); + + gGL.getTexUnit(0)->bind(mModelPreview); + + + LLView* preview_panel = getChild("preview_panel"); + + if (!preview_panel) + { + LL_WARNS() << "preview_panel not found in floater definition" << LL_ENDL; + } + LLRect rect = preview_panel->getRect(); + + if (rect != mPreviewRect) + { + mModelPreview->refresh(); + mPreviewRect = preview_panel->getRect(); + } + + gGL.begin( LLRender::QUADS ); + { + gGL.texCoord2f(0.f, 1.f); + gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop-1); + gGL.texCoord2f(0.f, 0.f); + gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom); + gGL.texCoord2f(1.f, 0.f); + gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mBottom); + gGL.texCoord2f(1.f, 1.f); + gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mTop-1); + } + gGL.end(); + + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); +} //----------------------------------------------------------------------------- // draw() @@ -1218,6 +1266,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) , mResetJoints( false ) , mModelNoErrors( true ) , mLastJointUpdate( false ) +, mHasDegenerate( false ) // { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -2707,8 +2756,20 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim void LLModelPreview::updateStatusMessages() { +// bit mask values for physics errors. used to prevent overwrite of single line status +// TODO: use this to provied multiline status + enum PhysicsError + { + NONE=0, + NOHAVOK=1, + DEGENERATE=2, + TOOMANYHULLS=4, + TOOMANYVERTSINHULL=8 + }; +// assert_main_thread(); + U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap //triangle/vertex/submesh count for each mesh asset for each lod std::vector tris[LLModel::NUM_LODS]; std::vector verts[LLModel::NUM_LODS]; @@ -2797,44 +2858,72 @@ void LLModelPreview::updateStatusMessages() { mMaxTriangleLimit = total_tris[LLModel::LOD_HIGH]; } - - bool has_degenerate = false; - + // make has_degenerate a member so that we can use it in the render method + // has_degenerate = false + mHasDegenerate = false; {//check for degenerate triangles in physics mesh U32 lod = LLModel::LOD_PHYSICS; const LLVector4a scale(0.5f); - for (U32 i = 0; i < mModel[lod].size() && !has_degenerate; ++i) + for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i)// make has_degenerate a member { //for each model in the lod if (mModel[lod][i] && mModel[lod][i]->mPhysics.mHull.empty()) { //no decomp exists S32 cur_submeshes = mModel[lod][i]->getNumVolumeFaces(); - for (S32 j = 0; j < cur_submeshes && !has_degenerate; ++j) + for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j)// make has_degenerate a member { //for each submesh (face), add triangles and vertices to current total LLVolumeFace& face = mModel[lod][i]->getVolumeFace(j); - for (S32 k = 0; (k < face.mNumIndices) && !has_degenerate; ) + for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; )// make has_degenerate a member { - U16 index_a = face.mIndices[k+0]; - U16 index_b = face.mIndices[k+1]; - U16 index_c = face.mIndices[k+2]; - - LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); - LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); - LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); - - if (ll_is_degenerate(v1,v2,v3)) + U16 index_a = face.mIndices[k + 0]; + U16 index_b = face.mIndices[k + 1]; + U16 index_c = face.mIndices[k + 2]; + // FIRE-23367/23387 - Allow forced empty triangle placeholders created by the LOD processing. + // LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); + // LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); + // LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); + + // if (ll_is_degenerate(v1, v2, v3)) + // { + // mHasDegenerate = true;// make has_degenerate a member + // } + // else + // { + // k += 3; + // } + if (index_c == 0 && index_b == 0 && index_a == 0) // test in reverse as 3rd index is less likely to be 0 in a normal case { - has_degenerate = true; + LL_DEBUGS("MeshValidation") << "Empty placeholder triangle (3 identical index 0 verts) ignored" << LL_ENDL; } else { - k += 3; + LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); + LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); + LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); + if (ll_is_degenerate(v1, v2, v3)) + { + mHasDegenerate = true;// make has_degenerate a member + } } + k += 3; } } } } } + // 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); + } + // + mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); std::string mesh_status_na = mFMP->getString("mesh_status_na"); @@ -2959,14 +3048,22 @@ void LLModelPreview::updateStatusMessages() } } } - 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); + 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) + { + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_vertex_limit_exceeded")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); + physStatusIcon->setImage(img); + } } if (getLoadState() >= LLModelLoader::ERROR_PARSING) @@ -2995,12 +3092,21 @@ void LLModelPreview::updateStatusMessages() mModelNoErrors = false; } } - - // Todo: investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics - // current use of has_degenerate won't block upload permanently - later checks will restore the button - if (!mModelNoErrors || has_degenerate) + // Improve the error checking the TO DO here is no longer applicable but not an FS comment so edited to stop it being picked up + //// To do investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics + //// current use of has_degenerate won't block upload permanently - later checks will restore the button + //if (!mModelNoErrors || mHasDegenerate) + //{ + // mFMP->childDisable("ok_btn"); + if (!mModelNoErrors || mHasDegenerate) { mFMP->childDisable("ok_btn"); + mFMP->childDisable("calculate_btn"); + } + else + { + mFMP->childEnable("ok_btn"); + mFMP->childEnable("calculate_btn"); } //add up physics triangles etc @@ -3616,11 +3722,30 @@ BOOL LLModelPreview::render() bool textures = mViewOption["show_textures"]; bool physics = mViewOption["show_physics"]; + // Extra configurability, to be exposed later as controls? + static LLCachedControl canvas_col(gSavedSettings, "MeshPreviewCanvasColor"); + static LLCachedControl edge_col(gSavedSettings, "MeshPreviewEdgeColor"); + static LLCachedControl base_col(gSavedSettings, "MeshPreviewBaseColor"); + static LLCachedControl brightness(gSavedSettings, "MeshPreviewBrightnessColor"); + static LLCachedControl edge_width(gSavedSettings, "MeshPreviewEdgeWidth"); + static LLCachedControl phys_edge_col(gSavedSettings, "MeshPreviewPhysicsEdgeColor"); + static LLCachedControl phys_fill_col(gSavedSettings, "MeshPreviewPhysicsFillColor"); + static LLCachedControl phys_edge_width(gSavedSettings, "MeshPreviewPhysicsEdgeWidth"); + static LLCachedControl deg_edge_col(gSavedSettings, "MeshPreviewDegenerateEdgeColor"); + static LLCachedControl deg_fill_col(gSavedSettings, "MeshPreviewDegenerateFillColor"); + static LLCachedControl deg_edge_width(gSavedSettings, "MeshPreviewDegenerateEdgeWidth"); + static LLCachedControl deg_point_size(gSavedSettings, "MeshPreviewDegeneratePointSize"); + // S32 width = getWidth(); S32 height = getHeight(); LLGLSUIDefault def; LLGLDisable no_blend(GL_BLEND); +// Clean up render of mesh preview +// LLGLEnable blend(GL_BLEND); +// gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); +// + LLGLEnable cull(GL_CULL_FACE); LLGLDepthTest depth(GL_TRUE); LLGLDisable fog(GL_FOG); @@ -3639,9 +3764,9 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); - - gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); - + // uploader improvements + //gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); + gGL.color4fv(static_cast(canvas_col).mV); gl_rect_2d_simple( width, height ); gGL.matrixMode(LLRender::MM_PROJECTION); @@ -3789,8 +3914,11 @@ BOOL LLModelPreview::render() stop_glerror(); gGL.pushMatrix(); - const F32 BRIGHTNESS = 0.9f; - gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); + // mesh uploader improvements configurable brightness + //const F32 BRIGHTNESS = 0.9f; + //gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); + gGL.color4fv(edge_col().mV); + // const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; @@ -3875,16 +4003,22 @@ BOOL LLModelPreview::render() } else { - gGL.diffuseColor4f(1,1,1,1); + // improved mesh uploader + // 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); - gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); - + // improved mesh uploader + //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); + gGL.diffuseColor4fv(static_cast(edge_col).mV); + // if (edges) { - glLineWidth(3.f); + glLineWidth(edge_width); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -3896,11 +4030,25 @@ BOOL LLModelPreview::render() if (physics) { + // model upload improvements - use the settings + ////Vector4a physicsFillColour(0.4, 0.4, 0.4, 0.4); + //const LLColor4 physicsFillColour(0.0, 0.5, 1.0, 0.5); + ////LLVector4a physicsEdgeColour(1.0, 1.0, 0.0, 1.0); + //const LLColor4 physicsEdgeColour=physicsFillColour*0.5; + //const LLColor4 degenerateFill(1.0, 0.0, 0.0, 0.5); + //const LLColor4 degenerateEdge(1.0,0.0,0.0,1.0); + // + glClear(GL_DEPTH_BUFFER_BIT); - - for (U32 i = 0; i < 2; i++) + // refactor to remove silly variable names + // for (U32 i = 0; i < 2; i++) + for (U32 pass = 0; pass < 2; pass++) + // { - if (i == 0) + // refactor to remove silly variable names + //if (i == 0) + if (pass == 0) + // { //depth only pass gGL.setColorMask(false, false); } @@ -3910,8 +4058,11 @@ BOOL LLModelPreview::render() } //enable alpha blending on second pass but not first pass - LLGLState blend(GL_BLEND, i); - + // refactor to remove silly variable names + //LLGLState blend(GL_BLEND, i); + LLGLState blend(GL_BLEND, pass); + // + gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) @@ -3920,175 +4071,196 @@ BOOL LLModelPreview::render() LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - if (!model) - { - continue; - } + if (!model) + { + continue; + } - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; - gGL.multMatrix((GLfloat*) mat.mMatrix); + gGL.multMatrix((GLfloat*)mat.mMatrix); - bool render_mesh = true; + bool render_mesh = true; + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) + { + LLMutexLock(decomp->mMutex); + + LLModel::Decomposition& physics = model->mPhysics; - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) + if (!physics.mHull.empty()) { - LLMutexLock(decomp->mMutex); - - LLModel::Decomposition& physics = model->mPhysics; + render_mesh = false; - if (!physics.mHull.empty()) - { - render_mesh = false; + if (physics.mMesh.empty()) + { //build vertex buffer for physics mesh + gMeshRepo.buildPhysicsMesh(physics); + } - if (physics.mMesh.empty()) - { //build vertex buffer for physics mesh - gMeshRepo.buildPhysicsMesh(physics); - } - - if (!physics.mMesh.empty()) - { //render hull instead of mesh - for (U32 i = 0; i < physics.mMesh.size(); ++i) + if (!physics.mMesh.empty()) + { //render hull instead of mesh + for (U32 i = 0; i < physics.mMesh.size(); ++i) + { + if (explode > 0.f) { - if (explode > 0.f) - { - gGL.pushMatrix(); + gGL.pushMatrix(); - LLVector3 offset = model->mHullCenter[i]-model->mCenterOfHullCenters; - offset *= explode; + LLVector3 offset = model->mHullCenter[i] - model->mCenterOfHullCenters; + offset *= explode; - gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); - } + gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); + } - static std::vector hull_colors; + static std::vector hull_colors; - if (i+1 >= hull_colors.size()) - { - hull_colors.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 128)); - } + if (i + 1 >= hull_colors.size()) + { + hull_colors.push_back(LLColor4U(rand() % 128 + 127, rand() % 128 + 127, rand() % 128 + 127, 128)); + } - gGL.diffuseColor4ubv(hull_colors[i].mV); - LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); + gGL.diffuseColor4ubv(hull_colors[i].mV); + LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); - if (explode > 0.f) - { - gGL.popMatrix(); - } + if (explode > 0.f) + { + gGL.popMatrix(); } } } } - - if (render_mesh) + } + + if (render_mesh) + { + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) - { - genBuffers(LLModel::LOD_PHYSICS, false); - } + genBuffers(LLModel::LOD_PHYSICS, false); + } - U32 num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); + U32 num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); + if (pass > 0){ for (U32 i = 0; i < num_models; ++i) { LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.diffuseColor4f(0.4f, 0.4f, 0.0f, 0.4f); + gGL.diffuseColor4fv(phys_fill_col().mV); buffer->setBuffer(type_mask & buffer->getTypeMask()); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); - - gGL.diffuseColor3f(1.f, 1.f, 0.f); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); - glLineWidth(2.f); + gGL.diffuseColor4fv(phys_edge_col().mV); + glLineWidth(phys_edge_width); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } } - - gGL.popMatrix(); } - glLineWidth(3.f); - glPointSize(8.f); - gPipeline.enableLightsFullbright(LLColor4::white); - //show degenerate triangles - LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - LLGLDisable cull(GL_CULL_FACE); - gGL.diffuseColor4f(1.f,0.f,0.f,1.f); - const LLVector4a scale(0.5f); + gGL.popMatrix(); + } - for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) + // refactor to remove silly variable names + // also only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] + //if (i > 0) + if (pass > 0 && mHasDegenerate) + // { - LLModelInstance& instance = *iter; - - LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - - if (!model) + glLineWidth(deg_edge_width); + glPointSize(deg_point_size); +// This single line is why the degenerate triangles display has been crap forever. +// gPipeline.enableLightsFullbright(LLColor4::white); + //show degenerate triangles + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + LLGLDisable cull(GL_CULL_FACE); + const LLVector4a scale(0.5f); + + for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) { - continue; - } + LLModelInstance& instance = *iter; - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - gGL.multMatrix((GLfloat*) mat.mMatrix); + if (!model) + { + continue; + } + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) - { - LLMutexLock(decomp->mMutex); + gGL.multMatrix((GLfloat*)mat.mMatrix); - LLModel::Decomposition& physics = model->mPhysics; - if (physics.mHull.empty()) + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) - { - genBuffers(LLModel::LOD_PHYSICS, false); - } - - for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) - { - LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; + LLMutexLock(decomp->mMutex); - buffer->setBuffer(type_mask & buffer->getTypeMask()); + LLModel::Decomposition& physics = model->mPhysics; - LLStrider pos_strider; - buffer->getVertexStrider(pos_strider, 0); - LLVector4a* pos = (LLVector4a*) pos_strider.get(); - - LLStrider idx; - buffer->getIndexStrider(idx, 0); + if (physics.mHull.empty()) + { + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + { + genBuffers(LLModel::LOD_PHYSICS, false); + } - for (U32 i = 0; i < buffer->getNumIndices(); i += 3) + auto num_degenerate = 0; + // More nested i variable silliness + // for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) + auto num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); + for (U32 v = 0; v < num_models; ++v) { - LLVector4a v1; v1.setMul(pos[*idx++], scale); - LLVector4a v2; v2.setMul(pos[*idx++], scale); - LLVector4a v3; v3.setMul(pos[*idx++], scale); + LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][v]; + // + if(buffer->getNumVerts() < 3)continue; + + buffer->setBuffer(type_mask & buffer->getTypeMask()); + + LLStrider pos_strider; + buffer->getVertexStrider(pos_strider, 0); + LLVector4a* pos = (LLVector4a*)pos_strider.get(); + + LLStrider idx; + buffer->getIndexStrider(idx, 0); - if (ll_is_degenerate(v1,v2,v3)) + LLVector4a v1, v2, v3; + // rename inner most i to avoid merge confusion + for (U32 indices_offset = 0; indices_offset < buffer->getNumIndices(); indices_offset += 3) { - buffer->draw(LLRender::LINE_LOOP, 3, i); - buffer->draw(LLRender::POINTS, 3, i); + v1.setMul(pos[*idx++], scale); + v2.setMul(pos[*idx++], scale); + v3.setMul(pos[*idx++], scale); + + if (ll_is_degenerate(v1, v2, v3)) + { + num_degenerate++; + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + gGL.diffuseColor3fv(deg_edge_col().mV); + buffer->drawRange(LLRender::TRIANGLES, 0, 2, 3, indices_offset); + buffer->drawRange(LLRender::POINTS, 0, 2, 3, indices_offset); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); + gGL.diffuseColor3fv(deg_fill_col().mV); + buffer->drawRange(LLRender::TRIANGLES, 0, 2, 3, indices_offset); + } } } } } - } - gGL.popMatrix(); + gGL.popMatrix(); + } + glLineWidth(1.f); + glPointSize(1.f); + gPipeline.enableLightsPreview(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } - glLineWidth(1.f); - glPointSize(1.f); - gPipeline.enableLightsPreview(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); } } } @@ -4170,16 +4342,19 @@ BOOL LLModelPreview::render() } buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); - gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); + // configurable colour and width + //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { - glLineWidth(3.f); + gGL.diffuseColor4fv(edge_col().mV); + glLineWidth(edge_width); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } + // } } } @@ -4237,8 +4412,11 @@ void LLModelPreview::rotate(F32 yaw_radians, F32 pitch_radians) void LLModelPreview::zoom(F32 zoom_amt) { F32 new_zoom = mCameraZoom+zoom_amt; - - mCameraZoom = llclamp(new_zoom, 1.f, 10.f); + // add configurable zoom TODO: stop clamping in render + // mCameraZoom = llclamp(new_zoom, 1.f, 10.f); + static LLCachedControl zoom_limit(gSavedSettings, "MeshPreviewZoomLimit"); + mCameraZoom = llclamp(new_zoom, 1.f, zoom_limit()); + // } void LLModelPreview::pan(F32 right, F32 up) @@ -4444,11 +4622,22 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("server_weight", "[SIM]", tbd); childSetTextArg("physics_weight", "[PH]", tbd); childSetTextArg("upload_fee", "[FEE]", tbd); - childSetTextArg("price_breakdown", "[STREAMING]", tbd); - childSetTextArg("price_breakdown", "[PHYSICS]", tbd); - childSetTextArg("price_breakdown", "[INSTANCES]", tbd); - childSetTextArg("price_breakdown", "[TEXTURES]", tbd); - childSetTextArg("price_breakdown", "[MODEL]", tbd); + // add extended info fields + //childSetTextArg("price_breakdown", "[STREAMING]", dashes); + //childSetTextArg("price_breakdown", "[PHYSICS]", dashes); + //childSetTextArg("price_breakdown", "[INSTANCES]", dashes); + //childSetTextArg("price_breakdown", "[TEXTURES]", dashes); + //childSetTextArg("price_breakdown", "[MODEL]", dashes); + std::string dashes = hasString("--") ? getString("--") : "--"; + childSetTextArg("price_breakdown", "[STREAMING]", dashes); + childSetTextArg("price_breakdown", "[PHYSICS]", dashes); + childSetTextArg("price_breakdown", "[INSTANCES]", dashes); + childSetTextArg("price_breakdown", "[TEXTURES]", dashes); + childSetTextArg("price_breakdown", "[MODEL]", dashes); + childSetTextArg("physics_breakdown", "[PCH]", dashes); + childSetTextArg("physics_breakdown", "[PM]", dashes); + childSetTextArg("physics_breakdown", "[PHU]", dashes); + // } } @@ -4498,6 +4687,16 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("price_breakdown", "[INSTANCES]", llformat("%d", result["upload_price_breakdown"]["mesh_instance"].asInteger())); childSetTextArg("price_breakdown", "[TEXTURES]", llformat("%d", result["upload_price_breakdown"]["texture"].asInteger())); childSetTextArg("price_breakdown", "[MODEL]", llformat("%d", result["upload_price_breakdown"]["model"].asInteger())); +// Updates for enhanced Mesh feedback at upload + childSetTextArg("physics_breakdown", "[PCH]", llformat("%0.3f", result["model_physics_cost"]["hull"].asReal())); + childSetTextArg("physics_breakdown", "[PM]", llformat("%0.3f", result["model_physics_cost"]["mesh"].asReal())); + childSetTextArg("physics_breakdown", "[PHU]", llformat("%0.3f", result["model_physics_cost"]["decomposition"].asReal())); + childSetTextArg("streaming_breakdown", "[STR_TOTAL]", llformat("%d", result["streaming_cost"].asInteger())); + childSetTextArg("streaming_breakdown", "[STR_HIGH]", llformat("%d", result["streaming_params"]["high_lod"].asInteger())); + childSetTextArg("streaming_breakdown", "[STR_MED]", llformat("%d", result["streaming_params"]["medium_lod"].asInteger())); + childSetTextArg("streaming_breakdown", "[STR_LOW]", llformat("%d", result["streaming_params"]["low_lod"].asInteger())); + childSetTextArg("streaming_breakdown", "[STR_LOWEST]", llformat("%d", result["streaming_params"]["lowest_lod"].asInteger())); +// childSetVisible("upload_fee", true); childSetVisible("price_breakdown", true); mUploadBtn->setEnabled(isModelUploadAllowed()); -- cgit v1.2.3 From 76369c2463246227e297c6fee88a4de4e6d4ed67 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Thu, 3 Jan 2019 14:30:01 +0200 Subject: SL-10288 comments cleanup --- indra/newview/llfloatermodelpreview.cpp | 118 +++++--------------------------- 1 file changed, 19 insertions(+), 99 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 01f0a5197d..c86eed2192 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,11 +427,8 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } - // mesh uploader changes to allow higher resolution render - // mModelPreview = new LLModelPreview(512, 512, this); auto size = gSavedSettings.getS32("PreviewRenderSize"); mModelPreview = new LLModelPreview(size, size, this ); - // mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); @@ -441,8 +438,6 @@ 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") @@ -664,7 +659,6 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) } } -// extracted method to simplify changes in layout void LLFloaterModelPreview::draw3dPreview() { gGL.color3f(1.f, 1.f, 1.f); @@ -1266,7 +1260,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) , mResetJoints( false ) , mModelNoErrors( true ) , mLastJointUpdate( false ) -, mHasDegenerate( false ) // +, mHasDegenerate( false ) { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -2756,7 +2750,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim void LLModelPreview::updateStatusMessages() { -// bit mask values for physics errors. used to prevent overwrite of single line status +// bit mask values for physics errors. used to prevent overwrite of single line status // TODO: use this to provied multiline status enum PhysicsError { @@ -2766,10 +2760,10 @@ void LLModelPreview::updateStatusMessages() TOOMANYHULLS=4, TOOMANYVERTSINHULL=8 }; -// + assert_main_thread(); - U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap + U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap //triangle/vertex/submesh count for each mesh asset for each lod std::vector tris[LLModel::NUM_LODS]; std::vector verts[LLModel::NUM_LODS]; @@ -2858,38 +2852,25 @@ void LLModelPreview::updateStatusMessages() { mMaxTriangleLimit = total_tris[LLModel::LOD_HIGH]; } - // make has_degenerate a member so that we can use it in the render method - // has_degenerate = false + mHasDegenerate = false; {//check for degenerate triangles in physics mesh U32 lod = LLModel::LOD_PHYSICS; const LLVector4a scale(0.5f); - for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i)// make has_degenerate a member + for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i) { //for each model in the lod if (mModel[lod][i] && mModel[lod][i]->mPhysics.mHull.empty()) { //no decomp exists S32 cur_submeshes = mModel[lod][i]->getNumVolumeFaces(); - for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j)// make has_degenerate a member + for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j) { //for each submesh (face), add triangles and vertices to current total LLVolumeFace& face = mModel[lod][i]->getVolumeFace(j); - for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; )// make has_degenerate a member + for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; ) { U16 index_a = face.mIndices[k + 0]; U16 index_b = face.mIndices[k + 1]; U16 index_c = face.mIndices[k + 2]; - // FIRE-23367/23387 - Allow forced empty triangle placeholders created by the LOD processing. - // LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); - // LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); - // LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); - - // if (ll_is_degenerate(v1, v2, v3)) - // { - // mHasDegenerate = true;// make has_degenerate a member - // } - // else - // { - // k += 3; - // } + if (index_c == 0 && index_b == 0 && index_a == 0) // test in reverse as 3rd index is less likely to be 0 in a normal case { LL_DEBUGS("MeshValidation") << "Empty placeholder triangle (3 identical index 0 verts) ignored" << LL_ENDL; @@ -2901,7 +2882,7 @@ void LLModelPreview::updateStatusMessages() LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); if (ll_is_degenerate(v1, v2, v3)) { - mHasDegenerate = true;// make has_degenerate a member + mHasDegenerate = true; } } k += 3; @@ -2911,7 +2892,7 @@ void LLModelPreview::updateStatusMessages() } } - // flag degenerates here rather than deferring to a MAV error later + // 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); @@ -2922,7 +2903,6 @@ void LLModelPreview::updateStatusMessages() LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); degenerateIcon->setImage(img); } - // mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); @@ -3092,12 +3072,7 @@ void LLModelPreview::updateStatusMessages() mModelNoErrors = false; } } - // Improve the error checking the TO DO here is no longer applicable but not an FS comment so edited to stop it being picked up - //// To do investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics - //// current use of has_degenerate won't block upload permanently - later checks will restore the button - //if (!mModelNoErrors || mHasDegenerate) - //{ - // mFMP->childDisable("ok_btn"); + if (!mModelNoErrors || mHasDegenerate) { mFMP->childDisable("ok_btn"); @@ -3722,7 +3697,7 @@ BOOL LLModelPreview::render() bool textures = mViewOption["show_textures"]; bool physics = mViewOption["show_physics"]; - // Extra configurability, to be exposed later as controls? + // Extra configurability, to be exposed later as controls? static LLCachedControl canvas_col(gSavedSettings, "MeshPreviewCanvasColor"); static LLCachedControl edge_col(gSavedSettings, "MeshPreviewEdgeColor"); static LLCachedControl base_col(gSavedSettings, "MeshPreviewBaseColor"); @@ -3735,16 +3710,12 @@ BOOL LLModelPreview::render() static LLCachedControl deg_fill_col(gSavedSettings, "MeshPreviewDegenerateFillColor"); static LLCachedControl deg_edge_width(gSavedSettings, "MeshPreviewDegenerateEdgeWidth"); static LLCachedControl deg_point_size(gSavedSettings, "MeshPreviewDegeneratePointSize"); - // + S32 width = getWidth(); S32 height = getHeight(); LLGLSUIDefault def; LLGLDisable no_blend(GL_BLEND); -// Clean up render of mesh preview -// LLGLEnable blend(GL_BLEND); -// gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); -// LLGLEnable cull(GL_CULL_FACE); LLGLDepthTest depth(GL_TRUE); @@ -3764,8 +3735,7 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); - // uploader improvements - //gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); + gGL.color4fv(static_cast(canvas_col).mV); gl_rect_2d_simple( width, height ); @@ -3914,11 +3884,7 @@ BOOL LLModelPreview::render() stop_glerror(); gGL.pushMatrix(); - // mesh uploader improvements configurable brightness - //const F32 BRIGHTNESS = 0.9f; - //gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); gGL.color4fv(edge_col().mV); - // const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; @@ -4003,19 +3969,12 @@ BOOL LLModelPreview::render() } else { - // improved mesh uploader - // 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 - //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); gGL.diffuseColor4fv(static_cast(edge_col).mV); - // if (edges) { glLineWidth(edge_width); @@ -4030,25 +3989,10 @@ BOOL LLModelPreview::render() if (physics) { - // model upload improvements - use the settings - ////Vector4a physicsFillColour(0.4, 0.4, 0.4, 0.4); - //const LLColor4 physicsFillColour(0.0, 0.5, 1.0, 0.5); - ////LLVector4a physicsEdgeColour(1.0, 1.0, 0.0, 1.0); - //const LLColor4 physicsEdgeColour=physicsFillColour*0.5; - //const LLColor4 degenerateFill(1.0, 0.0, 0.0, 0.5); - //const LLColor4 degenerateEdge(1.0,0.0,0.0,1.0); - // - glClear(GL_DEPTH_BUFFER_BIT); - // refactor to remove silly variable names - // for (U32 i = 0; i < 2; i++) for (U32 pass = 0; pass < 2; pass++) - // { - // refactor to remove silly variable names - //if (i == 0) if (pass == 0) - // { //depth only pass gGL.setColorMask(false, false); } @@ -4058,10 +4002,7 @@ BOOL LLModelPreview::render() } //enable alpha blending on second pass but not first pass - // refactor to remove silly variable names - //LLGLState blend(GL_BLEND, i); LLGLState blend(GL_BLEND, pass); - // gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); @@ -4165,16 +4106,11 @@ BOOL LLModelPreview::render() gGL.popMatrix(); } - // refactor to remove silly variable names - // also only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] - //if (i > 0) + // only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] if (pass > 0 && mHasDegenerate) - // { glLineWidth(deg_edge_width); glPointSize(deg_point_size); -// This single line is why the degenerate triangles display has been crap forever. -// gPipeline.enableLightsFullbright(LLColor4::white); //show degenerate triangles LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); LLGLDisable cull(GL_CULL_FACE); @@ -4212,13 +4148,10 @@ BOOL LLModelPreview::render() } auto num_degenerate = 0; - // More nested i variable silliness - // for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) auto num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); for (U32 v = 0; v < num_models; ++v) { LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][v]; - // if(buffer->getNumVerts() < 3)continue; buffer->setBuffer(type_mask & buffer->getTypeMask()); @@ -4231,7 +4164,6 @@ BOOL LLModelPreview::render() buffer->getIndexStrider(idx, 0); LLVector4a v1, v2, v3; - // rename inner most i to avoid merge confusion for (U32 indices_offset = 0; indices_offset < buffer->getNumIndices(); indices_offset += 3) { v1.setMul(pos[*idx++], scale); @@ -4342,8 +4274,6 @@ BOOL LLModelPreview::render() } buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); - // configurable colour and width - //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { @@ -4354,7 +4284,6 @@ BOOL LLModelPreview::render() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } - // } } } @@ -4412,11 +4341,9 @@ void LLModelPreview::rotate(F32 yaw_radians, F32 pitch_radians) void LLModelPreview::zoom(F32 zoom_amt) { F32 new_zoom = mCameraZoom+zoom_amt; - // add configurable zoom TODO: stop clamping in render - // mCameraZoom = llclamp(new_zoom, 1.f, 10.f); + // TODO: stop clamping in render static LLCachedControl zoom_limit(gSavedSettings, "MeshPreviewZoomLimit"); mCameraZoom = llclamp(new_zoom, 1.f, zoom_limit()); - // } void LLModelPreview::pan(F32 right, F32 up) @@ -4622,12 +4549,6 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("server_weight", "[SIM]", tbd); childSetTextArg("physics_weight", "[PH]", tbd); childSetTextArg("upload_fee", "[FEE]", tbd); - // add extended info fields - //childSetTextArg("price_breakdown", "[STREAMING]", dashes); - //childSetTextArg("price_breakdown", "[PHYSICS]", dashes); - //childSetTextArg("price_breakdown", "[INSTANCES]", dashes); - //childSetTextArg("price_breakdown", "[TEXTURES]", dashes); - //childSetTextArg("price_breakdown", "[MODEL]", dashes); std::string dashes = hasString("--") ? getString("--") : "--"; childSetTextArg("price_breakdown", "[STREAMING]", dashes); childSetTextArg("price_breakdown", "[PHYSICS]", dashes); @@ -4637,7 +4558,6 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("physics_breakdown", "[PCH]", dashes); childSetTextArg("physics_breakdown", "[PM]", dashes); childSetTextArg("physics_breakdown", "[PHU]", dashes); - // } } @@ -4687,7 +4607,7 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("price_breakdown", "[INSTANCES]", llformat("%d", result["upload_price_breakdown"]["mesh_instance"].asInteger())); childSetTextArg("price_breakdown", "[TEXTURES]", llformat("%d", result["upload_price_breakdown"]["texture"].asInteger())); childSetTextArg("price_breakdown", "[MODEL]", llformat("%d", result["upload_price_breakdown"]["model"].asInteger())); -// Updates for enhanced Mesh feedback at upload + childSetTextArg("physics_breakdown", "[PCH]", llformat("%0.3f", result["model_physics_cost"]["hull"].asReal())); childSetTextArg("physics_breakdown", "[PM]", llformat("%0.3f", result["model_physics_cost"]["mesh"].asReal())); childSetTextArg("physics_breakdown", "[PHU]", llformat("%0.3f", result["model_physics_cost"]["decomposition"].asReal())); @@ -4696,7 +4616,7 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("streaming_breakdown", "[STR_MED]", llformat("%d", result["streaming_params"]["medium_lod"].asInteger())); childSetTextArg("streaming_breakdown", "[STR_LOW]", llformat("%d", result["streaming_params"]["low_lod"].asInteger())); childSetTextArg("streaming_breakdown", "[STR_LOWEST]", llformat("%d", result["streaming_params"]["lowest_lod"].asInteger())); -// + childSetVisible("upload_fee", true); childSetVisible("price_breakdown", true); mUploadBtn->setEnabled(isModelUploadAllowed()); -- cgit v1.2.3 From 9c8584a3a7562810c83dd5e2d02e42e6d6870d96 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 11 Jan 2019 17:39:26 +0200 Subject: SL-10327 FIXED Scalable preview of mesh model is shown with black bar on top in the Upload Model menu --- indra/newview/llfloatermodelpreview.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index c86eed2192..2cc42460a5 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,8 +427,23 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } - auto size = gSavedSettings.getS32("PreviewRenderSize"); - mModelPreview = new LLModelPreview(size, size, this ); + + S32 tex_width = 512; + S32 tex_height = 512; + + S32 max_width = llmin(gSavedSettings.getS32("PreviewRenderSize"), (S32)gPipeline.mScreenWidth); + S32 max_height = llmin(gSavedSettings.getS32("PreviewRenderSize"), (S32)gPipeline.mScreenHeight); + + while ((tex_width << 1) <= max_width) + { + tex_width <<= 1; + } + while ((tex_height << 1) <= max_height) + { + tex_height <<= 1; + } + + mModelPreview = new LLModelPreview(tex_width, tex_height, this); mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); -- cgit v1.2.3 From 26fae750ba753f32f58bd56d297f2d98c5759e50 Mon Sep 17 00:00:00 2001 From: andreykproductengine Date: Mon, 14 Jan 2019 22:04:44 +0200 Subject: SL-10291 Replace apr_mutex with standard C++11 functionality --- indra/newview/llfloatermodelpreview.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 2cc42460a5..616bee84fd 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -266,7 +266,7 @@ mCalculateBtn(NULL) sInstance = this; mLastMouseX = 0; mLastMouseY = 0; - mStatusLock = new LLMutex(NULL); + mStatusLock = new LLMutex(); mModelPreview = NULL; mLODMode[LLModel::LOD_HIGH] = 0; @@ -1265,7 +1265,7 @@ void LLFloaterModelPreview::onMouseCaptureLostModelPreview(LLMouseHandler* handl //----------------------------------------------------------------------------- LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) -: LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE), LLMutex(NULL) +: LLViewerDynamicTexture(width, height, 3, ORDER_MIDDLE, FALSE), LLMutex() , mLodsQuery() , mLodsWithParsingError() , mPelvisZOffset( 0.0f ) -- cgit v1.2.3 From 00a6c069f21a7dcde52247e8bdf902e50369cc00 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 13 Feb 2019 16:55:22 +0200 Subject: SL-10328 FIXED Some parameters are not reset in the Upload Model menu when pressing button 'Clear settings & reset form' --- indra/newview/llfloatermodelpreview.cpp | 62 ++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 13 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 616bee84fd..e39e210939 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -304,10 +304,10 @@ BOOL LLFloaterModelPreview::postBuild() getChild("lod_triangle_limit_" + lod_name[lod])->setCommitCallback(boost::bind(&LLFloaterModelPreview::onLODParamCommit, this, lod, true)); } - childSetCommitCallback("upload_skin", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); - childSetCommitCallback("upload_joints", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); - childSetCommitCallback("lock_scale_if_joint_position", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); - childSetCommitCallback("upload_textures", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); + childSetCommitCallback("upload_skin", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); + childSetCommitCallback("upload_joints", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); + childSetCommitCallback("lock_scale_if_joint_position", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); + childSetCommitCallback("upload_textures", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); childSetTextArg("status", "[STATUS]", getString("status_idle")); @@ -449,6 +449,16 @@ void LLFloaterModelPreview::initModelPreview() mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); } +void LLFloaterModelPreview::onUploadOptionChecked(LLUICtrl* ctrl) +{ + if (mModelPreview) + { + auto name = ctrl->getName(); + mModelPreview->mViewOption[name] = !mModelPreview->mViewOption[name]; + } + toggleCalculateButton(true); +} + void LLFloaterModelPreview::onViewOptionChecked(LLUICtrl* ctrl) { if (mModelPreview) @@ -631,6 +641,7 @@ void LLFloaterModelPreview::onGenerateNormalsCommit(LLUICtrl* ctrl, void* userda void LLFloaterModelPreview::toggleGenarateNormals() { bool enabled = childGetValue("gen_normals").asBoolean(); + mModelPreview->mViewOption["gen_normals"] = enabled; childSetEnabled("crease_angle", enabled); if(enabled) { mModelPreview->generateNormals(); @@ -1156,10 +1167,8 @@ void LLFloaterModelPreview::initDecompControls() std::string label = llformat("%.1f", value); combo_box->add(label, value, ADD_BOTTOM, true); } - combo_box->setValue(param[i].mDefault.mFloat); - } - + combo_box->setValue(param[i].mDefault.mFloat); combo_box->setCommitCallback(onPhysicsParamCommit, (void*) ¶m[i]); } } @@ -1231,7 +1240,7 @@ void LLFloaterModelPreview::initDecompControls() //LL_INFOS() << "-----------------------------" << LL_ENDL; } } - + mDefaultDecompParams = mDecompParams; childSetCommitCallback("physics_explode", LLFloaterModelPreview::onExplodeCommit, this); } @@ -4420,6 +4429,7 @@ void LLFloaterModelPreview::onReset(void* user_data) std::string filename = mp->mLODFile[LLModel::LOD_HIGH]; fmp->resetDisplayOptions(); + fmp->resetUploadOptions(); //reset model preview fmp->initModelPreview(); @@ -4533,11 +4543,6 @@ void LLFloaterModelPreview::setStatusMessage(const std::string& msg) mStatusMessage = msg; } -void LLFloaterModelPreview::toggleCalculateButton() -{ - toggleCalculateButton(true); -} - void LLFloaterModelPreview::toggleCalculateButton(bool visible) { mCalculateBtn->setVisible(visible); @@ -4599,6 +4604,37 @@ void LLFloaterModelPreview::resetDisplayOptions() } } +void LLFloaterModelPreview::resetUploadOptions() +{ + childSetValue("import_scale", 1); + childSetValue("pelvis_offset", 0); + childSetValue("physics_explode", 0); + childSetValue("physics_file", ""); + childSetVisible("Retain%", false); + childSetVisible("Retain%_label", false); + childSetVisible("Detail Scale", true); + childSetVisible("Detail Scale label", true); + + getChild("lod_source_" + lod_name[NUM_LOD - 1])->setCurrentByIndex(LLModelPreview::LOD_FROM_FILE); + for (S32 lod = 0; lod < NUM_LOD - 1; ++lod) + { + getChild("lod_source_" + lod_name[lod])->setCurrentByIndex(LLModelPreview::GENERATE); + childSetValue("lod_file_" + lod_name[lod], ""); + } + + getChild("physics_lod_combo")->setCurrentByIndex(0); + + for(auto& p : mDefaultDecompParams) + { + std::string ctrl_name(p.first); + LLUICtrl* ctrl = getChild(ctrl_name); + if (ctrl) + { + ctrl->setValue(p.second); + } + } +} + void LLFloaterModelPreview::onModelPhysicsFeeReceived(const LLSD& result, std::string upload_url) { mModelPhysicsFee = result; -- cgit v1.2.3 From 54b444c5d5e4e7ee80801e5eeed6b32227096580 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Sat, 23 Feb 2019 20:05:15 +0200 Subject: Backed out changeset: d531bea24d6e --- indra/newview/llfloatermodelpreview.cpp | 62 +++++++-------------------------- 1 file changed, 13 insertions(+), 49 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index e39e210939..616bee84fd 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -304,10 +304,10 @@ BOOL LLFloaterModelPreview::postBuild() getChild("lod_triangle_limit_" + lod_name[lod])->setCommitCallback(boost::bind(&LLFloaterModelPreview::onLODParamCommit, this, lod, true)); } - childSetCommitCallback("upload_skin", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); - childSetCommitCallback("upload_joints", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); - childSetCommitCallback("lock_scale_if_joint_position", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); - childSetCommitCallback("upload_textures", boost::bind(&LLFloaterModelPreview::onUploadOptionChecked, this, _1), NULL); + childSetCommitCallback("upload_skin", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); + childSetCommitCallback("upload_joints", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); + childSetCommitCallback("lock_scale_if_joint_position", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); + childSetCommitCallback("upload_textures", boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this), NULL); childSetTextArg("status", "[STATUS]", getString("status_idle")); @@ -449,16 +449,6 @@ void LLFloaterModelPreview::initModelPreview() mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); } -void LLFloaterModelPreview::onUploadOptionChecked(LLUICtrl* ctrl) -{ - if (mModelPreview) - { - auto name = ctrl->getName(); - mModelPreview->mViewOption[name] = !mModelPreview->mViewOption[name]; - } - toggleCalculateButton(true); -} - void LLFloaterModelPreview::onViewOptionChecked(LLUICtrl* ctrl) { if (mModelPreview) @@ -641,7 +631,6 @@ void LLFloaterModelPreview::onGenerateNormalsCommit(LLUICtrl* ctrl, void* userda void LLFloaterModelPreview::toggleGenarateNormals() { bool enabled = childGetValue("gen_normals").asBoolean(); - mModelPreview->mViewOption["gen_normals"] = enabled; childSetEnabled("crease_angle", enabled); if(enabled) { mModelPreview->generateNormals(); @@ -1167,8 +1156,10 @@ void LLFloaterModelPreview::initDecompControls() std::string label = llformat("%.1f", value); combo_box->add(label, value, ADD_BOTTOM, true); } + combo_box->setValue(param[i].mDefault.mFloat); + } - combo_box->setValue(param[i].mDefault.mFloat); + combo_box->setCommitCallback(onPhysicsParamCommit, (void*) ¶m[i]); } } @@ -1240,7 +1231,7 @@ void LLFloaterModelPreview::initDecompControls() //LL_INFOS() << "-----------------------------" << LL_ENDL; } } - mDefaultDecompParams = mDecompParams; + childSetCommitCallback("physics_explode", LLFloaterModelPreview::onExplodeCommit, this); } @@ -4429,7 +4420,6 @@ void LLFloaterModelPreview::onReset(void* user_data) std::string filename = mp->mLODFile[LLModel::LOD_HIGH]; fmp->resetDisplayOptions(); - fmp->resetUploadOptions(); //reset model preview fmp->initModelPreview(); @@ -4543,6 +4533,11 @@ void LLFloaterModelPreview::setStatusMessage(const std::string& msg) mStatusMessage = msg; } +void LLFloaterModelPreview::toggleCalculateButton() +{ + toggleCalculateButton(true); +} + void LLFloaterModelPreview::toggleCalculateButton(bool visible) { mCalculateBtn->setVisible(visible); @@ -4604,37 +4599,6 @@ void LLFloaterModelPreview::resetDisplayOptions() } } -void LLFloaterModelPreview::resetUploadOptions() -{ - childSetValue("import_scale", 1); - childSetValue("pelvis_offset", 0); - childSetValue("physics_explode", 0); - childSetValue("physics_file", ""); - childSetVisible("Retain%", false); - childSetVisible("Retain%_label", false); - childSetVisible("Detail Scale", true); - childSetVisible("Detail Scale label", true); - - getChild("lod_source_" + lod_name[NUM_LOD - 1])->setCurrentByIndex(LLModelPreview::LOD_FROM_FILE); - for (S32 lod = 0; lod < NUM_LOD - 1; ++lod) - { - getChild("lod_source_" + lod_name[lod])->setCurrentByIndex(LLModelPreview::GENERATE); - childSetValue("lod_file_" + lod_name[lod], ""); - } - - getChild("physics_lod_combo")->setCurrentByIndex(0); - - for(auto& p : mDefaultDecompParams) - { - std::string ctrl_name(p.first); - LLUICtrl* ctrl = getChild(ctrl_name); - if (ctrl) - { - ctrl->setValue(p.second); - } - } -} - void LLFloaterModelPreview::onModelPhysicsFeeReceived(const LLSD& result, std::string upload_url) { mModelPhysicsFee = result; -- cgit v1.2.3 From 3de1f3e59e54d88ee5cff9607d9eebe9eb9950b5 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Sat, 23 Feb 2019 20:05:29 +0200 Subject: Backed out changeset: ce6ac58d801c --- indra/newview/llfloatermodelpreview.cpp | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 616bee84fd..79b9df2fa6 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,23 +427,8 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } - - S32 tex_width = 512; - S32 tex_height = 512; - - S32 max_width = llmin(gSavedSettings.getS32("PreviewRenderSize"), (S32)gPipeline.mScreenWidth); - S32 max_height = llmin(gSavedSettings.getS32("PreviewRenderSize"), (S32)gPipeline.mScreenHeight); - - while ((tex_width << 1) <= max_width) - { - tex_width <<= 1; - } - while ((tex_height << 1) <= max_height) - { - tex_height <<= 1; - } - - mModelPreview = new LLModelPreview(tex_width, tex_height, this); + auto size = gSavedSettings.getS32("PreviewRenderSize"); + mModelPreview = new LLModelPreview(size, size, this ); mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); -- cgit v1.2.3 From 150faaf53c3b59ff65aaa40a47d6678c741c4eaf Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Sat, 23 Feb 2019 20:06:46 +0200 Subject: Backed out changeset: f1fa95a76b9a --- indra/newview/llfloatermodelpreview.cpp | 118 +++++++++++++++++++++++++++----- 1 file changed, 99 insertions(+), 19 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 79b9df2fa6..7624245c16 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,8 +427,11 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } + // mesh uploader changes to allow higher resolution render + // mModelPreview = new LLModelPreview(512, 512, this); auto size = gSavedSettings.getS32("PreviewRenderSize"); mModelPreview = new LLModelPreview(size, size, this ); + // mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); @@ -438,6 +441,8 @@ 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") @@ -659,6 +664,7 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) } } +// extracted method to simplify changes in layout void LLFloaterModelPreview::draw3dPreview() { gGL.color3f(1.f, 1.f, 1.f); @@ -1260,7 +1266,7 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) , mResetJoints( false ) , mModelNoErrors( true ) , mLastJointUpdate( false ) -, mHasDegenerate( false ) +, mHasDegenerate( false ) // { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -2750,7 +2756,7 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim void LLModelPreview::updateStatusMessages() { -// bit mask values for physics errors. used to prevent overwrite of single line status +// bit mask values for physics errors. used to prevent overwrite of single line status // TODO: use this to provied multiline status enum PhysicsError { @@ -2760,10 +2766,10 @@ void LLModelPreview::updateStatusMessages() TOOMANYHULLS=4, TOOMANYVERTSINHULL=8 }; - +// assert_main_thread(); - U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap + U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap //triangle/vertex/submesh count for each mesh asset for each lod std::vector tris[LLModel::NUM_LODS]; std::vector verts[LLModel::NUM_LODS]; @@ -2852,25 +2858,38 @@ void LLModelPreview::updateStatusMessages() { mMaxTriangleLimit = total_tris[LLModel::LOD_HIGH]; } - + // make has_degenerate a member so that we can use it in the render method + // has_degenerate = false mHasDegenerate = false; {//check for degenerate triangles in physics mesh U32 lod = LLModel::LOD_PHYSICS; const LLVector4a scale(0.5f); - for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i) + for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i)// make has_degenerate a member { //for each model in the lod if (mModel[lod][i] && mModel[lod][i]->mPhysics.mHull.empty()) { //no decomp exists S32 cur_submeshes = mModel[lod][i]->getNumVolumeFaces(); - for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j) + for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j)// make has_degenerate a member { //for each submesh (face), add triangles and vertices to current total LLVolumeFace& face = mModel[lod][i]->getVolumeFace(j); - for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; ) + for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; )// make has_degenerate a member { U16 index_a = face.mIndices[k + 0]; U16 index_b = face.mIndices[k + 1]; U16 index_c = face.mIndices[k + 2]; - + // FIRE-23367/23387 - Allow forced empty triangle placeholders created by the LOD processing. + // LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); + // LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); + // LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); + + // if (ll_is_degenerate(v1, v2, v3)) + // { + // mHasDegenerate = true;// make has_degenerate a member + // } + // else + // { + // k += 3; + // } if (index_c == 0 && index_b == 0 && index_a == 0) // test in reverse as 3rd index is less likely to be 0 in a normal case { LL_DEBUGS("MeshValidation") << "Empty placeholder triangle (3 identical index 0 verts) ignored" << LL_ENDL; @@ -2882,7 +2901,7 @@ void LLModelPreview::updateStatusMessages() LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); if (ll_is_degenerate(v1, v2, v3)) { - mHasDegenerate = true; + mHasDegenerate = true;// make has_degenerate a member } } k += 3; @@ -2892,7 +2911,7 @@ void LLModelPreview::updateStatusMessages() } } - // flag degenerates here rather than deferring to a MAV error later + // 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); @@ -2903,6 +2922,7 @@ void LLModelPreview::updateStatusMessages() LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Error"); degenerateIcon->setImage(img); } + // mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); @@ -3072,7 +3092,12 @@ void LLModelPreview::updateStatusMessages() mModelNoErrors = false; } } - + // Improve the error checking the TO DO here is no longer applicable but not an FS comment so edited to stop it being picked up + //// To do investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics + //// current use of has_degenerate won't block upload permanently - later checks will restore the button + //if (!mModelNoErrors || mHasDegenerate) + //{ + // mFMP->childDisable("ok_btn"); if (!mModelNoErrors || mHasDegenerate) { mFMP->childDisable("ok_btn"); @@ -3697,7 +3722,7 @@ BOOL LLModelPreview::render() bool textures = mViewOption["show_textures"]; bool physics = mViewOption["show_physics"]; - // Extra configurability, to be exposed later as controls? + // Extra configurability, to be exposed later as controls? static LLCachedControl canvas_col(gSavedSettings, "MeshPreviewCanvasColor"); static LLCachedControl edge_col(gSavedSettings, "MeshPreviewEdgeColor"); static LLCachedControl base_col(gSavedSettings, "MeshPreviewBaseColor"); @@ -3710,12 +3735,16 @@ BOOL LLModelPreview::render() static LLCachedControl deg_fill_col(gSavedSettings, "MeshPreviewDegenerateFillColor"); static LLCachedControl deg_edge_width(gSavedSettings, "MeshPreviewDegenerateEdgeWidth"); static LLCachedControl deg_point_size(gSavedSettings, "MeshPreviewDegeneratePointSize"); - + // S32 width = getWidth(); S32 height = getHeight(); LLGLSUIDefault def; LLGLDisable no_blend(GL_BLEND); +// Clean up render of mesh preview +// LLGLEnable blend(GL_BLEND); +// gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); +// LLGLEnable cull(GL_CULL_FACE); LLGLDepthTest depth(GL_TRUE); @@ -3735,7 +3764,8 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); - + // uploader improvements + //gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); gGL.color4fv(static_cast(canvas_col).mV); gl_rect_2d_simple( width, height ); @@ -3884,7 +3914,11 @@ BOOL LLModelPreview::render() stop_glerror(); gGL.pushMatrix(); + // mesh uploader improvements configurable brightness + //const F32 BRIGHTNESS = 0.9f; + //gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); gGL.color4fv(edge_col().mV); + // const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; @@ -3969,12 +4003,19 @@ BOOL LLModelPreview::render() } else { + // improved mesh uploader + // 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 + //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); gGL.diffuseColor4fv(static_cast(edge_col).mV); + // if (edges) { glLineWidth(edge_width); @@ -3989,10 +4030,25 @@ BOOL LLModelPreview::render() if (physics) { + // model upload improvements - use the settings + ////Vector4a physicsFillColour(0.4, 0.4, 0.4, 0.4); + //const LLColor4 physicsFillColour(0.0, 0.5, 1.0, 0.5); + ////LLVector4a physicsEdgeColour(1.0, 1.0, 0.0, 1.0); + //const LLColor4 physicsEdgeColour=physicsFillColour*0.5; + //const LLColor4 degenerateFill(1.0, 0.0, 0.0, 0.5); + //const LLColor4 degenerateEdge(1.0,0.0,0.0,1.0); + // + glClear(GL_DEPTH_BUFFER_BIT); + // refactor to remove silly variable names + // for (U32 i = 0; i < 2; i++) for (U32 pass = 0; pass < 2; pass++) + // { + // refactor to remove silly variable names + //if (i == 0) if (pass == 0) + // { //depth only pass gGL.setColorMask(false, false); } @@ -4002,7 +4058,10 @@ BOOL LLModelPreview::render() } //enable alpha blending on second pass but not first pass + // refactor to remove silly variable names + //LLGLState blend(GL_BLEND, i); LLGLState blend(GL_BLEND, pass); + // gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); @@ -4106,11 +4165,16 @@ BOOL LLModelPreview::render() gGL.popMatrix(); } - // only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] + // refactor to remove silly variable names + // also only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] + //if (i > 0) if (pass > 0 && mHasDegenerate) + // { glLineWidth(deg_edge_width); glPointSize(deg_point_size); +// This single line is why the degenerate triangles display has been crap forever. +// gPipeline.enableLightsFullbright(LLColor4::white); //show degenerate triangles LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); LLGLDisable cull(GL_CULL_FACE); @@ -4148,10 +4212,13 @@ BOOL LLModelPreview::render() } auto num_degenerate = 0; + // More nested i variable silliness + // for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) auto num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); for (U32 v = 0; v < num_models; ++v) { LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][v]; + // if(buffer->getNumVerts() < 3)continue; buffer->setBuffer(type_mask & buffer->getTypeMask()); @@ -4164,6 +4231,7 @@ BOOL LLModelPreview::render() buffer->getIndexStrider(idx, 0); LLVector4a v1, v2, v3; + // rename inner most i to avoid merge confusion for (U32 indices_offset = 0; indices_offset < buffer->getNumIndices(); indices_offset += 3) { v1.setMul(pos[*idx++], scale); @@ -4274,6 +4342,8 @@ BOOL LLModelPreview::render() } buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); + // configurable colour and width + //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { @@ -4284,6 +4354,7 @@ BOOL LLModelPreview::render() glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } + // } } } @@ -4341,9 +4412,11 @@ void LLModelPreview::rotate(F32 yaw_radians, F32 pitch_radians) void LLModelPreview::zoom(F32 zoom_amt) { F32 new_zoom = mCameraZoom+zoom_amt; - // TODO: stop clamping in render + // add configurable zoom TODO: stop clamping in render + // mCameraZoom = llclamp(new_zoom, 1.f, 10.f); static LLCachedControl zoom_limit(gSavedSettings, "MeshPreviewZoomLimit"); mCameraZoom = llclamp(new_zoom, 1.f, zoom_limit()); + // } void LLModelPreview::pan(F32 right, F32 up) @@ -4549,6 +4622,12 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("server_weight", "[SIM]", tbd); childSetTextArg("physics_weight", "[PH]", tbd); childSetTextArg("upload_fee", "[FEE]", tbd); + // add extended info fields + //childSetTextArg("price_breakdown", "[STREAMING]", dashes); + //childSetTextArg("price_breakdown", "[PHYSICS]", dashes); + //childSetTextArg("price_breakdown", "[INSTANCES]", dashes); + //childSetTextArg("price_breakdown", "[TEXTURES]", dashes); + //childSetTextArg("price_breakdown", "[MODEL]", dashes); std::string dashes = hasString("--") ? getString("--") : "--"; childSetTextArg("price_breakdown", "[STREAMING]", dashes); childSetTextArg("price_breakdown", "[PHYSICS]", dashes); @@ -4558,6 +4637,7 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("physics_breakdown", "[PCH]", dashes); childSetTextArg("physics_breakdown", "[PM]", dashes); childSetTextArg("physics_breakdown", "[PHU]", dashes); + // } } @@ -4607,7 +4687,7 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("price_breakdown", "[INSTANCES]", llformat("%d", result["upload_price_breakdown"]["mesh_instance"].asInteger())); childSetTextArg("price_breakdown", "[TEXTURES]", llformat("%d", result["upload_price_breakdown"]["texture"].asInteger())); childSetTextArg("price_breakdown", "[MODEL]", llformat("%d", result["upload_price_breakdown"]["model"].asInteger())); - +// Updates for enhanced Mesh feedback at upload childSetTextArg("physics_breakdown", "[PCH]", llformat("%0.3f", result["model_physics_cost"]["hull"].asReal())); childSetTextArg("physics_breakdown", "[PM]", llformat("%0.3f", result["model_physics_cost"]["mesh"].asReal())); childSetTextArg("physics_breakdown", "[PHU]", llformat("%0.3f", result["model_physics_cost"]["decomposition"].asReal())); @@ -4616,7 +4696,7 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("streaming_breakdown", "[STR_MED]", llformat("%d", result["streaming_params"]["medium_lod"].asInteger())); childSetTextArg("streaming_breakdown", "[STR_LOW]", llformat("%d", result["streaming_params"]["low_lod"].asInteger())); childSetTextArg("streaming_breakdown", "[STR_LOWEST]", llformat("%d", result["streaming_params"]["lowest_lod"].asInteger())); - +// childSetVisible("upload_fee", true); childSetVisible("price_breakdown", true); mUploadBtn->setEnabled(isModelUploadAllowed()); -- cgit v1.2.3 From 599e08181544f214142703928a6d242a0ae72e60 Mon Sep 17 00:00:00 2001 From: AndreyL ProductEngine Date: Sat, 23 Feb 2019 20:08:03 +0200 Subject: Backed out changeset: d5795c04fecc --- indra/newview/llfloatermodelpreview.cpp | 527 ++++++++++---------------------- 1 file changed, 164 insertions(+), 363 deletions(-) (limited to 'indra/newview/llfloatermodelpreview.cpp') diff --git a/indra/newview/llfloatermodelpreview.cpp b/indra/newview/llfloatermodelpreview.cpp index 7624245c16..4f1ea4a89e 100644 --- a/indra/newview/llfloatermodelpreview.cpp +++ b/indra/newview/llfloatermodelpreview.cpp @@ -427,11 +427,8 @@ void LLFloaterModelPreview::initModelPreview() { delete mModelPreview; } - // mesh uploader changes to allow higher resolution render - // mModelPreview = new LLModelPreview(512, 512, this); - auto size = gSavedSettings.getS32("PreviewRenderSize"); - mModelPreview = new LLModelPreview(size, size, this ); - // + + mModelPreview = new LLModelPreview(512, 512, this ); mModelPreview->setPreviewTarget(16.f); mModelPreview->setDetailsCallback(boost::bind(&LLFloaterModelPreview::setDetails, this, _1, _2, _3, _4, _5)); mModelPreview->setModelUpdatedCallback(boost::bind(&LLFloaterModelPreview::toggleCalculateButton, this, _1)); @@ -441,16 +438,8 @@ 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(); } } @@ -664,43 +653,6 @@ void LLFloaterModelPreview::onLODParamCommit(S32 lod, bool enforce_tri_limit) } } -// extracted method to simplify changes in layout -void LLFloaterModelPreview::draw3dPreview() -{ - gGL.color3f(1.f, 1.f, 1.f); - - gGL.getTexUnit(0)->bind(mModelPreview); - - - LLView* preview_panel = getChild("preview_panel"); - - if (!preview_panel) - { - LL_WARNS() << "preview_panel not found in floater definition" << LL_ENDL; - } - LLRect rect = preview_panel->getRect(); - - if (rect != mPreviewRect) - { - mModelPreview->refresh(); - mPreviewRect = preview_panel->getRect(); - } - - gGL.begin( LLRender::QUADS ); - { - gGL.texCoord2f(0.f, 1.f); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mTop-1); - gGL.texCoord2f(0.f, 0.f); - gGL.vertex2i(mPreviewRect.mLeft, mPreviewRect.mBottom); - gGL.texCoord2f(1.f, 0.f); - gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mBottom); - gGL.texCoord2f(1.f, 1.f); - gGL.vertex2i(mPreviewRect.mRight-1, mPreviewRect.mTop-1); - } - gGL.end(); - - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); -} //----------------------------------------------------------------------------- // draw() @@ -1266,7 +1218,6 @@ LLModelPreview::LLModelPreview(S32 width, S32 height, LLFloater* fmp) , mResetJoints( false ) , mModelNoErrors( true ) , mLastJointUpdate( false ) -, mHasDegenerate( false ) // { mNeedsUpdate = TRUE; mCameraDistance = 0.f; @@ -2756,20 +2707,8 @@ void LLModelPreview::genLODs(S32 which_lod, U32 decimation, bool enforce_tri_lim void LLModelPreview::updateStatusMessages() { -// bit mask values for physics errors. used to prevent overwrite of single line status -// TODO: use this to provied multiline status - enum PhysicsError - { - NONE=0, - NOHAVOK=1, - DEGENERATE=2, - TOOMANYHULLS=4, - TOOMANYVERTSINHULL=8 - }; -// assert_main_thread(); - U32 has_physics_error{ PhysicsError::NONE }; // physics error bitmap //triangle/vertex/submesh count for each mesh asset for each lod std::vector tris[LLModel::NUM_LODS]; std::vector verts[LLModel::NUM_LODS]; @@ -2858,72 +2797,44 @@ void LLModelPreview::updateStatusMessages() { mMaxTriangleLimit = total_tris[LLModel::LOD_HIGH]; } - // make has_degenerate a member so that we can use it in the render method - // has_degenerate = false - mHasDegenerate = false; + + bool has_degenerate = false; + {//check for degenerate triangles in physics mesh U32 lod = LLModel::LOD_PHYSICS; const LLVector4a scale(0.5f); - for (U32 i = 0; i < mModel[lod].size() && !mHasDegenerate; ++i)// make has_degenerate a member + for (U32 i = 0; i < mModel[lod].size() && !has_degenerate; ++i) { //for each model in the lod if (mModel[lod][i] && mModel[lod][i]->mPhysics.mHull.empty()) { //no decomp exists S32 cur_submeshes = mModel[lod][i]->getNumVolumeFaces(); - for (S32 j = 0; j < cur_submeshes && !mHasDegenerate; ++j)// make has_degenerate a member + for (S32 j = 0; j < cur_submeshes && !has_degenerate; ++j) { //for each submesh (face), add triangles and vertices to current total LLVolumeFace& face = mModel[lod][i]->getVolumeFace(j); - for (S32 k = 0; (k < face.mNumIndices) && !mHasDegenerate; )// make has_degenerate a member + for (S32 k = 0; (k < face.mNumIndices) && !has_degenerate; ) { - U16 index_a = face.mIndices[k + 0]; - U16 index_b = face.mIndices[k + 1]; - U16 index_c = face.mIndices[k + 2]; - // FIRE-23367/23387 - Allow forced empty triangle placeholders created by the LOD processing. - // LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); - // LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); - // LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); - - // if (ll_is_degenerate(v1, v2, v3)) - // { - // mHasDegenerate = true;// make has_degenerate a member - // } - // else - // { - // k += 3; - // } - if (index_c == 0 && index_b == 0 && index_a == 0) // test in reverse as 3rd index is less likely to be 0 in a normal case + U16 index_a = face.mIndices[k+0]; + U16 index_b = face.mIndices[k+1]; + U16 index_c = face.mIndices[k+2]; + + LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); + LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); + LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); + + if (ll_is_degenerate(v1,v2,v3)) { - LL_DEBUGS("MeshValidation") << "Empty placeholder triangle (3 identical index 0 verts) ignored" << LL_ENDL; + has_degenerate = true; } else { - LLVector4a v1; v1.setMul(face.mPositions[index_a], scale); - LLVector4a v2; v2.setMul(face.mPositions[index_b], scale); - LLVector4a v3; v3.setMul(face.mPositions[index_c], scale); - if (ll_is_degenerate(v1, v2, v3)) - { - mHasDegenerate = true;// make has_degenerate a member - } + k += 3; } - k += 3; } } } } } - // 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); - } - // - mFMP->childSetTextArg("submeshes_info", "[SUBMESHES]", llformat("%d", total_submeshes[LLModel::LOD_HIGH])); std::string mesh_status_na = mFMP->getString("mesh_status_na"); @@ -3048,22 +2959,14 @@ void LLModelPreview::updateStatusMessages() } } } - + mFMP->childSetVisible("physics_status_message_text", physExceededVertexLimit); + LLIconCtrl* physStatusIcon = mFMP->getChild("physics_status_message_icon"); + physStatusIcon->setVisible(physExceededVertexLimit); if (physExceededVertexLimit) { - 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) - { - mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_vertex_limit_exceeded")); - LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); - physStatusIcon->setImage(img); - } + mFMP->childSetValue("physics_status_message_text", mFMP->getString("phys_status_vertex_limit_exceeded")); + LLUIImagePtr img = LLUI::getUIImage("ModelImport_Status_Warning"); + physStatusIcon->setImage(img); } if (getLoadState() >= LLModelLoader::ERROR_PARSING) @@ -3092,21 +2995,12 @@ void LLModelPreview::updateStatusMessages() mModelNoErrors = false; } } - // Improve the error checking the TO DO here is no longer applicable but not an FS comment so edited to stop it being picked up - //// To do investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics - //// current use of has_degenerate won't block upload permanently - later checks will restore the button - //if (!mModelNoErrors || mHasDegenerate) - //{ - // mFMP->childDisable("ok_btn"); - if (!mModelNoErrors || mHasDegenerate) + + // Todo: investigate use of has_degenerate and include into mModelNoErrors upload blocking mechanics + // current use of has_degenerate won't block upload permanently - later checks will restore the button + if (!mModelNoErrors || has_degenerate) { mFMP->childDisable("ok_btn"); - mFMP->childDisable("calculate_btn"); - } - else - { - mFMP->childEnable("ok_btn"); - mFMP->childEnable("calculate_btn"); } //add up physics triangles etc @@ -3722,30 +3616,11 @@ BOOL LLModelPreview::render() bool textures = mViewOption["show_textures"]; bool physics = mViewOption["show_physics"]; - // Extra configurability, to be exposed later as controls? - static LLCachedControl canvas_col(gSavedSettings, "MeshPreviewCanvasColor"); - static LLCachedControl edge_col(gSavedSettings, "MeshPreviewEdgeColor"); - static LLCachedControl base_col(gSavedSettings, "MeshPreviewBaseColor"); - static LLCachedControl brightness(gSavedSettings, "MeshPreviewBrightnessColor"); - static LLCachedControl edge_width(gSavedSettings, "MeshPreviewEdgeWidth"); - static LLCachedControl phys_edge_col(gSavedSettings, "MeshPreviewPhysicsEdgeColor"); - static LLCachedControl phys_fill_col(gSavedSettings, "MeshPreviewPhysicsFillColor"); - static LLCachedControl phys_edge_width(gSavedSettings, "MeshPreviewPhysicsEdgeWidth"); - static LLCachedControl deg_edge_col(gSavedSettings, "MeshPreviewDegenerateEdgeColor"); - static LLCachedControl deg_fill_col(gSavedSettings, "MeshPreviewDegenerateFillColor"); - static LLCachedControl deg_edge_width(gSavedSettings, "MeshPreviewDegenerateEdgeWidth"); - static LLCachedControl deg_point_size(gSavedSettings, "MeshPreviewDegeneratePointSize"); - // S32 width = getWidth(); S32 height = getHeight(); LLGLSUIDefault def; LLGLDisable no_blend(GL_BLEND); -// Clean up render of mesh preview -// LLGLEnable blend(GL_BLEND); -// gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); -// - LLGLEnable cull(GL_CULL_FACE); LLGLDepthTest depth(GL_TRUE); LLGLDisable fog(GL_FOG); @@ -3764,9 +3639,9 @@ BOOL LLModelPreview::render() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); gGL.loadIdentity(); - // uploader improvements - //gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); - gGL.color4fv(static_cast(canvas_col).mV); + + gGL.color4f(0.169f, 0.169f, 0.169f, 1.f); + gl_rect_2d_simple( width, height ); gGL.matrixMode(LLRender::MM_PROJECTION); @@ -3914,11 +3789,8 @@ BOOL LLModelPreview::render() stop_glerror(); gGL.pushMatrix(); - // mesh uploader improvements configurable brightness - //const F32 BRIGHTNESS = 0.9f; - //gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); - gGL.color4fv(edge_col().mV); - // + const F32 BRIGHTNESS = 0.9f; + gGL.color3f(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS); const U32 type_mask = LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_NORMAL | LLVertexBuffer::MAP_TEXCOORD0; @@ -4003,22 +3875,16 @@ BOOL LLModelPreview::render() } else { - // improved mesh uploader - // gGL.diffuseColor4f(1,1,1,1); - gGL.diffuseColor4fv(static_cast(base_col).mV); - // - + gGL.diffuseColor4f(1,1,1,1); } buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - // improved mesh uploader - //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); - gGL.diffuseColor4fv(static_cast(edge_col).mV); - // + gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); + if (edges) { - glLineWidth(edge_width); + glLineWidth(3.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); @@ -4030,25 +3896,11 @@ BOOL LLModelPreview::render() if (physics) { - // model upload improvements - use the settings - ////Vector4a physicsFillColour(0.4, 0.4, 0.4, 0.4); - //const LLColor4 physicsFillColour(0.0, 0.5, 1.0, 0.5); - ////LLVector4a physicsEdgeColour(1.0, 1.0, 0.0, 1.0); - //const LLColor4 physicsEdgeColour=physicsFillColour*0.5; - //const LLColor4 degenerateFill(1.0, 0.0, 0.0, 0.5); - //const LLColor4 degenerateEdge(1.0,0.0,0.0,1.0); - // - glClear(GL_DEPTH_BUFFER_BIT); - // refactor to remove silly variable names - // for (U32 i = 0; i < 2; i++) - for (U32 pass = 0; pass < 2; pass++) - // + + for (U32 i = 0; i < 2; i++) { - // refactor to remove silly variable names - //if (i == 0) - if (pass == 0) - // + if (i == 0) { //depth only pass gGL.setColorMask(false, false); } @@ -4058,11 +3910,8 @@ BOOL LLModelPreview::render() } //enable alpha blending on second pass but not first pass - // refactor to remove silly variable names - //LLGLState blend(GL_BLEND, i); - LLGLState blend(GL_BLEND, pass); - // - + LLGLState blend(GL_BLEND, i); + gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) @@ -4071,196 +3920,175 @@ BOOL LLModelPreview::render() LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - if (!model) - { - continue; - } - - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + if (!model) + { + continue; + } - gGL.multMatrix((GLfloat*)mat.mMatrix); + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; + gGL.multMatrix((GLfloat*) mat.mMatrix); - bool render_mesh = true; - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) - { - LLMutexLock(decomp->mMutex); - LLModel::Decomposition& physics = model->mPhysics; + bool render_mesh = true; - if (!physics.mHull.empty()) + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) { - render_mesh = false; + LLMutexLock(decomp->mMutex); - if (physics.mMesh.empty()) - { //build vertex buffer for physics mesh - gMeshRepo.buildPhysicsMesh(physics); - } + LLModel::Decomposition& physics = model->mPhysics; - if (!physics.mMesh.empty()) - { //render hull instead of mesh - for (U32 i = 0; i < physics.mMesh.size(); ++i) - { - if (explode > 0.f) + if (!physics.mHull.empty()) + { + render_mesh = false; + + if (physics.mMesh.empty()) + { //build vertex buffer for physics mesh + gMeshRepo.buildPhysicsMesh(physics); + } + + if (!physics.mMesh.empty()) + { //render hull instead of mesh + for (U32 i = 0; i < physics.mMesh.size(); ++i) { - gGL.pushMatrix(); + if (explode > 0.f) + { + gGL.pushMatrix(); - LLVector3 offset = model->mHullCenter[i] - model->mCenterOfHullCenters; - offset *= explode; + LLVector3 offset = model->mHullCenter[i]-model->mCenterOfHullCenters; + offset *= explode; - gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); - } + gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); + } - static std::vector hull_colors; + static std::vector hull_colors; - if (i + 1 >= hull_colors.size()) - { - hull_colors.push_back(LLColor4U(rand() % 128 + 127, rand() % 128 + 127, rand() % 128 + 127, 128)); - } + if (i+1 >= hull_colors.size()) + { + hull_colors.push_back(LLColor4U(rand()%128+127, rand()%128+127, rand()%128+127, 128)); + } - gGL.diffuseColor4ubv(hull_colors[i].mV); - LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); + gGL.diffuseColor4ubv(hull_colors[i].mV); + LLVertexBuffer::drawArrays(LLRender::TRIANGLES, physics.mMesh[i].mPositions, physics.mMesh[i].mNormals); - if (explode > 0.f) - { - gGL.popMatrix(); + if (explode > 0.f) + { + gGL.popMatrix(); + } } } } } - } - - if (render_mesh) - { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + + if (render_mesh) { - genBuffers(LLModel::LOD_PHYSICS, false); - } + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) + { + genBuffers(LLModel::LOD_PHYSICS, false); + } - U32 num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); - if (pass > 0){ + U32 num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); for (U32 i = 0; i < num_models; ++i) { LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.diffuseColor4fv(phys_fill_col().mV); + gGL.diffuseColor4f(0.4f, 0.4f, 0.0f, 0.4f); buffer->setBuffer(type_mask & buffer->getTypeMask()); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); + + gGL.diffuseColor3f(1.f, 1.f, 0.f); - gGL.diffuseColor4fv(phys_edge_col().mV); - glLineWidth(phys_edge_width); + glLineWidth(2.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts() - 1, buffer->getNumIndices(), 0); + buffer->drawRange(LLRender::TRIANGLES, 0, buffer->getNumVerts()-1, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } } + + gGL.popMatrix(); } - gGL.popMatrix(); - } + glLineWidth(3.f); + glPointSize(8.f); + gPipeline.enableLightsFullbright(LLColor4::white); + //show degenerate triangles + LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); + LLGLDisable cull(GL_CULL_FACE); + gGL.diffuseColor4f(1.f,0.f,0.f,1.f); + const LLVector4a scale(0.5f); - // refactor to remove silly variable names - // also only do this if mDegenerate was set in the preceding mesh checks [Check this if the ordering ever breaks] - //if (i > 0) - if (pass > 0 && mHasDegenerate) - // + for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) { - glLineWidth(deg_edge_width); - glPointSize(deg_point_size); -// This single line is why the degenerate triangles display has been crap forever. -// gPipeline.enableLightsFullbright(LLColor4::white); - //show degenerate triangles - LLGLDepthTest depth(GL_TRUE, GL_TRUE, GL_ALWAYS); - LLGLDisable cull(GL_CULL_FACE); - const LLVector4a scale(0.5f); - - for (LLMeshUploadThread::instance_list::iterator iter = mUploadData.begin(); iter != mUploadData.end(); ++iter) - { - LLModelInstance& instance = *iter; + LLModelInstance& instance = *iter; - LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; + LLModel* model = instance.mLOD[LLModel::LOD_PHYSICS]; - if (!model) - { - continue; - } + if (!model) + { + continue; + } - gGL.pushMatrix(); - LLMatrix4 mat = instance.mTransform; + gGL.pushMatrix(); + LLMatrix4 mat = instance.mTransform; - gGL.multMatrix((GLfloat*)mat.mMatrix); + gGL.multMatrix((GLfloat*) mat.mMatrix); - LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; - if (decomp) - { - LLMutexLock(decomp->mMutex); + LLPhysicsDecomp* decomp = gMeshRepo.mDecompThread; + if (decomp) + { + LLMutexLock(decomp->mMutex); - LLModel::Decomposition& physics = model->mPhysics; + LLModel::Decomposition& physics = model->mPhysics; - if (physics.mHull.empty()) + if (physics.mHull.empty()) + { + if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) { - if (mVertexBuffer[LLModel::LOD_PHYSICS].empty()) - { - genBuffers(LLModel::LOD_PHYSICS, false); - } - - auto num_degenerate = 0; - // More nested i variable silliness - // for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) - auto num_models = mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); - for (U32 v = 0; v < num_models; ++v) - { - LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][v]; - // - if(buffer->getNumVerts() < 3)continue; + genBuffers(LLModel::LOD_PHYSICS, false); + } + + for (U32 i = 0; i < mVertexBuffer[LLModel::LOD_PHYSICS][model].size(); ++i) + { + LLVertexBuffer* buffer = mVertexBuffer[LLModel::LOD_PHYSICS][model][i]; - buffer->setBuffer(type_mask & buffer->getTypeMask()); + buffer->setBuffer(type_mask & buffer->getTypeMask()); - LLStrider pos_strider; - buffer->getVertexStrider(pos_strider, 0); - LLVector4a* pos = (LLVector4a*)pos_strider.get(); + LLStrider pos_strider; + buffer->getVertexStrider(pos_strider, 0); + LLVector4a* pos = (LLVector4a*) pos_strider.get(); + + LLStrider idx; + buffer->getIndexStrider(idx, 0); - LLStrider idx; - buffer->getIndexStrider(idx, 0); + for (U32 i = 0; i < buffer->getNumIndices(); i += 3) + { + LLVector4a v1; v1.setMul(pos[*idx++], scale); + LLVector4a v2; v2.setMul(pos[*idx++], scale); + LLVector4a v3; v3.setMul(pos[*idx++], scale); - LLVector4a v1, v2, v3; - // rename inner most i to avoid merge confusion - for (U32 indices_offset = 0; indices_offset < buffer->getNumIndices(); indices_offset += 3) + if (ll_is_degenerate(v1,v2,v3)) { - v1.setMul(pos[*idx++], scale); - v2.setMul(pos[*idx++], scale); - v3.setMul(pos[*idx++], scale); - - if (ll_is_degenerate(v1, v2, v3)) - { - num_degenerate++; - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - gGL.diffuseColor3fv(deg_edge_col().mV); - buffer->drawRange(LLRender::TRIANGLES, 0, 2, 3, indices_offset); - buffer->drawRange(LLRender::POINTS, 0, 2, 3, indices_offset); - glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); - gGL.diffuseColor3fv(deg_fill_col().mV); - buffer->drawRange(LLRender::TRIANGLES, 0, 2, 3, indices_offset); - } + buffer->draw(LLRender::LINE_LOOP, 3, i); + buffer->draw(LLRender::POINTS, 3, i); } } } } - - gGL.popMatrix(); } - glLineWidth(1.f); - glPointSize(1.f); - gPipeline.enableLightsPreview(); - gGL.setSceneBlendType(LLRender::BT_ALPHA); + + gGL.popMatrix(); } + glLineWidth(1.f); + glPointSize(1.f); + gPipeline.enableLightsPreview(); + gGL.setSceneBlendType(LLRender::BT_ALPHA); } } } @@ -4342,19 +4170,16 @@ BOOL LLModelPreview::render() } buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); - // configurable colour and width - //gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); + gGL.diffuseColor3f(0.4f, 0.4f, 0.4f); if (edges) { - gGL.diffuseColor4fv(edge_col().mV); - glLineWidth(edge_width); + glLineWidth(3.f); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); buffer->draw(LLRender::TRIANGLES, buffer->getNumIndices(), 0); glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glLineWidth(1.f); } - // } } } @@ -4412,11 +4237,8 @@ void LLModelPreview::rotate(F32 yaw_radians, F32 pitch_radians) void LLModelPreview::zoom(F32 zoom_amt) { F32 new_zoom = mCameraZoom+zoom_amt; - // add configurable zoom TODO: stop clamping in render - // mCameraZoom = llclamp(new_zoom, 1.f, 10.f); - static LLCachedControl zoom_limit(gSavedSettings, "MeshPreviewZoomLimit"); - mCameraZoom = llclamp(new_zoom, 1.f, zoom_limit()); - // + + mCameraZoom = llclamp(new_zoom, 1.f, 10.f); } void LLModelPreview::pan(F32 right, F32 up) @@ -4622,22 +4444,11 @@ void LLFloaterModelPreview::toggleCalculateButton(bool visible) childSetTextArg("server_weight", "[SIM]", tbd); childSetTextArg("physics_weight", "[PH]", tbd); childSetTextArg("upload_fee", "[FEE]", tbd); - // add extended info fields - //childSetTextArg("price_breakdown", "[STREAMING]", dashes); - //childSetTextArg("price_breakdown", "[PHYSICS]", dashes); - //childSetTextArg("price_breakdown", "[INSTANCES]", dashes); - //childSetTextArg("price_breakdown", "[TEXTURES]", dashes); - //childSetTextArg("price_breakdown", "[MODEL]", dashes); - std::string dashes = hasString("--") ? getString("--") : "--"; - childSetTextArg("price_breakdown", "[STREAMING]", dashes); - childSetTextArg("price_breakdown", "[PHYSICS]", dashes); - childSetTextArg("price_breakdown", "[INSTANCES]", dashes); - childSetTextArg("price_breakdown", "[TEXTURES]", dashes); - childSetTextArg("price_breakdown", "[MODEL]", dashes); - childSetTextArg("physics_breakdown", "[PCH]", dashes); - childSetTextArg("physics_breakdown", "[PM]", dashes); - childSetTextArg("physics_breakdown", "[PHU]", dashes); - // + childSetTextArg("price_breakdown", "[STREAMING]", tbd); + childSetTextArg("price_breakdown", "[PHYSICS]", tbd); + childSetTextArg("price_breakdown", "[INSTANCES]", tbd); + childSetTextArg("price_breakdown", "[TEXTURES]", tbd); + childSetTextArg("price_breakdown", "[MODEL]", tbd); } } @@ -4687,16 +4498,6 @@ void LLFloaterModelPreview::handleModelPhysicsFeeReceived() childSetTextArg("price_breakdown", "[INSTANCES]", llformat("%d", result["upload_price_breakdown"]["mesh_instance"].asInteger())); childSetTextArg("price_breakdown", "[TEXTURES]", llformat("%d", result["upload_price_breakdown"]["texture"].asInteger())); childSetTextArg("price_breakdown", "[MODEL]", llformat("%d", result["upload_price_breakdown"]["model"].asInteger())); -// Updates for enhanced Mesh feedback at upload - childSetTextArg("physics_breakdown", "[PCH]", llformat("%0.3f", result["model_physics_cost"]["hull"].asReal())); - childSetTextArg("physics_breakdown", "[PM]", llformat("%0.3f", result["model_physics_cost"]["mesh"].asReal())); - childSetTextArg("physics_breakdown", "[PHU]", llformat("%0.3f", result["model_physics_cost"]["decomposition"].asReal())); - childSetTextArg("streaming_breakdown", "[STR_TOTAL]", llformat("%d", result["streaming_cost"].asInteger())); - childSetTextArg("streaming_breakdown", "[STR_HIGH]", llformat("%d", result["streaming_params"]["high_lod"].asInteger())); - childSetTextArg("streaming_breakdown", "[STR_MED]", llformat("%d", result["streaming_params"]["medium_lod"].asInteger())); - childSetTextArg("streaming_breakdown", "[STR_LOW]", llformat("%d", result["streaming_params"]["low_lod"].asInteger())); - childSetTextArg("streaming_breakdown", "[STR_LOWEST]", llformat("%d", result["streaming_params"]["lowest_lod"].asInteger())); -// childSetVisible("upload_fee", true); childSetVisible("price_breakdown", true); mUploadBtn->setEnabled(isModelUploadAllowed()); -- cgit v1.2.3