From 620d2f4ee595ec013784a374e9136a43b99a355f Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 17:15:41 +0300 Subject: SL-17532 Fix some changes vanishing over merge to D559 --- indra/newview/llvovolume.cpp | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index cb58c173d9..9c25606ce9 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -4773,7 +4773,7 @@ BOOL LLVOVolume::lineSegmentIntersect(const LLVector4a& start, const LLVector4a& { if ((pick_rigged) || (getAvatar() && (getAvatar()->isSelf()) && (LLFloater::isVisible(gFloaterTools)))) { - updateRiggedVolume(true, LLRiggedVolume::DO_NOT_UPDATE_FACES); + updateRiggedVolume(true, LLRiggedVolume::DO_NOT_UPDATE_FACES); volume = mRiggedVolume; transform = false; } @@ -4980,7 +4980,7 @@ void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume:: //Update mRiggedVolume to match current animation frame of avatar. //Also update position/size in octree. - if ((!force_treat_as_rigged) && (!treatAsRigged())) + if ((!force_treat_as_rigged) && (!treatAsRigged())) { clearRiggedVolume(); @@ -5009,7 +5009,7 @@ void LLVOVolume::updateRiggedVolume(bool force_treat_as_rigged, LLRiggedVolume:: updateRelativeXform(); } - mRiggedVolume->update(skin, avatar, volume, face_index, rebuild_face_octrees); + mRiggedVolume->update(skin, avatar, volume, face_index, rebuild_face_octrees); } void LLRiggedVolume::update( @@ -5172,12 +5172,7 @@ void LLRiggedVolume::update( if (rebuild_face_octrees) { dst_face.destroyOctree(); - - LLVector4a size; - size.setSub(dst_face.mExtents[1], dst_face.mExtents[0]); - size.splat(size.getLength3().getF32()*0.5f); - - dst_face.createOctree(1.f); + dst_face.createOctree(); } } } @@ -5427,7 +5422,6 @@ void LLVolumeGeometryManager::registerFace(LLSpatialGroup* group, LLFace* facep, LLViewerTexture* tex = facep->getTexture(); - U8 index = facep->getTextureIndex(); LLMaterial* mat = nullptr; @@ -6421,6 +6415,13 @@ struct CompareBatchBreakerRigged } }; +struct CompareDrawOrder +{ + bool operator()(const LLFace* const& lhs, const LLFace* const& rhs) + { + return lhs->getDrawOrderIndex() < rhs->getDrawOrderIndex(); + } +}; U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace** faces, U32 face_count, BOOL distance_sort, BOOL batch_textures, BOOL rigged) { @@ -6455,6 +6456,11 @@ U32 LLVolumeGeometryManager::genDrawInfo(LLSpatialGroup* group, U32 mask, LLFace //sort faces by things that break batches, including avatar and mesh id std::sort(faces, faces + face_count, CompareBatchBreakerRigged()); } + else + { + // preserve legacy draw order for rigged faces + std::sort(faces, faces + face_count, CompareDrawOrder()); + } } else if (!distance_sort) { -- cgit v1.2.3 From 4b37414dc0963a9db344c493055f501265f4e59a Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 19:49:36 +0300 Subject: Re-merged llvovolume.cpp Too many issue were detected after merge, so did a clean remerge of the file. --- indra/newview/llvovolume.cpp | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 9c25606ce9..7c58d23d0e 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -1994,7 +1994,7 @@ BOOL LLVOVolume::updateGeometry(LLDrawable *drawable) if (mDrawable->isState(LLDrawable::REBUILD_RIGGED)) { - updateRiggedVolume(false); + updateRiggedVolume(false); genBBoxes(FALSE); mDrawable->clearState(LLDrawable::REBUILD_RIGGED); } @@ -5704,7 +5704,7 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[1] < MAX_FACE_COUNT) { - face->setDrawOrderIndex(count[1]); + //face->setDrawOrderIndex(count[1]); list[1][count[1]++] = face; } } @@ -5712,12 +5712,36 @@ static inline void add_face(T*** list, U32* count, T* face) { if (count[0] < MAX_FACE_COUNT) { - face->setDrawOrderIndex(count[0]); + //face->setDrawOrderIndex(count[0]); list[0][count[0]++] = face; } } } +// return index into linkset for given object (0 for root prim) +U32 get_linkset_index(LLVOVolume* vobj) +{ + LL_PROFILE_ZONE_SCOPED_CATEGORY_DRAWABLE; + if (vobj->isRootEdit()) + { + return 0; + } + + LLViewerObject* root = vobj->getRootEdit(); + U32 idx = 1; + for (const auto& child : root->getChildren()) + { + if (child == vobj) + { + return idx; + } + ++idx; + } + + llassert(false); + return idx; //should never get here +} + void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) { LL_PROFILE_ZONE_SCOPED_CATEGORY_VOLUME; @@ -5881,6 +5905,8 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) avatar->addAttachmentOverridesForObject(vobj, NULL, false); } + U32 linkset_index = get_linkset_index(vobj); + // Standard rigged mesh attachments: bool rigged = !vobj->isAnimatedObject() && skinInfo && vobj->isAttachment(); // Animated objects. Have to check for isRiggedMesh() to @@ -5900,6 +5926,9 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) continue; } + // order by linkset index first and face index second + facep->setDrawOrderIndex(linkset_index * 100 + i); + // HACK -- brute force this check every time a drawable gets rebuilt vobj->updateTEMaterialTextures(i); #if 0 @@ -5939,11 +5968,6 @@ void LLVolumeGeometryManager::rebuildGeom(LLSpatialGroup* group) if (facep->isState(LLFace::RIGGED)) { //face is not rigged but used to be, remove from rigged face pool - LLDrawPoolAvatar* pool = (LLDrawPoolAvatar*) facep->getPool(); - if (pool) - { - pool->removeFace(facep); - } facep->clearState(LLFace::RIGGED); facep->mAvatar = NULL; facep->mSkinInfo = NULL; @@ -6251,7 +6275,7 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) { LLDrawable* drawablep = (LLDrawable*)(*drawable_iter)->getDrawable(); - if (drawablep && !drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL) && !drawablep->isState(LLDrawable::RIGGED) ) + if (drawablep && !drawablep->isDead() && drawablep->isState(LLDrawable::REBUILD_ALL)) { LLVOVolume* vobj = drawablep->getVOVolume(); @@ -6285,8 +6309,6 @@ void LLVolumeGeometryManager::rebuildMesh(LLSpatialGroup* group) LLVertexBuffer* buff = face->getVertexBuffer(); if (buff) { - llassert(!face->isState(LLFace::RIGGED)); - if (!face->getGeometryVolume(*volume, face->getTEOffset(), vobj->getRelativeXform(), vobj->getRelativeXformInvTrans(), face->getGeomIndex())) { //something's gone wrong with the vertex buffer accounting, rebuild this group -- cgit v1.2.3 From 4a1397c621eec2deb90d4953762fea6187c0a270 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 24 Oct 2022 23:35:28 +0300 Subject: SL-18414 Smarter material editor's cancel for overrides --- indra/newview/llmaterialeditor.cpp | 97 ++++++++++++++++++++++++++++++++++++-- indra/newview/llmaterialeditor.h | 3 ++ 2 files changed, 96 insertions(+), 4 deletions(-) diff --git a/indra/newview/llmaterialeditor.cpp b/indra/newview/llmaterialeditor.cpp index 8086bcf402..06705a277b 100644 --- a/indra/newview/llmaterialeditor.cpp +++ b/indra/newview/llmaterialeditor.cpp @@ -302,10 +302,6 @@ void LLMaterialEditor::onClickCloseBtn(bool app_quitting) void LLMaterialEditor::onClose(bool app_quitting) { - // todo: will only revert whatever was recently selected, - // Later should work based of tools floater - LLSelectMgr::getInstance()->selectionRevertGLTFMaterials(); - LLPreview::onClose(app_quitting); } @@ -1265,6 +1261,73 @@ void LLMaterialEditor::onCancelMsgCallback(const LLSD& notification, const LLSD& S32 option = LLNotificationsUtil::getSelectedOption(notification, response); if (0 == option) { + if (mIsOverride && !mObjectOverridesSavedValues.empty()) + { + // Reapply ids back onto selection. + // TODO: monitor selection changes and resave on selection changes + struct g : public LLSelectedObjectFunctor + { + g(LLMaterialEditor* me) : mEditor(me) {} + virtual bool apply(LLViewerObject* objectp) + { + if (!objectp || !objectp->permModify()) + { + return false; + } + + U32 local_id = objectp->getLocalID(); + if (mEditor->mObjectOverridesSavedValues.find(local_id) == mEditor->mObjectOverridesSavedValues.end()) + { + return false; + } + + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (U8 te = 0; te < num_tes; te++) + { + if (mEditor->mObjectOverridesSavedValues[local_id].size() > te + && objectp->getTE(te)->isSelected()) + { + objectp->setRenderMaterialID( + te, + mEditor->mObjectOverridesSavedValues[local_id][te], + false /*wait for bulk update*/); + } + } + return true; + } + LLMaterialEditor* mEditor; + } restorefunc(this); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&restorefunc); + + struct f : public LLSelectedObjectFunctor + { + virtual bool apply(LLViewerObject* object) + { + if (object && !object->permModify()) + { + return false; + } + + LLRenderMaterialParams* param_block = (LLRenderMaterialParams*)object->getParameterEntry(LLNetworkData::PARAMS_RENDER_MATERIAL); + if (param_block) + { + if (param_block->isEmpty()) + { + object->setHasRenderMaterialParams(false); + } + else + { + object->parameterChanged(LLNetworkData::PARAMS_RENDER_MATERIAL, true); + } + } + + object->sendTEUpdate(); + return true; + } + } sendfunc; + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&sendfunc); + } + closeFloater(); } } @@ -1410,6 +1473,32 @@ void LLMaterialEditor::loadLive() me->setTitle(me->getString("material_override_title")); me->childSetVisible("save", false); me->childSetVisible("save_as", false); + me->mObjectOverridesSavedValues.clear(); + + // Collect ids to be able to revert overrides. + // TODO: monitor selection changes and resave on selection changes + struct g : public LLSelectedObjectFunctor + { + g(LLMaterialEditor* me) : mEditor(me) {} + virtual bool apply(LLViewerObject* objectp) + { + if (!objectp) + { + return false; + } + + U32 local_id = objectp->getLocalID(); + S32 num_tes = llmin((S32)objectp->getNumTEs(), (S32)objectp->getNumFaces()); + for (U8 te = 0; te < num_tes; te++) + { + LLUUID mat_id = objectp->getRenderMaterialID(te); + mEditor->mObjectOverridesSavedValues[local_id].push_back(mat_id); + } + return true; + } + LLMaterialEditor* mEditor; + } savefunc(me); + LLSelectMgr::getInstance()->getSelection()->applyToObjects(&savefunc); me->openFloater(); me->setFocus(TRUE); diff --git a/indra/newview/llmaterialeditor.h b/indra/newview/llmaterialeditor.h index 23cb32aacf..60907b18ba 100644 --- a/indra/newview/llmaterialeditor.h +++ b/indra/newview/llmaterialeditor.h @@ -276,5 +276,8 @@ private: // if true, this instance is live instance editing overrides bool mIsOverride = false; + // local id, texture ids per face for object overrides + // for "cancel" support + std::map mObjectOverridesSavedValues; }; -- cgit v1.2.3