BVB Source Codes

CRYENGINE Show AnimatedCharacter.h Source code

Return Download CRYENGINE: download AnimatedCharacter.h Source code - Download CRYENGINE Source code - Type:.h
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. #ifndef __ANIMATEDCHARACTER_H__
  4. #define __ANIMATEDCHARACTER_H__
  5.  
  6. #pragma once
  7.  
  8. #include "IAnimatedCharacter.h"
  9. #include "IAnimationGraph.h"
  10. #include "AnimationGraphCVars.h" // this includes animated character cvars too
  11. #include <queue>
  12. #include <CryCore/BitFiddling.h>
  13. #include <CryAction/IDebugHistory.h>
  14. #include "CryActionPhysicQueues.h"
  15. #include "ICryMannequin.h"
  16. #include "Mannequin/MannequinAGState.h"
  17. #include "PersistantDebug.h"
  18. #include "IMovementController.h" // for SExactPositioningTarget
  19. #include "AnimatedCharacterEventProxies.h"
  20. #include <CryCore/Containers/CryListenerSet.h>
  21.  
  22. //--------------------------------------------------------------------------------
  23.  
  24. #define ANIMCHAR_PROFILE_HEAVY
  25.  
  26. //--------------------------------------------------------------------------------
  27.  
  28. #define ANIMCHAR_PROFILE FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION)
  29.  
  30. #ifdef ANIMCHAR_PROFILE_HEAVY
  31.         #define ANIMCHAR_PROFILE_DETAILED FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION)
  32. #else
  33.         #define ANIMCHAR_PROFILE_DETAILED {}
  34. #endif
  35.  
  36. #ifdef ANIMCHAR_PROFILE_HEAVY
  37.         #define ANIMCHAR_PROFILE_SCOPE(label) FRAME_PROFILER(label, GetISystem(), PROFILE_ACTION)
  38. #else
  39.         #define ANIMCHAR_PROFILE_SCOPE(label) {}
  40. #endif
  41.  
  42. //--------------------------------------------------------------------------------
  43.  
  44. #if defined(_DEBUG)
  45.         #define DEBUGHISTORY
  46. #endif
  47.  
  48. //--------------------------------------------------------------------------------
  49.  
  50. struct IAnimationBlending;
  51.  
  52. //--------------------------------------------------------------------------------
  53.  
  54. #if 0
  55.         #define ANIMCHAR_SIZED_VAR(type, name, bits) type name
  56. #else
  57.         #define ANIMCHAR_SIZED_VAR(type, name, bits) type name: bits
  58. #endif
  59.  
  60. //--------------------------------------------------------------------------------
  61.  
  62. struct IVec
  63. {
  64.         Vec3 normal;
  65.         Vec3 pos;
  66. };
  67.  
  68. //--------------------------------------------------------------------------------
  69.  
  70. enum EDebugHistoryID
  71. {
  72.         eDH_Undefined,
  73.  
  74.         eDH_FrameTime,
  75.  
  76.         eDH_TurnSpeed,
  77.         eDH_TravelSpeed,
  78.         eDH_TravelDist,
  79.         eDH_TravelDistScale,
  80.         eDH_TravelDirX,
  81.         eDH_TravelDirY,
  82.  
  83.         eDH_StateSelection_State,
  84.         eDH_StateSelection_StartTravelSpeed,
  85.         eDH_StateSelection_EndTravelSpeed,
  86.         eDH_StateSelection_TravelDistance,
  87.         eDH_StateSelection_StartTravelAngle,
  88.         eDH_StateSelection_EndTravelAngle,
  89.         eDH_StateSelection_EndBodyAngle,
  90.  
  91.         eDH_MovementControlMethodH,
  92.         eDH_MovementControlMethodV,
  93.  
  94.         eDH_EntMovementErrorTransX,
  95.         eDH_EntMovementErrorTransY,
  96.         eDH_EntMovementErrorRotZ,
  97.         eDH_EntTeleportMovementTransX,
  98.         eDH_EntTeleportMovementTransY,
  99.         eDH_EntTeleportMovementRotZ,
  100.         eDH_ProceduralAnimMovementTransX,
  101.         eDH_ProceduralAnimMovementTransY,
  102.         eDH_ProceduralAnimMovementRotZ,
  103.         eDH_AnimTargetCorrectionTransX,
  104.         eDH_AnimTargetCorrectionTransY,
  105.         eDH_AnimTargetCorrectionRotZ,
  106.         eDH_AnimAssetTransX,
  107.         eDH_AnimAssetTransY,
  108.         eDH_AnimAssetTransZ,
  109.         eDH_AnimAssetRotZ,
  110.  
  111.         eDH_EntLocationPosX,
  112.         eDH_EntLocationPosY,
  113.         eDH_EntLocationOriZ,
  114.  
  115.         eDH_AnimErrorDistance,
  116.         eDH_AnimErrorAngle,
  117.  
  118.         eDH_AnimEntityOffsetTransX,
  119.         eDH_AnimEntityOffsetTransY,
  120.         eDH_AnimEntityOffsetRotZ,
  121.  
  122.         eDH_ReqEntMovementTransX,
  123.         eDH_ReqEntMovementTransY,
  124.         eDH_ReqEntMovementRotZ,
  125.  
  126.         eDH_CarryCorrectionDistance,
  127.         eDH_CarryCorrectionAngle,
  128.  
  129.         eDH_TEMP00,
  130.         eDH_TEMP01,
  131.         eDH_TEMP02,
  132.         eDH_TEMP03,
  133.  
  134.         /*
  135.            eDH_EntityMoveSpeed,
  136.            eDH_EntityPhysSpeed,
  137.            eDH_ACRequestSpeed,
  138.          */
  139. };
  140.  
  141. //--------------------------------------------------------------------------------
  142.  
  143. enum EMCMComponent
  144. {
  145.         eMCMComponent_Horizontal = 0,
  146.         eMCMComponent_Vertical,
  147.  
  148.         eMCMComponent_COUNT,
  149. };
  150.  
  151. //--------------------------------------------------------------------------------
  152.  
  153. enum RequestedEntityMovementType
  154. {
  155.         RequestedEntMovementType_Undefined = -1,
  156.         RequestedEntMovementType_Absolute  = 1,
  157.         RequestedEntMovementType_Impulse   = 2, // Relative
  158. };
  159.  
  160. //--------------------------------------------------------------------------------
  161. struct IAnimatedCharacterListener
  162. {
  163.         virtual ~IAnimatedCharacterListener() {}
  164.         virtual void OnCharacterChange() = 0; // called when switching character or first -> third person switch
  165. };
  166.  
  167. //--------------------------------------------------------------------------------
  168. // TODO: Shuffle variable members around to better align and pack things tightly and reduce padding.
  169. class CAnimatedCharacter : public CGameObjectExtensionHelper<CAnimatedCharacter, IAnimatedCharacter>, public IAnimationGraphStateListener
  170. {
  171. public:
  172.         CAnimatedCharacter();
  173.         ~CAnimatedCharacter();
  174.  
  175.         // IAnimatedCharacter
  176.         virtual bool                 Init(IGameObject* pGameObject);
  177.         virtual void                 InitClient(int channelId)                                                       {};
  178.         virtual void                 PostInit(IGameObject* pGameObject);
  179.         virtual void                 PostInitClient(int channelId)                                                   {};
  180.         virtual bool                 ReloadExtension(IGameObject* pGameObject, const SEntitySpawnParams& params);
  181.         virtual void                 PostReloadExtension(IGameObject* pGameObject, const SEntitySpawnParams& params) {}
  182.         virtual void                 Release();
  183.         virtual void                 FullSerialize(TSerialize ser);
  184.         virtual bool                 NetSerialize(TSerialize ser, EEntityAspects aspect, uint8 profile, int flags) { return true; }
  185.         virtual void                 ProcessEvent(SEntityEvent& event);
  186.         virtual void                 PostSerialize();
  187.         virtual void                 SerializeSpawnInfo(TSerialize ser) {}
  188.         virtual ISerializableInfoPtr GetSpawnInfo()                     { return 0; }
  189.         virtual void                 Update(SEntityUpdateContext& ctx, int);
  190.         virtual void                 HandleEvent(const SGameObjectEvent&);
  191.         virtual void                 SetChannelId(uint16 id)     {}
  192.         virtual void                 SetAuthority(bool auth)     {}
  193.         virtual void                 PostUpdate(float frameTime) { CRY_ASSERT(false); }
  194.         virtual void                 PostRemoteSpawn()           {};
  195.         virtual void                 GetMemoryUsage(ICrySizer* s) const;
  196.  
  197.         virtual IActionController*   GetActionController()
  198.         {
  199.                 return m_pActionController;
  200.         }
  201.  
  202.         virtual const IActionController* GetActionController() const
  203.         {
  204.                 return m_pActionController;
  205.         }
  206.  
  207.         virtual void                             SetShadowCharacterSlot(int id);
  208.  
  209.         virtual void                             SetAnimationPlayerProxy(CAnimationPlayerProxy* proxy, int layer);
  210.         virtual CAnimationPlayerProxy*           GetAnimationPlayerProxy(int layer);
  211.  
  212.         virtual IAnimationGraphState*            GetAnimationGraphState()                  { return m_pMannequinAGState; }
  213.         virtual void                             PushForcedState(const char* state)        {}
  214.         virtual void                             ClearForcedStates()                       {}
  215.         virtual void                             ChangeGraph(const char* graph, int layer) {}
  216.  
  217.         virtual void                             AddMovement(const SCharacterMoveRequest& request);
  218.  
  219.         virtual const SPredictedCharacterStates& GetOverriddenMotionParameters() const                                            { return m_moveRequest.prediction; }
  220.         virtual void                             SetOverriddenMotionParameters(const SPredictedCharacterStates& motionParameters) { m_moveRequest.prediction = motionParameters; }
  221.         virtual void                             SetBlendWeightParam(const EMotionParamID motionParamID, const float value, const uint8 targetFlags = eBWPT_All);
  222.  
  223.         virtual void                             SetEntityRotation(const Quat& rot) {}
  224.  
  225.         virtual const SAnimatedCharacterParams& GetParams()                        { return m_params; }
  226.         virtual void                            SetParams(const SAnimatedCharacterParams& params);
  227.         virtual int                             GetCurrentStance();
  228.         virtual void                            RequestStance(int stanceID, const char* name);
  229.         virtual bool                            InStanceTransition();
  230.  
  231.         virtual void                            SetFacialAlertnessLevel(int alertness) { m_facialAlertness = alertness; }
  232.         virtual int                             GetFacialAlertnessLevel()              { return m_facialAlertness; }
  233.  
  234.         virtual void                            ResetState();
  235.         virtual void                            ResetInertiaCache();
  236.  
  237.         virtual float                           FilterView(SViewParams& viewParams) const;
  238.  
  239.         virtual uint32                          MakeFace(const char* pExpressionName, bool usePreviewChannel = true, float lifeTime = 1.f);
  240.  
  241.         virtual void                            AllowLookIk(bool allow, int layer = -1);
  242.         virtual bool                            IsLookIkAllowed() const { return (m_disallowLookIKFlags == 0); }
  243.  
  244.         virtual void                            AllowAimIk(bool allow);
  245.         virtual bool                            IsAimIkAllowed() const { return m_allowAimIk; }
  246.  
  247.         virtual void                            TriggerRecoil(float duration, float kinematicImpact, float kickIn /*=0.8f*/, EAnimatedCharacterArms arms /*= eACA_BothArms*/);
  248.         virtual void                            SetWeaponRaisedPose(EWeaponRaisedPose pose);
  249.  
  250.         virtual SGroundAlignmentParams&         GetGroundAlignmentParams();
  251.  
  252.         //! Override for the entity's desired movement -> replace it with animation movement components
  253.         void                           UseAnimationMovementForEntity(bool xyMove, bool zMove, bool rotation);
  254.  
  255.         virtual EColliderMode          GetPhysicalColliderMode() const { return m_colliderMode; }
  256.         virtual void                   ForceRefreshPhysicalColliderMode();
  257.         virtual void                   RequestPhysicalColliderMode(EColliderMode mode, EColliderModeLayer layer, const char* tag = NULL);
  258.         virtual void                   SetCharacterCollisionFlags(unsigned int flags) { m_characterCollisionFlags = flags; }
  259.         virtual void                   SetMovementControlMethods(EMovementControlMethod horizontal, EMovementControlMethod vertical);
  260.         virtual void                   SetMovementControlMethods(EMCMSlot slot, EMovementControlMethod horizontal, EMovementControlMethod vertical, const char* tag = NULL);
  261.  
  262.         virtual void                   SetDoMotionParams(bool doMotionParams) { m_doMotionParams = doMotionParams; }
  263.         virtual void                   EnableLandBob(const SLandBobParams& landBobParams);
  264.         virtual void                   DisableLandBob();
  265.  
  266.         virtual const QuatT&           GetAnimLocation() const                 { return m_entLocation; }
  267.         virtual const float            GetEntitySpeed() const                  { return m_actualEntSpeed; }
  268.         virtual const float            GetEntitySpeedHorizontal() const        { return m_actualEntSpeedHorizontal; }
  269.         virtual const Vec2&            GetEntityMovementDirHorizontal() const  { return m_actualEntMovementDirHorizontal; }
  270.         virtual const Vec2&            GetEntityVelocityHorizontal() const     { return m_actualEntVelocityHorizontal; }
  271.         virtual const Vec2&            GetEntityAccelerationHorizontal() const { return m_actualEntAccelerationHorizontal; }
  272.         virtual const float            GetEntityTangentialAcceleration() const { return m_actualEntTangentialAcceleration; }
  273.         virtual const Vec3&            GetExpectedEntMovement() const          { return m_expectedEntMovement; }
  274.         virtual float                  GetAngularSpeedHorizontal() const;
  275.  
  276.         virtual void                   SetNoMovementOverride(bool external);
  277.  
  278.         virtual EMovementControlMethod GetMCMH() const;
  279.         virtual EMovementControlMethod GetMCMV() const;
  280.  
  281.         virtual void                   SetInGrabbedState(bool bEnable);
  282.  
  283.         // Returns the angle (in degrees) of the ground below the character.
  284.         // Zero is flat ground (along facing direction), positive when character facing uphill, negative when character facing downhill.
  285.         virtual float GetSlopeDegreeMoveDir() const { return m_fGroundSlopeMoveDirSmooth; }
  286.         virtual float GetSlopeDegree() const        { return m_fGroundSlopeSmooth; }
  287.  
  288.         void          ForceMovement(const QuatT& relativeMovement);
  289.         void          ForceOverrideRotation(const Quat& qWorldRotation);
  290.  
  291. #if DEBUG_VELOCITY()
  292.         virtual void AddDebugVelocity(const QuatT& movement, const float frameTime, const char* szComment, const ColorF& colorF, const bool pastMovement = false) const;
  293.         virtual bool DebugVelocitiesEnabled() const;
  294. #endif
  295.         // ~IAnimatedCharacter
  296.  
  297.         // IAnimationGraphStateListener
  298.         virtual void SetOutput(const char* output, const char* value);
  299.         virtual void QueryComplete(TAnimationGraphQueryID queryID, bool succeeded);
  300.         virtual void DestroyedState(IAnimationGraphState*);
  301.         // ~IAnimationGraphStateListener
  302.  
  303.         // TODO: Is this function really needed? It's only used in CAGFreeFall::CanLeaveState
  304.         ILINE const QuatT& GetPrevEntityLocation() const { return m_prevEntLocation; }
  305.  
  306.         // TODO: Is this function really needed? It's only used in some special case in ExactPositioning.cpp
  307.         ILINE const QuatT& GetRequestedEntityMovement() const { return m_requestedEntityMovement; }
  308.  
  309.         // Need to be accessible for the event proxies.
  310.         void       PrepareAnimatedCharacterForUpdate();
  311.         void       GenerateMovementRequest();
  312.         void       PrepareAndStartAnimProc();
  313.  
  314. private:
  315.         void PerformSimpleMovement();
  316.         void DeleteActionController();
  317.         void SetActionController(const char* filename);
  318.  
  319.         bool NoMovementOverride() const;
  320.  
  321.         void CalculateParamsForCurrentMotions();
  322.  
  323.         void PostAnimationUpdate();
  324.         void PostProcessingUpdate();
  325.  
  326.         //void OnPhysicsPreStep( float frameTime );
  327.         void       InitVars();
  328.         void       ResetVars();
  329.  
  330.         void       DisableEntitySystemCharacterUpdate();
  331.  
  332.         void       InitShadowCharacter();
  333.  
  334.         void       UpdateTime();
  335.  
  336.         void       UpdateMCMs();
  337.         void       UpdateMCMComponent(EMCMComponent component);
  338.         void       PreventAnimTargetOvershooting(EMCMComponent component);
  339.         QuatT      OverrideEntityMovement(const QuatT& ent, const QuatT& anim) const;
  340.         QuatT      MergeMCM(const QuatT& ent, const QuatT& anim, bool flat) const;
  341.  
  342.         ILINE bool RecentQuickLoad() { return ((m_lastSerializeReadFrameID + 3) > m_curFrameID); }
  343.  
  344.         bool       EvaluateSimpleMovementConditions() const;
  345.         void       UpdateSimpleMovementConditions();
  346.  
  347.         bool       InitializeMannequin();
  348.  
  349.         void       PreAnimationUpdate();
  350.  
  351.         void       UpdateGroundAlignment();
  352.  
  353.         void       UpdateSkeletonSettings();
  354.  
  355.         void       SetDesiredLocalLocation(ISkeletonAnim* pSkeletonAnim, const QuatT& desiredLocalLocation, float fDeltaTime);
  356.         void       SetMotionParam(ISkeletonAnim* const pSkeletonAnim, const EMotionParamID motionParamID, const float value) const;
  357.  
  358.         void       GetCurrentEntityLocation();
  359.         QuatT      CalculateDesiredAnimMovement() const;
  360.         void       AcquireRequestedBehaviourMovement();
  361.         QuatT      CalculateWantedEntityMovement(const QuatT& desiredAnimMovement) const;
  362.  
  363.         void       RefreshAnimTarget();
  364.  
  365.         ILINE bool RecentCollision() const { return ((m_collisionFrameID + 5) > m_curFrameID); }
  366.         Vec3       RemovePenetratingComponent(const Vec3& v, const Vec3& n) const;
  367.  
  368.         ILINE bool InCutscene()
  369.         {
  370.                 if ((m_pSkeletonAnim != NULL) && (m_pSkeletonAnim->GetTrackViewStatus() != 0))
  371.                         return true;
  372.  
  373.                 return false;
  374.         }
  375.  
  376.         QuatT CalculateDesiredLocation() const;
  377.  
  378.         void  CalculateAndRequestPhysicalEntityMovement();
  379.         void  RequestPhysicalEntityMovement(const QuatT& wantedEntMovement);
  380.  
  381.         // PROTOTYPE: Limit entity velocity to animation velocity projected along entity velocity direction.
  382.         QuatT      DoEntityClamping(const QuatT& wantedEntMovement) const;
  383.  
  384.         ILINE bool AllowEntityClamping() const
  385.         {
  386.                 bool allowEntityClamp = (GetMCMH() == eMCM_ClampedEntity);
  387.  
  388.                 /*
  389.                    // NOTE: During AnimTarget MCM is forced to Entity (approaching/preparing) or Animation (active), so this is redundant.
  390.                    const SAnimationTarget* pAnimTarget = m_animationGraphStates.GetAnimationTarget();
  391.                    bool hasAnimTarget = (pAnimTarget != NULL) && (pAnimTarget->preparing || pAnimTarget->activated);
  392.                  */
  393.  
  394.                 /*
  395.                    // NOTE: MCM is forced to Entity for all players, so this is redundant.
  396.                    // NOTE: Actually, it's only entity in first person, not nessecarily in third person.
  397.                    IActor* pActor = CCryAction::GetCryAction()->GetIActorSystem()->GetActor(pEntity->GetId());
  398.                    bool isPlayer = pActor->IsPlayer();
  399.                  */
  400.  
  401. #ifdef _DEBUG
  402.                 if (allowEntityClamp && (CAnimationGraphCVars::Get().m_entityAnimClamp == 0))
  403.                         allowEntityClamp = false;
  404. #endif
  405.                 return allowEntityClamp;
  406.         }
  407.  
  408.         void UpdatePhysicalColliderMode();
  409.         void UpdatePhysicsInertia();
  410.  
  411.         void CreateExtraSolidCollider();
  412.         void DestroyExtraSolidCollider();
  413.  
  414.         void EnableRigidCollider(float radius);
  415.         void DisableRigidCollider();
  416.  
  417.         void UpdateCharacterPtrs();
  418.         void ValidateCharacterPtrs();
  419.  
  420.         void SetBlendFromRagdollizeParams(const SGameObjectEvent& event);
  421.         void SetRagdollizeParams(const SGameObjectEvent& event);
  422.         void KickOffRagdoll();
  423.         bool StartAnimationProcessing(const QuatT& entityLocation) const;
  424.         void StartAnimationProcessing() const;
  425.         void SetAnimationPostProcessParameters(const QuatT& entityLocation, const bool finishImmediate = false) const;
  426.         void SetAnimationPostProcessParameters() const;
  427.  
  428.         void ComputeGroundSlope();
  429.  
  430.         // [Benito] Note:
  431.         // Normal processing assumes that animation processing starts during PrePhysicsUpdate event (See PrePhysicsUpdate/Update functions)
  432.         // This is not the case for the 'grabbed' state, where the final entity location is not known until the very end of the frame
  433.         ILINE bool UseNormalAnimationProcessing() const { return !m_inGrabbedState; }
  434.  
  435.         // Consistency Tests
  436.         void RunTests();
  437.  
  438.         // Debug rendering (in world) and text
  439.         bool DebugFilter() const;
  440.         bool DebugTextEnabled() const;
  441.         void DebugRenderCurLocations() const;
  442.         void DebugDisplayNewLocationsAndMovements(const QuatT& entLocation, const QuatT& entMovement,
  443.                                                   const QuatT& animMovement,
  444.                                                   float frameTime) const;
  445.  
  446.         void LayoutHelper(const char* id, const char* name, bool visible, float minout, float maxout, float minin, float maxin, float x, float y, float w = 1.0f, float h = 1.0f);
  447.  
  448.         // DebugHistory Graphs
  449.         void SetupDebugHistories();
  450.  
  451.         //void DebugGraphMotionParams(const ISkeletonAnim* pSkeletonAnim);
  452.         void DebugBlendWeights(const ISkeletonAnim* pSkeletonAnim);
  453.  
  454.         void DebugHistory_AddValue(const char* id, float x) const;
  455.         void DebugGraphQT(const QuatT& m, const char* tx, const char* ty, const char* rz, const char* tz = 0) const;
  456.  
  457. public:
  458.         virtual void RegisterListener(IAnimatedCharacterListener* eventListener, const char* name) { m_listeners.Add(eventListener, name); }
  459.         virtual void UnregisterListener(IAnimatedCharacterListener* eventListener)                 { m_listeners.Remove(eventListener); }
  460.  
  461. private:
  462.  
  463.         CAnimatedCharacterComponent_PrepareAnimatedCharacterForUpdate* m_pComponentPrepareCharForUpdate;
  464.  
  465.         //EventListeners
  466.         typedef CListenerSet<IAnimatedCharacterListener*> TAnimCharListeners;
  467.         TAnimCharListeners m_listeners;
  468.  
  469.         // Mannequin (not serialized)
  470.         IActionController*              m_pActionController;
  471.         SAnimationContext*              m_pAnimContext;
  472.         const IAnimationDatabase*       m_pAnimDatabase1P;
  473.         const IAnimationDatabase*       m_pAnimDatabase3P;
  474.         const IAnimationDatabase*       m_pSoundDatabase;
  475.         bool                            m_lastACFirstPerson;
  476.         string                          m_AGScopeMask;
  477.  
  478.         MannequinAG::CMannequinAGState* m_pMannequinAGState;
  479.  
  480.         CAnimationPlayerProxy*          m_pAnimationPlayerProxies[eAnimationGraphLayer_COUNT];
  481.  
  482.         // Not serialized
  483.         SAnimatedCharacterParams m_params; // TODO: Garbage collect unused members of this struct.
  484.  
  485.         // Not serialized. Cached values for updating inertia
  486.         float m_fPrevInertia;
  487.         float m_fPrevInertiaAccel;
  488.         float m_fPrevTimeImpulseRecover;
  489.  
  490.         // Not serialized
  491.         bool m_moveOverride_useAnimXY;
  492.         bool m_moveOverride_useAnimZ;
  493.         bool m_moveOverride_useAnimRot;
  494.  
  495.         // Not serialized
  496.         int m_facialAlertness; // TODO: Make this an int8 instead. We never use more than a few unique values.
  497.  
  498.         // Serialized
  499.         // TODO: Turn the stance enums into uint8 instead of int32.
  500.         int m_currentStance;
  501.  
  502.         // Not serialized
  503.         int                    m_requestedStance;
  504.         TAnimationGraphQueryID m_stanceQuery;
  505.  
  506.         unsigned int           m_disallowLookIKFlags; // 1 bit for each animationgraph layer plus one for the game. LookIK is allowed if this is 0.
  507.         ANIMCHAR_SIZED_VAR(bool, m_allowAimIk, 1);
  508.  
  509.         // Not serialized
  510.         int         m_curFrameID;                   // Updated every frame in UpdateTime().
  511.         int         m_lastResetFrameId;             // Initialized to the current frame id in ResetVars().
  512.         int         m_updateGrabbedInputFrameID;    // This is updated in PostAnimationUpdate(), when checking grabbed AG input.
  513.         int         m_moveRequestFrameID;           // NOTE: GetFrameID() returns an int and this is initialized to -1 in ResetVars().
  514.         mutable int m_lastAnimProcFrameID;          // last time StartAnimationProcessing was called.
  515.         int         m_lastSerializeReadFrameID;     //
  516.         int         m_lastPostProcessUpdateFrameID; //
  517.  
  518.         int         m_shadowCharacterSlot;
  519.         bool        m_hasShadowCharacter;
  520.  
  521.         // TODO: Pack as bits with other bools.
  522.         bool              m_bSimpleMovementSetOnce;
  523.  
  524.         EWeaponRaisedPose m_curWeaponRaisedPose;
  525.  
  526.         // Not serialized
  527.         SCharacterMoveRequest m_moveRequest;
  528.  
  529.         // Not serialized
  530.         // TODO: Pack these as bits instead.
  531.         bool m_isPlayer;
  532.  
  533.         // Not serialized
  534.         CTimeValue m_curFrameStartTime;
  535.  
  536.         // Not serialized
  537.         double m_curFrameTime;
  538.         double m_prevFrameTime;
  539.         double m_curFrameTimeOriginal;
  540.  
  541.         // Not serialized
  542.         bool  m_hasForcedMovement;
  543.         QuatT m_forcedMovementRelative;
  544.  
  545.         bool  m_hasForcedOverrideRotation;
  546.         Quat  m_forcedOverrideRotationWorld;
  547.  
  548.         // Not serialized
  549.         QuatT m_entLocation;     // Current entity location.
  550.         QuatT m_prevEntLocation; // Previous entity location.
  551.         Vec3  m_expectedEntMovement;
  552.         QuatT m_actualEntMovement;   // This is the actual measured difference in location between two frames.
  553.         QuatT m_entTeleportMovement; // Offset between entity locations between and after set pos/rot (teleportation).
  554.         QuatT m_desiredLocalLocation;
  555.  
  556.         // PROCEDURAL LEANING STUFF (wip)
  557.         // Not serialized
  558.         bool  EnableProceduralLeaning();
  559.         float GetProceduralLeaningScale();
  560.         QuatT CalculateProceduralLeaning();
  561. #define NumAxxSamples 32
  562.         Vec2       m_reqLocalEntAxx[NumAxxSamples];
  563.         Vec2       m_reqEntVelo[NumAxxSamples];
  564.         CTimeValue m_reqEntTime[NumAxxSamples];
  565.         int        m_reqLocalEntAxxNextIndex;
  566.         Vec3       m_smoothedActualEntVelo;
  567.         float      m_smoothedAmountAxx;
  568.         Vec3       m_avgLocalEntAxx;
  569.  
  570.         bool       m_doMotionParams;
  571.  
  572.         // Not serialized
  573.         // TODO: Pack these two as one uint8, 4 bits each.
  574.         int8 m_requestedEntMoveDirLH4;
  575.         int8 m_actualEntMoveDirLH4;
  576.  
  577.         // Serialized
  578.         // TODO: Make sure EMovementControlMethod is not bigger than 8 bits.
  579.         EMovementControlMethod m_movementControlMethod[eMCMComponent_COUNT][eMCMSlot_COUNT];
  580.         const char*            m_movementControlMethodTags[eMCMSlot_COUNT];
  581.         const char*            m_currentMovementControlMethodTags[eMCMComponent_COUNT];
  582.         float                  m_elapsedTimeMCM[eMCMComponent_COUNT];
  583.  
  584.         // Serialized
  585.         // TODO: Make sure EColliderMode is not bigger than 8 bits.
  586.         const char*   m_colliderModeLayersTag[eColliderModeLayer_COUNT];
  587.         EColliderMode m_colliderModeLayers[eColliderModeLayer_COUNT];
  588.         EColliderMode m_colliderMode;
  589.  
  590.         // Not serialized
  591.         // TODO: Try to pack these into bits instead. ANIMCHAR_SIZED_VAR(bool, name, 1);
  592.         bool m_simplifiedAGSpeedInputsRequested;
  593.         bool m_simplifiedAGSpeedInputsActual;
  594.  
  595.         // Not serialized
  596.         QuatT                       m_requestedEntityMovement;
  597.         RequestedEntityMovementType m_requestedEntityMovementType;
  598.         int                         m_requestedIJump;          // TODO: Turn this into an int8 instead.
  599.         bool                        m_bDisablePhysicalGravity; // TODO: Pack this into bits instead.
  600.  
  601.         // Not serialized
  602.         bool  m_simplifyMovement;                 // TODO: Pack this into bits instead.
  603.         bool  m_forceDisableSlidingContactEvents; // TODO: Pack this into bits instead.
  604.         float m_noMovementTimer;                  // TODO: This does not have to be very accurate. Try packing it as an uint8 or uint16.
  605.         Vec2  m_actualEntVelocityHorizontal;
  606.         Vec2  m_actualEntMovementDirHorizontal;
  607.         Vec2  m_actualEntAccelerationHorizontal;
  608.         float m_actualEntTangentialAcceleration;
  609.         float m_actualEntSpeed;
  610.  
  611.         // Serialized
  612.         float m_actualEntSpeedHorizontal; // TODO: Look into how this is actually used. (at least it's converted from QuatT to float, rest was redundant)
  613.  
  614.         // Not serialized
  615.         const SExactPositioningTarget* m_pAnimTarget;
  616.         ICharacterInstance*            m_pCharacter;
  617.         ISkeletonAnim*                 m_pSkeletonAnim;
  618.         ISkeletonPose*                 m_pSkeletonPose;
  619.         ICharacterInstance*            m_pShadowCharacter;
  620.         ISkeletonAnim*                 m_pShadowSkeletonAnim;
  621.         ISkeletonPose*                 m_pShadowSkeletonPose;
  622.  
  623.         // Not serialized
  624.         // TODO: Pack these as bits instead.
  625.         bool m_noMovementOverrideExternal;
  626.         bool m_bAnimationGraphStatePaused;
  627.  
  628.         // Not serialized
  629.         f32                     m_fJumpSmooth;
  630.         f32                     m_fJumpSmoothRate;
  631.  
  632.         f32                     m_fGroundSlopeMoveDirSmooth;
  633.         f32                     m_fGroundSlopeMoveDirRate;
  634.  
  635.         f32                     m_fGroundSlope;
  636.         f32                     m_fGroundSlopeSmooth;
  637.         f32                     m_fGroundSlopeRate;
  638.  
  639.         f32                     m_fRootHeightSmooth;
  640.         f32                     m_fRootHeightRate;
  641.  
  642.         SLandBobParams          m_landBobParams;
  643.         f32                     m_fallMaxHeight;
  644.         f32                     m_landBobTime;
  645.         f32                     m_totalLandBob;
  646.         bool                    m_wasInAir;
  647.  
  648.         SGroundAlignmentParams  m_groundAlignmentParams;
  649.  
  650.         f32                     m_fDesiredMoveSpeedSmoothQTX;
  651.         f32                     m_fDesiredMoveSpeedSmoothRateQTX;
  652.         f32                     m_fDesiredTurnSpeedSmoothQTX;
  653.         f32                     m_fDesiredTurnSpeedSmoothRateQTX;
  654.         Vec2                    m_fDesiredStrafeSmoothQTX;
  655.         Vec2                    m_fDesiredStrafeSmoothRateQTX;
  656.         bool                    m_forcedRefreshColliderMode;
  657.  
  658.         bool                    m_bPendingRagdoll;
  659.         SRagdollizeParams       m_ragdollParams;
  660.         SBlendFromRagdollParams m_blendFromRagollizeParams;
  661.  
  662.         // Not serialized
  663.         // Move these to pack better with other small variables.
  664.         uint8 m_prevAnimPhaseHash;
  665.         float m_prevAnimEntOffsetHash; // TODO: This could maybe be turned into an int8 and packed with some other 8 bitters.
  666.         float m_prevMoveVeloHash;
  667.         uint8 m_prevMoveJump;
  668.  
  669.         // Serialized
  670.  
  671.         int              m_collisionFrameID;
  672.         int              m_collisionNormalCount;
  673.         Vec3             m_collisionNormal[4];
  674.  
  675.         IPhysicalEntity* m_pFeetColliderPE;
  676.         IPhysicalEntity* m_pRigidColliderPE;
  677.  
  678.         // Not serialized
  679.         unsigned int m_characterCollisionFlags; // geom_colltype_player by default.
  680.  
  681.         // DebugHistory Graphs
  682.         // TODO: Look at how this is managed.
  683.         mutable IDebugHistoryManager* m_debugHistoryManager;
  684.  
  685.         IAnimationPoseAlignerPtr      m_pPoseAligner;
  686.  
  687.         mutable int                   m_lastAnimationUpdateFrameId;
  688.         bool                          m_inGrabbedState;
  689.  
  690.         bool                          m_useMannequinAGState;
  691.  
  692.         bool                          m_proxiesInitialized;
  693. };
  694.  
  695. //--------------------------------------------------------------------------------
  696. #undef UNIQUE
  697. #if defined(CRY_PLATFORM_64BIT)
  698.         #define UNIQUE(s) (s + string().Format("%016llX", (uint64) this)).c_str()
  699. #else
  700.         #define UNIQUE(s) (s + string().Format("%08X", (uint32) this)).c_str()
  701. #endif
  702.  
  703. //--------------------------------------------------------------------------------
  704.  
  705. extern float ApplyAntiOscilationFilter(float value, float filtersize);
  706. extern void  ScaleQuatAngles(Quat& q, const Ang3& a);
  707. extern float GetQuatAbsAngle(const Quat& q);
  708. extern f32   GetYaw(const Vec3& v0, const Vec3& v1);
  709. extern f32   GetYaw(const Vec2& v0, const Vec2& v1);
  710. extern QuatT ApplyWorldOffset(const QuatT& origin, const QuatT& offset);
  711. extern QuatT GetWorldOffset(const QuatT& origin, const QuatT& destination);
  712. extern QuatT GetClampedOffset(const QuatT& offset, float maxDistance, float maxAngle, float& distance, float& angle);
  713. extern QuatT ExtractHComponent(const QuatT& m);
  714. extern QuatT ExtractVComponent(const QuatT& m);
  715. extern QuatT CombineHVComponents2D(const QuatT& cmpH, const QuatT& cmpV);
  716. extern QuatT CombineHVComponents3D(const QuatT& cmpH, const QuatT& cmpV);
  717. extern void  DebugRenderAngleMeasure(CPersistantDebug* pPD, const Vec3& origin, const Quat& orientation, const Quat& offset, float fraction);
  718. extern void  DebugRenderDistanceMeasure(CPersistantDebug* pPD, const Vec3& origin, const Vec3& offset, float fraction);
  719. extern QuatT GetDebugEntityLocation(const char* name, const QuatT& _default);
  720.  
  721. //--------------------------------------------------------------------------------
  722.  
  723. #undef ANIMCHAR_SIZED_VAR
  724.  
  725. #endif
  726.  
downloadAnimatedCharacter.h Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top