PageRenderTime 42ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llflexibleobject.h

https://bitbucket.org/lindenlab/viewer-beta/
C Header | 147 lines | 74 code | 18 blank | 55 comment | 0 complexity | 066f40e065fe7987dd465dd4e60f6dd7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llflexibleobject.h
  3. * @author JJ Ventrella, Andrew Meadows, Tom Yedwab
  4. * @brief Flexible object definition
  5. *
  6. * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. /**
  28. * This is for specifying objects in the world that are animated and
  29. * rendered locally - on the viewer. Flexible Objects are linear arrays
  30. * of positions, which stay at a fixed distance from each other. One
  31. * position is fixed as an "anchor" and is attached to some other object
  32. * in the world, determined by the server. All the other positions are
  33. * updated according to local physics.
  34. */
  35. #ifndef LL_LLFLEXIBLEOBJECT_H
  36. #define LL_LLFLEXIBLEOBJECT_H
  37. #include "llprimitive.h"
  38. #include "llvovolume.h"
  39. #include "llwind.h"
  40. // 10 ms for the whole thing!
  41. const F32 FLEXIBLE_OBJECT_TIMESLICE = 0.003f;
  42. const U32 FLEXIBLE_OBJECT_MAX_LOD = 10;
  43. // See llprimitive.h for LLFlexibleObjectData and DEFAULT/MIN/MAX values
  44. //-------------------------------------------------------------------
  45. struct LLFlexibleObjectSection
  46. {
  47. // Input parameters
  48. LLVector2 mScale;
  49. LLQuaternion mAxisRotation;
  50. // Simulated state
  51. LLVector3 mPosition;
  52. LLVector3 mVelocity;
  53. LLVector3 mDirection;
  54. LLQuaternion mRotation;
  55. // Derivatives (Not all currently used, will come back with LLVolume changes to automagically generate normals)
  56. LLVector3 mdPosition;
  57. //LLMatrix4 mRotScale;
  58. //LLMatrix4 mdRotScale;
  59. };
  60. //---------------------------------------------------------
  61. // The LLVolumeImplFlexible class
  62. //---------------------------------------------------------
  63. class LLVolumeImplFlexible : public LLVolumeInterface
  64. {
  65. public:
  66. LLVolumeImplFlexible(LLViewerObject* volume, LLFlexibleObjectData* attributes);
  67. // Implements LLVolumeInterface
  68. U32 getID() const { return mID; }
  69. LLVector3 getFramePosition() const;
  70. LLQuaternion getFrameRotation() const;
  71. LLVolumeInterfaceType getInterfaceType() const { return INTERFACE_FLEXIBLE; }
  72. BOOL doIdleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  73. BOOL doUpdateGeometry(LLDrawable *drawable);
  74. LLVector3 getPivotPosition() const;
  75. void onSetVolume(const LLVolumeParams &volume_params, const S32 detail);
  76. void onSetScale(const LLVector3 &scale, BOOL damped);
  77. void onParameterChanged(U16 param_type, LLNetworkData *data, BOOL in_use, bool local_origin);
  78. void onShift(const LLVector4a &shift_vector);
  79. bool isVolumeUnique() const { return true; }
  80. bool isVolumeGlobal() const { return true; }
  81. bool isActive() const { return true; }
  82. const LLMatrix4& getWorldMatrix(LLXformMatrix* xform) const;
  83. void updateRelativeXform();
  84. void doFlexibleUpdate(); // Called to update the simulation
  85. void doFlexibleRebuild(); // Called to rebuild the geometry
  86. void preRebuild();
  87. //void setAttributes( LLFlexibleObjectData );
  88. void setParentPositionAndRotationDirectly( LLVector3 p, LLQuaternion r );
  89. void setUsingCollisionSphere( bool u );
  90. void setCollisionSphere( LLVector3 position, F32 radius );
  91. void setRenderingCollisionSphere( bool r);
  92. LLVector3 getEndPosition();
  93. LLQuaternion getEndRotation();
  94. LLVector3 getNodePosition( int nodeIndex );
  95. LLVector3 getAnchorPosition() const;
  96. private:
  97. //--------------------------------------
  98. // private members
  99. //--------------------------------------
  100. // Backlink only; don't make this an LLPointer.
  101. LLViewerObject* mVO;
  102. LLTimer mTimer;
  103. LLVector3 mAnchorPosition;
  104. LLVector3 mParentPosition;
  105. LLQuaternion mParentRotation;
  106. LLQuaternion mLastFrameRotation;
  107. LLQuaternion mLastSegmentRotation;
  108. BOOL mInitialized;
  109. BOOL mUpdated;
  110. LLFlexibleObjectData* mAttributes;
  111. LLFlexibleObjectSection mSection [ (1<<FLEXIBLE_OBJECT_MAX_SECTIONS)+1 ];
  112. S32 mInitializedRes;
  113. S32 mSimulateRes;
  114. S32 mRenderRes;
  115. U32 mFrameNum;
  116. LLVector3 mCollisionSpherePosition;
  117. F32 mCollisionSphereRadius;
  118. U32 mID;
  119. //--------------------------------------
  120. // private methods
  121. //--------------------------------------
  122. void setAttributesOfAllSections (LLVector3* inScale = NULL);
  123. void remapSections(LLFlexibleObjectSection *source, S32 source_sections,
  124. LLFlexibleObjectSection *dest, S32 dest_sections);
  125. public:
  126. // Global setting for update rate
  127. static F32 sUpdateFactor;
  128. };// end of class definition
  129. #endif // LL_LLFLEXIBLEOBJECT_H