diff options
author | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-08-15 23:44:46 -0500 |
commit | 38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch) | |
tree | adca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/lltoolplacer.cpp | |
parent | README.txt (diff) | |
download | meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2 meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz |
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/lltoolplacer.cpp')
-rw-r--r-- | linden/indra/newview/lltoolplacer.cpp | 244 |
1 files changed, 244 insertions, 0 deletions
diff --git a/linden/indra/newview/lltoolplacer.cpp b/linden/indra/newview/lltoolplacer.cpp new file mode 100644 index 0000000..594be6c --- /dev/null +++ b/linden/indra/newview/lltoolplacer.cpp | |||
@@ -0,0 +1,244 @@ | |||
1 | /** | ||
2 | * @file lltoolplacer.cpp | ||
3 | * @brief Tool for placing new objects into the world | ||
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 | // self header | ||
31 | #include "lltoolplacer.h" | ||
32 | |||
33 | // linden library headers | ||
34 | #include "llprimitive.h" | ||
35 | |||
36 | // viewer headers | ||
37 | #include "llbutton.h" | ||
38 | #include "llviewercontrol.h" | ||
39 | #include "llfirstuse.h" | ||
40 | #include "llfloatertools.h" | ||
41 | #include "llselectmgr.h" | ||
42 | #include "llstatusbar.h" | ||
43 | #include "lltoolcomp.h" | ||
44 | #include "lltoolmgr.h" | ||
45 | #include "llviewerobject.h" | ||
46 | #include "llviewerregion.h" | ||
47 | #include "llviewerwindow.h" | ||
48 | #include "llworld.h" | ||
49 | #include "viewer.h" | ||
50 | #include "llui.h" | ||
51 | |||
52 | //static | ||
53 | LLPCode LLToolPlacer::sObjectType = LL_PCODE_CUBE; | ||
54 | |||
55 | LLToolPlacer::LLToolPlacer() | ||
56 | : LLTool( "Create" ) | ||
57 | { | ||
58 | } | ||
59 | |||
60 | // Used by the placer tool to add copies of the current selection. | ||
61 | // Inspired by add_object(). JC | ||
62 | BOOL add_duplicate(S32 x, S32 y) | ||
63 | { | ||
64 | LLVector3 ray_start_region; | ||
65 | LLVector3 ray_end_region; | ||
66 | LLViewerRegion* regionp = NULL; | ||
67 | BOOL b_hit_land = FALSE; | ||
68 | S32 hit_face = -1; | ||
69 | LLViewerObject* hit_obj = NULL; | ||
70 | BOOL success = raycast_for_new_obj_pos( x, y, &hit_obj, &hit_face, &b_hit_land, &ray_start_region, &ray_end_region, ®ionp ); | ||
71 | if( !success ) | ||
72 | { | ||
73 | make_ui_sound("UISndInvalidOp"); | ||
74 | return FALSE; | ||
75 | } | ||
76 | if( hit_obj && (hit_obj->isAvatar() || hit_obj->isAttachment()) ) | ||
77 | { | ||
78 | // Can't create objects on avatars or attachments | ||
79 | make_ui_sound("UISndInvalidOp"); | ||
80 | return FALSE; | ||
81 | } | ||
82 | |||
83 | |||
84 | // Limit raycast to a single object. | ||
85 | // Speeds up server raycast + avoid problems with server ray hitting objects | ||
86 | // that were clipped by the near plane or culled on the viewer. | ||
87 | LLUUID ray_target_id; | ||
88 | if( hit_obj ) | ||
89 | { | ||
90 | ray_target_id = hit_obj->getID(); | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | ray_target_id.setNull(); | ||
95 | } | ||
96 | |||
97 | gSelectMgr->selectDuplicateOnRay(ray_start_region, | ||
98 | ray_end_region, | ||
99 | b_hit_land, // suppress raycast | ||
100 | FALSE, // intersection | ||
101 | ray_target_id, | ||
102 | gSavedSettings.getBOOL("CreateToolCopyCenters"), | ||
103 | gSavedSettings.getBOOL("CreateToolCopyRotates"), | ||
104 | FALSE); // select copy | ||
105 | |||
106 | if (regionp | ||
107 | && (regionp->getRegionFlags() & REGION_FLAGS_SANDBOX)) | ||
108 | { | ||
109 | LLFirstUse::useSandbox(); | ||
110 | } | ||
111 | |||
112 | return TRUE; | ||
113 | } | ||
114 | |||
115 | |||
116 | BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask) | ||
117 | { | ||
118 | BOOL added = TRUE; | ||
119 | |||
120 | if (gSavedSettings.getBOOL("CreateToolCopySelection")) | ||
121 | { | ||
122 | added = add_duplicate(x, y); | ||
123 | } | ||
124 | else | ||
125 | { | ||
126 | added = add_object( sObjectType, x, y, NO_PHYSICS ); | ||
127 | } | ||
128 | |||
129 | // ...and go back to the default tool | ||
130 | if (added && !gSavedSettings.getBOOL("CreateToolKeepSelected")) | ||
131 | { | ||
132 | gCurrentToolset->selectTool( gToolTranslate ); | ||
133 | } | ||
134 | |||
135 | return added; | ||
136 | } | ||
137 | |||
138 | BOOL LLToolPlacer::handleHover(S32 x, S32 y, MASK mask) | ||
139 | { | ||
140 | lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPlacer" << llendl; | ||
141 | gViewerWindow->getWindow()->setCursor(UI_CURSOR_TOOLCREATE); | ||
142 | return TRUE; | ||
143 | } | ||
144 | |||
145 | void LLToolPlacer::handleSelect() | ||
146 | { | ||
147 | gFloaterTools->setStatusText("Click in the world to create, shift-click to select"); | ||
148 | } | ||
149 | |||
150 | void LLToolPlacer::handleDeselect() | ||
151 | { | ||
152 | gFloaterTools->setStatusText(""); | ||
153 | } | ||
154 | |||
155 | ////////////////////////////////////////////////////// | ||
156 | // LLToolPlacerPanel | ||
157 | |||
158 | // static | ||
159 | LLPCode LLToolPlacerPanel::sCube = LL_PCODE_CUBE; | ||
160 | LLPCode LLToolPlacerPanel::sPrism = LL_PCODE_PRISM; | ||
161 | LLPCode LLToolPlacerPanel::sPyramid = LL_PCODE_PYRAMID; | ||
162 | LLPCode LLToolPlacerPanel::sTetrahedron = LL_PCODE_TETRAHEDRON; | ||
163 | LLPCode LLToolPlacerPanel::sCylinder = LL_PCODE_CYLINDER; | ||
164 | LLPCode LLToolPlacerPanel::sCylinderHemi= LL_PCODE_CYLINDER_HEMI; | ||
165 | LLPCode LLToolPlacerPanel::sCone = LL_PCODE_CONE; | ||
166 | LLPCode LLToolPlacerPanel::sConeHemi = LL_PCODE_CONE_HEMI; | ||
167 | LLPCode LLToolPlacerPanel::sTorus = LL_PCODE_TORUS; | ||
168 | LLPCode LLToolPlacerPanel::sSquareTorus = LLViewerObject::LL_VO_SQUARE_TORUS; | ||
169 | LLPCode LLToolPlacerPanel::sTriangleTorus = LLViewerObject::LL_VO_TRIANGLE_TORUS; | ||
170 | LLPCode LLToolPlacerPanel::sSphere = LL_PCODE_SPHERE; | ||
171 | LLPCode LLToolPlacerPanel::sSphereHemi = LL_PCODE_SPHERE_HEMI; | ||
172 | LLPCode LLToolPlacerPanel::sTree = LL_PCODE_LEGACY_TREE; | ||
173 | LLPCode LLToolPlacerPanel::sGrass = LL_PCODE_LEGACY_GRASS; | ||
174 | LLPCode LLToolPlacerPanel::sTreeNew = LL_PCODE_TREE_NEW; | ||
175 | |||
176 | S32 LLToolPlacerPanel::sButtonsAdded = 0; | ||
177 | LLButton* LLToolPlacerPanel::sButtons[ TOOL_PLACER_NUM_BUTTONS ]; | ||
178 | |||
179 | LLToolPlacerPanel::LLToolPlacerPanel(const std::string& name, const LLRect& rect) | ||
180 | : | ||
181 | LLPanel( name, rect ) | ||
182 | { | ||
183 | /* DEPRECATED - JC | ||
184 | addButton( "UIImgCubeUUID", "UIImgCubeSelectedUUID", &LLToolPlacerPanel::sCube ); | ||
185 | addButton( "UIImgPrismUUID", "UIImgPrismSelectedUUID", &LLToolPlacerPanel::sPrism ); | ||
186 | addButton( "UIImgPyramidUUID", "UIImgPyramidSelectedUUID", &LLToolPlacerPanel::sPyramid ); | ||
187 | addButton( "UIImgTetrahedronUUID", "UIImgTetrahedronSelectedUUID", &LLToolPlacerPanel::sTetrahedron ); | ||
188 | addButton( "UIImgCylinderUUID", "UIImgCylinderSelectedUUID", &LLToolPlacerPanel::sCylinder ); | ||
189 | addButton( "UIImgHalfCylinderUUID", "UIImgHalfCylinderSelectedUUID",&LLToolPlacerPanel::sCylinderHemi ); | ||
190 | addButton( "UIImgConeUUID", "UIImgConeSelectedUUID", &LLToolPlacerPanel::sCone ); | ||
191 | addButton( "UIImgHalfConeUUID", "UIImgHalfConeSelectedUUID", &LLToolPlacerPanel::sConeHemi ); | ||
192 | addButton( "UIImgSphereUUID", "UIImgSphereSelectedUUID", &LLToolPlacerPanel::sSphere ); | ||
193 | addButton( "UIImgHalfSphereUUID", "UIImgHalfSphereSelectedUUID", &LLToolPlacerPanel::sSphereHemi ); | ||
194 | addButton( "UIImgTreeUUID", "UIImgTreeSelectedUUID", &LLToolPlacerPanel::sTree ); | ||
195 | addButton( "UIImgGrassUUID", "UIImgGrassSelectedUUID", &LLToolPlacerPanel::sGrass ); | ||
196 | addButton( "ObjectTorusImageID", "ObjectTorusActiveImageID", &LLToolPlacerPanel::sTorus ); | ||
197 | addButton( "ObjectTubeImageID", "ObjectTubeActiveImageID", &LLToolPlacerPanel::sSquareTorus ); | ||
198 | */ | ||
199 | } | ||
200 | |||
201 | void LLToolPlacerPanel::addButton( const LLString& up_state, const LLString& down_state, LLPCode* pcode ) | ||
202 | { | ||
203 | const S32 TOOL_SIZE = 32; | ||
204 | const S32 HORIZ_SPACING = TOOL_SIZE + 5; | ||
205 | const S32 VERT_SPACING = TOOL_SIZE + 5; | ||
206 | const S32 VPAD = 10; | ||
207 | const S32 HPAD = 7; | ||
208 | |||
209 | S32 row = sButtonsAdded / 4; | ||
210 | S32 column = sButtonsAdded % 4; | ||
211 | |||
212 | LLRect help_rect = gSavedSettings.getRect("ToolHelpRect"); | ||
213 | |||
214 | // Build the rectangle, recalling the origin is at lower left | ||
215 | // and we want the icons to build down from the top. | ||
216 | LLRect rect; | ||
217 | rect.setLeftTopAndSize( | ||
218 | HPAD + (column * HORIZ_SPACING), | ||
219 | help_rect.mBottom - VPAD - (row * VERT_SPACING), | ||
220 | TOOL_SIZE, | ||
221 | TOOL_SIZE ); | ||
222 | |||
223 | LLButton* btn = new LLButton( | ||
224 | "ToolPlacerOptBtn", | ||
225 | rect, | ||
226 | up_state, | ||
227 | down_state, | ||
228 | "", &LLToolPlacerPanel::setObjectType, | ||
229 | pcode, | ||
230 | LLFontGL::sSansSerif); | ||
231 | btn->setFollowsBottom(); | ||
232 | btn->setFollowsLeft(); | ||
233 | addChild(btn); | ||
234 | |||
235 | sButtons[sButtonsAdded] = btn; | ||
236 | sButtonsAdded++; | ||
237 | } | ||
238 | |||
239 | // static | ||
240 | void LLToolPlacerPanel::setObjectType( void* data ) | ||
241 | { | ||
242 | LLPCode pcode = *(LLPCode*) data; | ||
243 | LLToolPlacer::setObjectType( pcode ); | ||
244 | } | ||