From 1aa4e4e68d972ed118ebab14d01c829dc79cfc18 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Thu, 12 Nov 2009 20:54:00 -0500 Subject: EXT-2434 update avatar rendering cost First crack at updating the rendering cost calculation for avatars to account for the possibility of invisible avatars. Also generalized rendering cost of attachments to be more general - added debug code to build floater will be post-reviewed --- indra/newview/llfloatertools.cpp | 27 +++++++++ indra/newview/llfloatertools.h | 1 + indra/newview/llvoavatar.cpp | 121 ++++----------------------------------- indra/newview/llvovolume.cpp | 101 ++++++++++++++++++++++++++++++++ indra/newview/llvovolume.h | 2 +- 5 files changed, 141 insertions(+), 111 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 3c3dfb760e..672160073e 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -422,6 +422,12 @@ void LLFloaterTools::refresh() LLResMgr::getInstance()->getIntegerString(prim_count_string, LLSelectMgr::getInstance()->getSelection()->getObjectCount()); childSetTextArg("prim_count", "[COUNT]", prim_count_string); + // calculate selection rendering cost + std::string prim_cost_string; + LLResMgr::getInstance()->getIntegerString(prim_cost_string, calcRenderCost()); + childSetTextArg("render_cost", "[COUNT]", prim_cost_string); + + // disable the object and prim counts if nothing selected bool have_selection = ! LLSelectMgr::getInstance()->getSelection()->isEmpty(); childSetEnabled("obj_count", have_selection); @@ -964,6 +970,27 @@ void LLFloaterTools::onClickGridOptions() //floaterp->addDependentFloater(LLFloaterBuildOptions::getInstance(), FALSE); } +S32 LLFloaterTools::calcRenderCost() +{ + S32 cost = 0; + for (LLObjectSelection::iterator selection_iter = LLSelectMgr::getInstance()->getSelection()->begin(); + selection_iter != LLSelectMgr::getInstance()->getSelection()->end(); + ++selection_iter) + { + LLSelectNode *select_node = *selection_iter; + if (select_node) + { + LLVOVolume *viewer_volume = (LLVOVolume*)select_node->getObject(); + if (viewer_volume) + { + cost += viewer_volume->getRenderCost(); + } + } + } + + return cost; +} + // static void LLFloaterTools::setEditTool(void* tool_pointer) { diff --git a/indra/newview/llfloatertools.h b/indra/newview/llfloatertools.h index a3e0cac034..05a88a31d3 100644 --- a/indra/newview/llfloatertools.h +++ b/indra/newview/llfloatertools.h @@ -121,6 +121,7 @@ private: static bool multipleFacesSelectedConfirm(const LLSD& notification, const LLSD& response); static void setObjectType( LLPCode pcode ); void onClickGridOptions(); + S32 calcRenderCost(); public: LLButton *mBtnFocus; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 62ac8adad0..d7e31e8436 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -624,7 +624,6 @@ F32 LLVOAvatar::sGreyUpdateTime = 0.f; // Helper functions //----------------------------------------------------------------------------- static F32 calc_bouncy_animation(F32 x); -static U32 calc_shame(const LLVOVolume* volume, std::set &textures); //----------------------------------------------------------------------------- // LLVOAvatar() @@ -7637,9 +7636,17 @@ void LLVOAvatar::idleUpdateRenderCost() return; } - U32 shame = 1; + U32 shame = 0; - std::set textures; + for (U8 baked_index = 0; baked_index < BAKED_NUM_INDICES; baked_index++) + { + const LLVOAvatarDictionary::BakedEntry *baked_dict = LLVOAvatarDictionary::getInstance()->getBakedTexture((EBakedTextureIndex)baked_index); + ETextureIndex tex_index = baked_dict->mTextureIndex; + if (isTextureVisible(tex_index)) + { + shame +=25; + } + } for (attachment_map_t::const_iterator iter = mAttachmentPoints.begin(); iter != mAttachmentPoints.end(); @@ -7660,15 +7667,13 @@ void LLVOAvatar::idleUpdateRenderCost() const LLVOVolume* volume = drawable->getVOVolume(); if (volume) { - shame += calc_shame(volume, textures); + shame += volume->getRenderCost(); } } } } } - shame += textures.size() * 5; - setDebugText(llformat("%d", shame)); F32 green = 1.f-llclamp(((F32) shame-1024.f)/1024.f, 0.f, 1.f); F32 red = llmin((F32) shame/1024.f, 1.f); @@ -7713,110 +7718,6 @@ const std::string LLVOAvatar::getBakedStatusForPrintout() const } -U32 calc_shame(const LLVOVolume* volume, std::set &textures) -{ - if (!volume) - { - return 0; - } - - U32 shame = 0; - - U32 invisi = 0; - U32 shiny = 0; - U32 glow = 0; - U32 alpha = 0; - U32 flexi = 0; - U32 animtex = 0; - U32 particles = 0; - U32 scale = 0; - U32 bump = 0; - U32 planar = 0; - - if (volume->isFlexible()) - { - flexi = 1; - } - if (volume->isParticleSource()) - { - particles = 1; - } - - const LLVector3& sc = volume->getScale(); - scale += (U32) sc.mV[0] + (U32) sc.mV[1] + (U32) sc.mV[2]; - - const LLDrawable* drawablep = volume->mDrawable; - - if (volume->isSculpted()) - { - const LLSculptParams *sculpt_params = (LLSculptParams *) volume->getParameterEntry(LLNetworkData::PARAMS_SCULPT); - LLUUID sculpt_id = sculpt_params->getSculptTexture(); - textures.insert(sculpt_id); - } - - for (S32 i = 0; i < drawablep->getNumFaces(); ++i) - { - const LLFace* face = drawablep->getFace(i); - const LLTextureEntry* te = face->getTextureEntry(); - const LLViewerTexture* img = face->getTexture(); - - textures.insert(img->getID()); - - if (face->getPoolType() == LLDrawPool::POOL_ALPHA) - { - alpha++; - } - else if (img->getPrimaryFormat() == GL_ALPHA) - { - invisi = 1; - } - - if (te) - { - if (te->getBumpmap()) - { - bump = 1; - } - if (te->getShiny()) - { - shiny = 1; - } - if (te->getGlow() > 0.f) - { - glow = 1; - } - if (face->mTextureMatrix != NULL) - { - animtex++; - } - if (te->getTexGen()) - { - planar++; - } - } - } - - shame += invisi + shiny + glow + alpha*4 + flexi*8 + animtex*4 + particles*16+bump*4+scale+planar; - - LLViewerObject::const_child_list_t& child_list = volume->getChildren(); - for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); - iter != child_list.end(); - ++iter) - { - const LLViewerObject* child_objectp = *iter; - const LLDrawable* child_drawablep = child_objectp->mDrawable; - if (child_drawablep) - { - const LLVOVolume* child_volumep = child_drawablep->getVOVolume(); - if (child_volumep) - { - shame += calc_shame(child_volumep, textures); - } - } - } - - return shame; -} //virtual S32 LLVOAvatar::getTexImageSize() const diff --git a/indra/newview/llvovolume.cpp b/indra/newview/llvovolume.cpp index 2def905bbb..e5531a1497 100644 --- a/indra/newview/llvovolume.cpp +++ b/indra/newview/llvovolume.cpp @@ -2541,6 +2541,107 @@ const LLMatrix4 LLVOVolume::getRenderMatrix() const return mDrawable->getWorldMatrix(); } +U32 LLVOVolume::getRenderCost() const +{ + U32 shame = 0; + + U32 invisi = 0; + U32 shiny = 0; + U32 glow = 0; + U32 alpha = 0; + U32 flexi = 0; + U32 animtex = 0; + U32 particles = 0; + U32 scale = 0; + U32 bump = 0; + U32 planar = 0; + + if (isFlexible()) + { + flexi = 1; + } + if (isParticleSource()) + { + particles = 1; + } + + const LLVector3& sc = getScale(); + scale += (U32) sc.mV[0] + (U32) sc.mV[1] + (U32) sc.mV[2]; + + const LLDrawable* drawablep = mDrawable; + + if (isSculpted()) + { + const LLSculptParams *sculpt_params = (LLSculptParams *) getParameterEntry(LLNetworkData::PARAMS_SCULPT); + LLUUID sculpt_id = sculpt_params->getSculptTexture(); + shame += 5; + } + + for (S32 i = 0; i < drawablep->getNumFaces(); ++i) + { + const LLFace* face = drawablep->getFace(i); + const LLTextureEntry* te = face->getTextureEntry(); + const LLViewerTexture* img = face->getTexture(); + + shame += 5; + + if (face->getPoolType() == LLDrawPool::POOL_ALPHA) + { + alpha++; + } + else if (img->getPrimaryFormat() == GL_ALPHA) + { + invisi = 1; + } + + if (te) + { + if (te->getBumpmap()) + { + bump = 1; + } + if (te->getShiny()) + { + shiny = 1; + } + if (te->getGlow() > 0.f) + { + glow = 1; + } + if (face->mTextureMatrix != NULL) + { + animtex++; + } + if (te->getTexGen()) + { + planar++; + } + } + } + + shame += invisi + shiny + glow + alpha*4 + flexi*8 + animtex*4 + particles*16+bump*4+scale+planar; + + LLViewerObject::const_child_list_t& child_list = getChildren(); + for (LLViewerObject::child_list_t::const_iterator iter = child_list.begin(); + iter != child_list.end(); + ++iter) + { + const LLViewerObject* child_objectp = *iter; + const LLDrawable* child_drawablep = child_objectp->mDrawable; + if (child_drawablep) + { + const LLVOVolume* child_volumep = child_drawablep->getVOVolume(); + if (child_volumep) + { + shame += child_volumep->getRenderCost(); + } + } + } + + return shame; + +} + //static void LLVOVolume::preUpdateGeom() { diff --git a/indra/newview/llvovolume.h b/indra/newview/llvovolume.h index 10fc8865fc..fb543efc04 100644 --- a/indra/newview/llvovolume.h +++ b/indra/newview/llvovolume.h @@ -120,7 +120,7 @@ public: const LLMatrix4& getRelativeXform() const { return mRelativeXform; } const LLMatrix3& getRelativeXformInvTrans() const { return mRelativeXformInvTrans; } /*virtual*/ const LLMatrix4 getRenderMatrix() const; - + U32 getRenderCost() const; /*virtual*/ BOOL lineSegmentIntersect(const LLVector3& start, const LLVector3& end, S32 face = -1, // which face to check, -1 = ALL_SIDES -- cgit v1.2.3 From 69f4b29761aa31d2ac46268eccf5b1cb7edf30f1 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Fri, 13 Nov 2009 11:11:11 -0500 Subject: EXT-2434 update rendering cost to reflect changes in avatar rendering finished the updates to avatar rendering cost and formalized the display of selected object render cost in the build tools floater. Both checkins reviewed by Vir. --- indra/newview/llfloatertools.cpp | 6 ++++-- indra/newview/llvoavatar.cpp | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llfloatertools.cpp b/indra/newview/llfloatertools.cpp index 672160073e..9854d2594b 100644 --- a/indra/newview/llfloatertools.cpp +++ b/indra/newview/llfloatertools.cpp @@ -425,13 +425,14 @@ void LLFloaterTools::refresh() // calculate selection rendering cost std::string prim_cost_string; LLResMgr::getInstance()->getIntegerString(prim_cost_string, calcRenderCost()); - childSetTextArg("render_cost", "[COUNT]", prim_cost_string); + childSetTextArg("RenderingCost", "[COUNT]", prim_cost_string); // disable the object and prim counts if nothing selected bool have_selection = ! LLSelectMgr::getInstance()->getSelection()->isEmpty(); childSetEnabled("obj_count", have_selection); childSetEnabled("prim_count", have_selection); + childSetEnabled("RenderingCost", have_selection); // Refresh child tabs mPanelPermissions->refresh(); @@ -562,6 +563,7 @@ void LLFloaterTools::updatePopup(LLCoordGL center, MASK mask) mBtnEdit ->setToggleState( edit_visible ); mRadioGroupEdit->setVisible( edit_visible ); + childSetVisible("RenderingCost", edit_visible || focus_visible || move_visible); if (mCheckSelectIndividual) { @@ -983,7 +985,7 @@ S32 LLFloaterTools::calcRenderCost() LLVOVolume *viewer_volume = (LLVOVolume*)select_node->getObject(); if (viewer_volume) { - cost += viewer_volume->getRenderCost(); + cost += viewer_volume->getRenderCost(); } } } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index d7e31e8436..b6c1ee2f11 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -7644,7 +7644,7 @@ void LLVOAvatar::idleUpdateRenderCost() ETextureIndex tex_index = baked_dict->mTextureIndex; if (isTextureVisible(tex_index)) { - shame +=25; + shame +=20; } } -- cgit v1.2.3 From 036b0b7d8d16bc37ccc618b616db864c67c940e4 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Fri, 13 Nov 2009 11:43:32 -0500 Subject: removed dead code that was triggering a warning on some platforms --HG-- branch : avatar-pipeline --- indra/newview/llappearancemgr.cpp | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'indra/newview') diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 456eaa43c6..8d66cefa4f 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -323,44 +323,6 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items) items = new_items; } -static void removeDuplicateItems(LLInventoryModel::item_array_t& dst, const LLInventoryModel::item_array_t& src) -{ - LLInventoryModel::item_array_t new_dst; - std::set mark_inventory; - - S32 inventory_dups = 0; - - for (LLInventoryModel::item_array_t::const_iterator src_pos = src.begin(); - src_pos != src.end(); - ++src_pos) - { - LLUUID src_item_id = (*src_pos)->getLinkedUUID(); - mark_inventory.insert(src_item_id); - } - - for (LLInventoryModel::item_array_t::const_iterator dst_pos = dst.begin(); - dst_pos != dst.end(); - ++dst_pos) - { - LLUUID dst_item_id = (*dst_pos)->getLinkedUUID(); - - if (mark_inventory.find(dst_item_id) == mark_inventory.end()) - { - // Item is not already present in COF. - new_dst.put(*dst_pos); - mark_inventory.insert(dst_item_id); - } - else - { - inventory_dups++; - } - } - llinfos << "removeDups, original " << dst.count() << " final " << new_dst.count() - << " inventory dups " << inventory_dups << llendl; - - dst = new_dst; -} - static void onWearableAssetFetch(LLWearable* wearable, void* data) { LLWearableHoldingPattern* holder = (LLWearableHoldingPattern*)data; -- cgit v1.2.3 From 2aa9f1bcbe0c51f9de24d52a08726dc13038f5b8 Mon Sep 17 00:00:00 2001 From: "Nyx (Neal Orman)" Date: Fri, 13 Nov 2009 14:57:06 -0500 Subject: EXT-2477 minimizing while in appearance editing mode leaves a bad state when minimizing the viewer while in appearance editing mode with unsaved changes kicks you out of appearance editing mode and leaves you unable to recover as the editor always starts itself on the shape tab. Fixed this in two ways: 1) if a wearable is dirty when the editor is opened, that is the tab that is selected. 2) the camera mode is not forcibly changed away from appearance editing mode on minimize. This only needs to happen if we are in mouselook. Code reviewed by Vir. --HG-- branch : avatar-pipeline --- indra/newview/llviewerwindow.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview') diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 1054223dcf..90a79698f6 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -1015,7 +1015,10 @@ BOOL LLViewerWindow::handleActivate(LLWindow *window, BOOL activated) } // SL-53351: Make sure we're not in mouselook when minimised, to prevent control issues - gAgent.changeCameraToDefault(); + if (gAgent.getCameraMode() == CAMERA_MODE_MOUSELOOK) + { + gAgent.changeCameraToDefault(); + } send_agent_pause(); -- cgit v1.2.3