PageRenderTime 13ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmath/llvolumeoctree.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 134 lines | 82 code | 26 blank | 26 comment | 0 complexity | 00f45f786ff493edea6ed2b5c7f0b46a MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llvolumeoctree.h
  3. * @brief LLVolume octree classes.
  4. *
  5. * $LicenseInfo:firstyear=2002&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_LLVOLUME_OCTREE_H
  27. #define LL_LLVOLUME_OCTREE_H
  28. #include "linden_common.h"
  29. #include "llmemory.h"
  30. #include "lloctree.h"
  31. #include "llvolume.h"
  32. #include "llvector4a.h"
  33. class LLVolumeTriangle : public LLRefCount
  34. {
  35. public:
  36. LLVolumeTriangle()
  37. {
  38. }
  39. LLVolumeTriangle(const LLVolumeTriangle& rhs)
  40. {
  41. *this = rhs;
  42. }
  43. const LLVolumeTriangle& operator=(const LLVolumeTriangle& rhs)
  44. {
  45. llerrs << "Illegal operation!" << llendl;
  46. return *this;
  47. }
  48. ~LLVolumeTriangle()
  49. {
  50. }
  51. LLVector4a mPositionGroup;
  52. const LLVector4a* mV[3];
  53. U16 mIndex[3];
  54. F32 mRadius;
  55. virtual const LLVector4a& getPositionGroup() const;
  56. virtual const F32& getBinRadius() const;
  57. };
  58. class LLVolumeOctreeListener : public LLOctreeListener<LLVolumeTriangle>
  59. {
  60. public:
  61. LLVolumeOctreeListener(LLOctreeNode<LLVolumeTriangle>* node);
  62. ~LLVolumeOctreeListener();
  63. LLVolumeOctreeListener(const LLVolumeOctreeListener& rhs)
  64. {
  65. *this = rhs;
  66. }
  67. const LLVolumeOctreeListener& operator=(const LLVolumeOctreeListener& rhs)
  68. {
  69. llerrs << "Illegal operation!" << llendl;
  70. return *this;
  71. }
  72. //LISTENER FUNCTIONS
  73. virtual void handleChildAddition(const LLOctreeNode<LLVolumeTriangle>* parent,
  74. LLOctreeNode<LLVolumeTriangle>* child);
  75. virtual void handleStateChange(const LLTreeNode<LLVolumeTriangle>* node) { }
  76. virtual void handleChildRemoval(const LLOctreeNode<LLVolumeTriangle>* parent,
  77. const LLOctreeNode<LLVolumeTriangle>* child) { }
  78. virtual void handleInsertion(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
  79. virtual void handleRemoval(const LLTreeNode<LLVolumeTriangle>* node, LLVolumeTriangle* tri) { }
  80. virtual void handleDestruction(const LLTreeNode<LLVolumeTriangle>* node) { }
  81. public:
  82. LLVector4a mBounds[2]; // bounding box (center, size) of this node and all its children (tight fit to objects)
  83. LLVector4a mExtents[2]; // extents (min, max) of this node and all its children
  84. };
  85. class LLOctreeTriangleRayIntersect : public LLOctreeTraveler<LLVolumeTriangle>
  86. {
  87. public:
  88. const LLVolumeFace* mFace;
  89. LLVector4a mStart;
  90. LLVector4a mDir;
  91. LLVector4a mEnd;
  92. LLVector3* mIntersection;
  93. LLVector2* mTexCoord;
  94. LLVector3* mNormal;
  95. LLVector3* mBinormal;
  96. F32* mClosestT;
  97. bool mHitFace;
  98. LLOctreeTriangleRayIntersect(const LLVector4a& start, const LLVector4a& dir,
  99. const LLVolumeFace* face, F32* closest_t,
  100. LLVector3* intersection,LLVector2* tex_coord, LLVector3* normal, LLVector3* bi_normal);
  101. void traverse(const LLOctreeNode<LLVolumeTriangle>* node);
  102. virtual void visit(const LLOctreeNode<LLVolumeTriangle>* node);
  103. };
  104. class LLVolumeOctreeValidate : public LLOctreeTraveler<LLVolumeTriangle>
  105. {
  106. virtual void visit(const LLOctreeNode<LLVolumeTriangle>* branch);
  107. };
  108. #endif