aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llnetmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llnetmap.cpp91
1 files changed, 29 insertions, 62 deletions
diff --git a/linden/indra/newview/llnetmap.cpp b/linden/indra/newview/llnetmap.cpp
index 01400b1..9226fac 100644
--- a/linden/indra/newview/llnetmap.cpp
+++ b/linden/indra/newview/llnetmap.cpp
@@ -103,15 +103,20 @@ LLNetMap::LLNetMap(
103 103
104 mObjectImageCenterGlobal = gAgent.getCameraPositionGlobal(); 104 mObjectImageCenterGlobal = gAgent.getCameraPositionGlobal();
105 105
106 // TODO: exteralize hardcoded constants.
106 const S32 DIR_WIDTH = 10; 107 const S32 DIR_WIDTH = 10;
107 const S32 DIR_HEIGHT = 10; 108 const S32 DIR_HEIGHT = 10;
108 LLRect major_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH, 0 ); 109 LLRect major_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH, 0 );
109 110 const LLColor4 minor_color( 1.f, 1.f, 1.f, .7f );
110 mTextBoxNorth = new LLTextBox( "N", major_dir_rect ); 111 const LLRect minor_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH * 2, 0 );
111 mTextBoxNorth->setFontStyle(LLFontGL::DROP_SHADOW_SOFT); 112
113 // Note: removing special treatment for north compass point (DEV-10559). -MG
114 //mTextBoxNorth = new LLTextBox( "N", major_dir_rect );
115 //mTextBoxNorth->setFontStyle(LLFontGL::DROP_SHADOW_SOFT);
116 //addChild( mTextBoxNorth );
117 mTextBoxNorth = new LLTextBox( "N", major_dir_rect );
118 mTextBoxNorth->setColor( minor_color );
112 addChild( mTextBoxNorth ); 119 addChild( mTextBoxNorth );
113
114 LLColor4 minor_color( 1.f, 1.f, 1.f, .7f );
115 120
116 mTextBoxEast = new LLTextBox( "E", major_dir_rect ); 121 mTextBoxEast = new LLTextBox( "E", major_dir_rect );
117 mTextBoxEast->setColor( minor_color ); 122 mTextBoxEast->setColor( minor_color );
@@ -127,8 +132,6 @@ LLNetMap::LLNetMap(
127 mTextBoxSouth->setColor( minor_color ); 132 mTextBoxSouth->setColor( minor_color );
128 addChild( mTextBoxSouth ); 133 addChild( mTextBoxSouth );
129 134
130 LLRect minor_dir_rect( 0, DIR_HEIGHT, DIR_WIDTH * 2, 0 );
131
132 mTextBoxSouthEast = new LLTextBox( "SE", minor_dir_rect ); 135 mTextBoxSouthEast = new LLTextBox( "SE", minor_dir_rect );
133 mTextBoxSouthEast->setColor( minor_color ); 136 mTextBoxSouthEast->setColor( minor_color );
134 addChild( mTextBoxSouthEast ); 137 addChild( mTextBoxSouthEast );
@@ -163,8 +166,6 @@ LLNetMap::LLNetMap(
163 mPopupMenuHandle = menu->getHandle(); 166 mPopupMenuHandle = menu->getHandle();
164 167
165 sInstance = this; 168 sInstance = this;
166
167 gSavedSettings.getControl("MiniMapRotate")->addListener(&mNetMapListener);
168} 169}
169 170
170LLNetMap::~LLNetMap() 171LLNetMap::~LLNetMap()
@@ -172,17 +173,6 @@ LLNetMap::~LLNetMap()
172 sInstance = NULL; 173 sInstance = NULL;
173} 174}
174 175
175EWidgetType LLNetMap::getWidgetType() const
176{
177 return WIDGET_TYPE_NET_MAP;
178}
179
180LLString LLNetMap::getWidgetTag() const
181{
182 return LL_NET_MAP_TAG;
183}
184
185
186void LLNetMap::setScale( F32 scale ) 176void LLNetMap::setScale( F32 scale )
187{ 177{
188 gMiniMapScale = scale; 178 gMiniMapScale = scale;
@@ -196,20 +186,8 @@ void LLNetMap::setScale( F32 scale )
196 F32 half_width = (F32)(getRect().getWidth() / 2); 186 F32 half_width = (F32)(getRect().getWidth() / 2);
197 F32 half_height = (F32)(getRect().getHeight() / 2); 187 F32 half_height = (F32)(getRect().getHeight() / 2);
198 F32 radius = sqrt( half_width * half_width + half_height * half_height ); 188 F32 radius = sqrt( half_width * half_width + half_height * half_height );
199
200 F32 region_widths = (2.f*radius)/gMiniMapScale; 189 F32 region_widths = (2.f*radius)/gMiniMapScale;
201 190 F32 meters = region_widths * LLWorld::getInstance()->getRegionWidthInMeters();
202 F32 meters;
203 if (!gWorldPointer)
204 {
205 // Hack! Sometimes world hasn't been initialized at this point.
206 meters = 256.f*region_widths;
207 }
208 else
209 {
210 meters = region_widths * gWorldPointer->getRegionWidthInMeters();
211 }
212
213 F32 num_pixels = (F32)mObjectImagep->getWidth(); 191 F32 num_pixels = (F32)mObjectImagep->getWidth();
214 mObjectMapTPM = num_pixels/meters; 192 mObjectMapTPM = num_pixels/meters;
215 mObjectMapPixels = 2.f*radius; 193 mObjectMapPixels = 2.f*radius;
@@ -233,10 +211,6 @@ void LLNetMap::draw()
233{ 211{
234 static LLFrameTimer map_timer; 212 static LLFrameTimer map_timer;
235 213
236 if (!getVisible() || !gWorldPointer)
237 {
238 return;
239 }
240 if (mObjectImagep.isNull()) 214 if (mObjectImagep.isNull())
241 { 215 {
242 createObjectImage(); 216 createObjectImage();
@@ -273,15 +247,15 @@ void LLNetMap::draw()
273 if( LLNetMap::sRotateMap ) 247 if( LLNetMap::sRotateMap )
274 { 248 {
275 // rotate subsequent draws to agent rotation 249 // rotate subsequent draws to agent rotation
276 rotation = atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ); 250 rotation = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
277 glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f); 251 glRotatef( rotation * RAD_TO_DEG, 0.f, 0.f, 1.f);
278 } 252 }
279 253
280 // figure out where agent is 254 // figure out where agent is
281 S32 region_width = llround(gWorldPointer->getRegionWidthInMeters()); 255 S32 region_width = llround(LLWorld::getInstance()->getRegionWidthInMeters());
282 256
283 for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); 257 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin();
284 iter != gWorldp->mActiveRegionList.end(); ++iter) 258 iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter)
285 { 259 {
286 LLViewerRegion* regionp = *iter; 260 LLViewerRegion* regionp = *iter;
287 // Find x and y position relative to camera's center. 261 // Find x and y position relative to camera's center.
@@ -397,8 +371,8 @@ void LLNetMap::draw()
397 LLVector3 pos_map; 371 LLVector3 pos_map;
398 372
399 // Draw avatars 373 // Draw avatars
400 for (LLWorld::region_list_t::iterator iter = gWorldp->mActiveRegionList.begin(); 374 for (LLWorld::region_list_t::iterator iter = LLWorld::getInstance()->mActiveRegionList.begin();
401 iter != gWorldp->mActiveRegionList.end(); ++iter) 375 iter != LLWorld::getInstance()->mActiveRegionList.end(); ++iter)
402 { 376 {
403 LLViewerRegion* regionp = *iter; 377 LLViewerRegion* regionp = *iter;
404 const LLVector3d& origin_global = regionp->getOriginGlobal(); 378 const LLVector3d& origin_global = regionp->getOriginGlobal();
@@ -462,19 +436,18 @@ void LLNetMap::draw()
462 } 436 }
463 437
464 // Draw dot for self avatar position 438 // Draw dot for self avatar position
465 //drawTracking( gAgent.getPosGlobalFromAgent(gAgent.getFrameAgent().getCenter()), gSelfMapColor );
466 pos_global = gAgent.getPositionGlobal(); 439 pos_global = gAgent.getPositionGlobal();
467 pos_map = globalPosToView(pos_global); 440 pos_map = globalPosToView(pos_global);
468 gl_draw_image(llround(pos_map.mV[VX]) - 4, 441 LLUIImagePtr you = LLWorldMapView::sAvatarYouSmallImage;
469 llround(pos_map.mV[VY]) - 4, 442 you->draw(
470 LLWorldMapView::sAvatarYouSmallImage, 443 llround(pos_map.mV[VX]) - you->getWidth()/2,
471 LLColor4::white); 444 llround(pos_map.mV[VY]) - you->getHeight()/2);
472 445
473 // Draw frustum 446 // Draw frustum
474 F32 meters_to_pixels = gMiniMapScale/ gWorldPointer->getRegionWidthInMeters(); 447 F32 meters_to_pixels = gMiniMapScale/ LLWorld::getInstance()->getRegionWidthInMeters();
475 448
476 F32 horiz_fov = gCamera->getView() * gCamera->getAspect(); 449 F32 horiz_fov = LLViewerCamera::getInstance()->getView() * LLViewerCamera::getInstance()->getAspect();
477 F32 far_clip_meters = gCamera->getFar(); 450 F32 far_clip_meters = LLViewerCamera::getInstance()->getFar();
478 F32 far_clip_pixels = far_clip_meters * meters_to_pixels; 451 F32 far_clip_pixels = far_clip_meters * meters_to_pixels;
479 452
480 F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 ); 453 F32 half_width_meters = far_clip_meters * tan( horiz_fov / 2 );
@@ -503,7 +476,7 @@ void LLNetMap::draw()
503 // If we don't rotate the map, we have to rotate the frustum. 476 // If we don't rotate the map, we have to rotate the frustum.
504 gGL.pushMatrix(); 477 gGL.pushMatrix();
505 gGL.translatef( ctr_x, ctr_y, 0 ); 478 gGL.translatef( ctr_x, ctr_y, 0 );
506 glRotatef( atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f); 479 glRotatef( atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] ) * RAD_TO_DEG, 0.f, 0.f, -1.f);
507 gGL.begin( GL_TRIANGLES ); 480 gGL.begin( GL_TRIANGLES );
508 gGL.vertex2f( 0, 0 ); 481 gGL.vertex2f( 0, 0 );
509 gGL.vertex2f( -half_width_pixels, far_clip_pixels ); 482 gGL.vertex2f( -half_width_pixels, far_clip_pixels );
@@ -539,7 +512,7 @@ LLVector3 LLNetMap::globalPosToView( const LLVector3d& global_pos )
539 512
540 if( LLNetMap::sRotateMap ) 513 if( LLNetMap::sRotateMap )
541 { 514 {
542 F32 radians = atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ); 515 F32 radians = atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
543 LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f)); 516 LLQuaternion rot(radians, LLVector3(0.f, 0.f, 1.f));
544 pos_local.rotVec( rot ); 517 pos_local.rotVec( rot );
545 } 518 }
@@ -583,7 +556,7 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
583 556
584 LLVector3 pos_local( (F32)x, (F32)y, 0 ); 557 LLVector3 pos_local( (F32)x, (F32)y, 0 );
585 558
586 F32 radians = - atan2( gCamera->getAtAxis().mV[VX], gCamera->getAtAxis().mV[VY] ); 559 F32 radians = - atan2( LLViewerCamera::getInstance()->getAtAxis().mV[VX], LLViewerCamera::getInstance()->getAtAxis().mV[VY] );
587 560
588 if( LLNetMap::sRotateMap ) 561 if( LLNetMap::sRotateMap )
589 { 562 {
@@ -591,7 +564,7 @@ LLVector3d LLNetMap::viewPosToGlobal( S32 x, S32 y )
591 pos_local.rotVec( rot ); 564 pos_local.rotVec( rot );
592 } 565 }
593 566
594 pos_local *= ( gWorldPointer->getRegionWidthInMeters() / gMiniMapScale ); 567 pos_local *= ( LLWorld::getInstance()->getRegionWidthInMeters() / gMiniMapScale );
595 568
596 LLVector3d pos_global; 569 LLVector3d pos_global;
597 pos_global.setVec( pos_local ); 570 pos_global.setVec( pos_local );
@@ -614,7 +587,7 @@ BOOL LLNetMap::handleToolTip( S32 x, S32 y, LLString& msg, LLRect* sticky_rect_s
614 { 587 {
615 return FALSE; 588 return FALSE;
616 } 589 }
617 LLViewerRegion* region = gWorldPointer->getRegionFromPosGlobal( viewPosToGlobal( x, y ) ); 590 LLViewerRegion* region = LLWorld::getInstance()->getRegionFromPosGlobal( viewPosToGlobal( x, y ) );
618 if( region ) 591 if( region )
619 { 592 {
620 msg.assign( region->getName() ); 593 msg.assign( region->getName() );
@@ -828,9 +801,3 @@ void LLNetMap::handleZoomLevel(void* which)
828 break; 801 break;
829 } 802 }
830} 803}
831
832bool LLRotateNetMapListener::handleEvent(LLPointer<LLEvent> event, const LLSD& user_data)
833{
834 LLNetMap::setRotateMap(event->getValue().asBoolean());
835 return true;
836}