llhudicon.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /**
  2. * @file llhudicon.h
  3. * @brief LLHUDIcon class definition
  4. *
  5. * $LicenseInfo:firstyear=2006&license=viewergpl$
  6. *
  7. * Copyright (c) 2006-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. // Renders a 2D icon billboard floating at the location specified.
  33. #ifndef LL_LLHUDICON_H
  34. #define LL_LLHUDICON_H
  35. #include <vector>
  36. #include "llframetimer.h"
  37. #include "lluuid.h"
  38. #include "llhudobject.h"
  39. class LLViewerTexture;
  40. class LLHUDIcon final : public LLHUDObject
  41. {
  42. friend class LLHUDObject;
  43. public:
  44. void render() override;
  45. void markDead() override;
  46. F32 getDistance() const override { return mDistance; }
  47. void setImage(LLViewerTexture* imagep);
  48. LL_INLINE void setScale(F32 fraction_of_fov) { mScale = fraction_of_fov; }
  49. void restartLifeTimer() { mLifeTimer.reset(); }
  50. static LLHUDIcon* lineSegmentIntersectAll(const LLVector4a& start,
  51. const LLVector4a& end,
  52. LLVector4a* intersection);
  53. static void cleanupDeadIcons();
  54. LL_INLINE static void updateAll() { cleanupDeadIcons(); }
  55. LL_INLINE static S32 getNumInstances() { return sIconInstances.size(); }
  56. bool getHidden() const { return mHidden; }
  57. void setHidden(bool hide) { mHidden = hide; }
  58. bool lineSegmentIntersect(const LLVector4a& start, const LLVector4a& end,
  59. LLVector4a* intersection);
  60. void setClickedCallback(void (*cb)(const LLUUID&)) { mClickedCallback = cb; }
  61. void fireClickedCallback(const LLUUID& id);
  62. public:
  63. static F32 MAX_VISIBLE_TIME;
  64. protected:
  65. LLHUDIcon(U8 type);
  66. ~LLHUDIcon() override;
  67. private:
  68. LLPointer<LLViewerTexture> mImagep;
  69. LLFrameTimer mAnimTimer;
  70. LLFrameTimer mLifeTimer;
  71. F32 mDistance;
  72. F32 mScale;
  73. bool mHidden;
  74. bool mIsScriptBugIcon;
  75. void (*mClickedCallback)(const LLUUID& id);
  76. typedef std::vector<LLPointer<LLHUDIcon> > icon_instance_t;
  77. static icon_instance_t sIconInstances;
  78. };
  79. #endif // LL_LLHUDICON_H