aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/lltoolface.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/lltoolface.cpp160
1 files changed, 160 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolface.cpp b/linden/indra/newview/lltoolface.cpp
new file mode 100644
index 0000000..504a787
--- /dev/null
+++ b/linden/indra/newview/lltoolface.cpp
@@ -0,0 +1,160 @@
1/**
2 * @file lltoolface.cpp
3 * @brief A tool to manipulate faces
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30// File includes
31#include "lltoolface.h"
32
33// Library includes
34#include "v3math.h"
35
36// Viewer includes
37#include "llagent.h"
38//#include "llbuildview.h"
39#include "llviewercontrol.h"
40#include "llselectmgr.h"
41#include "lltoolview.h"
42#include "llviewerobject.h"
43#include "llviewerwindow.h"
44#include "llfloatertools.h"
45
46// Globals
47LLToolFace *gToolFace = NULL;
48
49//
50// Member functions
51//
52
53LLToolFace::LLToolFace()
54: LLTool("Texture")
55{ }
56
57
58LLToolFace::~LLToolFace()
59{ }
60
61
62BOOL LLToolFace::handleDoubleClick(S32 x, S32 y, MASK mask)
63{
64 if (!gSelectMgr->isEmpty())
65 {
66 // You should already have an object selected from the mousedown.
67 // If so, show its properties
68 //gBuildView->showFacePanel();
69 gFloaterTools->showPanel( LLFloaterTools::PANEL_FACE );
70 //gBuildView->showMore(LLBuildView::PANEL_FACE);
71 return TRUE;
72 }
73 else
74 {
75 // Nothing selected means the first mouse click was probably
76 // bad, so try again.
77 return FALSE;
78 }
79}
80
81
82BOOL LLToolFace::handleMouseDown(S32 x, S32 y, MASK mask)
83{
84 gPickFaces = TRUE;
85 gViewerWindow->hitObjectOrLandGlobalAsync(x, y, mask, pickCallback);
86 return TRUE;
87}
88
89void LLToolFace::pickCallback(S32 x, S32 y, MASK mask)
90{
91 LLViewerObject* hit_obj = gViewerWindow->lastObjectHit();
92 if (hit_obj)
93 {
94 S32 hit_face = gLastHitObjectFace;
95
96 if (hit_obj->isAvatar())
97 {
98 // ...clicked on an avatar, so don't do anything
99 return;
100 }
101
102 // ...clicked on a world object, try to pick the appropriate face
103
104 if (mask & MASK_SHIFT)
105 {
106 // If object not selected, need to inform sim
107 if ( !hit_obj->isSelected() )
108 {
109 // object wasn't selected so add the object and face
110 gSelectMgr->selectObjectOnly(hit_obj, hit_face);
111 }
112 else if (!gSelectMgr->contains(hit_obj, hit_face) )
113 {
114 // object is selected, but not this face, so add it.
115 gSelectMgr->addAsIndividual(hit_obj, hit_face);
116 }
117 else
118 {
119 // object is selected, as is this face, so remove the face.
120 gSelectMgr->remove(hit_obj, hit_face);
121
122 // BUG: If you remove the last face, the simulator won't know about it.
123 }
124 }
125 else
126 {
127 // clicked without modifiers, select only
128 // this face
129 gSelectMgr->deselectAll();
130 gSelectMgr->selectObjectOnly(hit_obj, hit_face);
131 }
132 }
133 else
134 {
135 if (!(mask == MASK_SHIFT))
136 {
137 gSelectMgr->deselectAll();
138 }
139 }
140}
141
142
143void LLToolFace::handleSelect()
144{
145 // From now on, draw faces
146 gSelectMgr->setTEMode(TRUE);
147}
148
149
150void LLToolFace::handleDeselect()
151{
152 // Stop drawing faces
153 gSelectMgr->setTEMode(FALSE);
154}
155
156
157void LLToolFace::render()
158{
159 // for now, do nothing
160}