aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolbrush.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/lltoolbrush.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltoolbrush.cpp77
1 files changed, 37 insertions, 40 deletions
diff --git a/linden/indra/newview/lltoolbrush.cpp b/linden/indra/newview/lltoolbrush.cpp
index 5f402a8..2db1d5b 100644
--- a/linden/indra/newview/lltoolbrush.cpp
+++ b/linden/indra/newview/lltoolbrush.cpp
@@ -35,6 +35,7 @@
35#include "lltoolselectland.h" 35#include "lltoolselectland.h"
36 36
37#include "llgl.h" 37#include "llgl.h"
38#include "llglimmediate.h"
38 39
39#include "message.h" 40#include "message.h"
40 41
@@ -107,10 +108,10 @@ void LLToolBrushLand::modifyLandAtPointGlobal(const LLVector3d &pos_global,
107 S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); 108 S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction");
108 109
109 determineAffectedRegions(mLastAffectedRegions, pos_global); 110 determineAffectedRegions(mLastAffectedRegions, pos_global);
110 for(LLViewerRegion* regionp = mLastAffectedRegions.getFirstData(); 111 for(region_list_t::iterator iter = mLastAffectedRegions.begin();
111 regionp != NULL; 112 iter != mLastAffectedRegions.end(); ++iter)
112 regionp = mLastAffectedRegions.getNextData())
113 { 113 {
114 LLViewerRegion* regionp = *iter;
114 //BOOL is_changed = FALSE; 115 //BOOL is_changed = FALSE;
115 LLVector3 pos_region = regionp->getPosRegionFromGlobal(pos_global); 116 LLVector3 pos_region = regionp->getPosRegionFromGlobal(pos_global);
116 LLSurface &land = regionp->getLand(); 117 LLSurface &land = regionp->getLand();
@@ -199,7 +200,7 @@ void LLToolBrushLand::modifyLandInSelectionGlobal()
199 200
200 S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction"); 201 S32 radioAction = gSavedSettings.getS32("RadioLandBrushAction");
201 202
202 mLastAffectedRegions.removeAllNodes(); 203 mLastAffectedRegions.clear();
203 204
204 determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], min.mdV[VY], 0)); 205 determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], min.mdV[VY], 0));
205 determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], max.mdV[VY], 0)); 206 determineAffectedRegions(mLastAffectedRegions, LLVector3d(min.mdV[VX], max.mdV[VY], 0));
@@ -222,10 +223,10 @@ void LLToolBrushLand::modifyLandInSelectionGlobal()
222 } 223 }
223 224
224 // Stop if our selection include a no-terraform region 225 // Stop if our selection include a no-terraform region
225 for(LLViewerRegion* regionp = mLastAffectedRegions.getFirstData(); 226 for(region_list_t::iterator iter = mLastAffectedRegions.begin();
226 regionp != NULL; 227 iter != mLastAffectedRegions.end(); ++iter)
227 regionp = mLastAffectedRegions.getNextData())
228 { 228 {
229 LLViewerRegion* regionp = *iter;
229 if (!canTerraform(regionp)) 230 if (!canTerraform(regionp))
230 { 231 {
231 alertNoTerraform(regionp); 232 alertNoTerraform(regionp);
@@ -233,10 +234,10 @@ void LLToolBrushLand::modifyLandInSelectionGlobal()
233 } 234 }
234 } 235 }
235 236
236 for(LLViewerRegion* regionp = mLastAffectedRegions.getFirstData(); 237 for(region_list_t::iterator iter = mLastAffectedRegions.begin();
237 regionp != NULL; 238 iter != mLastAffectedRegions.end(); ++iter)
238 regionp = mLastAffectedRegions.getNextData())
239 { 239 {
240 LLViewerRegion* regionp = *iter;
240 //BOOL is_changed = FALSE; 241 //BOOL is_changed = FALSE;
241 LLVector3 min_region = regionp->getPosRegionFromGlobal(min); 242 LLVector3 min_region = regionp->getPosRegionFromGlobal(min);
242 LLVector3 max_region = regionp->getPosRegionFromGlobal(max); 243 LLVector3 max_region = regionp->getPosRegionFromGlobal(max);
@@ -397,7 +398,7 @@ BOOL LLToolBrushLand::handleHover( S32 x, S32 y, MASK mask )
397BOOL LLToolBrushLand::handleMouseUp(S32 x, S32 y, MASK mask) 398BOOL LLToolBrushLand::handleMouseUp(S32 x, S32 y, MASK mask)
398{ 399{
399 BOOL handled = FALSE; 400 BOOL handled = FALSE;
400 mLastAffectedRegions.removeAllNodes(); 401 mLastAffectedRegions.clear();
401 if( hasMouseCapture() ) 402 if( hasMouseCapture() )
402 { 403 {
403 // Release the mouse 404 // Release the mouse
@@ -451,15 +452,15 @@ void LLToolBrushLand::render()
451 spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 ); 452 spot.mdV[VY] = floor( spot.mdV[VY] + 0.5 );
452 453
453 mBrushIndex = gSavedSettings.getS32("RadioLandBrushSize"); 454 mBrushIndex = gSavedSettings.getS32("RadioLandBrushSize");
454 LLLinkedList<LLViewerRegion> regions; 455 region_list_t regions;
455 determineAffectedRegions(regions, spot); 456 determineAffectedRegions(regions, spot);
456 457
457 // Now, for each region, render the overlay 458 // Now, for each region, render the overlay
458 LLVector3 pos_world = gAgent.getRegion()->getPosRegionFromGlobal(spot); 459 LLVector3 pos_world = gAgent.getRegion()->getPosRegionFromGlobal(spot);
459 for(LLViewerRegion* region = regions.getFirstData(); 460 for(region_list_t::iterator iter = regions.begin();
460 region != NULL; 461 iter != regions.end(); ++iter)
461 region = regions.getNextData())
462 { 462 {
463 LLViewerRegion* region = *iter;
463 renderOverlay(region->getLand(), 464 renderOverlay(region->getLand(),
464 region->getPosRegionFromGlobal(spot), 465 region->getPosRegionFromGlobal(spot),
465 pos_world); 466 pos_world);
@@ -476,33 +477,29 @@ void LLToolBrushLand::renderOverlay(LLSurface& land, const LLVector3& pos_region
476 LLGLSNoTexture gls_no_texture; 477 LLGLSNoTexture gls_no_texture;
477 LLGLDepthTest mDepthTest(GL_TRUE); 478 LLGLDepthTest mDepthTest(GL_TRUE);
478 glPushMatrix(); 479 glPushMatrix();
479 glColor4fv(OVERLAY_COLOR.mV); 480 gGL.color4fv(OVERLAY_COLOR.mV);
480 glTranslatef(0.0f, 0.0f, 1.0f); 481 glTranslatef(0.0f, 0.0f, 1.0f);
481 //glPushMatrix(); 482
482 //glTranslatef(spot.mV[VX], spot.mV[VY], 100.0f);
483 //gl_rect_2d(0, 10, 10, 0);
484 //glPopMatrix();
485 S32 i = (S32) pos_region.mV[VX]; 483 S32 i = (S32) pos_region.mV[VX];
486 S32 j = (S32) pos_region.mV[VY]; 484 S32 j = (S32) pos_region.mV[VY];
487 S32 half_edge = llfloor(LAND_BRUSH_SIZE[mBrushIndex]); 485 S32 half_edge = llfloor(LAND_BRUSH_SIZE[mBrushIndex]);
488 //F32 dz = 0.0f; 486
489 //S32 dist = 0; 487 gGL.begin(GL_POINTS);
490 glBegin(GL_POINTS);
491 for(S32 di = -half_edge; di <= half_edge; di++) 488 for(S32 di = -half_edge; di <= half_edge; di++)
492 { 489 {
493 if((i+di) < 0 || (i+di) >= (S32)land.mGridsPerEdge) continue; 490 if((i+di) < 0 || (i+di) >= (S32)land.mGridsPerEdge) continue;
494 for(S32 dj = -half_edge; dj <= half_edge; dj++) 491 for(S32 dj = -half_edge; dj <= half_edge; dj++)
495 { 492 {
496 if( (j+dj) < 0 || (j+dj) >= (S32)land.mGridsPerEdge ) continue; 493 if( (j+dj) < 0 || (j+dj) >= (S32)land.mGridsPerEdge ) continue;
497 glVertex3f(pos_world.mV[VX] + di, pos_world.mV[VY] + dj, 494 gGL.vertex3f(pos_world.mV[VX] + di, pos_world.mV[VY] + dj,
498 land.getZ((i+di)+(j+dj)*land.mGridsPerEdge)); 495 land.getZ((i+di)+(j+dj)*land.mGridsPerEdge));
499 } 496 }
500 } 497 }
501 glEnd(); 498 gGL.end();
502 glPopMatrix(); 499 glPopMatrix();
503} 500}
504 501
505void LLToolBrushLand::determineAffectedRegions(LLLinkedList<LLViewerRegion>& regions, 502void LLToolBrushLand::determineAffectedRegions(region_list_t& regions,
506 const LLVector3d& spot ) const 503 const LLVector3d& spot ) const
507{ 504{
508 LLVector3d corner(spot); 505 LLVector3d corner(spot);
@@ -510,27 +507,27 @@ void LLToolBrushLand::determineAffectedRegions(LLLinkedList<LLViewerRegion>& reg
510 corner.mdV[VY] -= (LAND_BRUSH_SIZE[mBrushIndex] / 2); 507 corner.mdV[VY] -= (LAND_BRUSH_SIZE[mBrushIndex] / 2);
511 LLViewerRegion* region = NULL; 508 LLViewerRegion* region = NULL;
512 region = gWorldPointer->getRegionFromPosGlobal(corner); 509 region = gWorldPointer->getRegionFromPosGlobal(corner);
513 if(region && !regions.checkData(region)) 510 if(region && regions.find(region) == regions.end())
514 { 511 {
515 regions.addData(region); 512 regions.insert(region);
516 } 513 }
517 corner.mdV[VY] += LAND_BRUSH_SIZE[mBrushIndex]; 514 corner.mdV[VY] += LAND_BRUSH_SIZE[mBrushIndex];
518 region = gWorldPointer->getRegionFromPosGlobal(corner); 515 region = gWorldPointer->getRegionFromPosGlobal(corner);
519 if(region && !regions.checkData(region)) 516 if(region && regions.find(region) == regions.end())
520 { 517 {
521 regions.addData(region); 518 regions.insert(region);
522 } 519 }
523 corner.mdV[VX] += LAND_BRUSH_SIZE[mBrushIndex]; 520 corner.mdV[VX] += LAND_BRUSH_SIZE[mBrushIndex];
524 region = gWorldPointer->getRegionFromPosGlobal(corner); 521 region = gWorldPointer->getRegionFromPosGlobal(corner);
525 if(region && !regions.checkData(region)) 522 if(region && regions.find(region) == regions.end())
526 { 523 {
527 regions.addData(region); 524 regions.insert(region);
528 } 525 }
529 corner.mdV[VY] -= LAND_BRUSH_SIZE[mBrushIndex]; 526 corner.mdV[VY] -= LAND_BRUSH_SIZE[mBrushIndex];
530 region = gWorldPointer->getRegionFromPosGlobal(corner); 527 region = gWorldPointer->getRegionFromPosGlobal(corner);
531 if(region && !regions.checkData(region)) 528 if(region && regions.find(region) == regions.end())
532 { 529 {
533 regions.addData(region); 530 regions.insert(region);
534 } 531 }
535} 532}
536 533
@@ -557,10 +554,10 @@ void LLToolBrushLand::onMouseCaptureLost()
557// static 554// static
558void LLToolBrushLand::undo() 555void LLToolBrushLand::undo()
559{ 556{
560 for(LLViewerRegion* regionp = mLastAffectedRegions.getFirstData(); 557 for(region_list_t::iterator iter = mLastAffectedRegions.begin();
561 regionp != NULL; 558 iter != mLastAffectedRegions.end(); ++iter)
562 regionp = mLastAffectedRegions.getNextData())
563 { 559 {
560 LLViewerRegion* regionp = *iter;
564 gMessageSystem->newMessageFast(_PREHASH_UndoLand); 561 gMessageSystem->newMessageFast(_PREHASH_UndoLand);
565 gMessageSystem->nextBlockFast(_PREHASH_AgentData); 562 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
566 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); 563 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );
@@ -573,10 +570,10 @@ void LLToolBrushLand::undo()
573/* 570/*
574void LLToolBrushLand::redo() 571void LLToolBrushLand::redo()
575{ 572{
576 for(LLViewerRegion* regionp = mLastAffectedRegions.getFirstData(); 573 for(region_list_t::iterator iter = mLastAffectedRegions.begin();
577 regionp != NULL; 574 iter != mLastAffectedRegions.end(); ++iter)
578 regionp = mLastAffectedRegions.getNextData())
579 { 575 {
576 LLViewerRegion* regionp = *iter;
580 gMessageSystem->newMessageFast(_PREHASH_RedoLand); 577 gMessageSystem->newMessageFast(_PREHASH_RedoLand);
581 gMessageSystem->nextBlockFast(_PREHASH_AgentData); 578 gMessageSystem->nextBlockFast(_PREHASH_AgentData);
582 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() ); 579 gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID() );