PageRenderTime 35ms CodeModel.GetById 20ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_MANIPSCALE_H
  27. #define LL_MANIPSCALE_H
  28. // llmanipscale.h
  29. //
  30. // copyright 2001-2002, linden research inc
  31. #include "lltool.h"
  32. #include "v3math.h"
  33. #include "v4math.h"
  34. #include "llmanip.h"
  35. #include "llviewerobject.h"
  36. #include "llbbox.h"
  37. F32 get_default_max_prim_scale(bool is_flora = false);
  38. class LLToolComposite;
  39. class LLColor4;
  40. typedef enum e_scale_manipulator_type
  41. {
  42. SCALE_MANIP_CORNER,
  43. SCALE_MANIP_FACE
  44. } EScaleManipulatorType;
  45. class LLManipScale : public LLManip
  46. {
  47. public:
  48. class ManipulatorHandle
  49. {
  50. public:
  51. LLVector3 mPosition;
  52. EManipPart mManipID;
  53. EScaleManipulatorType mType;
  54. ManipulatorHandle(LLVector3 pos, EManipPart id, EScaleManipulatorType type):mPosition(pos), mManipID(id), mType(type){}
  55. };
  56. LLManipScale( LLToolComposite* composite );
  57. ~LLManipScale();
  58. virtual BOOL handleMouseDown( S32 x, S32 y, MASK mask );
  59. virtual BOOL handleMouseUp( S32 x, S32 y, MASK mask );
  60. virtual BOOL handleHover( S32 x, S32 y, MASK mask );
  61. virtual void render();
  62. virtual void handleSelect();
  63. virtual BOOL handleMouseDownOnPart(S32 x, S32 y, MASK mask);
  64. virtual void highlightManipulators(S32 x, S32 y); // decided which manipulator, if any, should be highlighted by mouse hover
  65. virtual BOOL canAffectSelection();
  66. static void setUniform( BOOL b );
  67. static BOOL getUniform();
  68. static void setStretchTextures( BOOL b );
  69. static BOOL getStretchTextures();
  70. static void setShowAxes( BOOL b );
  71. static BOOL getShowAxes();
  72. private:
  73. void renderCorners( const LLBBox& local_bbox );
  74. void renderFaces( const LLBBox& local_bbox );
  75. void renderEdges( const LLBBox& local_bbox );
  76. void renderBoxHandle( F32 x, F32 y, F32 z );
  77. void renderAxisHandle( const LLVector3& start, const LLVector3& end );
  78. void renderGuidelinesPart( const LLBBox& local_bbox );
  79. void renderSnapGuides( const LLBBox& local_bbox );
  80. void revert();
  81. inline void conditionalHighlight( U32 part, const LLColor4* highlight = NULL, const LLColor4* normal = NULL );
  82. void drag( S32 x, S32 y );
  83. void dragFace( S32 x, S32 y );
  84. void dragCorner( S32 x, S32 y );
  85. void sendUpdates( BOOL send_position_update, BOOL send_scale_update, BOOL corner = FALSE);
  86. LLVector3 faceToUnitVector( S32 part ) const;
  87. LLVector3 cornerToUnitVector( S32 part ) const;
  88. LLVector3 edgeToUnitVector( S32 part ) const;
  89. LLVector3 partToUnitVector( S32 part ) const;
  90. LLVector3 unitVectorToLocalBBoxExtent( const LLVector3& v, const LLBBox& bbox ) const;
  91. F32 partToMaxScale( S32 part, const LLBBox& bbox ) const;
  92. F32 partToMinScale( S32 part, const LLBBox& bbox ) const;
  93. LLVector3 nearestAxis( const LLVector3& v ) const;
  94. void stretchFace( const LLVector3& drag_start_agent, const LLVector3& drag_delta_agent);
  95. void adjustTextureRepeats(); // Adjusts texture coords based on mSavedScale and current scale, only works for boxes
  96. void updateSnapGuides(const LLBBox& bbox);
  97. private:
  98. struct compare_manipulators
  99. {
  100. bool operator() (const ManipulatorHandle* const a, const ManipulatorHandle* const b) const
  101. {
  102. if (a->mType != b->mType)
  103. return a->mType < b->mType;
  104. else if (a->mPosition.mV[VZ] != b->mPosition.mV[VZ])
  105. return a->mPosition.mV[VZ] < b->mPosition.mV[VZ];
  106. else
  107. return a->mManipID < b->mManipID;
  108. }
  109. };
  110. F32 mBoxHandleSize; // The size of the handles at the corners of the bounding box
  111. F32 mScaledBoxHandleSize; // handle size after scaling for selection feedback
  112. LLVector3d mDragStartPointGlobal;
  113. LLVector3d mDragStartCenterGlobal; // The center of the bounding box of all selected objects at time of drag start
  114. LLVector3d mDragPointGlobal;
  115. LLVector3d mDragFarHitGlobal;
  116. S32 mLastMouseX;
  117. S32 mLastMouseY;
  118. BOOL mSendUpdateOnMouseUp;
  119. U32 mLastUpdateFlags;
  120. typedef std::set<ManipulatorHandle*, compare_manipulators> minpulator_list_t;
  121. minpulator_list_t mProjectedManipulators;
  122. LLVector4 mManipulatorVertices[14];
  123. F32 mScaleSnapUnit1; // size of snap multiples for axis 1
  124. F32 mScaleSnapUnit2; // size of snap multiples for axis 2
  125. LLVector3 mScalePlaneNormal1; // normal of plane in which scale occurs that most faces camera
  126. LLVector3 mScalePlaneNormal2; // normal of plane in which scale occurs that most faces camera
  127. LLVector3 mSnapGuideDir1;
  128. LLVector3 mSnapGuideDir2;
  129. LLVector3 mSnapDir1;
  130. LLVector3 mSnapDir2;
  131. F32 mSnapRegimeOffset;
  132. F32 mSnapGuideLength;
  133. LLVector3 mScaleCenter;
  134. LLVector3 mScaleDir;
  135. F32 mScaleSnapValue;
  136. BOOL mInSnapRegime;
  137. F32* mManipulatorScales;
  138. };
  139. #endif // LL_MANIPSCALE_H