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)); } } } } }
void LLViewerRegion::getAvatars ( LLUUIDList& avatar_ids , const LLVector3d& relative_to , F32 radius ) const { avatar_ids.clear(); // const LLVector3d& origin_global = getOriginGlobal(); S32 count = mMapAvatars.count(); for (S32 i = 0; i < count; i++) { LLVector3d pos_global = unpackLocalToGlobalPosition( mMapAvatars.get(i), origin_global ); const F32 distance = dist_vec( pos_global, relative_to ); if( distance <= radius ) { avatar_ids.push_back( mMapAvatarIDs.get(i) ); } } }
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); } } } } }
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); } } } } }