void LLWorld::updateVisibilities() { F32 cur_far_clip = LLViewerCamera::getInstance()->getFar(); // Go through the culled list and check for visible regions (region is visible if land is visible) for (region_list_t::iterator iter = mCulledRegionList.begin(); iter != mCulledRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN); if (part) { LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1])) { mCulledRegionList.erase(curiter); mVisibleRegionList.push_back(regionp); } } } // Update all of the visible regions for (region_list_t::iterator iter = mVisibleRegionList.begin(); iter != mVisibleRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; if (!regionp->getLand().hasZData()) { continue; } LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN); if (part) { LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1])) { regionp->calculateCameraDistance(); if (!gNoRender) { regionp->getLand().updatePatchVisibilities(gAgent); } } else { mVisibleRegionList.erase(curiter); mCulledRegionList.push_back(regionp); } } } // Sort visible regions mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); LLViewerCamera::getInstance()->setFar(cur_far_clip); }
// Draw the area that will be affected. void LLToolBrushLand::render() { if(mGotHover) { //llinfos << "LLToolBrushLand::render()" << llendl; LLVector3d spot; if(gViewerWindow->mousePointOnLandGlobal(mMouseX, mMouseY, &spot)) { spot.mdV[VX] = floor( spot.mdV[VX] + 0.5 ); spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 ); mBrushSize = gSavedSettings.getF32("LandBrushSize"); region_list_t regions; determineAffectedRegions(regions, spot); // Now, for each region, render the overlay LLVector3 pos_world = gAgent.getRegion()->getPosRegionFromGlobal(spot); for(region_list_t::iterator iter = regions.begin(); iter != regions.end(); ++iter) { LLViewerRegion* region = *iter; renderOverlay(region->getLand(), region->getPosRegionFromGlobal(spot), pos_world); } } mGotHover = FALSE; } }
F32 LLWorld::resolveLandHeightGlobal(const LLVector3d &pos_global) { LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global); if (regionp) { return regionp->getLand().resolveHeightGlobal(pos_global); } return 0.0f; }
LLVector3 LLWorld::resolveLandNormalGlobal(const LLVector3d &pos_global) { LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global); if (!regionp) { return LLVector3::z_axis; } return regionp->getLand().resolveNormalGlobal(pos_global); }
LLSurfacePatch * LLWorld::resolveLandPatchGlobal(const LLVector3d &pos_global) { // returns a pointer to the patch at this location LLViewerRegion *regionp = getRegionFromPosGlobal(pos_global); if (!regionp) { return NULL; } return regionp->getLand().resolvePatchGlobal(pos_global); }
void LLWorld::updateVisibilities() { F32 cur_far_clip = LLViewerCamera::getInstance()->getFar(); LLViewerCamera::getInstance()->setFar(mLandFarClip); F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; // Go through the culled list and check for visible regions for (region_list_t::iterator iter = mCulledRegionList.begin(); iter != mCulledRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (!regionp->getLand().hasZData() || LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) { mCulledRegionList.erase(curiter); mVisibleRegionList.push_back(regionp); } } // Update all of the visible regions for (region_list_t::iterator iter = mVisibleRegionList.begin(); iter != mVisibleRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; if (!regionp->getLand().hasZData()) { continue; } F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); F32 radius = 0.5f*fsqrtf(height * height + diagonal_squared); if (LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) { regionp->calculateCameraDistance(); if (!gNoRender) { regionp->getLand().updatePatchVisibilities(gAgent); } } else { mVisibleRegionList.erase(curiter); mCulledRegionList.push_back(regionp); } } // Sort visible regions mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); LLViewerCamera::getInstance()->setFar(cur_far_clip); }
BOOL LLToolBrushLand::handleMouseDown(S32 x, S32 y, MASK mask) { BOOL handled = FALSE; // Find the z value of the initial click. LLVector3d spot; if( gViewerWindow->mousePointOnLandGlobal( x, y, &spot ) ) { // Round to nearest X,Y grid spot.mdV[VX] = floor( spot.mdV[VX] + 0.5 ); spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 ); LLRegionPosition region_position( spot ); LLViewerRegion* regionp = region_position.getRegion(); if (!canTerraform(regionp)) { alertNoTerraform(regionp); return TRUE; } LLVector3 pos_region = region_position.getPositionRegion(); U32 grids = regionp->getLand().mGridsPerEdge; S32 i = llclamp( (S32)pos_region.mV[VX], 0, (S32)grids ); S32 j = llclamp( (S32)pos_region.mV[VY], 0, (S32)grids ); mStartingZ = regionp->getLand().getZ(i+j*grids); mMouseX = x; mMouseY = y; gIdleCallbacks.addFunction( &LLToolBrushLand::onIdle, (void*)this ); setMouseCapture( TRUE ); LLViewerParcelMgr::getInstance()->setSelectionVisible(FALSE); handled = TRUE; } return handled; }
void LLNetMap::draw() { static LLFrameTimer map_timer; if (mObjectImagep.isNull()) { createObjectImage(); } mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); F32 rotation = 0; // Prepare a scissor region { LLGLEnable scissor(GL_SCISSOR_TEST); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(getLocalRect()); glMatrixMode(GL_MODELVIEW); // Draw background rectangle if(isBackgroundVisible()) { gGL.color4fv(isBackgroundOpaque() ? getBackgroundColor().mV : getTransparentColor().mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); BOOL rotate_map = gSavedSettings.getBOOL( "MiniMapRotate" ); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); LLColor4 this_region_color = gColors.getColor( "NetMapThisRegion" ); LLColor4 live_region_color = gColors.getColor( "NetMapLiveRegion" ); LLColor4 dead_region_color = gColors.getColor( "NetMapDeadRegion" ); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; gGL.color4fv(regionp == gAgent.getRegion() ? this_region_color.mV : live_region_color.mV); if (!regionp->isAlive()) { gGL.color4fv(dead_region_color.mV); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLVector3d old_center = mObjectImageCenterGlobal; LLVector3d new_center = gAgent.getCameraPositionGlobal(); new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]); new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]); new_center.mdV[2] = 0.f; if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = FALSE; mObjectImageCenterGlobal = new_center; // Center moved enough. // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw buildings gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); map_center_agent -= gAgent.getCameraPositionAgent(); map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); LLVector3d pos_global; LLVector3 pos_map; // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist = F32_MAX; F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE; // Draw avatars LLColor4 avatar_color = gColors.getColor( "MapAvatar" ); LLColor4 friend_color = gColors.getColor( "MapFriend" ); std::vector<LLUUID> avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions); for(U32 i=0; i<avatar_ids.size(); i++) { // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. // just be careful to sort the avatar IDs along with the positions. -MG pos_map = globalPosToView(positions[i], rotate_map); LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], is_agent_friend(avatar_ids[i]) ? friend_color : avatar_color, pos_map.mV[VZ], mDotRadius); F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist) { closest_dist = dist_to_cursor; mClosestAgentToCursor = avatar_ids[i]; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), rotate_map, gTrackColor ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), rotate_map, gTrackColor ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), rotate_map, gTrackColor ); } } // Draw dot for self avatar position pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global, rotate_map); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; S32 dot_width = llround(mDotRadius * 2.f); you->draw( llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv(gColors.getColor("NetMapFrustum").mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv(gColors.getColor("NetMapFrustumRotating").mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); glRotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } // Rotation of 0 means that North is up setDirectionPos( getChild<LLTextBox>("e_label"), rotation); setDirectionPos( getChild<LLTextBox>("n_label"), rotation + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("w_label"), rotation + F_PI); setDirectionPos( getChild<LLTextBox>("s_label"), rotation + F_PI + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("ne_label"), rotation + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("nw_label"), rotation + F_PI_BY_TWO + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("sw_label"), rotation + F_PI + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("se_label"), rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); LLView::draw(); }
void LLNetMap::draw() { static LLFrameTimer map_timer; static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white); static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white); static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white); static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white); static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white); static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white); if (mObjectImagep.isNull()) { createObjectImage(); } mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); // Prepare a scissor region F32 rotation = 0; gGL.pushMatrix(); gGL.pushUIMatrix(); LLVector3 offset = gGL.getUITranslation(); LLVector3 scale = gGL.getUIScale(); glLoadIdentity(); gGL.loadUIIdentity(); glScalef(scale.mV[0], scale.mV[1], scale.mV[2]); gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); { LLLocalClipRect clip(getLocalRect()); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); glMatrixMode(GL_MODELVIEW); // Draw background rectangle LLColor4 background_color = mBackgroundColor.get(); gGL.color4fv( background_color.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; if (regionp == gAgent.getRegion()) { gGL.color4f(1.f, 1.f, 1.f, 1.f); } else { gGL.color4f(0.8f, 0.8f, 0.8f, 1.f); } if (!regionp->isAlive()) { gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLVector3d old_center = mObjectImageCenterGlobal; LLVector3d new_center = gAgent.getCameraPositionGlobal(); new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]); new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]); new_center.mdV[2] = 0.f; if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = FALSE; mObjectImageCenterGlobal = new_center; // Center moved enough. // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw buildings gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); map_center_agent -= gAgent.getCameraPositionAgent(); map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); LLVector3d pos_global; LLVector3 pos_map; // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; //localMouse(&local_mouse_x, &local_mouse_y); LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist = F32_MAX; F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE; // Draw avatars 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(); S32 i; LLVector3 pos_local; U32 compact_local; U8 bits; // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. // just be careful to sort the avatar IDs along with the positions. -MG for (i = 0; i < count; i++) { compact_local = regionp->mMapAvatars.get(i); bits = compact_local & 0xFF; pos_local.mV[VZ] = F32(bits) * 4.f; compact_local >>= 8; bits = compact_local & 0xFF; pos_local.mV[VY] = (F32)bits; compact_local >>= 8; bits = compact_local & 0xFF; pos_local.mV[VX] = (F32)bits; pos_global.setVec( pos_local ); pos_global += origin_global; pos_map = globalPosToView(pos_global); BOOL show_as_friend = FALSE; if( i < regionp->mMapAvatarIDs.count()) { show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(regionp->mMapAvatarIDs.get(i)) != NULL); } LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], show_as_friend ? map_avatar_friend_color : map_avatar_color, pos_map.mV[VZ], mDotRadius); F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist) { closest_dist = dist_to_cursor; mClosestAgentToCursor = regionp->mMapAvatarIDs.get(i); } } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), map_track_color ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), map_track_color ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), map_track_color ); } } // Draw dot for self avatar position pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; S32 dot_width = llround(mDotRadius * 2.f); you->draw(llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv((map_frustum_color()).mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv((map_frustum_rotating_color()).mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); glRotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } gGL.popMatrix(); gGL.popUIMatrix(); LLUICtrl::draw(); }
void LLToolBrushLand::modifyLandInSelectionGlobal() { if (LLViewerParcelMgr::getInstance()->selectionEmpty()) { return; } if (LLToolMgr::getInstance()->getCurrentTool() == LLToolSelectLand::getInstance()) { // selecting land, don't do anything return; } LLVector3d min; LLVector3d max; LLViewerParcelMgr::getInstance()->getSelection(min, max); S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); mLastAffectedRegions.clear(); determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], min.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], max.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], min.mdV[VY], 0)); determineAffectedRegions(mLastAffectedRegions, LLVector3d(max.mdV[VX], max.mdV[VY], 0)); LLRegionPosition mid_point_region((min + max) * 0.5); LLViewerRegion* center_region = mid_point_region.getRegion(); if (center_region) { LLVector3 pos_region = mid_point_region.getPositionRegion(); U32 grids = center_region->getLand().mGridsPerEdge; S32 i = llclamp( (S32)pos_region.mV[VX], 0, (S32)grids ); S32 j = llclamp( (S32)pos_region.mV[VY], 0, (S32)grids ); mStartingZ = center_region->getLand().getZ(i+j*grids); } else { mStartingZ = 0.f; } // Stop if our selection include a no-terraform region for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; if (!canTerraform(regionp)) { alertNoTerraform(regionp); return; } } for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; //BOOL is_changed = FALSE; LLVector3 min_region = regionp->getPosRegionFromGlobal(min); LLVector3 max_region = regionp->getPosRegionFromGlobal(max); min_region.clamp(0.f, regionp->getWidth()); max_region.clamp(0.f, regionp->getWidth()); F32 seconds = gSavedSettings.getF32("LandBrushForce"); LLSurface &land = regionp->getLand(); char action = E_LAND_LEVEL; switch (radioAction) { case 0: // // average toward mStartingZ action = E_LAND_LEVEL; seconds *= 0.25f; break; case 1: action = E_LAND_RAISE; seconds *= 0.25f; break; case 2: action = E_LAND_LOWER; seconds *= 0.25f; break; case 3: action = E_LAND_SMOOTH; seconds *= 5.0f; break; case 4: action = E_LAND_NOISE; seconds *= 0.5f; break; case 5: action = E_LAND_REVERT; seconds = 0.5f; break; default: //action = E_LAND_INVALID; //seconds = 0.0f; return; break; } // Don't send a message to the region if nothing changed. //if(!is_changed) continue; // Now to update the patch information so it will redraw correctly. LLSurfacePatch *patchp= land.resolvePatchRegion(min_region); if (patchp) { patchp->dirtyZ(); } // Also force the property lines to update, normals to recompute, etc. regionp->forceUpdate(); // tell the simulator what we've done LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ModifyLand); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ModifyBlock); msg->addU8Fast(_PREHASH_Action, (U8)action); msg->addU8Fast(_PREHASH_BrushSize, getBrushIndex()); msg->addF32Fast(_PREHASH_Seconds, seconds); msg->addF32Fast(_PREHASH_Height, mStartingZ); BOOL parcel_selected = LLViewerParcelMgr::getInstance()->getParcelSelection()->getWholeParcelSelected(); LLParcel* selected_parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); if (parcel_selected && selected_parcel) { msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, selected_parcel->getLocalID()); msg->addF32Fast(_PREHASH_West, min_region.mV[VX] ); msg->addF32Fast(_PREHASH_South, min_region.mV[VY] ); msg->addF32Fast(_PREHASH_East, max_region.mV[VX] ); msg->addF32Fast(_PREHASH_North, max_region.mV[VY] ); } else { msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, -1); msg->addF32Fast(_PREHASH_West, min_region.mV[VX] ); msg->addF32Fast(_PREHASH_South, min_region.mV[VY] ); msg->addF32Fast(_PREHASH_East, max_region.mV[VX] ); msg->addF32Fast(_PREHASH_North, max_region.mV[VY] ); } msg->nextBlock("ModifyBlockExtended"); msg->addF32("BrushSize", mBrushSize); msg->sendMessage(regionp->getHost()); } }
void LLToolBrushLand::modifyLandAtPointGlobal(const LLVector3d &pos_global, MASK mask) { S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); mLastAffectedRegions.clear(); determineAffectedRegions(mLastAffectedRegions, pos_global); for(region_list_t::iterator iter = mLastAffectedRegions.begin(); iter != mLastAffectedRegions.end(); ++iter) { LLViewerRegion* regionp = *iter; //BOOL is_changed = FALSE; LLVector3 pos_region = regionp->getPosRegionFromGlobal(pos_global); LLSurface &land = regionp->getLand(); char action = E_LAND_LEVEL; switch (radioAction) { case 0: // // average toward mStartingZ action = E_LAND_LEVEL; break; case 1: action = E_LAND_RAISE; break; case 2: action = E_LAND_LOWER; break; case 3: action = E_LAND_SMOOTH; break; case 4: action = E_LAND_NOISE; break; case 5: action = E_LAND_REVERT; break; default: action = E_LAND_INVALID; break; } // Don't send a message to the region if nothing changed. //if(!is_changed) continue; // Now to update the patch information so it will redraw correctly. LLSurfacePatch *patchp= land.resolvePatchRegion(pos_region); if (patchp) { patchp->dirtyZ(); } // Also force the property lines to update, normals to recompute, etc. regionp->forceUpdate(); // tell the simulator what we've done F32 seconds = (1.0f / gFPSClamped) * gSavedSettings.getF32("LandBrushForce"); F32 x_pos = (F32)pos_region.mV[VX]; F32 y_pos = (F32)pos_region.mV[VY]; LLMessageSystem* msg = gMessageSystem; msg->newMessageFast(_PREHASH_ModifyLand); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->nextBlockFast(_PREHASH_ModifyBlock); msg->addU8Fast(_PREHASH_Action, (U8)action); msg->addU8Fast(_PREHASH_BrushSize, getBrushIndex()); msg->addF32Fast(_PREHASH_Seconds, seconds); msg->addF32Fast(_PREHASH_Height, mStartingZ); msg->nextBlockFast(_PREHASH_ParcelData); msg->addS32Fast(_PREHASH_LocalID, -1); msg->addF32Fast(_PREHASH_West, x_pos ); msg->addF32Fast(_PREHASH_South, y_pos ); msg->addF32Fast(_PREHASH_East, x_pos ); msg->addF32Fast(_PREHASH_North, y_pos ); msg->nextBlock("ModifyBlockExtended"); msg->addF32("BrushSize", mBrushSize); msg->sendMessage(regionp->getHost()); } }
// There are three types of water objects: // Region water objects: the water in a region. // Hole water objects: water in the void but within current draw distance. // Edge water objects: the water outside the draw distance, up till the horizon. // // For example: // // -----------------------horizon------------------------- // | | | | // | Edge Water | | | // | | | | // | | | | // | | | | // | | | | // | | rwidth | | // | | <-----> | | // ------------------------------------------------------- // | |Hole |other| | | // | |Water|reg. | | | // | |-----------------| | // | |other|cur. |<--> | | // | |reg. | reg.| \__|_ draw distance | // | |-----------------| | // | | | |<--->| | // | | | | \__|_ range | // ------------------------------------------------------- // | |<----width------>|<--horizon ext.->| // | | | | // | | | | // | | | | // | | | | // | | | | // | | | | // | | | | // ------------------------------------------------------- // void LLWorld::updateWaterObjects() { if (!gAgent.getRegion()) { return; } if (mRegionList.empty()) { llwarns << "No regions!" << llendl; return; } LLViewerRegion const* regionp = gAgent.getRegion(); // Region width in meters. S32 const rwidth = (S32)regionp->getWidth(); // The distance we might see into the void // when standing on the edge of a region, in meters. S32 const draw_distance = llceil(mLandFarClip); // We can only have "holes" in the water (where there no region) if we // can have existing regions around it. Taking into account that this // code is only executed when we enter a region, and not when we walk // around in it, we (only) need to take into account regions that fall // within the draw_distance. // // Set 'range' to draw_distance, rounded up to the nearest multiple of rwidth. S32 const nsims = (draw_distance + rwidth - 1) / rwidth; S32 const range = nsims * rwidth; // Get South-West corner of current region. U32 region_x, region_y; from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); // The min. and max. coordinates of the South-West corners of the Hole water objects. S32 const min_x = (S32)region_x - range; S32 const min_y = (S32)region_y - range; S32 const max_x = (S32)region_x + rwidth-256 + range; S32 const max_y = (S32)region_y + rwidth-256 + range; // Attempt to determine a sensible water height for all the // Hole Water objects. // // It make little sense to try to guess what the best water // height should be when that isn't completely obvious: if it's // impossible to satisfy every region's water height without // getting a jump in the water height. // // In order to keep the reasoning simple, we assume something // logical as a group of connected regions, where the coastline // is at the outer edge. Anything more complex that would "break" // under such an assumption would probably break anyway (would // depend on terrain editing and existing mega prims, say, if // anything would make sense at all). // // So, what we do is find all connected regions within the // draw distance that border void, and then pick the lowest // water height of those (coast) regions. S32 const n = 2 * nsims + 1; S32 const origin = nsims + nsims * n; std::vector<F32> water_heights(n * n); std::vector<U8> checked(n * n, 0); // index = nx + ny * n + origin; U8 const region_bit = 1; U8 const hole_bit = 2; U8 const bordering_hole_bit = 4; U8 const bordering_edge_bit = 8; // Use the legacy waterheight for the Edge water in the case // that we don't find any Hole water at all. F32 water_height = DEFAULT_WATER_HEIGHT; int max_count = 0; LL_DEBUGS("WaterHeight") << "Current region: " << regionp->getName() << "; water height: " << regionp->getWaterHeight() << " m." << LL_ENDL; std::map<S32, int> water_height_counts; typedef std::queue<std::pair<S32, S32>, std::deque<std::pair<S32, S32> > > nxny_pairs_type; nxny_pairs_type nxny_pairs; nxny_pairs.push(nxny_pairs_type::value_type(0, 0)); water_heights[origin] = regionp->getWaterHeight(); checked[origin] = region_bit; // For debugging purposes. int number_of_connected_regions = 1; int uninitialized_regions = 0; int bordering_hole = 0; int bordering_edge = 0; while(!nxny_pairs.empty()) { S32 const nx = nxny_pairs.front().first; S32 const ny = nxny_pairs.front().second; LL_DEBUGS("WaterHeight") << "nx,ny = " << nx << "," << ny << LL_ENDL; S32 const index = nx + ny * n + origin; nxny_pairs.pop(); for (S32 dir = 0; dir < 4; ++dir) { S32 const cnx = nx + gDirAxes[dir][0]; S32 const cny = ny + gDirAxes[dir][1]; LL_DEBUGS("WaterHeight") << "dir = " << dir << "; cnx,cny = " << cnx << "," << cny << LL_ENDL; S32 const cindex = cnx + cny * n + origin; bool is_hole = false; bool is_edge = false; LLViewerRegion* new_region_found = NULL; if (cnx < -nsims || cnx > nsims || cny < -nsims || cny > nsims) { LL_DEBUGS("WaterHeight") << " Edge Water!" << LL_ENDL; // Bumped into Edge water object. is_edge = true; } else if (checked[cindex]) { LL_DEBUGS("WaterHeight") << " Already checked before!" << LL_ENDL; // Already checked. is_hole = (checked[cindex] & hole_bit); } else { S32 x = (S32)region_x + cnx * rwidth; S32 y = (S32)region_y + cny * rwidth; U64 region_handle = to_region_handle(x, y); new_region_found = getRegionFromHandle(region_handle); is_hole = !new_region_found; checked[cindex] = is_hole ? hole_bit : region_bit; } if (is_hole) { // This was a region that borders at least one 'hole'. // Count the found coastline. F32 new_water_height = water_heights[index]; LL_DEBUGS("WaterHeight") << " This is void; counting coastline with water height of " << new_water_height << LL_ENDL; S32 new_water_height_cm = llround(new_water_height * 100); int count = (water_height_counts[new_water_height_cm] += 1); // Just use the lowest water height: this is mainly about the horizon water, // and whatever we do, we don't want it to be possible to look under the water // when looking in the distance: it is better to make a step downwards in water // height when going away from the avie than a step upwards. However, since // everyone is used to DEFAULT_WATER_HEIGHT, don't allow a single region // to drag the water level below DEFAULT_WATER_HEIGHT on it's own. if (bordering_hole == 0 || // First time we get here. (new_water_height >= DEFAULT_WATER_HEIGHT && new_water_height < water_height) || (new_water_height < DEFAULT_WATER_HEIGHT && count > max_count) ) { water_height = new_water_height; } if (count > max_count) { max_count = count; } if (!(checked[index] & bordering_hole_bit)) { checked[index] |= bordering_hole_bit; ++bordering_hole; } } else if (is_edge && !(checked[index] & bordering_edge_bit)) { checked[index] |= bordering_edge_bit; ++bordering_edge; } if (!new_region_found) { // Dead end, there is no region here. continue; } // Found a new connected region. ++number_of_connected_regions; if (new_region_found->getName().empty()) { // Uninitialized LLViewerRegion, don't use it's water height. LL_DEBUGS("WaterHeight") << " Uninitialized region." << LL_ENDL; ++uninitialized_regions; continue; } nxny_pairs.push(nxny_pairs_type::value_type(cnx, cny)); water_heights[cindex] = new_region_found->getWaterHeight(); LL_DEBUGS("WaterHeight") << " Found a new region (name: " << new_region_found->getName() << "; water height: " << water_heights[cindex] << " m)!" << LL_ENDL; } } llinfos << "Number of connected regions: " << number_of_connected_regions << " (" << uninitialized_regions << " uninitialized); number of regions bordering Hole water: " << bordering_hole << "; number of regions bordering Edge water: " << bordering_edge << llendl; llinfos << "Coastline count (height, count): "; bool first = true; for (std::map<S32, int>::iterator iter = water_height_counts.begin(); iter != water_height_counts.end(); ++iter) { if (!first) llcont << ", "; llcont << "(" << (iter->first / 100.f) << ", " << iter->second << ")"; first = false; } llcont << llendl; llinfos << "Water height used for Hole and Edge water objects: " << water_height << llendl; // Update all Region water objects. for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter) { LLViewerRegion* regionp = *iter; LLVOWater* waterp = regionp->getLand().getWaterObj(); if (waterp) { gObjectList.updateActive(waterp); } } // Clean up all existing Hole water objects. for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin(); iter != mHoleWaterObjects.end(); ++iter) { LLVOWater* waterp = *iter; gObjectList.killObject(waterp); } mHoleWaterObjects.clear(); // Let the Edge and Hole water boxes be 1024 meter high so that they // are never too small to be drawn (A LL_VO_*_WATER box has water // rendered on it's bottom surface only), and put their bottom at // the current regions water height. F32 const box_height = 1024; F32 const water_center_z = water_height + box_height / 2; const S32 step = 256; // Create new Hole water objects within 'range' where there is no region. for (S32 x = min_x; x <= max_x; x += step) { for (S32 y = min_y; y <= max_y; y += step) { U64 region_handle = to_region_handle(x, y); if (!getRegionFromHandle(region_handle)) { LLVOWater* waterp = (LLVOWater*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp->setUseTexture(FALSE); waterp->setPositionGlobal(LLVector3d(x + step / 2, y + step / 2, water_center_z)); waterp->setScale(LLVector3((F32)step, (F32)step, box_height)); gPipeline.createObject(waterp); mHoleWaterObjects.push_back(waterp); } } } // Center of the region. S32 const center_x = region_x + step / 2; S32 const center_y = region_y + step / 2; // Width of the area with Hole water objects. S32 const width = step + 2 * range; S32 const horizon_extend = 2048 + 512 - range; // Legacy value. // The overlap is needed to get rid of sky pixels being visible between the // Edge and Hole water object at greater distances (due to floating point // round off errors). S32 const edge_hole_overlap = 1; // Twice the actual overlap. for (S32 dir = 0; dir < 8; ++dir) { // Size of the Edge water objects. S32 const dim_x = (gDirAxes[dir][0] == 0) ? width : (horizon_extend + edge_hole_overlap); S32 const dim_y = (gDirAxes[dir][1] == 0) ? width : (horizon_extend + edge_hole_overlap); // And their position. S32 const water_center_x = center_x + (width + horizon_extend) / 2 * gDirAxes[dir][0]; S32 const water_center_y = center_y + (width + horizon_extend) / 2 * gDirAxes[dir][1]; LLVOWater* waterp = mEdgeWaterObjects[dir]; if (!waterp || waterp->isDead()) { // The edge water objects can be dead because they're attached to the region that the // agent was in when they were originally created. mEdgeWaterObjects[dir] = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp = mEdgeWaterObjects[dir]; waterp->setUseTexture(FALSE); waterp->setIsEdgePatch(TRUE); // Mark that this is edge water and not hole water. gPipeline.createObject(waterp); } waterp->setRegion(gAgent.getRegion()); LLVector3d water_pos(water_center_x, water_center_y, water_center_z); LLVector3 water_scale((F32) dim_x, (F32) dim_y, box_height); waterp->setPositionGlobal(water_pos); waterp->setScale(water_scale); gObjectList.updateActive(waterp); } }
void LLNetMap::draw() { static LLFrameTimer map_timer; if (mObjectImagep.isNull()) { createObjectImage(); } mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); // Prepare a scissor region F32 rotation = 0; { LLGLEnable scissor(GL_SCISSOR_TEST); { LLGLSNoTexture no_texture; LLLocalClipRect clip(getLocalRect()); glMatrixMode(GL_MODELVIEW); // Draw background rectangle gGL.color4fv( mBackgroundColor.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); if( LLNetMap::sRotateMap ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin(); iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * gMiniMapScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * gMiniMapScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + gMiniMapScale ; F32 right = left + gMiniMapScale ; if (regionp == gAgent.getRegion()) { gGL.color4f(1.f, 1.f, 1.f, 1.f); } else { gGL.color4f(0.8f, 0.8f, 0.8f, 1.f); } if (!regionp->isAlive()) { gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } // Draw using texture. LLViewerImage::bindTexture(regionp->getLand().getSTexture()); gGL.begin(LLVertexBuffer::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { LLViewerImage::bindTexture(regionp->getLand().getWaterTexture()); gGL.begin(LLVertexBuffer::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } LLVector3d old_center = mObjectImageCenterGlobal; LLVector3d new_center = gAgent.getCameraPositionGlobal(); new_center.mdV[0] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[0]); new_center.mdV[1] = (5.f/mObjectMapTPM)*floor(0.2f*mObjectMapTPM*new_center.mdV[1]); new_center.mdV[2] = 0.f; if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = FALSE; mObjectImageCenterGlobal = new_center; // Center moved enough. // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw buildings gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); map_center_agent -= gAgent.getCameraPositionAgent(); map_center_agent.mV[VX] *= gMiniMapScale/region_width; map_center_agent.mV[VY] *= gMiniMapScale/region_width; LLViewerImage::bindTexture(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLVertexBuffer::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); LLVector3d pos_global; LLVector3 pos_map; // Draw avatars for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin(); iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter) { LLViewerRegion* regionp = *iter; const LLVector3d& origin_global = regionp->getOriginGlobal(); S32 count = regionp->mMapAvatars.count(); S32 i; LLVector3 pos_local; U32 compact_local; U8 bits; // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. // just be careful to sort the avatar IDs along with the positions. -MG for (i = 0; i < count; i++) { compact_local = regionp->mMapAvatars.get(i); bits = compact_local & 0xFF; pos_local.mV[VZ] = F32(bits) * 4.f; compact_local >>= 8; bits = compact_local & 0xFF; pos_local.mV[VY] = (F32)bits; compact_local >>= 8; bits = compact_local & 0xFF; pos_local.mV[VX] = (F32)bits; pos_global.setVec( pos_local ); pos_global += origin_global; pos_map = globalPosToView(pos_global); BOOL show_as_friend = FALSE; if( i < regionp->mMapAvatarIDs.count()) { show_as_friend = is_agent_friend(regionp->mMapAvatarIDs.get(i)); } LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], show_as_friend ? gFriendMapColor : gAvatarMapColor, pos_map.mV[VZ]); } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), gTrackColor ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), gTrackColor ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), gTrackColor ); } } // Draw dot for self avatar position pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global); LLUIImagePtr you = LLWorldMapView::sAvatarYouSmallImage; you->draw( llround(pos_map.mV[VX]) - you->getWidth()/2, llround(pos_map.mV[VY]) - you->getHeight()/2); // Draw frustum F32 meters_to_pixels = gMiniMapScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; LLGLSNoTexture no_texture; if( LLNetMap::sRotateMap ) { gGL.color4fv(gFrustumMapColor.mV); gGL.begin( LLVertexBuffer::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv(gRotatingFrustumMapColor.mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); glRotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLVertexBuffer::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } // Rotation of 0 means that North is up setDirectionPos( mTextBoxEast, rotation ); setDirectionPos( mTextBoxNorth, rotation + F_PI_BY_TWO ); setDirectionPos( mTextBoxWest, rotation + F_PI ); setDirectionPos( mTextBoxSouth, rotation + F_PI + F_PI_BY_TWO ); setDirectionPos( mTextBoxNorthEast, rotation + F_PI_BY_TWO / 2); setDirectionPos( mTextBoxNorthWest, rotation + F_PI_BY_TWO + F_PI_BY_TWO / 2); setDirectionPos( mTextBoxSouthWest, rotation + F_PI + F_PI_BY_TWO / 2); setDirectionPos( mTextBoxSouthEast, rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); LLUICtrl::draw(); }
void LLWorld::updateVisibilities() { F32 cur_far_clip = LLViewerCamera::getInstance()->getFar(); //-------------------------voodoo-------------------------- //LLViewerCamera::getInstance()->setFar(mLandFarClip); //F32 diagonal_squared = F_SQRT2 * F_SQRT2 * mWidth * mWidth; //------------------------------------------------------------- // Go through the culled list and check for visible regions for (region_list_t::iterator iter = mCulledRegionList.begin(); iter != mCulledRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN); if (part) //-------------------------Voodoo------------------------------------- //F32 height = regionp->getLand().getMaxZ() - regionp->getLand().getMinZ(); //F32 radius = 0.5f * (F32) sqrt(height * height + diagonal_squared); //if (!regionp->getLand().hasZData() // || LLViewerCamera::getInstance()->sphereInFrustum(regionp->getCenterAgent(), radius)) //--------------------------------------------------------------------- { LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1])) { mCulledRegionList.erase(curiter); mVisibleRegionList.push_back(regionp); } } } // Update all of the visible regions for (region_list_t::iterator iter = mVisibleRegionList.begin(); iter != mVisibleRegionList.end(); ) { region_list_t::iterator curiter = iter++; LLViewerRegion* regionp = *curiter; if (!regionp->getLand().hasZData()) { continue; } LLSpatialPartition* part = regionp->getSpatialPartition(LLViewerRegion::PARTITION_TERRAIN); if (part) { LLSpatialGroup* group = (LLSpatialGroup*) part->mOctree->getListener(0); if (LLViewerCamera::getInstance()->AABBInFrustum(group->mBounds[0], group->mBounds[1])) { regionp->calculateCameraDistance(); if (!gNoRender) { regionp->getLand().updatePatchVisibilities(gAgent); } } else { mVisibleRegionList.erase(curiter); mCulledRegionList.push_back(regionp); } } } // Sort visible regions mVisibleRegionList.sort(LLViewerRegion::CompareDistance()); LLViewerCamera::getInstance()->setFar(cur_far_clip); }
void LLNetMap::draw() { // Ansariel: Synchronize netmap scale throughout instances if (mScale != sScale) { setScale(sScale); } static LLFrameTimer map_timer; static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white); static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white); static LLUIColor map_avatar_linden_color = LLUIColorTable::instance().getColor("MapAvatarLindenColor", LLColor4::blue); static LLUIColor map_avatar_muted_color = LLUIColorTable::instance().getColor("MapAvatarMutedColor", LLColor4::grey3); static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white); static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white); static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white); static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white); static LLUIColor map_chat_ring_color = LLUIColorTable::instance().getColor("MapChatRingColor", LLColor4::yellow); static LLUIColor map_shout_ring_color = LLUIColorTable::instance().getColor("MapShoutRingColor", LLColor4::red); if (mObjectImagep.isNull()) { createObjectImage(); } static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); if (auto_center) { mCurPan = lerp(mCurPan, mTargetPan, LLCriticalDamp::getInterpolant(0.1f)); } // Prepare a scissor region F32 rotation = 0; gGL.pushMatrix(); gGL.pushUIMatrix(); LLVector3 offset = gGL.getUITranslation(); LLVector3 scale = gGL.getUIScale(); gGL.loadIdentity(); gGL.loadUIIdentity(); gGL.scalef(scale.mV[0], scale.mV[1], scale.mV[2]); gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); { LLLocalClipRect clip(getLocalRect()); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.matrixMode(LLRender::MM_MODELVIEW); // Draw background rectangle LLColor4 background_color = mBackgroundColor.get(); gGL.color4fv( background_color.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPan.mV[VX]); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPan.mV[VY]); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); gGL.rotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; if (regionp == gAgent.getRegion()) { gGL.color4f(1.f, 1.f, 1.f, 1.f); } else { gGL.color4f(0.8f, 0.8f, 0.8f, 1.f); } if (!regionp->isAlive()) { gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } // Redraw object layer periodically if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = false; // Locate the centre of the object layer, accounting for panning LLVector3 new_center = globalPosToView(gAgentCamera.getCameraPositionGlobal()); new_center.mV[VX] -= mCurPan.mV[VX]; new_center.mV[VY] -= mCurPan.mV[VY]; new_center.mV[VZ] = 0.f; mObjectImageCenterGlobal = viewPosToGlobal(llfloor(new_center.mV[VX]), llfloor(new_center.mV[VY])); // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw objects gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); LLVector3 camera_position = gAgentCamera.getCameraPositionAgent(); map_center_agent -= camera_position; map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; //localMouse(&local_mouse_x, &local_mouse_y); LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist_squared = F32_MAX; // value will be overridden in the loop F32 min_pick_dist_squared = (mDotRadius * MIN_PICK_SCALE) * (mDotRadius * MIN_PICK_SCALE); LLVector3 pos_map; uuid_vec_t avatar_ids; std::vector<LLVector3d> positions; bool unknown_relative_z; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgentCamera.getCameraPositionGlobal()); // Draw avatars for (U32 i = 0; i < avatar_ids.size(); i++) { pos_map = globalPosToView(positions[i]); LLUUID uuid = avatar_ids[i]; bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL); LLColor4 color = show_as_friend ? map_avatar_friend_color : map_avatar_color; // <FS:Ansariel> Check for unknown Z-offset => AVATAR_UNKNOWN_Z_OFFSET //unknown_relative_z = positions[i].mdV[VZ] == COARSEUPDATE_MAX_Z && // camera_position.mV[VZ] >= COARSEUPDATE_MAX_Z; unknown_relative_z = false; if (positions[i].mdV[VZ] == AVATAR_UNKNOWN_Z_OFFSET) { if (camera_position.mV[VZ] >= COARSEUPDATE_MAX_Z) { // No exact data and cam >=1020 => we don't know if // other avatar is above or below us => unknown unknown_relative_z = true; } else { // No exact data but cam is below 1020 => other avatar // is definitely above us => bump Z-offset to F32_MAX // so we get the up chevron pos_map.mV[VZ] = F32_MAX; } } // </FS:Ansariel> // Colorize muted avatars and Lindens std::string fullName; LLMuteList* muteListInstance = LLMuteList::getInstance(); if (muteListInstance->isMuted(uuid)) color = map_avatar_muted_color; else if (gCacheName->getFullName(uuid, fullName) && muteListInstance->isLinden(fullName)) color = map_avatar_linden_color; // Mark Avatars with special colors - Ansariel if (LLNetMap::sAvatarMarksMap.find(uuid) != LLNetMap::sAvatarMarksMap.end()) { color = LLNetMap::sAvatarMarksMap[uuid]; } //color based on contact sets prefs if(LGGContactSets::getInstance()->hasFriendColorThatShouldShow(uuid,FALSE,FALSE,FALSE,TRUE)) { color = LGGContactSets::getInstance()->getFriendColor(uuid); } // [RLVa:KB] - Checked: 2010-04-19 (RLVa-1.2.0f) | Modified: RLVa-1.2.0f | FS-Specific LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], ((!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? color : map_avatar_color.get()), pos_map.mV[VZ], mDotRadius, unknown_relative_z); // [/RLVa:KB] // LLWorldMapView::drawAvatar( // pos_map.mV[VX], pos_map.mV[VY], // color, // pos_map.mV[VZ], mDotRadius, // unknown_relative_z); if(uuid.notNull()) { bool selected = false; uuid_vec_t::iterator sel_iter = gmSelected.begin(); for (; sel_iter != gmSelected.end(); sel_iter++) { if(*sel_iter == uuid) { selected = true; break; } } if(selected) { if( (pos_map.mV[VX] < 0) || (pos_map.mV[VY] < 0) || (pos_map.mV[VX] >= getRect().getWidth()) || (pos_map.mV[VY] >= getRect().getHeight()) ) { S32 x = llround( pos_map.mV[VX] ); S32 y = llround( pos_map.mV[VY] ); LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10); } else { LLWorldMapView::drawTrackingDot(pos_map.mV[VX],pos_map.mV[VY],color,0.f); } } } F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { closest_dist_squared = dist_to_cursor_squared; mClosestAgentToCursor = uuid; mClosestAgentPosition = positions[i]; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), map_track_color ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), map_track_color ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), map_track_color ); } } // Draw dot for self avatar position LLVector3d pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global); S32 dot_width = llround(mDotRadius * 2.f); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; if (you) { you->draw(llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { mClosestAgentToCursor = gAgent.getID(); mClosestAgentPosition = pos_global; } // Draw chat range ring(s) static LLUICachedControl<bool> chat_ring("MiniMapChatRing", true); if(chat_ring) { drawRing(LLWorld::getInstance()->getSayDistance(), pos_map, map_chat_ring_color); drawRing(LLWorld::getInstance()->getShoutDistance(), pos_map, map_shout_ring_color); } } // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv((map_frustum_color()).mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv((map_frustum_rotating_color()).mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); gGL.rotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } gGL.popMatrix(); gGL.popUIMatrix(); LLUICtrl::draw(); }
// Takes a line defined by "point_a" and "point_b" and determines the closest (to point_a) // point where the the line intersects an object or the land surface. Stores the results // in "intersection" and "intersection_normal" and returns a scalar value that represents // the normalized distance along the line from "point_a" to "intersection". // // Currently assumes point_a and point_b only differ in z-direction, // but it may eventually become more general. F32 LLWorld::resolveStepHeightGlobal(const LLVOAvatar* avatarp, const LLVector3d &point_a, const LLVector3d &point_b, LLVector3d &intersection, LLVector3 &intersection_normal, LLViewerObject **viewerObjectPtr) { // initialize return value to null if (viewerObjectPtr) { *viewerObjectPtr = NULL; } LLViewerRegion *regionp = getRegionFromPosGlobal(point_a); if (!regionp) { // We're outside the world intersection = 0.5f * (point_a + point_b); intersection_normal.setVec(0.0f, 0.0f, 1.0f); return 0.5f; } // calculate the length of the segment F32 segment_length = (F32)((point_a - point_b).length()); if (0.0f == segment_length) { intersection = point_a; intersection_normal.setVec(0.0f, 0.0f, 1.0f); return segment_length; } // get land height // Note: we assume that the line is parallel to z-axis here LLVector3d land_intersection = point_a; F32 normalized_land_distance; land_intersection.mdV[VZ] = regionp->getLand().resolveHeightGlobal(point_a); normalized_land_distance = (F32)(point_a.mdV[VZ] - land_intersection.mdV[VZ]) / segment_length; intersection = land_intersection; intersection_normal = resolveLandNormalGlobal(land_intersection); if (avatarp && !avatarp->mFootPlane.isExactlyClear()) { LLVector3 foot_plane_normal(avatarp->mFootPlane.mV); LLVector3 start_pt = avatarp->getRegion()->getPosRegionFromGlobal(point_a); // added 0.05 meters to compensate for error in foot plane reported by Havok F32 norm_dist_from_plane = ((start_pt * foot_plane_normal) - avatarp->mFootPlane.mV[VW]) + 0.05f; norm_dist_from_plane = llclamp(norm_dist_from_plane / segment_length, 0.f, 1.f); if (norm_dist_from_plane < normalized_land_distance) { // collided with object before land normalized_land_distance = norm_dist_from_plane; intersection = point_a; intersection.mdV[VZ] -= norm_dist_from_plane * segment_length; intersection_normal = foot_plane_normal; } else { intersection = land_intersection; intersection_normal = resolveLandNormalGlobal(land_intersection); } } return normalized_land_distance; }
void LLNetMap::draw() { static LLFrameTimer map_timer; static LLUIColor map_avatar_color = LLUIColorTable::instance().getColor("MapAvatarColor", LLColor4::white); static LLUIColor map_avatar_friend_color = LLUIColorTable::instance().getColor("MapAvatarFriendColor", LLColor4::white); static LLUIColor map_track_color = LLUIColorTable::instance().getColor("MapTrackColor", LLColor4::white); //static LLUIColor map_track_disabled_color = LLUIColorTable::instance().getColor("MapTrackDisabledColor", LLColor4::white); static LLUIColor map_frustum_color = LLUIColorTable::instance().getColor("MapFrustumColor", LLColor4::white); static LLUIColor map_frustum_rotating_color = LLUIColorTable::instance().getColor("MapFrustumRotatingColor", LLColor4::white); if (mObjectImagep.isNull()) { createObjectImage(); } static LLUICachedControl<bool> auto_center("MiniMapAutoCenter", true); if (auto_center) { mCurPan = lerp(mCurPan, mTargetPan, LLSmoothInterpolation::getInterpolant(0.1f)); } // Prepare a scissor region F32 rotation = 0; gGL.pushMatrix(); gGL.pushUIMatrix(); LLVector3 offset = gGL.getUITranslation(); LLVector3 scale = gGL.getUIScale(); gGL.loadIdentity(); gGL.loadUIIdentity(); gGL.scalef(scale.mV[0], scale.mV[1], scale.mV[2]); gGL.translatef(offset.mV[0], offset.mV[1], offset.mV[2]); { LLLocalClipRect clip(getLocalRect()); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); gGL.matrixMode(LLRender::MM_MODELVIEW); // Draw background rectangle LLColor4 background_color = mBackgroundColor.get(); gGL.color4fv( background_color.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPan.mV[VX]); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPan.mV[VY]); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); static LLUICachedControl<bool> rotate_map("MiniMapRotate", true); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); gGL.rotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = ll_round(LLWorld::getInstance()->getRegionWidthInMeters()); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; if (regionp == gAgent.getRegion()) { gGL.color4f(1.f, 1.f, 1.f, 1.f); } else { gGL.color4f(0.8f, 0.8f, 0.8f, 1.f); } if (!regionp->isAlive()) { gGL.color4f(1.f, 0.5f, 0.5f, 1.f); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } // Redraw object layer periodically if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = false; // Locate the centre of the object layer, accounting for panning LLVector3 new_center = globalPosToView(gAgentCamera.getCameraPositionGlobal()); new_center.mV[VX] -= mCurPan.mV[VX]; new_center.mV[VY] -= mCurPan.mV[VY]; new_center.mV[VZ] = 0.f; mObjectImageCenterGlobal = viewPosToGlobal(llfloor(new_center.mV[VX]), llfloor(new_center.mV[VY])); // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw objects gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); LLVector3 camera_position = gAgentCamera.getCameraPositionAgent(); map_center_agent -= camera_position; map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; //localMouse(&local_mouse_x, &local_mouse_y); LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist_squared = F32_MAX; // value will be overridden in the loop F32 min_pick_dist_squared = (mDotRadius * MIN_PICK_SCALE) * (mDotRadius * MIN_PICK_SCALE); LLVector3 pos_map; uuid_vec_t avatar_ids; std::vector<LLVector3d> positions; bool unknown_relative_z; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, gAgentCamera.getCameraPositionGlobal()); // Draw avatars for (U32 i = 0; i < avatar_ids.size(); i++) { LLUUID uuid = avatar_ids[i]; // Skip self, we'll draw it later if (uuid == gAgent.getID()) continue; pos_map = globalPosToView(positions[i]); bool show_as_friend = (LLAvatarTracker::instance().getBuddyInfo(uuid) != NULL); LLColor4 color = show_as_friend ? map_avatar_friend_color : map_avatar_color; unknown_relative_z = positions[i].mdV[VZ] == COARSEUPDATE_MAX_Z && camera_position.mV[VZ] >= COARSEUPDATE_MAX_Z; LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], color, pos_map.mV[VZ], mDotRadius, unknown_relative_z); if(uuid.notNull()) { bool selected = false; uuid_vec_t::iterator sel_iter = gmSelected.begin(); for (; sel_iter != gmSelected.end(); sel_iter++) { if(*sel_iter == uuid) { selected = true; break; } } if(selected) { if( (pos_map.mV[VX] < 0) || (pos_map.mV[VY] < 0) || (pos_map.mV[VX] >= getRect().getWidth()) || (pos_map.mV[VY] >= getRect().getHeight()) ) { S32 x = ll_round( pos_map.mV[VX] ); S32 y = ll_round( pos_map.mV[VY] ); LLWorldMapView::drawTrackingCircle( getRect(), x, y, color, 1, 10); } else { LLWorldMapView::drawTrackingDot(pos_map.mV[VX],pos_map.mV[VY],color,0.f); } } } F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { closest_dist_squared = dist_to_cursor_squared; mClosestAgentToCursor = uuid; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), map_track_color ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), map_track_color ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), map_track_color ); } } // Draw dot for self avatar position LLVector3d pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global); S32 dot_width = ll_round(mDotRadius * 2.f); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; if (you) { you->draw(ll_round(pos_map.mV[VX] - mDotRadius), ll_round(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); F32 dist_to_cursor_squared = dist_vec_squared(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor_squared < min_pick_dist_squared && dist_to_cursor_squared < closest_dist_squared) { mClosestAgentToCursor = gAgent.getID(); } } // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv((map_frustum_color()).mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv((map_frustum_rotating_color()).mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); gGL.rotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } gGL.popMatrix(); gGL.popUIMatrix(); LLUICtrl::draw(); }
void LLNetMap::draw() { static LLFrameTimer map_timer; if (mObjectImagep.isNull()) { createObjectImage(); } if (gSavedSettings.getS32( "MiniMapCenter") != MAP_CENTER_NONE) { mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); } F32 rotation = 0; // Prepare a scissor region { LLGLEnable scissor(GL_SCISSOR_TEST); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(getLocalRect()); gGL.matrixMode(LLRender::MM_MODELVIEW); // Draw background rectangle if(isBackgroundVisible()) { LLColor4 background_color = isBackgroundOpaque() ? getBackgroundColor().mV : getTransparentColor().mV; gGL.color4fv( background_color.mV ); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); static LLCachedControl<bool> rotate_map("MiniMapRotate", true); if (rotate_map) { // rotate subsequent draws to agent rotation rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); gGL.rotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is LLColor4 this_region_color = gColors.getColor( "NetMapThisRegion" ); LLColor4 live_region_color = gColors.getColor( "NetMapLiveRegion" ); LLColor4 dead_region_color = gColors.getColor( "NetMapDeadRegion" ); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; S32 region_width = llround(regionp->getWidth()); // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgentCamera.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; gGL.color4fv(regionp == gAgent.getRegion() ? this_region_color.mV : live_region_color.mV); if (!regionp->isAlive()) { gGL.color4fv(dead_region_color.mV); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } // Redraw object layer periodically if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = false; // Locate the centre of the object layer, accounting for panning LLVector3 new_center = globalPosToView(gAgentCamera.getCameraPositionGlobal(), rotate_map); new_center.mV[VX] -= mCurPanX; new_center.mV[VY] -= mCurPanY; new_center.mV[VZ] = 0.f; mObjectImageCenterGlobal = viewPosToGlobal(llround(new_center.mV[VX]), llround(new_center.mV[VY]), rotate_map); // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw buildings gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); map_center_agent -= gAgentCamera.getCameraPositionAgent(); map_center_agent.mV[0] *= mScale/LLWorld::getInstance()->getRegionWidthInMeters(); map_center_agent.mV[1] *= mScale/LLWorld::getInstance()->getRegionWidthInMeters(); gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); LLVector3d pos_global; LLVector3 pos_map; // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; LLUI::getMousePositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist = F32_MAX; F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE; // Draw avatars // LLColor4 mapcolor = gAvatarMapColor; static const LLCachedControl<LLColor4> standard_color(gColors,"MapAvatar",LLColor4(0.f,1.f,0.f,1.f)); static const LLCachedControl<LLColor4> friend_color_stored("AscentFriendColor",LLColor4(1.f,1.f,0.f,1.f)); static const LLCachedControl<LLColor4> em_color("AscentEstateOwnerColor",LLColor4(1.f,0.6f,1.f,1.f)); static const LLCachedControl<LLColor4> linden_color("AscentLindenColor",LLColor4(0.f,0.f,1.f,1.f)); static const LLCachedControl<LLColor4> muted_color("AscentMutedColor",LLColor4(0.7f,0.7f,0.7f,1.f)); // Draw avatars // [RLVa:KB] - Version: 1.23.4 | Alternate: Snowglobe-1.2.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b LLColor4 friend_color = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? friend_color_stored : standard_color; // [/RLVa:KB] std::vector<LLUUID> avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions); for(U32 i=0; i<avatar_ids.size(); i++) { LLColor4 avColor = standard_color; // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. // just be careful to sort the avatar IDs along with the positions. -MG pos_map = globalPosToView(positions[i], rotate_map); if (positions[i].mdV[VZ] == 0.f) { pos_map.mV[VZ] = 16000.f; } std::string avName; gCacheName->getFullName(avatar_ids[i], avName); if(LLMuteList::getInstance()->isMuted(avatar_ids[i])) { avColor = muted_color; } LLViewerRegion* avatar_region = LLWorld::getInstance()->getRegionFromPosGlobal(positions[i]); LLUUID estate_owner = avatar_region? avatar_region->getOwner() : LLUUID::null; // MOYMOD Minimap custom av colors. boost::unordered_map<const LLUUID,LLColor4>::const_iterator it = mm_MarkerColors.find(avatar_ids[i]); if(it != mm_MarkerColors.end()) { avColor = it->second; } //Lindens are always more Linden than your friend, make that take precedence else if(LLMuteList::getInstance()->isLinden(avName)) { avColor = linden_color; } //check if they are an estate owner at their current position else if(estate_owner.notNull() && avatar_ids[i] == estate_owner) { avColor = em_color; } //without these dots, SL would suck. else if(is_agent_friend(avatar_ids[i])) { avColor = friend_color; } LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], avColor, pos_map.mV[VZ], mDotRadius); F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist) { closest_dist = dist_to_cursor; mClosestAgentToCursor = avatar_ids[i]; mClosestAgentPosition = positions[i]; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking(gAgent.getAutoPilotTargetGlobal(), rotate_map, gTrackColor); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking(LLAvatarTracker::instance().getGlobalPos(), rotate_map, gTrackColor); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking(LLTracker::getTrackedPositionGlobal(), rotate_map, gTrackColor); } } // Draw dot for self avatar position pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global, rotate_map); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; S32 dot_width = llround(mDotRadius * 2.f); you->draw( llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = LLViewerCamera::getInstance()->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if (rotate_map) { gGL.color4fv(gColors.getColor("NetMapFrustum").mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv(gColors.getColor("NetMapFrustumRotating").mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); gGL.rotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } // Rotation of 0 means that North is up setDirectionPos( getChild<LLTextBox>("e_label"), rotation); setDirectionPos( getChild<LLTextBox>("n_label"), rotation + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("w_label"), rotation + F_PI); setDirectionPos( getChild<LLTextBox>("s_label"), rotation + F_PI + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("ne_label"), rotation + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("nw_label"), rotation + F_PI_BY_TWO + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("sw_label"), rotation + F_PI + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("se_label"), rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); LLView::draw(); }
void LLNetMap::draw() { static LLFrameTimer map_timer; if (mObjectImagep.isNull()) { createObjectImage(); } LLCachedControl<S32> minimap_center(gSavedSettings, "MiniMapCenter"); if (minimap_center != MAP_CENTER_NONE) { mCurPanX = lerp(mCurPanX, mTargetPanX, LLCriticalDamp::getInterpolant(0.1f)); mCurPanY = lerp(mCurPanY, mTargetPanY, LLCriticalDamp::getInterpolant(0.1f)); } LLViewerCamera* camera = LLViewerCamera::getInstance(); F32 rotation = 0; // Prepare a scissor region { LLGLEnable scissor(GL_SCISSOR_TEST); { gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); LLLocalClipRect clip(getLocalRect()); glMatrixMode(GL_MODELVIEW); // Draw background rectangle if(isBackgroundVisible()) { gGL.color4fv(isBackgroundOpaque() ? getBackgroundColor().mV : getTransparentColor().mV); gl_rect_2d(0, getRect().getHeight(), getRect().getWidth(), 0); } } // region 0,0 is in the middle S32 center_sw_left = getRect().getWidth() / 2 + llfloor(mCurPanX); S32 center_sw_bottom = getRect().getHeight() / 2 + llfloor(mCurPanY); gGL.pushMatrix(); gGL.translatef( (F32) center_sw_left, (F32) center_sw_bottom, 0.f); BOOL rotate_map = gSavedSettings.getBOOL( "MiniMapRotate" ); if( rotate_map ) { // rotate subsequent draws to agent rotation rotation = atan2( camera->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ); glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); } // figure out where agent is S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters()); LLColor4 this_region_color = gColors.getColor( "NetMapThisRegion" ); LLColor4 live_region_color = gColors.getColor( "NetMapLiveRegion" ); LLColor4 dead_region_color = gColors.getColor( "NetMapDeadRegion" ); for (LLWorld::region_list_t::const_iterator iter = LLWorld::getInstance()->getRegionList().begin(); iter != LLWorld::getInstance()->getRegionList().end(); ++iter) { LLViewerRegion* regionp = *iter; // Find x and y position relative to camera's center. LLVector3 origin_agent = regionp->getOriginAgent(); LLVector3 rel_region_pos = origin_agent - gAgent.getCameraPositionAgent(); F32 relative_x = (rel_region_pos.mV[0] / region_width) * mScale; F32 relative_y = (rel_region_pos.mV[1] / region_width) * mScale; // background region rectangle F32 bottom = relative_y; F32 left = relative_x; F32 top = bottom + mScale ; F32 right = left + mScale ; gGL.color4fv(regionp == gAgent.getRegion() ? this_region_color.mV : live_region_color.mV); if (!regionp->isAlive()) { gGL.color4fv(dead_region_color.mV); } // Draw using texture. gGL.getTexUnit(0)->bind(regionp->getLand().getSTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); // Draw water gGL.setAlphaRejectSettings(LLRender::CF_GREATER, ABOVE_WATERLINE_ALPHA / 255.f); { if (regionp->getLand().getWaterTexture()) { gGL.getTexUnit(0)->bind(regionp->getLand().getWaterTexture()); gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(left, top); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(left, bottom); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(right, bottom); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(right, top); gGL.end(); } } gGL.setAlphaRejectSettings(LLRender::CF_DEFAULT); } // Redraw object layer periodically if (mUpdateNow || (map_timer.getElapsedTimeF32() > 0.5f)) { mUpdateNow = FALSE; // Locate the centre of the object layer, accounting for panning LLVector3 new_center = globalPosToView(gAgent.getCameraPositionGlobal(), rotate_map); new_center.mV[0] -= mCurPanX; new_center.mV[1] -= mCurPanY; new_center.mV[2] = 0.f; mObjectImageCenterGlobal = viewPosToGlobal(llround(new_center.mV[0]), llround(new_center.mV[1]), rotate_map); // Create the base texture. U8 *default_texture = mObjectRawImagep->getData(); memset( default_texture, 0, mObjectImagep->getWidth() * mObjectImagep->getHeight() * mObjectImagep->getComponents() ); // Draw buildings //gObjectList.renderObjectsForMap(*this); LLCachedControl<bool> mm_fastminimap(gSavedSettings, "mm_fastminimap"); if (!mm_fastminimap) { gObjectList.renderObjectsForMap(*this); mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); } mObjectImagep->setSubImage(mObjectRawImagep, 0, 0, mObjectImagep->getWidth(), mObjectImagep->getHeight()); map_timer.reset(); } LLVector3 map_center_agent = gAgent.getPosAgentFromGlobal(mObjectImageCenterGlobal); map_center_agent -= gAgent.getCameraPositionAgent(); map_center_agent.mV[VX] *= mScale/region_width; map_center_agent.mV[VY] *= mScale/region_width; gGL.getTexUnit(0)->bind(mObjectImagep); F32 image_half_width = 0.5f*mObjectMapPixels; F32 image_half_height = 0.5f*mObjectMapPixels; gGL.begin(LLRender::QUADS); gGL.texCoord2f(0.f, 1.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, image_half_height + map_center_agent.mV[VY]); gGL.texCoord2f(0.f, 0.f); gGL.vertex2f(map_center_agent.mV[VX] - image_half_width, map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 0.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], map_center_agent.mV[VY] - image_half_height); gGL.texCoord2f(1.f, 1.f); gGL.vertex2f(image_half_width + map_center_agent.mV[VX], image_half_height + map_center_agent.mV[VY]); gGL.end(); gGL.popMatrix(); LLVector3d pos_global; LLVector3 pos_map; // Mouse pointer in local coordinates S32 local_mouse_x; S32 local_mouse_y; LLUI::getCursorPositionLocal(this, &local_mouse_x, &local_mouse_y); mClosestAgentToCursor.setNull(); F32 closest_dist = F32_MAX; F32 min_pick_dist = mDotRadius * MIN_PICK_SCALE; // Draw avatars // LLColor4 mapcolor = gAvatarMapColor; static LLCachedControl<LLColor4U> sMapAvatar(gColors, "MapAvatar"); LLColor4 avatar_color = (LLColor4)sMapAvatar; LLColor4 standard_color = avatar_color; //LLColor4 friend_color = gColors.getColor( "MapFriend" ); // [RLVa:KB] - Version: 1.23.4 | Alternate: Snowglobe-1.2.4 | Checked: 2009-07-08 (RLVa-1.0.0e) | Modified: RLVa-0.2.0b LLColor4 friend_color = (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? gColors.getColor("MapFriend") : avatar_color; // [/RLVa:KB] LLColor4 linden_color = gColors.getColor( "MapLinden" ); LLColor4 muted_color = gColors.getColor( "MapMuted" ); std::vector<LLUUID> avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions); U32 a; static LLCachedControl<bool> friendsGroupsOnMinimap(gSavedSettings, "PhoenixContactSetsColorizeMiniMap"); for(U32 i=0; i<avatar_ids.size(); i++) { avatar_color = standard_color; // TODO: it'd be very cool to draw these in sorted order from lowest Z to highest. // just be careful to sort the avatar IDs along with the positions. -MG LLVector3d currentPos(positions[i]); bool isHeightUnknown = (currentPos.mdV[VZ] == 0.f); if (avatar_ids[i].notNull() && isHeightUnknown) { LLViewerObject* viewerObject = gObjectList.findObject(avatar_ids[i]); if (viewerObject) { currentPos.mdV[VZ] = viewerObject->getPositionGlobal().mdV[VZ]; isHeightUnknown = false; } } pos_map = globalPosToView(currentPos, rotate_map); std::string first, last; gCacheName->getName(avatar_ids[i], first, last); if (LLMuteList::getInstance()->isMuted(avatar_ids[i])) avatar_color = muted_color; if (is_agent_friend(avatar_ids[i]) || LGGContactSets::getInstance()->isNonFriend(avatar_ids[i])) { if(friendsGroupsOnMinimap) { LLColor4 fgColor = LGGContactSets::getInstance()->getFriendColor(avatar_ids[i]); if(fgColor!=LGGContactSets::getInstance()->getDefaultColor()) avatar_color=fgColor; }else avatar_color = friend_color; } if((last == "Linden") || (last == "Tester")) avatar_color = linden_color; // MOYMOD Minimap custom av colors. for(a=0;a<mm_netmapnum;a+=1)if(avatar_ids[i]==mm_mapkeys[a])avatar_color=mm_mapcols[a]; // [RLVa:KB] - Alternate: Phoenix-370 | Checked: 2009-07-21 (RLVa-1.0.0) | Added: RLVa-1.0.0 // Phoenix-specific: shouldn't be able to tell anything "personal" about anyone from the minimap under @shownames=n LLWorldMapView::drawAvatar( pos_map.mV[VX], pos_map.mV[VY], (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES)) ? avatar_color : standard_color, pos_map.mV[VZ],mDotRadius, isHeightUnknown); // [/RLVa:KB] // LLWorldMapView::drawAvatar( // pos_map.mV[VX], pos_map.mV[VY], avatar_color, pos_map.mV[VZ],mDotRadius); F32 dist_to_cursor = dist_vec(LLVector2(pos_map.mV[VX], pos_map.mV[VY]), LLVector2(local_mouse_x,local_mouse_y)); if(dist_to_cursor < min_pick_dist && dist_to_cursor < closest_dist) { closest_dist = dist_to_cursor; mClosestAgentToCursor = avatar_ids[i]; mClosestAgentPosition = currentPos; } } // Draw dot for autopilot target if (gAgent.getAutoPilot()) { drawTracking( gAgent.getAutoPilotTargetGlobal(), rotate_map, gTrackColor ); } else { LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus(); if ( LLTracker::TRACKING_AVATAR == tracking_status ) { drawTracking( LLAvatarTracker::instance().getGlobalPos(), rotate_map, gTrackColor ); } else if ( LLTracker::TRACKING_LANDMARK == tracking_status || LLTracker::TRACKING_LOCATION == tracking_status ) { drawTracking( LLTracker::getTrackedPositionGlobal(), rotate_map, gTrackColor ); } } // Draw dot for self avatar position pos_global = gAgent.getPositionGlobal(); pos_map = globalPosToView(pos_global, rotate_map); LLUIImagePtr you = LLWorldMapView::sAvatarYouLargeImage; S32 dot_width = llround(mDotRadius * 2.f); you->draw( llround(pos_map.mV[VX] - mDotRadius), llround(pos_map.mV[VY] - mDotRadius), dot_width, dot_width); // Draw frustum F32 meters_to_pixels = mScale/ LLWorld::getInstance()->getRegionWidthInMeters(); F32 horiz_fov = camera->getView() * LLViewerCamera::getInstance()->getAspect(); F32 far_clip_meters = camera->getFar(); F32 far_clip_pixels = far_clip_meters * meters_to_pixels; F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); F32 half_width_pixels = half_width_meters * meters_to_pixels; F32 ctr_x = (F32)center_sw_left; F32 ctr_y = (F32)center_sw_bottom; gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); if( rotate_map ) { gGL.color4fv(gColors.getColor("NetMapFrustum").mV); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( ctr_x, ctr_y ); gGL.vertex2f( ctr_x - half_width_pixels, ctr_y + far_clip_pixels ); gGL.vertex2f( ctr_x + half_width_pixels, ctr_y + far_clip_pixels ); gGL.end(); } else { gGL.color4fv(gColors.getColor("NetMapFrustumRotating").mV); // If we don't rotate the map, we have to rotate the frustum. gGL.pushMatrix(); gGL.translatef( ctr_x, ctr_y, 0 ); glRotatef( atan2( camera->getAtAxis().mV[VX], camera->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); gGL.begin( LLRender::TRIANGLES ); gGL.vertex2f( 0, 0 ); gGL.vertex2f( -half_width_pixels, far_clip_pixels ); gGL.vertex2f( half_width_pixels, far_clip_pixels ); gGL.end(); gGL.popMatrix(); } } // Rotation of 0 means that North is up setDirectionPos( getChild<LLTextBox>("e_label"), rotation); setDirectionPos( getChild<LLTextBox>("n_label"), rotation + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("w_label"), rotation + F_PI); setDirectionPos( getChild<LLTextBox>("s_label"), rotation + F_PI + F_PI_BY_TWO); setDirectionPos( getChild<LLTextBox>("ne_label"), rotation + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("nw_label"), rotation + F_PI_BY_TWO + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("sw_label"), rotation + F_PI + F_PI_BY_TWO / 2); setDirectionPos( getChild<LLTextBox>("se_label"), rotation + F_PI + F_PI_BY_TWO + F_PI_BY_TWO / 2); LLView::draw(); }