lltoolface.cpp

Go to the documentation of this file.
00001 
00032 #include "llviewerprecompiledheaders.h"
00033 
00034 // File includes
00035 #include "lltoolface.h" 
00036 
00037 // Library includes
00038 #include "v3math.h"
00039 
00040 // Viewer includes
00041 #include "llagent.h"
00042 //#include "llbuildview.h"
00043 #include "llviewercontrol.h"
00044 #include "llselectmgr.h"
00045 #include "lltoolview.h"
00046 #include "llviewerobject.h"
00047 #include "llviewerwindow.h"
00048 #include "llfloatertools.h"
00049 
00050 // Globals
00051 LLToolFace *gToolFace = NULL;
00052 
00053 //
00054 // Member functions
00055 //
00056 
00057 LLToolFace::LLToolFace()
00058 :       LLTool("Texture")
00059 { }
00060 
00061 
00062 LLToolFace::~LLToolFace()
00063 { }
00064 
00065 
00066 BOOL LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
00067 {
00068         if (!gSelectMgr->getSelection()->isEmpty())
00069         {
00070                 // You should already have an object selected from the mousedown.
00071                 // If so, show its properties
00072                 //gBuildView->showFacePanel();
00073                 gFloaterTools->showPanel( LLFloaterTools::PANEL_FACE );
00074                 //gBuildView->showMore(LLBuildView::PANEL_FACE);
00075                 return TRUE;
00076         }
00077         else
00078         {
00079                 // Nothing selected means the first mouse click was probably
00080                 // bad, so try again.
00081                 return FALSE;
00082         }
00083 }
00084 
00085 
00086 BOOL LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
00087 {
00088         gPickFaces = TRUE;
00089         gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
00090         return TRUE;
00091 }
00092 
00093 void LLToolFace::pickCallback(S32 x, S32 y, MASK mask)
00094 {
00095         LLViewerObject* hit_obj = gViewerWindow->lastObjectHit();
00096         if (hit_obj)
00097         {
00098                 S32 hit_face = gLastHitObjectFace;
00099                 
00100                 if (hit_obj->isAvatar())
00101                 {
00102                         // ...clicked on an avatar, so don't do anything
00103                         return;
00104                 }
00105 
00106                 // ...clicked on a world object, try to pick the appropriate face
00107 
00108                 if (mask & MASK_SHIFT)
00109                 {
00110                         // If object not selected, need to inform sim
00111                         if ( !hit_obj->isSelected() )
00112                         {
00113                                 // object wasn't selected so add the object and face
00114                                 gSelectMgr->selectObjectOnly(hit_obj, hit_face);
00115                         }
00116                         else if (!gSelectMgr->getSelection()->contains(hit_obj, hit_face) )
00117                         {
00118                                 // object is selected, but not this face, so add it.
00119                                 gSelectMgr->addAsIndividual(hit_obj, hit_face);
00120                         }
00121                         else
00122                         {
00123                                 // object is selected, as is this face, so remove the face.
00124                                 gSelectMgr->remove(hit_obj, hit_face);
00125 
00126                                 // BUG: If you remove the last face, the simulator won't know about it.
00127                         }
00128                 }
00129                 else
00130                 {
00131                         // clicked without modifiers, select only
00132                         // this face
00133                         gSelectMgr->deselectAll();
00134                         gSelectMgr->selectObjectOnly(hit_obj, hit_face);
00135                 }
00136         }
00137         else
00138         {
00139                 if (!(mask == MASK_SHIFT))
00140                 {
00141                         gSelectMgr->deselectAll();
00142                 }
00143         }
00144 }
00145 
00146 
00147 void LLToolFace::handleSelect()
00148 {
00149         // From now on, draw faces
00150         gSelectMgr->setTEMode(TRUE);
00151 }
00152 
00153 
00154 void LLToolFace::handleDeselect()
00155 {
00156         // Stop drawing faces
00157         gSelectMgr->setTEMode(FALSE);
00158 }
00159 
00160 
00161 void LLToolFace::render()
00162 {
00163         // for now, do nothing
00164 }

Generated on Thu Jul 1 06:09:21 2010 for Second Life Viewer by  doxygen 1.4.7