llkeyframewalkmotion.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * @file llkeyframewalkmotion.h
  3. * @brief Implementation of LLKeframeWalkMotion 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_LLKEYFRAMEWALKMOTION_H
  33. #define LL_LLKEYFRAMEWALKMOTION_H
  34. #include "llcharacter.h"
  35. #include "llkeyframemotion.h"
  36. #include "llpreprocessor.h"
  37. #include "llvector3d.h"
  38. #define MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST (20.f)
  39. #define MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST (20.f)
  40. class LLKeyframeWalkMotion final : public LLKeyframeMotion
  41. {
  42. friend class LLWalkAdjustMotion;
  43. protected:
  44. LOG_CLASS(LLKeyframeWalkMotion);
  45. public:
  46. LLKeyframeWalkMotion(const LLUUID& id);
  47. LL_INLINE static LLMotion* create(const LLUUID& id)
  48. {
  49. return new LLKeyframeWalkMotion(id);
  50. }
  51. LLMotionInitStatus onInitialize(LLCharacter* character) override;
  52. bool onActivate() override;
  53. void onDeactivate() override;
  54. bool onUpdate(F32 time, U8* joint_mask) override;
  55. public:
  56. LLCharacter* mCharacter;
  57. F32 mRealTimeLast;
  58. F32 mAdjTimeLast;
  59. };
  60. class LLWalkAdjustMotion final : public LLMotion
  61. {
  62. protected:
  63. LOG_CLASS(LLWalkAdjustMotion);
  64. public:
  65. LLWalkAdjustMotion(const LLUUID& id);
  66. LL_INLINE static LLMotion* create(const LLUUID& id) { return new LLWalkAdjustMotion(id); }
  67. public:
  68. LLMotionInitStatus onInitialize(LLCharacter* character) override;
  69. bool onActivate() override;
  70. void onDeactivate() override;
  71. bool onUpdate(F32 time, U8* joint_mask) override;
  72. LL_INLINE LLJoint::JointPriority getPriority() override { return LLJoint::HIGH_PRIORITY; }
  73. LL_INLINE bool getLoop() override { return true; }
  74. LL_INLINE F32 getDuration() override { return 0.f; }
  75. LL_INLINE F32 getEaseInDuration() override { return 0.f; }
  76. LL_INLINE F32 getEaseOutDuration() override { return 0.f; }
  77. LL_INLINE F32 getMinPixelArea() override { return MIN_REQUIRED_PIXEL_AREA_WALK_ADJUST; }
  78. LL_INLINE LLMotionBlendType getBlendType() override { return ADDITIVE_BLEND; }
  79. public:
  80. LLCharacter* mCharacter;
  81. LLJoint* mLeftAnkleJoint;
  82. LLJoint* mRightAnkleJoint;
  83. LLPointer<LLJointState> mPelvisState;
  84. LLJoint* mPelvisJoint;
  85. LLVector3d mLastLeftAnklePos;
  86. LLVector3d mLastRightAnklePos;
  87. F32 mLastTime;
  88. F32 mAvgCorrection;
  89. F32 mSpeedAdjust;
  90. F32 mAnimSpeed;
  91. F32 mAvgSpeed;
  92. F32 mRelativeDir;
  93. LLVector3 mPelvisOffset;
  94. F32 mAnkleOffset;
  95. };
  96. class LLFlyAdjustMotion final : public LLMotion
  97. {
  98. protected:
  99. LOG_CLASS(LLFlyAdjustMotion);
  100. public:
  101. LLFlyAdjustMotion(const LLUUID& id);
  102. LL_INLINE static LLMotion* create(const LLUUID& id) { return new LLFlyAdjustMotion(id); }
  103. public:
  104. LLMotionInitStatus onInitialize(LLCharacter* character) override;
  105. bool onActivate() override;
  106. LL_INLINE void onDeactivate() override {}
  107. bool onUpdate(F32 time, U8* joint_mask) override;
  108. LL_INLINE LLJoint::JointPriority getPriority() override { return LLJoint::HIGHER_PRIORITY; }
  109. LL_INLINE bool getLoop() override { return true; }
  110. LL_INLINE F32 getDuration() override { return 0.f; }
  111. LL_INLINE F32 getEaseInDuration() override { return 0.f; }
  112. LL_INLINE F32 getEaseOutDuration() override { return 0.f; }
  113. LL_INLINE F32 getMinPixelArea() override { return MIN_REQUIRED_PIXEL_AREA_FLY_ADJUST; }
  114. LL_INLINE LLMotionBlendType getBlendType() override { return ADDITIVE_BLEND; }
  115. protected:
  116. LLCharacter* mCharacter;
  117. LLPointer<LLJointState> mPelvisState;
  118. F32 mRoll;
  119. };
  120. #endif // LL_LLKeyframeWalkMotion_H