lltargetingmotion.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /**
  2. * @file lltargetingmotion.h
  3. * @brief Implementation of LLTargetingMotion class.
  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_LLTARGETINGMOTION_H
  33. #define LL_LLTARGETINGMOTION_H
  34. #include "llmotion.h"
  35. #define TARGETING_EASEIN_DURATION 0.3f
  36. #define TARGETING_EASEOUT_DURATION 0.5f
  37. #define TARGETING_PRIORITY LLJoint::HIGH_PRIORITY
  38. #define MIN_REQUIRED_PIXEL_AREA_TARGETING 1000.f;
  39. class LLTargetingMotion final : public LLMotion
  40. {
  41. protected:
  42. LOG_CLASS(LLTargetingMotion);
  43. public:
  44. LLTargetingMotion(const LLUUID& id);
  45. LL_INLINE static LLMotion* create(const LLUUID& id) { return new LLTargetingMotion(id); }
  46. // Motions must specify whether or not they loop
  47. LL_INLINE bool getLoop() override { return true; }
  48. // Motions must report their total duration
  49. LL_INLINE F32 getDuration() override { return 0.f; }
  50. // Motions must report their "ease in" duration
  51. LL_INLINE F32 getEaseInDuration() override { return TARGETING_EASEIN_DURATION; }
  52. // Motions must report their "ease out" duration.
  53. LL_INLINE F32 getEaseOutDuration() override { return TARGETING_EASEOUT_DURATION; }
  54. // Motions must report their priority
  55. LL_INLINE LLJoint::JointPriority getPriority() override { return TARGETING_PRIORITY; }
  56. LL_INLINE LLMotionBlendType getBlendType() override { return ADDITIVE_BLEND; }
  57. // Called to determine when a motion should be activated/deactivated based
  58. // on avatar pixel coverage
  59. LL_INLINE F32 getMinPixelArea() override { return MIN_REQUIRED_PIXEL_AREA_TARGETING; }
  60. // Run-time (post constructor) initialization, called after parameters have
  61. // been set. Must return true to indicate success and be available for
  62. // activation.
  63. LLMotionInitStatus onInitialize(LLCharacter* character) override;
  64. // Called when a motion is activated. Must return true to indicate success,
  65. // or else it will be deactivated.
  66. LL_INLINE bool onActivate() override { return true; }
  67. // Called per time step. Must return true while it is active, and must
  68. // return false when the motion is completed.
  69. bool onUpdate(F32 time, U8* joint_mask) override;
  70. // Called when a motion is deactivated
  71. LL_INLINE void onDeactivate() override {}
  72. public:
  73. LLCharacter* mCharacter;
  74. LLPointer<LLJointState> mTorsoState;
  75. LLJoint* mPelvisJoint;
  76. LLJoint* mTorsoJoint;
  77. LLJoint* mRightHandJoint;
  78. };
  79. #endif // LL_LLTARGETINGMOTION_H