llhudeffectlookat.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /**
  2. * @file llhudeffectlookat.h
  3. * @brief LLHUDEffectLookAt class definition
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewergpl$
  6. *
  7. * Copyright (c) 2002-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_LLHUDEFFECTLOOKAT_H
  33. #define LL_LLHUDEFFECTLOOKAT_H
  34. #include "llhudeffect.h"
  35. class LLViewerObject;
  36. class LLVOAvatar;
  37. class LLAttentionSet;
  38. typedef enum e_lookat_type
  39. {
  40. LOOKAT_TARGET_NONE,
  41. LOOKAT_TARGET_IDLE,
  42. LOOKAT_TARGET_AUTO_LISTEN,
  43. LOOKAT_TARGET_FREELOOK,
  44. LOOKAT_TARGET_RESPOND,
  45. LOOKAT_TARGET_HOVER,
  46. LOOKAT_TARGET_CONVERSATION,
  47. LOOKAT_TARGET_SELECT,
  48. LOOKAT_TARGET_FOCUS,
  49. LOOKAT_TARGET_MOUSELOOK,
  50. LOOKAT_TARGET_CLEAR,
  51. LOOKAT_NUM_TARGETS
  52. } ELookAtType;
  53. class LLHUDEffectLookAt final : public LLHUDEffect
  54. {
  55. friend class LLHUDObject;
  56. protected:
  57. LOG_CLASS(LLHUDEffectLookAt);
  58. public:
  59. void markDead() override;
  60. void setSourceObject(LLViewerObject* objectp) override;
  61. bool setLookAt(ELookAtType target_type, LLViewerObject* object,
  62. LLVector3 position);
  63. void clearLookAtTarget();
  64. LL_INLINE ELookAtType getLookAtType() { return mTargetType; }
  65. LL_INLINE const LLVector3& getTargetPos() { return mTargetPos; }
  66. LL_INLINE const LLVector3d& getTargetOffset() { return mTargetOffsetGlobal; }
  67. LL_INLINE bool calcTargetPosition();
  68. static void updateSettings();
  69. protected:
  70. LLHUDEffectLookAt(U8 type);
  71. ~LLHUDEffectLookAt() override = default;
  72. void update() override;
  73. void render() override;
  74. void packData(LLMessageSystem* mesgsys) override;
  75. void unpackData(LLMessageSystem* mesgsys, S32 blocknum) override;
  76. // Look-at behavior has either target position or target object with offset
  77. void setTargetObjectAndOffset(LLViewerObject* objp,
  78. const LLVector3d& offset);
  79. void setTargetPosGlobal(const LLVector3d &target_pos_global);
  80. public:
  81. static bool sDebugLookAt;
  82. private:
  83. ELookAtType mTargetType;
  84. LLVector3d mTargetOffsetGlobal;
  85. LLVector3 mLastSentOffsetGlobal;
  86. F32 mKillTime;
  87. F32 mNotifyTime;
  88. LLFrameTimer mTimer;
  89. LLVector3 mTargetPos;
  90. F32 mLastSendTime;
  91. LLAttentionSet* mAttentions;
  92. bool mNotified;
  93. static U32 sMaxLookAtBroadcastDist;
  94. };
  95. #endif // LL_LLHUDEFFECTLOOKAT_H