PageRenderTime 337ms CodeModel.GetById 162ms app.highlight 15ms RepoModel.GetById 95ms app.codeStats 0ms

/indra/newview/llmanipscale.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 168 lines | 111 code | 29 blank | 28 comment | 5 complexity | 1750da34a649df53c8b7f71ef06acf6d MD5 | raw file
  1/** 
  2 * @file llmanipscale.h
  3 * @brief LLManipScale class definition
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_MANIPSCALE_H
 28#define LL_MANIPSCALE_H
 29
 30// llmanipscale.h
 31//
 32// copyright 2001-2002, linden research inc
 33
 34
 35#include "lltool.h"
 36#include "v3math.h"
 37#include "v4math.h"
 38#include "llmanip.h"
 39#include "llviewerobject.h"
 40#include "llbbox.h"
 41
 42
 43F32 get_default_max_prim_scale(bool is_flora = false);
 44
 45class LLToolComposite;
 46class LLColor4;
 47
 48typedef	enum e_scale_manipulator_type
 49{
 50	SCALE_MANIP_CORNER,
 51	SCALE_MANIP_FACE
 52} EScaleManipulatorType;
 53
 54
 55class LLManipScale : public LLManip
 56{
 57public:
 58	class ManipulatorHandle
 59	{
 60	public:
 61		LLVector3	mPosition;
 62		EManipPart	mManipID;
 63		EScaleManipulatorType			mType;
 64
 65		ManipulatorHandle(LLVector3 pos, EManipPart id, EScaleManipulatorType type):mPosition(pos), mManipID(id), mType(type){}
 66	};
 67
 68
 69	LLManipScale( LLToolComposite* composite );
 70	~LLManipScale();
 71
 72	virtual BOOL	handleMouseDown( S32 x, S32 y, MASK mask );
 73	virtual BOOL	handleMouseUp( S32 x, S32 y, MASK mask );
 74	virtual BOOL	handleHover( S32 x, S32 y, MASK mask );
 75	virtual void	render();
 76	virtual void	handleSelect();
 77
 78	virtual BOOL	handleMouseDownOnPart(S32 x, S32 y, MASK mask);
 79	virtual void	highlightManipulators(S32 x, S32 y);	// decided which manipulator, if any, should be highlighted by mouse hover
 80	virtual BOOL	canAffectSelection();
 81
 82	static void		setUniform( BOOL b );
 83	static BOOL		getUniform();
 84	static void		setStretchTextures( BOOL b );
 85	static BOOL		getStretchTextures();
 86	static void		setShowAxes( BOOL b );
 87	static BOOL		getShowAxes();
 88
 89private:
 90	void			renderCorners( const LLBBox& local_bbox );
 91	void			renderFaces( const LLBBox& local_bbox );
 92	void			renderEdges( const LLBBox& local_bbox );
 93	void			renderBoxHandle( F32 x, F32 y, F32 z );
 94	void			renderAxisHandle( const LLVector3& start, const LLVector3& end );
 95	void			renderGuidelinesPart( const LLBBox& local_bbox );
 96	void			renderSnapGuides( const LLBBox& local_bbox );
 97
 98	void			revert();
 99	
100	inline void		conditionalHighlight( U32 part, const LLColor4* highlight = NULL, const LLColor4* normal = NULL );
101
102	void			drag( S32 x, S32 y );
103	void			dragFace( S32 x, S32 y );
104	void			dragCorner( S32 x, S32 y );
105
106	void			sendUpdates( BOOL send_position_update, BOOL send_scale_update, BOOL corner = FALSE);
107
108	LLVector3		faceToUnitVector( S32 part ) const;
109	LLVector3		cornerToUnitVector( S32 part ) const;
110	LLVector3		edgeToUnitVector( S32 part ) const;
111	LLVector3		partToUnitVector( S32 part ) const;
112	LLVector3		unitVectorToLocalBBoxExtent( const LLVector3& v, const LLBBox& bbox ) const;
113	F32				partToMaxScale( S32 part, const LLBBox& bbox ) const;
114	F32				partToMinScale( S32 part, const LLBBox& bbox ) const;
115	LLVector3		nearestAxis( const LLVector3& v ) const;
116
117	void			stretchFace( const LLVector3& drag_start_agent, const LLVector3& drag_delta_agent);
118
119	void			adjustTextureRepeats();		// Adjusts texture coords based on mSavedScale and current scale, only works for boxes
120
121	void			updateSnapGuides(const LLBBox& bbox);
122private:
123
124	struct compare_manipulators
125	{
126		bool operator() (const ManipulatorHandle* const a, const ManipulatorHandle* const b) const
127		{
128			if (a->mType != b->mType)
129				return a->mType < b->mType;
130			else if (a->mPosition.mV[VZ] != b->mPosition.mV[VZ])
131				return a->mPosition.mV[VZ] < b->mPosition.mV[VZ];
132			else
133				return a->mManipID < b->mManipID;
134		}
135	};
136
137
138	F32				mBoxHandleSize;		// The size of the handles at the corners of the bounding box
139	F32				mScaledBoxHandleSize; // handle size after scaling for selection feedback
140	LLVector3d		mDragStartPointGlobal;
141	LLVector3d		mDragStartCenterGlobal;	// The center of the bounding box of all selected objects at time of drag start
142	LLVector3d		mDragPointGlobal;
143	LLVector3d 		mDragFarHitGlobal;
144	S32				mLastMouseX;
145	S32				mLastMouseY;
146	BOOL			mSendUpdateOnMouseUp;
147	U32 			mLastUpdateFlags;
148	typedef std::set<ManipulatorHandle*, compare_manipulators> minpulator_list_t;
149	minpulator_list_t mProjectedManipulators;
150	LLVector4		mManipulatorVertices[14];
151	F32				mScaleSnapUnit1;  // size of snap multiples for axis 1
152	F32				mScaleSnapUnit2;  // size of snap multiples for axis 2
153	LLVector3		mScalePlaneNormal1; // normal of plane in which scale occurs that most faces camera
154	LLVector3		mScalePlaneNormal2; // normal of plane in which scale occurs that most faces camera
155	LLVector3		mSnapGuideDir1;
156	LLVector3		mSnapGuideDir2;
157	LLVector3		mSnapDir1;
158	LLVector3		mSnapDir2;
159	F32				mSnapRegimeOffset;
160	F32				mSnapGuideLength;
161	LLVector3		mScaleCenter;
162	LLVector3		mScaleDir;
163	F32				mScaleSnapValue;
164	BOOL			mInSnapRegime;
165	F32*			mManipulatorScales;
166};
167
168#endif  // LL_MANIPSCALE_H