summaryrefslogtreecommitdiff
path: root/indra/newview/lltoolplacer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/lltoolplacer.cpp')
-rw-r--r--indra/newview/lltoolplacer.cpp186
1 files changed, 52 insertions, 134 deletions
diff --git a/indra/newview/lltoolplacer.cpp b/indra/newview/lltoolplacer.cpp
index a27053faa3..93ba3b2558 100644
--- a/indra/newview/lltoolplacer.cpp
+++ b/indra/newview/lltoolplacer.cpp
@@ -2,30 +2,25 @@
* @file lltoolplacer.cpp
* @brief Tool for placing new objects into the world
*
- * $LicenseInfo:firstyear=2001&license=viewergpl$
- *
- * Copyright (c) 2001-2007, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2001&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -34,13 +29,10 @@
// self header
#include "lltoolplacer.h"
-// linden library headers
-#include "llprimitive.h"
-
// viewer headers
#include "llbutton.h"
#include "llviewercontrol.h"
-#include "llfirstuse.h"
+//#include "llfirstuse.h"
#include "llfloatertools.h"
#include "llselectmgr.h"
#include "llstatusbar.h"
@@ -58,11 +50,18 @@
#include "llvolumemessage.h"
#include "llhudmanager.h"
#include "llagent.h"
-#include "audioengine.h"
+#include "llagentcamera.h"
+#include "llaudioengine.h"
#include "llhudeffecttrail.h"
#include "llviewerobjectlist.h"
#include "llviewercamera.h"
#include "llviewerstats.h"
+#include "llvoavatarself.h"
+
+// linden library headers
+#include "llprimitive.h"
+#include "llwindow.h" // incBusyCount()
+#include "material_codes.h"
const LLVector3 DEFAULT_OBJECT_SCALE(0.5f, 0.5f, 0.5f);
@@ -81,14 +80,22 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
// Viewer-side pick to find the right sim to create the object on.
// First find the surface the object will be created on.
- gViewerWindow->hitObjectOrLandGlobalImmediate(x, y, NULL, FALSE);
+ LLPickInfo pick = gViewerWindow->pickImmediate(x, y, FALSE);
// Note: use the frontmost non-flora version because (a) plants usually have lots of alpha and (b) pants' Havok
// representations (if any) are NOT the same as their viewer representation.
- *hit_obj = gObjectList.findObject( gLastHitNonFloraObjectID );
- *hit_face = gLastHitNonFloraObjectFace;
- *b_hit_land = !(*hit_obj) && !gLastHitNonFloraPosGlobal.isExactlyZero();
- LLVector3d land_pos_global = gLastHitNonFloraPosGlobal;
+ if (pick.mPickType == LLPickInfo::PICK_FLORA)
+ {
+ *hit_obj = NULL;
+ *hit_face = -1;
+ }
+ else
+ {
+ *hit_obj = pick.getObject();
+ *hit_face = pick.mObjectFace;
+ }
+ *b_hit_land = !(*hit_obj) && !pick.mPosGlobal.isExactlyZero();
+ LLVector3d land_pos_global = pick.mPosGlobal;
// Make sure there's a surface to place the new object on.
BOOL bypass_sim_raycast = FALSE;
@@ -109,7 +116,7 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
}
// Make sure the surface isn't too far away.
- LLVector3d ray_start_global = gAgent.getCameraPositionGlobal();
+ LLVector3d ray_start_global = gAgentCamera.getCameraPositionGlobal();
F32 dist_to_surface_sq = (F32)((surface_pos_global - ray_start_global).magVecSquared());
if( dist_to_surface_sq > (max_dist_from_camera * max_dist_from_camera) )
{
@@ -117,7 +124,7 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
}
// Find the sim where the surface lives.
- LLViewerRegion *regionp = gWorldp->getRegionFromPosGlobal(surface_pos_global);
+ LLViewerRegion *regionp = LLWorld::getInstance()->getRegionFromPosGlobal(surface_pos_global);
if (!regionp)
{
llwarns << "Trying to add object outside of all known regions!" << llendl;
@@ -130,8 +137,8 @@ BOOL LLToolPlacer::raycastForNewObjPos( S32 x, S32 y, LLViewerObject** hit_obj,
*region = regionp;
*ray_start_region = regionp->getPosRegionFromGlobal( ray_start_global );
- F32 near_clip = gCamera->getNear() + 0.01f; // Include an epsilon to avoid rounding issues.
- *ray_start_region += gCamera->getAtAxis() * near_clip;
+ F32 near_clip = LLViewerCamera::getInstance()->getNear() + 0.01f; // Include an epsilon to avoid rounding issues.
+ *ray_start_region += LLViewerCamera::getInstance()->getAtAxis() * near_clip;
if( bypass_sim_raycast )
{
@@ -177,7 +184,7 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
if (regionp->getRegionFlags() & REGION_FLAGS_SANDBOX)
{
- LLFirstUse::useSandbox();
+ //LLFirstUse::useSandbox();
}
// Set params for new object based on its PCode.
@@ -216,8 +223,8 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
// Play creation sound
if (gAudiop)
{
- F32 volume = gSavedSettings.getBOOL("MuteUI") ? 0.f : gSavedSettings.getF32("AudioLevelUI");
- gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")), gAgent.getID(), volume);
+ gAudiop->triggerSound( LLUUID(gSavedSettings.getString("UISndObjectCreate")),
+ gAgent.getID(), 1.0f, LLAudioEngine::AUDIO_TYPE_UI);
}
gMessageSystem->newMessageFast(_PREHASH_ObjectAdd);
@@ -415,18 +422,18 @@ BOOL LLToolPlacer::addObject( LLPCode pcode, S32 x, S32 y, U8 use_physics )
// Spawns a message, so must be after above send
if (create_selected)
{
- gSelectMgr->deselectAll();
+ LLSelectMgr::getInstance()->deselectAll();
gViewerWindow->getWindow()->incBusyCount();
}
// VEFFECT: AddObject
- LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
- effectp->setSourceObject((LLViewerObject*)gAgent.getAvatarObject());
+ LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE);
+ effectp->setSourceObject((LLViewerObject*)gAgentAvatarp);
effectp->setPositionGlobal(regionp->getPosGlobalFromRegion(ray_end_region));
effectp->setDuration(LL_HUD_DUR_SHORT);
effectp->setColor(LLColor4U(gAgent.getEffectColor()));
- gViewerStats->incStat(LLViewerStats::ST_CREATE_COUNT);
+ LLViewerStats::getInstance()->incStat(LLViewerStats::ST_CREATE_COUNT);
return TRUE;
}
@@ -468,7 +475,7 @@ BOOL LLToolPlacer::addDuplicate(S32 x, S32 y)
ray_target_id.setNull();
}
- gSelectMgr->selectDuplicateOnRay(ray_start_region,
+ LLSelectMgr::getInstance()->selectDuplicateOnRay(ray_start_region,
ray_end_region,
b_hit_land, // suppress raycast
FALSE, // intersection
@@ -480,7 +487,7 @@ BOOL LLToolPlacer::addDuplicate(S32 x, S32 y)
if (regionp
&& (regionp->getRegionFlags() & REGION_FLAGS_SANDBOX))
{
- LLFirstUse::useSandbox();
+ //LLFirstUse::useSandbox();
}
return TRUE;
@@ -503,7 +510,7 @@ BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask)
// ...and go back to the default tool
if (added && !gSavedSettings.getBOOL("CreateToolKeepSelected"))
{
- gToolMgr->getCurrentToolset()->selectTool( gToolTranslate );
+ LLToolMgr::getInstance()->getCurrentToolset()->selectTool( LLToolCompTranslate::getInstance() );
}
return added;
@@ -512,7 +519,7 @@ BOOL LLToolPlacer::placeObject(S32 x, S32 y, MASK mask)
BOOL LLToolPlacer::handleHover(S32 x, S32 y, MASK mask)
{
lldebugst(LLERR_USER_INPUT) << "hover handled by LLToolPlacer" << llendl;
- gViewerWindow->getWindow()->setCursor(UI_CURSOR_TOOLCREATE);
+ gViewerWindow->setCursor(UI_CURSOR_TOOLCREATE);
return TRUE;
}
@@ -525,92 +532,3 @@ void LLToolPlacer::handleDeselect()
{
}
-//////////////////////////////////////////////////////
-// LLToolPlacerPanel
-
-// static
-LLPCode LLToolPlacerPanel::sCube = LL_PCODE_CUBE;
-LLPCode LLToolPlacerPanel::sPrism = LL_PCODE_PRISM;
-LLPCode LLToolPlacerPanel::sPyramid = LL_PCODE_PYRAMID;
-LLPCode LLToolPlacerPanel::sTetrahedron = LL_PCODE_TETRAHEDRON;
-LLPCode LLToolPlacerPanel::sCylinder = LL_PCODE_CYLINDER;
-LLPCode LLToolPlacerPanel::sCylinderHemi= LL_PCODE_CYLINDER_HEMI;
-LLPCode LLToolPlacerPanel::sCone = LL_PCODE_CONE;
-LLPCode LLToolPlacerPanel::sConeHemi = LL_PCODE_CONE_HEMI;
-LLPCode LLToolPlacerPanel::sTorus = LL_PCODE_TORUS;
-LLPCode LLToolPlacerPanel::sSquareTorus = LLViewerObject::LL_VO_SQUARE_TORUS;
-LLPCode LLToolPlacerPanel::sTriangleTorus = LLViewerObject::LL_VO_TRIANGLE_TORUS;
-LLPCode LLToolPlacerPanel::sSphere = LL_PCODE_SPHERE;
-LLPCode LLToolPlacerPanel::sSphereHemi = LL_PCODE_SPHERE_HEMI;
-LLPCode LLToolPlacerPanel::sTree = LL_PCODE_LEGACY_TREE;
-LLPCode LLToolPlacerPanel::sGrass = LL_PCODE_LEGACY_GRASS;
-
-S32 LLToolPlacerPanel::sButtonsAdded = 0;
-LLButton* LLToolPlacerPanel::sButtons[ TOOL_PLACER_NUM_BUTTONS ];
-
-LLToolPlacerPanel::LLToolPlacerPanel(const std::string& name, const LLRect& rect)
- :
- LLPanel( name, rect )
-{
- /* DEPRECATED - JC
- addButton( "UIImgCubeUUID", "UIImgCubeSelectedUUID", &LLToolPlacerPanel::sCube );
- addButton( "UIImgPrismUUID", "UIImgPrismSelectedUUID", &LLToolPlacerPanel::sPrism );
- addButton( "UIImgPyramidUUID", "UIImgPyramidSelectedUUID", &LLToolPlacerPanel::sPyramid );
- addButton( "UIImgTetrahedronUUID", "UIImgTetrahedronSelectedUUID", &LLToolPlacerPanel::sTetrahedron );
- addButton( "UIImgCylinderUUID", "UIImgCylinderSelectedUUID", &LLToolPlacerPanel::sCylinder );
- addButton( "UIImgHalfCylinderUUID", "UIImgHalfCylinderSelectedUUID",&LLToolPlacerPanel::sCylinderHemi );
- addButton( "UIImgConeUUID", "UIImgConeSelectedUUID", &LLToolPlacerPanel::sCone );
- addButton( "UIImgHalfConeUUID", "UIImgHalfConeSelectedUUID", &LLToolPlacerPanel::sConeHemi );
- addButton( "UIImgSphereUUID", "UIImgSphereSelectedUUID", &LLToolPlacerPanel::sSphere );
- addButton( "UIImgHalfSphereUUID", "UIImgHalfSphereSelectedUUID", &LLToolPlacerPanel::sSphereHemi );
- addButton( "UIImgTreeUUID", "UIImgTreeSelectedUUID", &LLToolPlacerPanel::sTree );
- addButton( "UIImgGrassUUID", "UIImgGrassSelectedUUID", &LLToolPlacerPanel::sGrass );
- addButton( "ObjectTorusImageID", "ObjectTorusActiveImageID", &LLToolPlacerPanel::sTorus );
- addButton( "ObjectTubeImageID", "ObjectTubeActiveImageID", &LLToolPlacerPanel::sSquareTorus );
- */
-}
-
-void LLToolPlacerPanel::addButton( const LLString& up_state, const LLString& down_state, LLPCode* pcode )
-{
- const S32 TOOL_SIZE = 32;
- const S32 HORIZ_SPACING = TOOL_SIZE + 5;
- const S32 VERT_SPACING = TOOL_SIZE + 5;
- const S32 VPAD = 10;
- const S32 HPAD = 7;
-
- S32 row = sButtonsAdded / 4;
- S32 column = sButtonsAdded % 4;
-
- LLRect help_rect = gSavedSettings.getRect("ToolHelpRect");
-
- // Build the rectangle, recalling the origin is at lower left
- // and we want the icons to build down from the top.
- LLRect rect;
- rect.setLeftTopAndSize(
- HPAD + (column * HORIZ_SPACING),
- help_rect.mBottom - VPAD - (row * VERT_SPACING),
- TOOL_SIZE,
- TOOL_SIZE );
-
- LLButton* btn = new LLButton(
- "ToolPlacerOptBtn",
- rect,
- up_state,
- down_state,
- "", &LLToolPlacerPanel::setObjectType,
- pcode,
- LLFontGL::sSansSerif);
- btn->setFollowsBottom();
- btn->setFollowsLeft();
- addChild(btn);
-
- sButtons[sButtonsAdded] = btn;
- sButtonsAdded++;
-}
-
-// static
-void LLToolPlacerPanel::setObjectType( void* data )
-{
- LLPCode pcode = *(LLPCode*) data;
- LLToolPlacer::setObjectType( pcode );
-}