llvograss.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /**
  2. * @file llvograss.h
  3. * @brief Description of LLVOGrass class
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewergpl$
  6. *
  7. * Copyright (c) 2001-2009, Linden Research, Inc.
  8. *
  9. * Second Life Viewer Source Code
  10. * The source code in this file ("Source Code") is provided by Linden Lab
  11. * to you under the terms of the GNU General Public License, version 2.0
  12. * ("GPL"), unless you have obtained a separate licensing agreement
  13. * ("Other License"), formally executed by you and Linden Lab. Terms of
  14. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  15. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  16. *
  17. * There are special exceptions to the terms and conditions of the GPL as
  18. * it is applied to this Source Code. View the full text of the exception
  19. * in the file doc/FLOSS-exception.txt in this software distribution, or
  20. * online at
  21. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  22. *
  23. * By copying, modifying or distributing this software, you acknowledge
  24. * that you have read and understood your obligations described above,
  25. * and agree to abide by those obligations.
  26. *
  27. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  28. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  29. * COMPLETENESS OR PERFORMANCE.
  30. * $/LicenseInfo$
  31. */
  32. #ifndef LL_LLVOGRASS_H
  33. #define LL_LLVOGRASS_H
  34. #include <map>
  35. #include "llviewerobject.h"
  36. class LLSelectNode;
  37. class LLSurfacePatch;
  38. class LLViewerTexture;
  39. class LLVOGrass final : public LLAlphaObject
  40. {
  41. protected:
  42. LOG_CLASS(LLVOGrass);
  43. ~LLVOGrass() override = default;
  44. public:
  45. LLVOGrass(const LLUUID& id, LLViewerRegion* regionp);
  46. // Initialize data that is only initialized once per class.
  47. static void initClass();
  48. static void cleanupClass();
  49. U32 getPartitionType() const override;
  50. U32 processUpdateMessage(LLMessageSystem* mesgsys, void** user_data,
  51. U32 block_num, EObjectUpdateType upd_type,
  52. LLDataPacker* dp) override;
  53. static void import(LLFILE* file, LLMessageSystem* mesgsys,
  54. const LLVector3& pos);
  55. void exportFile(LLFILE* file, const LLVector3& position);
  56. void updateDrawable(bool force_damped) override;
  57. LLDrawable* createDrawable() override;
  58. bool updateGeometry(LLDrawable* drawable) override;
  59. void getGeometry(S32 idx, LLStrider<LLVector4a>& verticesp,
  60. LLStrider<LLVector3>& normalsp,
  61. LLStrider<LLVector2>& texcoordsp,
  62. LLStrider<LLColor4U>& colorsp,
  63. LLStrider<LLColor4U>& emissivep,
  64. LLStrider<U16>& indicesp) override;
  65. LL_INLINE void updateFaceSize(S32 idx) override {}
  66. void updateTextures() override;
  67. bool updateLOD() override;
  68. // Generate accurate apparent angle and area
  69. void setPixelAreaAndAngle() override;
  70. void plantBlades();
  71. // Whether this object needs to do an idleUpdate:
  72. LL_INLINE bool isActive() const override { return true; }
  73. void idleUpdate(F64 time) override;
  74. bool lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
  75. // Which face to check, -1 = ALL_SIDES
  76. S32 face = -1,
  77. bool pick_transparent = false,
  78. bool pick_rigged = false,
  79. // Which face was hit
  80. S32* face_hit = NULL,
  81. // Intersection point
  82. LLVector4a* intersection = NULL,
  83. // Texture coordinates of the intersection point
  84. LLVector2* tex_coord = NULL,
  85. // Surface normal at the intersection point
  86. LLVector4a* normal = NULL,
  87. // Surface tangent at the intersection point
  88. LLVector4a* tangent = NULL) override;
  89. void generateSilhouette(LLSelectNode* nodep);
  90. private:
  91. void generateSilhouetteVertices(std::vector<LLVector3> &vertices,
  92. std::vector<LLVector3> &normals,
  93. const LLVector3& view_vec,
  94. const LLMatrix4& mat,
  95. const LLMatrix3& norm_mat);
  96. void updateSpecies();
  97. public:
  98. struct GrassSpeciesData
  99. {
  100. LLUUID mTextureID;
  101. F32 mBladeSizeX;
  102. F32 mBladeSizeY;
  103. };
  104. U64 mLastPatchUpdateTime;
  105. F32 mBladeSizeX;
  106. F32 mBladeSizeY;
  107. F32 mBWAOverlap;
  108. LLSurfacePatch* mPatch; // Stores the land patch where the grass is centered
  109. U8 mSpecies; // Species of grass
  110. static S32 sMaxGrassSpecies;
  111. typedef std::map<std::string, S32> species_list_t;
  112. static species_list_t sSpeciesNames;
  113. private:
  114. F32 mLastHeight; // For cheap update hack
  115. S32 mNumBlades;
  116. typedef std::map<U32, GrassSpeciesData*> data_map_t;
  117. static data_map_t sSpeciesTable;
  118. };
  119. #endif // LL_VO_GRASS_