Muting an avatar now also removes their attached lights. Also cleaned up light update code(no change in behavior)

This commit is contained in:
Shyotl
2012-10-22 03:07:07 -05:00
parent d2004e88f9
commit 9ef10b1663
3 changed files with 64 additions and 28 deletions

View File

@@ -295,6 +295,23 @@ BOOL LLMuteList::isLinden(const std::string& name) const
return last_name == "Linden";
}
static LLVOAvatar* find_avatar(const LLUUID& id)
{
LLViewerObject *obj = gObjectList.findObject(id);
while (obj && obj->isAttachment())
{
obj = (LLViewerObject *)obj->getParent();
}
if (obj && obj->isAvatar())
{
return (LLVOAvatar*)obj;
}
else
{
return NULL;
}
}
BOOL LLMuteList::add(const LLMute& mute, U32 flags)
{
@@ -391,6 +408,12 @@ BOOL LLMuteList::add(const LLMute& mute, U32 flags)
LLViewerPartSim::getInstance()->clearParticlesByOwnerID(localmute.mID);
}
}
//mute local lights that are attached to the avatar
LLVOAvatar *avatarp = find_avatar(localmute.mID);
if (avatarp)
{
LLPipeline::removeMutedAVsLights(avatarp);
}
return TRUE;
}
}

View File

@@ -1455,6 +1455,21 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
}
//static
void LLPipeline::removeMutedAVsLights(LLVOAvatar* muted_avatar)
{
LLFastTimer t(FTM_REMOVE_FROM_LIGHT_SET);
for (light_set_t::iterator iter = gPipeline.mNearbyLights.begin();
iter != gPipeline.mNearbyLights.end();)
{
if (iter->drawable->getVObj()->isAttachment() && iter->drawable->getVObj()->getAvatar() == muted_avatar)
{
gPipeline.mLights.erase(iter->drawable);
gPipeline.mNearbyLights.erase(iter++);
}
}
}
U32 LLPipeline::addObject(LLViewerObject *vobj)
{
llassert_always(vobj);
@@ -5012,38 +5027,34 @@ void LLPipeline::calcNearbyLights(LLCamera& camera)
F32 max_dist = LIGHT_MAX_RADIUS * 4.f; // ignore enitrely lights > 4 * max light rad
// UPDATE THE EXISTING NEARBY LIGHTS
if (!LLPipeline::sSkipUpdate)
light_set_t cur_nearby_lights;
for (light_set_t::iterator iter = mNearbyLights.begin();
iter != mNearbyLights.end(); iter++)
{
light_set_t cur_nearby_lights;
for (light_set_t::iterator iter = mNearbyLights.begin();
iter != mNearbyLights.end(); iter++)
const Light* light = &(*iter);
LLDrawable* drawable = light->drawable;
LLVOVolume* volight = drawable->getVOVolume();
if (!volight || !drawable->isState(LLDrawable::LIGHT))
{
const Light* light = &(*iter);
LLDrawable* drawable = light->drawable;
LLVOVolume* volight = drawable->getVOVolume();
if (!volight || !drawable->isState(LLDrawable::LIGHT))
{
setLight(drawable,false); //remove from mLight list
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
if (light->fade <= -LIGHT_FADE_TIME)
{
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
if (!sRenderAttachedLights && volight && volight->isAttachment())
{
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
F32 dist = calc_light_dist(volight, cam_pos, max_dist);
cur_nearby_lights.insert(Light(drawable, dist, light->fade));
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
mNearbyLights = cur_nearby_lights;
if (light->fade <= -LIGHT_FADE_TIME)
{
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
if (!sRenderAttachedLights && volight && volight->isAttachment())
{
drawable->clearState(LLDrawable::NEARBY_LIGHT);
continue;
}
F32 dist = calc_light_dist(volight, cam_pos, max_dist);
cur_nearby_lights.insert(Light(drawable, dist, light->fade));
}
mNearbyLights = cur_nearby_lights;
// FIND NEW LIGHTS THAT ARE IN RANGE
light_set_t new_nearby_lights;
for (LLDrawable::drawable_set_t::iterator iter = mLights.begin();

View File

@@ -155,6 +155,8 @@ public:
void unlinkDrawable(LLDrawable*);
static void removeMutedAVsLights(LLVOAvatar*);
// Object related methods
void markVisible(LLDrawable *drawablep, LLCamera& camera);
void markOccluder(LLSpatialGroup* group);