void LLLocalSpeakerMgr::updateSpeakerList() { // pull speakers from voice channel LLSpeakerMgr::updateSpeakerList(); // add non-voice speakers in chat range std::vector< LLCharacter* >::iterator avatar_it; for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it) { LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it; if (!avatarp->isDead() && dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= CHAT_NORMAL_RADIUS) { setSpeaker(avatarp->getID()); } } // check if text only speakers have moved out of chat range for (speaker_map_t::iterator speaker_it = mSpeakers.begin(); speaker_it != mSpeakers.end(); ++speaker_it) { LLUUID speaker_id = speaker_it->first; LLSpeaker* speakerp = speaker_it->second; if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY) { LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id); if (!avatarp || avatarp->isDead() || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS) { speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL; speakerp->mDotColor = INACTIVE_COLOR; speakerp->mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT); } } } }
bool LLTrackingData::haveTrackingInfo() { LLVOAvatar* avatarp = gObjectList.findAvatar(mAvatarID); if(avatarp && !avatarp->isDead()) { mCoarseLocationTimer.checkExpirationAndReset(COARSE_FREQUENCY); mUpdateTimer.setTimerExpirySec(FIND_FREQUENCY); mAgentGone.setTimerExpirySec(OFFLINE_SECONDS); mHaveInfo = true; return true; } if(mHaveCoarseInfo && !mCoarseLocationTimer.checkExpirationAndReset(COARSE_FREQUENCY)) { // if we reach here, then we have a 'recent' coarse update mUpdateTimer.setTimerExpirySec(FIND_FREQUENCY); mAgentGone.setTimerExpirySec(OFFLINE_SECONDS); return true; } if(mUpdateTimer.checkExpirationAndReset(FIND_FREQUENCY)) { LLAvatarTracker::instance().findAgent(); mHaveCoarseInfo = false; } if(mAgentGone.checkExpirationAndReset(OFFLINE_SECONDS)) { mHaveInfo = false; mHaveCoarseInfo = false; } return mHaveInfo; }
void LLFloaterHUD::find() // Scanner activated by Scan button { if(mHalt) return; // this basically checks if the scan has been toggled on or off otherwise llvoavatar calls the scan on avatar activity mListNames->deleteAllItems(); //Clear the list std::vector< LLCharacter* >::iterator avatar_it; for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it) { LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it; if (avatarp->isDead() || avatarp->isSelf()) //Dont show the user! { continue; } if (dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= SCAN_MAX_RADIUS) //Scanner radius set in indra constants. { // Pull in that avatar data! std::string name = avatarp->getFullname(); LLVector3d position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); LLUUID avid = avatarp->getID(); // Work out distance relative to user! LLVector3d mypos = gAgent.getPositionGlobal(); LLVector3d delta = position - mypos; F32 distance = (F32)delta.magVec(); //Build the list LLSD element; element["id"] = avid; element["columns"][LIST_AVATAR_NAME]["column"] = "name"; element["columns"][LIST_AVATAR_NAME]["value"] = name; element["columns"][LIST_DISTANCE]["column"] = "distance"; element["columns"][LIST_DISTANCE]["value"] = distance; mListNames->addElement(element); mListNames->sortByColumn("distance", TRUE); mListNames->setCallbackUserData(this); } } return; }
// static // Send request for one region, no timer checks void LLAvatarRenderInfoAccountant::sendRenderInfoToRegion(LLViewerRegion * regionp) { std::string url = regionp->getCapability("AvatarRenderInfo"); if (!url.empty()) { if (logRenderInfo()) { LL_INFOS() << "LRI: Sending avatar render info to region " << regionp->getName() << " from " << url << LL_ENDL; } // Build the render info to POST to the region LLSD report = LLSD::emptyMap(); LLSD agents = LLSD::emptyMap(); std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); while( iter != LLCharacter::sInstances.end() ) { LLVOAvatar* avatar = dynamic_cast<LLVOAvatar*>(*iter); if (avatar && avatar->getRezzedStatus() >= 2 && // Mostly rezzed (maybe without baked textures downloaded) !avatar->isDead() && // Not dead yet avatar->getObjectHost() == regionp->getHost()) // Ensure it's on the same region { avatar->calculateUpdateRenderCost(); // Make sure the numbers are up-to-date LLSD info = LLSD::emptyMap(); if (avatar->getVisualComplexity() > 0) { info[KEY_WEIGHT] = avatar->getVisualComplexity(); agents[avatar->getID().asString()] = info; if (logRenderInfo()) { LL_INFOS() << "LRI: Sending avatar render info for " << avatar->getID() << ": " << info << LL_ENDL; LL_INFOS() << "LRI: other info geometry " << avatar->getAttachmentGeometryBytes() << ", area " << avatar->getAttachmentSurfaceArea() << LL_ENDL; } } } iter++; } report[KEY_AGENTS] = agents; if (agents.size() > 0) { LLHTTPClient::post(url, report, new LLAvatarRenderInfoPostResponder(regionp->getHandle())); } } }
//----------------------------------------------------------------------------- // shutdown() //----------------------------------------------------------------------------- void LLMorphView::shutdown() { LLVOAvatar::onCustomizeEnd(); LLVOAvatar *avatarp = gAgent.getAvatarObject(); if(avatarp && !avatarp->isDead()) { avatarp->startMotion( ANIM_AGENT_BODY_NOISE ); avatarp->mSpecialRenderMode = 0; // reset camera LLViewerCamera::getInstance()->setNear(mOldCameraNearClip); } }
void LLDrawPoolAvatar::renderShadow(S32 pass) { LLFastTimer t(LLFastTimer::FTM_SHADOW_AVATAR); if (mDrawFace.empty()) { return; } const LLFace *facep = mDrawFace[0]; if (!facep->getDrawable()) { return; } LLVOAvatar *avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); if (avatarp->isDead() || avatarp->mIsDummy || avatarp->mDrawable.isNull()) { return; } BOOL impostor = avatarp->isImpostor(); if (impostor) { return; } if (pass == 0) { if (sShaderLevel > 0) { gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; } avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } else { renderRigged(avatarp, RIGGED_SIMPLE); renderRigged(avatarp, RIGGED_ALPHA); renderRigged(avatarp, RIGGED_FULLBRIGHT); renderRigged(avatarp, RIGGED_FULLBRIGHT_SHINY); renderRigged(avatarp, RIGGED_SHINY); renderRigged(avatarp, RIGGED_FULLBRIGHT_ALPHA); } }
//----------------------------------------------------------------------------- // initialize() //----------------------------------------------------------------------------- void LLMorphView::initialize() { mCameraPitch = 0.f; mCameraYaw = 0.f; mCameraDist = -1.f; LLVOAvatar *avatarp = gAgent.getAvatarObject(); if (!avatarp || avatarp->isDead()) { gAgent.changeCameraToDefault(); return; } avatarp->stopMotion( ANIM_AGENT_BODY_NOISE ); avatarp->mSpecialRenderMode = 3; // set up camera for close look at avatar mOldCameraNearClip = LLViewerCamera::getInstance()->getNear(); LLViewerCamera::getInstance()->setNear(MORPH_NEAR_CLIP); }
void LLDrawPoolAvatar::renderShadow(S32 pass) { LLFastTimer t(FTM_SHADOW_AVATAR); if (mDrawFace.empty()) { return; } const LLFace *facep = mDrawFace[0]; if (!facep->getDrawable()) { return; } LLVOAvatar *avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); if (avatarp->isDead() || avatarp->mIsDummy || avatarp->mDrawable.isNull()) { return; } BOOL impostor = avatarp->isImpostor(); if (impostor) { return; } if (pass == 0) { avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } else { renderRigged(avatarp, RIGGED_SIMPLE); renderRigged(avatarp, RIGGED_ALPHA); renderRigged(avatarp, RIGGED_FULLBRIGHT); renderRigged(avatarp, RIGGED_FULLBRIGHT_SHINY); renderRigged(avatarp, RIGGED_SHINY); renderRigged(avatarp, RIGGED_FULLBRIGHT_ALPHA); } }
LLVector3d LLAvatarTracker::getGlobalPos() { if(!mTrackedAgentValid || !mTrackingData) return LLVector3d(); LLVector3d global_pos; LLVOAvatar* avatarp = gObjectList.findAvatar(mTrackingData->mAvatarID); if(avatarp && !avatarp->isDead()) { global_pos = avatarp->getPositionGlobal(); // HACK - for making the tracker point above the avatar's head // rather than its groin global_pos.mdV[VZ] += 0.7f * avatarp->mBodySize.mV[VZ]; mTrackingData->mGlobalPositionEstimate = global_pos; } else { global_pos = mTrackingData->mGlobalPositionEstimate; } return global_pos; }
void LLAvatarTracker::getDegreesAndDist(F32& rot, F64& horiz_dist, F64& vert_dist) { if(!mTrackingData) return; LLVector3d global_pos; LLVOAvatar* avatarp = gObjectList.findAvatar(mTrackingData->mAvatarID); if(avatarp && !avatarp->isDead()) { global_pos = avatarp->getPositionGlobal(); mTrackingData->mGlobalPositionEstimate = global_pos; } else { global_pos = mTrackingData->mGlobalPositionEstimate; } LLVector3d to_vec = global_pos - gAgent.getPositionGlobal(); horiz_dist = sqrt(to_vec.mdV[VX] * to_vec.mdV[VX] + to_vec.mdV[VY] * to_vec.mdV[VY]); vert_dist = to_vec.mdV[VZ]; rot = F32(RAD_TO_DEG * atan2(to_vec.mdV[VY], to_vec.mdV[VX])); }
void LLLocalSpeakerMgr::updateSpeakerList() { // pull speakers from voice channel LLSpeakerMgr::updateSpeakerList(); if (gDisconnected)//the world is cleared. { return ; } // pick up non-voice speakers in chat range std::vector<LLUUID> avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgent.getPositionGlobal(), CHAT_NORMAL_RADIUS); for(U32 i=0; i<avatar_ids.size(); i++) { setSpeaker(avatar_ids[i]); } // check if text only speakers have moved out of chat range for (speaker_map_t::iterator speaker_it = mSpeakers.begin(); speaker_it != mSpeakers.end(); ++speaker_it) { LLUUID speaker_id = speaker_it->first; LLSpeaker* speakerp = speaker_it->second; if (speakerp->mStatus == LLSpeaker::STATUS_TEXT_ONLY) { LLVOAvatar* avatarp = (LLVOAvatar*)gObjectList.findObject(speaker_id); if (!avatarp || avatarp->isDead() || dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) > CHAT_NORMAL_RADIUS) { speakerp->mStatus = LLSpeaker::STATUS_NOT_IN_CHANNEL; speakerp->mDotColor = INACTIVE_COLOR; speakerp->mActivityTimer.resetWithExpiry(SPEAKER_TIMEOUT); } } } }
void LLWorld::getAvatars(std::vector<LLUUID>* avatar_ids, std::vector<LLVector3d>* positions, const LLVector3d& relative_to, F32 radius) const { if(avatar_ids != NULL) { avatar_ids->clear(); } if(positions != NULL) { positions->clear(); } for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; const LLVector3d& origin_global = regionp->getOriginGlobal(); S32 count = regionp->mMapAvatars.count(); for (S32 i = 0; i < count; i++) { LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.get(i), origin_global); if(dist_vec(pos_global, relative_to) <= radius) { if(positions != NULL) { positions->push_back(pos_global); } if(avatar_ids != NULL) { avatar_ids->push_back(regionp->mMapAvatarIDs.get(i)); } } } } // retrieve the list of close avatars from viewer objects as well // for when we are above 1000m, only do this when we are retrieving // uuid's too as there could be duplicates if(avatar_ids != NULL) { for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; if(pVOAvatar->isDead() || pVOAvatar->isSelf()) continue; LLUUID uuid = pVOAvatar->getID(); if(uuid.isNull()) continue; LLVector3d pos_global = pVOAvatar->getPositionGlobal(); if(dist_vec(pos_global, relative_to) <= radius) { bool found = false; uuid_vec_t::iterator sel_iter = avatar_ids->begin(); for (; sel_iter != avatar_ids->end(); sel_iter++) { if(*sel_iter == uuid) { found = true; break; } } if(!found) { if(positions != NULL) positions->push_back(pos_global); avatar_ids->push_back(uuid); } } } } }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; #ifdef LL_RRINTERFACE_H //MK if (gRRenabled && gAgent.mRRInterface.mContainsShownames) { close(); } #endif //mk //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); bool announce = gSavedSettings.getBOOL("RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name, first, last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); if (obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // Apparently, sometimes the name comes out empty, with a " " name. This is because // getFullname concatenates first and last name with a " " in the middle. // This code will avoid adding a nameless entry to the list until it acquires a name. //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue; } } ifdef LL_DISPLAY_NAMES std::string display_name = name; if (LLAvatarNameCache::useDisplayNames()) { LLAvatarName avatar_name; if (LLAvatarNameCache::get(avid, &avatar_name)) { if (LLAvatarNameCache::useDisplayNames() == 2) { display_name = avatar_name.mDisplayName; } else { display_name = avatar_name.getNames(); } } } #endif if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars[avid] = entry; } #ifdef LL_DISPLAY_NAMES // update avatar display name. mAvatars[avid].setDisplayName(display_name); #endif } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } #ifdef LL_DISPLAY_NAMES std::string display_name = name; if (LLAvatarNameCache::useDisplayNames()) { LLAvatarName avatar_name; if (LLAvatarNameCache::get(avid, &avatar_name)) { if (LLAvatarNameCache::useDisplayNames() == 2) { display_name = avatar_name.mDisplayName; } else { display_name = avatar_name.getNames(); } } } #endif if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars[avid] = entry; } #ifdef LL_DISPLAY_NAMES // update avatar display name. mAvatars[avid].setDisplayName(display_name); #endif } } //let us send the keys in a more timely fashion if(announce && !announce_keys.empty()) { std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if(ids.tellp() > 200) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); num_ids = 0; ids.seekp(0); ids.str(""); } } if(num_ids > 0) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }
void LLFloaterAvatarList::updateAvatarList() { //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } //moved to pipeline to prevent a crash //gPipeline.forAllVisibleDrawables(updateParticleActivity); //todo: make this less of a hacked up copypasta from dales 1.18. if(gAudiop != NULL) { LLAudioEngine::source_map::iterator iter; for (iter = gAudiop->mAllSources.begin(); iter != gAudiop->mAllSources.end(); ++iter) { LLAudioSource *sourcep = iter->second; LLUUID uuid = sourcep->getOwnerID(); LLAvatarListEntry *ent = getAvatarEntry(uuid); if ( ent ) { ent->setActivity(LLAvatarListEntry::ACTIVITY_SOUND); } } } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); BOOST_FOREACH(std::vector<LLCharacter*>::value_type& iter, LLCharacter::sInstances) { LLUUID avid = iter->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); static LLCachedControl<bool> announce(gSavedSettings, "RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLVOAvatar* avatarp = gObjectList.findAvatar(avid); if (avatarp) { // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); if (!LLAvatarNameCache::getPNSName(avatarp->getID(), name)) continue; //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (!gCacheName->getFullName(avid, name)) //seems redudant with LLAvatarNameCache::getPNSName above... { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } LLAvatarListEntry* entry = getAvatarEntry(avid); if (entry) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); entry->setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); if(avatarp->isTyping())entry->setActivity(LLAvatarListEntry::ACTIVITY_TYPING); } else { // Avatar not there yet, add it if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position))); } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (!LLAvatarNameCache::getPNSName(avid, name)) { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } LLAvatarListEntry* entry = getAvatarEntry(avid); if (entry) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); entry->setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position))); } } } //let us send the keys in a more timely fashion if (announce && !announce_keys.empty()) { // NOTE: This fragment is repeated in sendKey std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if (ids.tellp() > 200) { send_keys_message(transact_num, num_ids, ids.str()); num_ids = 0; ids.seekp(0); ids.str(""); } } if (num_ids > 0) send_keys_message(transact_num, num_ids, ids.str()); } }
void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { if (pass == -1) { for (S32 i = 1; i < getNumPasses(); i++) { //skip foot shadows prerender(); beginRenderPass(i); renderAvatars(single_avatar, i); endRenderPass(i); } return; } if (mDrawFace.empty() && !single_avatar) { return; } LLVOAvatar *avatarp; if (single_avatar) { avatarp = single_avatar; } else { const LLFace *facep = mDrawFace[0]; if (!facep->getDrawable()) { return; } avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); } if (avatarp->isDead() || avatarp->mDrawable.isNull()) { return; } if (!single_avatar && !avatarp->isFullyLoaded()) { if (pass == 0 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0)) { // debug code to draw a sphere in place of avatar gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); gGL.setColorMask(true, true); LLVector3 pos = avatarp->getPositionAgent(); gGL.color4f(1.0f, 1.0f, 1.0f, 0.7f); gGL.pushMatrix(); gGL.translatef((F32)(pos.mV[VX]), (F32)(pos.mV[VY]), (F32)(pos.mV[VZ])); gGL.scalef(0.15f, 0.15f, 0.3f); gSphere.renderGGL(); gGL.popMatrix(); gGL.setColorMask(true, false); } // don't render please return; } BOOL impostor = avatarp->isImpostor() && !single_avatar; if (impostor && pass != 0) { //don't draw anything but the impostor for impostored avatars return; } if (pass == 0 && !impostor && LLPipeline::sUnderWaterRender) { //don't draw foot shadows under water return; } if (pass == 0) { if (!LLPipeline::sReflectionRender) { LLVOAvatar::sNumVisibleAvatars++; } if (impostor) { if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) { if (normal_channel > -1) { avatarp->mImpostor.bindTexture(2, normal_channel); } if (specular_channel > -1) { avatarp->mImpostor.bindTexture(1, specular_channel); } } avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } return; } if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view { gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f)); } if (pass == 1) { // render rigid meshes (eyeballs) first avatarp->renderRigid(); return; } if (pass == 3) { if (is_deferred_render) { renderDeferredRiggedSimple(avatarp); } else { renderRiggedSimple(avatarp); } return; } if (pass == 4) { if (is_deferred_render) { renderDeferredRiggedBump(avatarp); } else { renderRiggedFullbright(avatarp); } return; } if (pass == 5) { renderRiggedShinySimple(avatarp); return; } if (pass == 6) { renderRiggedFullbrightShiny(avatarp); return; } if (pass >= 7 && pass < 9) { LLGLEnable blend(GL_BLEND); gGL.setColorMask(true, true); gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); if (pass == 7) { renderRiggedAlpha(avatarp); return; } if (pass == 8) { renderRiggedFullbrightAlpha(avatarp); return; } } if (pass == 9) { LLGLEnable blend(GL_BLEND); LLGLDisable test(GL_ALPHA_TEST); gGL.flush(); LLGLEnable polyOffset(GL_POLYGON_OFFSET_FILL); glPolygonOffset(-1.0f, -1.0f); gGL.setSceneBlendType(LLRender::BT_ADD); LLGLDepthTest depth(GL_TRUE, GL_FALSE); gGL.setColorMask(false, true); renderRiggedGlow(avatarp); gGL.setColorMask(true, false); gGL.setSceneBlendType(LLRender::BT_ALPHA); return; } if (sShaderLevel > 0) { gAvatarMatrixParam = sVertexProgram->mUniform[LLViewerShaderMgr::AVATAR_MATRIX]; } if (sShaderLevel >= SHADER_LEVEL_CLOTH) { LLMatrix4 rot_mat; LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); LLMatrix4 cfr(OGL_TO_CFR_ROTATION); rot_mat *= cfr; LLVector4 wind; wind.setVec(avatarp->mWindVec); wind.mV[VW] = 0; wind = wind * rot_mat; wind.mV[VW] = avatarp->mWindVec.mV[VW]; sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_WIND, wind.mV); F32 phase = -1.f * (avatarp->mRipplePhase); F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); LLVector4 sin_params(freq, freq, freq, phase); sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_SINWAVE, sin_params.mV); LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); gravity = gravity * rot_mat; sVertexProgram->vertexAttrib4fv(LLViewerShaderMgr::AVATAR_GRAVITY, gravity.mV); } if (!single_avatar || avatarp == single_avatar) { avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } }
void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) { LLFastTimer t(FTM_RENDER_AVATARS); if (pass == -1) { for (S32 i = 1; i < getNumPasses(); i++) { //skip foot shadows prerender(); beginRenderPass(i); renderAvatars(single_avatar, i); endRenderPass(i); } return; } if (mDrawFace.empty() && !single_avatar) { return; } LLVOAvatar *avatarp; if (single_avatar) { avatarp = single_avatar; } else { const LLFace *facep = mDrawFace[0]; if (!facep->getDrawable()) { return; } avatarp = (LLVOAvatar *)facep->getDrawable()->getVObj().get(); } if (avatarp->isDead() || avatarp->mDrawable.isNull()) { return; } if (!single_avatar && !avatarp->isFullyLoaded() ) { if (pass==0 && (!gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_PARTICLES) || LLViewerPartSim::getMaxPartCount() <= 0)) { // debug code to draw a sphere in place of avatar gGL.getTexUnit(0)->bind(LLViewerFetchedTexture::sWhiteImagep); gGL.setColorMask(true, true); LLVector3 pos = avatarp->getPositionAgent(); gGL.color4f(1.0f, 1.0f, 1.0f, 0.7f); gGL.pushMatrix(); gGL.translatef((F32)(pos.mV[VX]), (F32)(pos.mV[VY]), (F32)(pos.mV[VZ])); gGL.scalef(0.15f, 0.15f, 0.3f); gSphere.renderGGL(); gGL.popMatrix(); gGL.setColorMask(true, false); } // don't render please return; } BOOL impostor = avatarp->isImpostor() && !single_avatar; if (impostor && pass != 0) { //don't draw anything but the impostor for impostored avatars return; } if (pass == 0 && !impostor && LLPipeline::sUnderWaterRender) { //don't draw foot shadows under water return; } if (pass == 0) { if (!LLPipeline::sReflectionRender) { LLVOAvatar::sNumVisibleAvatars++; } if (impostor) { if (LLPipeline::sRenderDeferred && !LLPipeline::sReflectionRender && avatarp->mImpostor.isComplete()) { if (normal_channel > -1) { avatarp->mImpostor.bindTexture(2, normal_channel); } if (specular_channel > -1) { avatarp->mImpostor.bindTexture(1, specular_channel); } } avatarp->renderImpostor(LLColor4U(255,255,255,255), sDiffuseChannel); } //else if (gPipeline.hasRenderDebugFeatureMask(LLPipeline::RENDER_DEBUG_FEATURE_FOOT_SHADOWS) && !LLPipeline::sRenderDeferred) //{ // avatarp->renderFootShadows(); //} return; } llassert(LLPipeline::sImpostorRender || !avatarp->isVisuallyMuted()); /*if (single_avatar && avatarp->mSpecialRenderMode >= 1) // 1=anim preview, 2=image preview, 3=morph view { gPipeline.enableLightsAvatarEdit(LLColor4(.5f, .5f, .5f, 1.f)); }*/ if (pass == 1) { // render rigid meshes (eyeballs) first avatarp->renderRigid(); return; } if (pass == 3) { if (is_deferred_render) { renderDeferredRiggedSimple(avatarp); } else { renderRiggedSimple(avatarp); if (LLPipeline::sRenderDeferred) { //render "simple" materials renderRigged(avatarp, RIGGED_MATERIAL); renderRigged(avatarp, RIGGED_MATERIAL_ALPHA_MASK); renderRigged(avatarp, RIGGED_MATERIAL_ALPHA_EMISSIVE); renderRigged(avatarp, RIGGED_NORMMAP); renderRigged(avatarp, RIGGED_NORMMAP_MASK); renderRigged(avatarp, RIGGED_NORMMAP_EMISSIVE); renderRigged(avatarp, RIGGED_SPECMAP); renderRigged(avatarp, RIGGED_SPECMAP_MASK); renderRigged(avatarp, RIGGED_SPECMAP_EMISSIVE); renderRigged(avatarp, RIGGED_NORMSPEC); renderRigged(avatarp, RIGGED_NORMSPEC_MASK); renderRigged(avatarp, RIGGED_NORMSPEC_EMISSIVE); } } return; } if (pass == 4) { if (is_deferred_render) { renderDeferredRiggedBump(avatarp); } else { renderRiggedFullbright(avatarp); } return; } if (is_deferred_render && pass >= 5 && pass <= 21) { S32 p = pass-5; if (p != 1 && p != 5 && p != 9 && p != 13) { renderDeferredRiggedMaterial(avatarp, p); } return; } if (pass == 5) { renderRiggedShinySimple(avatarp); return; } if (pass == 6) { renderRiggedFullbrightShiny(avatarp); return; } if (pass >= 7 && pass < 13) { if (pass == 7) { renderRiggedAlpha(avatarp); if (LLPipeline::sRenderDeferred && !is_post_deferred_render) { //render transparent materials under water LLGLEnable blend(GL_BLEND); gGL.setColorMask(true, true); gGL.blendFunc(LLRender::BF_SOURCE_ALPHA, LLRender::BF_ONE_MINUS_SOURCE_ALPHA, LLRender::BF_ZERO, LLRender::BF_ONE_MINUS_SOURCE_ALPHA); renderRigged(avatarp, RIGGED_MATERIAL_ALPHA); renderRigged(avatarp, RIGGED_SPECMAP_BLEND); renderRigged(avatarp, RIGGED_NORMMAP_BLEND); renderRigged(avatarp, RIGGED_NORMSPEC_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); gGL.setColorMask(true, false); } return; } if (pass == 8) { renderRiggedFullbrightAlpha(avatarp); return; } if (LLPipeline::sRenderDeferred && is_post_deferred_render) { S32 p = 0; switch (pass) { case 9: p = 1; break; case 10: p = 5; break; case 11: p = 9; break; case 12: p = 13; break; } { LLGLEnable blend(GL_BLEND); renderDeferredRiggedMaterial(avatarp, p); } return; } else if (pass == 9) { renderRiggedGlow(avatarp); return; } } if (pass == 13) { renderRiggedGlow(avatarp); return; } if ((sShaderLevel >= SHADER_LEVEL_CLOTH)) { LLMatrix4 rot_mat; LLViewerCamera::getInstance()->getMatrixToLocal(rot_mat); LLMatrix4 cfr(OGL_TO_CFR_ROTATION.getF32ptr()); rot_mat *= cfr; LLVector4 wind; wind.setVec(avatarp->mWindVec); wind.mV[VW] = 0; wind = wind * rot_mat; wind.mV[VW] = avatarp->mWindVec.mV[VW]; sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_WIND, 1, wind.mV); F32 phase = -1.f * (avatarp->mRipplePhase); F32 freq = 7.f + (noise1(avatarp->mRipplePhase) * 2.f); LLVector4 sin_params(freq, freq, freq, phase); sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_SINWAVE, 1, sin_params.mV); LLVector4 gravity(0.f, 0.f, -CLOTHING_GRAVITY_EFFECT, 0.f); gravity = gravity * rot_mat; sVertexProgram->uniform4fv(LLViewerShaderMgr::AVATAR_GRAVITY, 1, gravity.mV); } if( !single_avatar || (avatarp == single_avatar) ) { avatarp->renderSkinned(AVATAR_RENDER_PASS_SINGLE); } }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); for (i = 0; i < count; ++i) { std::string name; std::string first; std::string last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); if (obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. if (avatarp->isDead() || avatarp->isSelf()) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // Apparently, sometimes the name comes out empty, with a " " name. This is because // getFullname concatenates first and last name with a " " in the middle. // This code will avoid adding a nameless entry to the list until it acquires a name. //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); mAvatars[avid] = entry; } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); mAvatars[avid] = entry; } } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }
BOOL FloaterAvatarList::tick() { if(!gDisconnected) { LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if(check && check->getValue()) { //UPDATES// LLVector3d agent_pos = gAgent.getPositionGlobal(); std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions,agent_pos); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for(std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if(!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } int i = 0; int len = avatar_ids.size(); for(i = 0; i < len; i++) { LLUUID &avid = avatar_ids[i]; if(avid != gAgent.getID()) { std::string name; std::string first; std::string last; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); bool same_region = false; bool in_draw = false; if(obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } if (avatarp->isDead()) { continue; } position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); in_draw = true; same_region = avatarp->getRegion() == gAgent.getRegion(); }else { if( i < (int)positions.size()) { position = positions[i]; } else { continue; } same_region = gAgent.getRegion()->pointInRegionGlobal(position); } if(gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue;//name = LLCacheName::getDefaultName(); } if (mAvatars.find(avid) == mAvatars.end()) { avatar_entry new_entry; new_entry.id = avid; new_entry.is_linden = (strcmp(last.c_str(),"Linden") == 0 || strcmp(last.c_str(),"Tester") == 0) ? true : false; mAvatars[avid] = new_entry; if(gSavedSettings.getBOOL("EmeraldRadarChatKeys")) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel")); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 1) + avid.asString()); gAgent.sendReliableMessage(); } } avatar_entry* entry = &(mAvatars[avid]); entry->name = name; entry->position = position; entry->same_region = same_region; entry->last_update_frame = gFrameCount; entry->last_update_sec.reset(); bool in_chat = (position - agent_pos).magVec() < 20.0f; chat_alerts(entry,same_region, in_draw, in_chat); if(entry->last_in_sim != same_region) { LLViewerRegion* regionp = gAgent.getRegion(); if(sInstance->mEstateMemoryBans.find(regionp) != sInstance->mEstateMemoryBans.end()) { std::set<LLUUID> *mem = &mEstateMemoryBans[regionp]; if(mem->find(avid) != mem->end()) { cmdline_printchat("Enforcing memory ban."); execEstateKick(avid); } } } entry->last_in_sim = same_region; entry->last_in_draw = in_draw; entry->last_in_chat = in_chat; } } //END UPDATES// //EXPIRE// std::map<LLUUID, avatar_entry>::iterator iter; std::queue<LLUUID> delete_queue; for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++) { //avatar_entry *entry = &iter->second; F32 aged = iter->second.last_update_sec.getElapsedTimeF32(); if ( aged > CLEANUP_TIMEOUT ) { LLUUID av_id = iter->first; delete_queue.push(av_id); } else if(iter->second.last_update_frame != gFrameCount) if(iter->second.last_update_frame != -1) { LLUUID av_id = iter->first; chat_alerts(&iter->second,false, false, false); iter->second.last_in_sim = false; iter->second.last_in_draw = false; iter->second.last_in_chat = false; iter->second.last_update_frame = -1; if(gSavedSettings.getBOOL("EmeraldRadarChatKeys")) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel")); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 0) + av_id.asString()); gAgent.sendReliableMessage(); } } } while(!delete_queue.empty()) { mAvatars.erase(delete_queue.front()); delete_queue.pop(); } //END EXPIRE// //DRAW// if (sInstance->getVisible()) { LLCheckboxCtrl* fetch_data = getChild<LLCheckboxCtrl>("fetch_avdata_enabled_cb"); BOOL fetching = fetch_data->getValue(); LLDynamicArray<LLUUID> selected = mAvatarList->getSelectedIDs(); S32 scrollpos = mAvatarList->getScrollPos(); mAvatarList->deleteAllItems(); std::map<LLUUID, avatar_entry>::iterator iter; for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++) { LLUUID av_id; av_id = iter->first; avatar_entry *entry = &iter->second; //llinfos << entry->last_update_sec.getElapsedSeconds() << llendl; if(entry->last_update_sec.getElapsedTimeF32() < 5.0f) { LLSD element; if(entry->has_info == false && fetching && last_av_req.getElapsedTimeF32() > MIN_REQUEST_INTERVAL) { F32 now = entry->lifetime.getElapsedTimeF32(); F32 diff = now - entry->last_info_req; bool requested = entry->info_requested(); if(diff > entry->request_timeout || !requested) { if(requested && entry->request_timeout < 256.0f)entry->request_timeout *= 2.0f; last_av_req.reset(); entry->last_info_req = entry->lifetime.getElapsedTimeF32(); LLMessageSystem *msg = gMessageSystem; msg->newMessageFast(_PREHASH_AvatarPropertiesRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_AvatarID, av_id); gAgent.sendReliableMessage(); } } LLVector3d delta = entry->position - agent_pos; F32 distance = (F32)delta.magVec(); delta.mdV[VZ] = 0.0f; //F32 side_distance = (F32)delta.magVec(); if(av_id.isNull())continue; element["id"] = av_id; std::string icon = ""; if(entry->is_linden) { element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD"; } element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name"; element["columns"][LIST_AVATAR_NAME]["type"] = "text"; element["columns"][LIST_AVATAR_NAME]["value"] = entry->name; element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor("DefaultListText").getValue(); element["columns"][LIST_DISTANCE]["column"] = "distance"; element["columns"][LIST_DISTANCE]["type"] = "text"; if(entry->position.mdV[VZ] == 0.0) { static F32 *sRenderFarClip = rebind_llcontrol<F32>("RenderFarClip",&gSavedSettings,true); element["columns"][LIST_DISTANCE]["value"] = llformat("> %d", S32(*sRenderFarClip) ); }else { element["columns"][LIST_DISTANCE]["value"] = llformat("%.2f", distance); } LLColor4 dist_color; static LLColor4U *sAvatarListTextDistNormalRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistNormalRange",&gColors,true); static LLColor4U *sAvatarListTextDistShoutRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistShoutRange",&gColors,true); static LLColor4U *sAvatarListTextDistOver = rebind_llcontrol<LLColor4U>("AvatarListTextDistOver",&gColors,true); if(distance <= 20.0f)dist_color = LLColor4(*sAvatarListTextDistNormalRange); else if(distance > 20.0f && distance <= 96.0f)dist_color = LLColor4(*sAvatarListTextDistShoutRange); else dist_color = LLColor4(*sAvatarListTextDistOver); element["columns"][LIST_DISTANCE]["color"] = dist_color.getValue(); if(entry->has_info) { static F32 *sEmeraldAvatarAgeAlertDays = rebind_llcontrol<F32>("EmeraldAvatarAgeAlertDays",&gSavedSettings,true); if(entry->account_age < *sEmeraldAvatarAgeAlertDays && entry->age_alerted == false) { entry->age_alerted = true; } element["columns"][LIST_AGE]["column"] = "age"; element["columns"][LIST_AGE]["type"] = "text"; element["columns"][LIST_AGE]["value"] = llformat("%d",entry->account_age); LLColor4 age_color; static LLColor4U *sAvatarListTextAgeYoung = rebind_llcontrol<LLColor4U>("AvatarListTextAgeYoung",&gColors,true); static LLColor4U *sAvatarListTextAgeNormal = rebind_llcontrol<LLColor4U>("AvatarListTextAgeNormal",&gColors,true); if ( entry->account_age <= 7 )age_color = LLColor4(*sAvatarListTextAgeYoung); else age_color = LLColor4(*sAvatarListTextAgeNormal); element["columns"][LIST_AGE]["color"] = age_color.getValue(); } element["columns"][LIST_SIM]["column"] = "samesim"; element["columns"][LIST_SIM]["type"] = "text"; icon = ""; if(entry->last_update_sec.getElapsedTimeF32() < 0.5) { if(entry->same_region) { icon = "account_id_green.tga"; } }else { icon = "avatar_gone.tga"; } if (!icon.empty() ) { element["columns"][LIST_SIM].erase("color"); element["columns"][LIST_SIM]["type"] = "icon"; element["columns"][LIST_SIM]["value"] = icon; } icon = ""; if(!entry->has_info) { if(entry->info_requested()) { if(entry->request_timeout < 256.0f) icon = "info_fetching.tga"; else icon = "info_error.tga"; }else icon = "info_unknown.tga"; }else { switch(entry->agent_info.payment) { case PAYMENT_NONE: break; case PAYMENT_ON_FILE: icon = "payment_info_filled.tga"; break; case PAYMENT_USED: icon = "payment_info_used.tga"; break; case PAYMENT_LINDEN: // confusingly named icon, maybe use something else icon = "icon_top_pick.tga"; break; } } element["columns"][LIST_PAYMENT]["column"] = "payment_data"; element["columns"][LIST_PAYMENT]["type"] = "text"; if ( !icon.empty() ) { element["columns"][LIST_PAYMENT]["type"] = "icon"; element["columns"][LIST_PAYMENT]["value"] = icon; } S32 seentime = (S32)entry->lifetime.getElapsedTimeF32(); S32 hours = (S32)(seentime / (60*60)); S32 mins = (S32)((seentime - hours*(60*60)) / 60); S32 secs = (S32)((seentime - hours*(60*60) - mins*60)); element["columns"][LIST_TIME]["column"] = "time"; element["columns"][LIST_TIME]["type"] = "text"; element["columns"][LIST_TIME]["color"] = gColors.getColor("DefaultListText").getValue(); element["columns"][LIST_TIME]["value"] = llformat("%d:%02d:%02d", hours,mins,secs); element["columns"][LIST_CLIENT]["column"] = "client"; element["columns"][LIST_CLIENT]["type"] = "text"; static LLColor4U *sAvatarNameColor = rebind_llcontrol<LLColor4U>("AvatarNameColor",&gColors,true); static LLColor4U *sScrollUnselectedColor = rebind_llcontrol<LLColor4U>("ScrollUnselectedColor",&gColors,true); LLColor4 avatar_name_color = LLColor4(*sAvatarNameColor); std::string client; LLVOAvatar *av = (LLVOAvatar*)gObjectList.findObject(av_id); if(av) { LLVOAvatar::resolveClient(avatar_name_color, client, av); if(client == "") { avatar_name_color = LLColor4(*sScrollUnselectedColor); client = "?"; } element["columns"][LIST_CLIENT]["value"] = client.c_str(); } else { element["columns"][LIST_CLIENT]["value"] = "Out Of Range"; avatar_name_color = LLColor4(*sScrollUnselectedColor); } avatar_name_color = (avatar_name_color * 0.5) + (LLColor4(*sScrollUnselectedColor) * 0.5); element["columns"][LIST_CLIENT]["color"] = avatar_name_color.getValue(); mAvatarList->addElement(element, ADD_BOTTOM); } } mAvatarList->sortItems(); mAvatarList->selectMultiple(selected); mAvatarList->setScrollPos(scrollpos); } //END DRAW// } } if( mTracking && LLTracker::getTrackedPositionGlobal().isExactlyZero() ) { // trying to track an avatar, but tracker stopped tracking if ( mAvatars.find(mTrackedAvatar) != mAvatars.end() && !mTrackByLocation) { mTrackByLocation = TRUE; } else { LLTracker::stopTracking(NULL); mTracking = FALSE; } } if ( mTracking && mTrackByLocation) { std::string name = mAvatars[mTrackedAvatar].name; std::string tooltip = "Tracking last known position"; name += " (near)"; LLTracker::trackLocation(mAvatars[mTrackedAvatar].position,name, tooltip); } return FALSE; }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); bool announce = gSavedSettings.getBOOL("RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name; std::string first; std::string last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLVOAvatar* avatarp = gObjectList.findAvatar(avid); if (avatarp) { // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // [Ansariel: Display name support] LLAvatarName avatar_name; if (LLAvatarNameCache::get(avatarp->getID(), &avatar_name)) { static const LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0); switch (phoenix_name_system) { case 0 : name = avatar_name.getLegacyName(); break; case 1 : name = (avatar_name.mIsDisplayNameDefault ? avatar_name.mDisplayName : avatar_name.getCompleteName()); break; case 2 : name = avatar_name.mDisplayName; break; default : name = avatar_name.getLegacyName(); break; } first = avatar_name.mLegacyFirstName; last = avatar_name.mLegacyLastName; } else continue; // [/Ansariel: Display name support] //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (!gCacheName->getFullName(avid, name)) //seems redudant with LLAvatarNameCache::get above... { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars[avid] = entry; } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (!gCacheName->getFullName(avid, name)) { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars[avid] = entry; } } } //let us send the keys in a more timely fashion if(announce && !announce_keys.empty()) { std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if(ids.tellp() > 200) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); num_ids = 0; ids.seekp(0); ids.str(""); } } if(num_ids > 0) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }
void LLWorld::getAvatars(std::vector<LLUUID>* avatar_ids, std::vector<LLVector3d>* positions, const LLVector3d& relative_to, F32 radius) const { F32 radius_squared = radius * radius; if(avatar_ids != NULL) { avatar_ids->clear(); } if(positions != NULL) { positions->clear(); } // get the list of avatars from the character list first, so distances are correct // when agent is above 1020m and other avatars are nearby for (std::vector<LLCharacter*>::iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLVOAvatar* pVOAvatar = (LLVOAvatar*) *iter; if (!pVOAvatar->isDead() && !pVOAvatar->isSelf() && !pVOAvatar->mIsDummy) { LLUUID uuid = pVOAvatar->getID(); if(!uuid.isNull()) { LLVector3d pos_global = pVOAvatar->getPositionGlobal(); if(dist_vec_squared(pos_global, relative_to) <= radius_squared) { if(positions != NULL) { positions->push_back(pos_global); } if(avatar_ids !=NULL) { avatar_ids->push_back(uuid); } } } } } // region avatars added for situations where radius is greater than RenderFarClip for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; const LLVector3d& origin_global = regionp->getOriginGlobal(); S32 count = regionp->mMapAvatars.count(); for (S32 i = 0; i < count; i++) { LLVector3d pos_global = unpackLocalToGlobalPosition(regionp->mMapAvatars.get(i), origin_global); if(dist_vec_squared(pos_global, relative_to) <= radius_squared) { LLUUID uuid = regionp->mMapAvatarIDs.get(i); // if this avatar doesn't already exist in the list, add it if(uuid.notNull() && avatar_ids != NULL && std::find(avatar_ids->begin(), avatar_ids->end(), uuid) == avatar_ids->end()) { if(positions != NULL) { positions->push_back(pos_global); } avatar_ids->push_back(uuid); } } } } }