45b2336dce
* WIP - small legacy cleanup Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * More cleanups + build fixes Use AZstd instead of std types in a few places. Remove m_nameTable. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Legacy code cleanups Remove unused methods using legacy functionality * EditorViewportWidget::AdjustObjectPosition * DisplayContext - remove `renderer` pointer * DisplayContext - log errors when functions using `renderer` are called * CTrackGizmo::DrawAxis - log errors when function uses `renderer`. * Legacy CCamera - remove Project, Unproject and CalcScreenBounds * Remove all unused methods from Cry_GeoDistance.h/Cry_GeoIntersect.h * Remove Lineseg_Triangle from Cry_GeoOverlap.h * IEntityRenderState.h - remove unused types * SMeshColor remove Lerp method and associated constructor. * IMaterial.h - remove unused types and a few methods * IRenderMesh.h - remove a few unused methods and use int8 instead of byte * IRender.h - remove almost all of the contents * IShader.h - remove unused types and a few methods * IStatObj.h - remove unused types and a few methods * SSystemGlobalEnvironment - remove `renderer` pointer * IRenderGraph - remove 2 unused methods * physinterface.h - remove almost all of the contents * CXmlUtils no longer inherits ISystemEventListener * CXmlNode no longer has custom new/delete * Remove IRenderer from some test mocks. Removed files: * CryName.h * Cry_MatrixDiag.h * Cry_XOptimise.h * HeapAllocator.h * IRendererMock.h * PoolAllocator.h Things to consider: * Remove GetMemoryUsage & friends. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Apply review suggestions IMovieSystem.h - remove unused includes. Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Move unreachable code to `#if 0` block This is hopefully temporary measure until the original functionality is re-implemented Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Fix bad merge I messed up. Fix bad merge I messed up, by re-removing FrameProfiler.h from crycommon_files.cmake (this was removed in an earlier commit this morning: https://github.com/o3de/o3de/pull/3394). Signed-off-by: bosnichd <bosnichd@amazon.com> * Update Code/Framework/AzCore/AzCore/std/string/string_view.h Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * implement review suggestion Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * following review, using LYSHINE_ATOM_TODO to guard Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * Remove commented out include Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> * EditorViewportWidget.cpp: Convert commented out code to guarded one Signed-off-by: nemerle <96597+nemerle@users.noreply.github.com> Co-authored-by: bosnichd <bosnichd@amazon.com> Co-authored-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
191 lines
6.9 KiB
C++
191 lines
6.9 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <LyShine/Animation/IUiAnimation.h>
|
|
#include <AzCore/Serialization/SerializeContext.h>
|
|
#include <AzCore/std/containers/map.h>
|
|
|
|
struct PlayingUIAnimSequence
|
|
{
|
|
//! Sequence playing
|
|
AZStd::intrusive_ptr<IUiAnimSequence> sequence;
|
|
|
|
//! Start/End/Current playing time for this sequence.
|
|
float startTime;
|
|
float endTime;
|
|
float currentTime;
|
|
float currentSpeed;
|
|
|
|
//! Sequence from other sequence's sequence track
|
|
bool trackedSequence;
|
|
bool bSingleFrame;
|
|
};
|
|
|
|
struct IConsoleCmdArgs;
|
|
|
|
class UiAnimationSystem
|
|
: public IUiAnimationSystem
|
|
{
|
|
typedef AZStd::vector<PlayingUIAnimSequence> PlayingSequences;
|
|
|
|
public:
|
|
AZ_CLASS_ALLOCATOR(UiAnimationSystem, AZ::SystemAllocator, 0)
|
|
AZ_RTTI(UiAnimationSystem, "{2592269B-EF74-4409-B29F-682DC0B45DAF}", IUiAnimationSystem)
|
|
|
|
UiAnimationSystem();
|
|
|
|
~UiAnimationSystem();
|
|
|
|
void Release() { delete this; };
|
|
|
|
bool Load(const char* pszFile, const char* pszMission);
|
|
|
|
ISystem* GetSystem() { return m_pSystem; }
|
|
|
|
IUiAnimTrack* CreateTrack(EUiAnimCurveType type);
|
|
|
|
IUiAnimSequence* CreateSequence(const char* sequence, bool bLoad = false, uint32 id = 0);
|
|
IUiAnimSequence* LoadSequence(const char* pszFilePath);
|
|
IUiAnimSequence* LoadSequence(XmlNodeRef& xmlNode, bool bLoadEmpty = true);
|
|
|
|
void AddSequence(IUiAnimSequence* pSequence);
|
|
void RemoveSequence(IUiAnimSequence* pSequence);
|
|
IUiAnimSequence* FindSequence(const char* sequence) const;
|
|
IUiAnimSequence* FindSequenceById(uint32 id) const;
|
|
IUiAnimSequence* GetSequence(int i) const;
|
|
int GetNumSequences() const;
|
|
IUiAnimSequence* GetPlayingSequence(int i) const;
|
|
int GetNumPlayingSequences() const;
|
|
bool IsCutScenePlaying() const;
|
|
|
|
uint32 GrabNextSequenceId()
|
|
{ return m_nextSequenceId++; }
|
|
|
|
int OnSequenceRenamed(const char* before, const char* after);
|
|
int OnCameraRenamed(const char* before, const char* after);
|
|
|
|
bool AddUiAnimationListener(IUiAnimSequence* pSequence, IUiAnimationListener* pListener);
|
|
bool RemoveUiAnimationListener(IUiAnimSequence* pSequence, IUiAnimationListener* pListener);
|
|
|
|
void RemoveAllSequences();
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
// Sequence playback.
|
|
//////////////////////////////////////////////////////////////////////////
|
|
void PlaySequence(const char* sequence, IUiAnimSequence* parentSeq = NULL, bool bResetFX = true,
|
|
bool bTrackedSequence = false, float startTime = -FLT_MAX, float endTime = -FLT_MAX);
|
|
void PlaySequence(IUiAnimSequence* seq, IUiAnimSequence* parentSeq = NULL, bool bResetFX = true,
|
|
bool bTrackedSequence = false, float startTime = -FLT_MAX, float endTime = -FLT_MAX);
|
|
void PlayOnLoadSequences();
|
|
|
|
bool StopSequence(const char* sequence);
|
|
bool StopSequence(IUiAnimSequence* seq);
|
|
bool AbortSequence(IUiAnimSequence* seq, bool bLeaveTime = false);
|
|
|
|
void StopAllSequences();
|
|
void StopAllCutScenes();
|
|
void Pause(bool bPause);
|
|
|
|
void Reset(bool bPlayOnReset, bool bSeekToStart);
|
|
void StillUpdate();
|
|
void PreUpdate(const float dt);
|
|
void PostUpdate(const float dt);
|
|
void Render();
|
|
|
|
bool IsPlaying(IUiAnimSequence* seq) const;
|
|
|
|
void Pause();
|
|
void Resume();
|
|
|
|
void SetRecording(bool recording) { m_bRecording = recording; };
|
|
bool IsRecording() const { return m_bRecording; };
|
|
|
|
void SetCallback(IUiAnimationCallback* pCallback) { m_pCallback = pCallback; }
|
|
IUiAnimationCallback* GetCallback() { return m_pCallback; }
|
|
void Callback(IUiAnimationCallback::ECallbackReason Reason, IUiAnimNode* pNode);
|
|
|
|
void Serialize(XmlNodeRef& xmlNode, bool bLoading, bool bRemoveOldNodes = false, bool bLoadEmpty = true);
|
|
void InitPostLoad(bool remapIds, LyShine::EntityIdMap* entityIdMap);
|
|
|
|
void SetSequenceStopBehavior(ESequenceStopBehavior behavior);
|
|
IUiAnimationSystem::ESequenceStopBehavior GetSequenceStopBehavior();
|
|
|
|
float GetPlayingTime(IUiAnimSequence* pSeq);
|
|
bool SetPlayingTime(IUiAnimSequence* pSeq, float fTime);
|
|
|
|
float GetPlayingSpeed(IUiAnimSequence* pSeq);
|
|
bool SetPlayingSpeed(IUiAnimSequence* pSeq, float fTime);
|
|
|
|
bool GetStartEndTime(IUiAnimSequence* pSeq, float& fStartTime, float& fEndTime);
|
|
bool SetStartEndTime(IUiAnimSequence* pSeq, const float fStartTime, const float fEndTime);
|
|
|
|
void GoToFrame(const char* seqName, float targetFrame);
|
|
|
|
void SerializeNodeType(EUiAnimNodeType& animNodeType, XmlNodeRef& xmlNode, bool bLoading, const uint version, int flags);
|
|
virtual void SerializeParamType(CUiAnimParamType& animParamType, XmlNodeRef& xmlNode, bool bLoading, const uint version);
|
|
virtual void SerializeParamData(UiAnimParamData& animParamData, XmlNodeRef& xmlNode, bool bLoading);
|
|
|
|
static const char* GetParamTypeName(const CUiAnimParamType& animParamType);
|
|
|
|
void OnCameraCut();
|
|
|
|
static void StaticInitialize();
|
|
|
|
static void Reflect(AZ::SerializeContext* serializeContext);
|
|
|
|
void NotifyTrackEventListeners(const char* eventName, const char* valueName, IUiAnimSequence* pSequence) override;
|
|
|
|
private:
|
|
void NotifyListeners(IUiAnimSequence* pSequence, IUiAnimationListener::EUiAnimationEvent event);
|
|
|
|
void InternalStopAllSequences(bool bIsAbort, bool bAnimate);
|
|
bool InternalStopSequence(IUiAnimSequence* seq, bool bIsAbort, bool bAnimate);
|
|
|
|
bool FindSequence(IUiAnimSequence* sequence, PlayingSequences::const_iterator& sequenceIteratorOut) const;
|
|
bool FindSequence(IUiAnimSequence* sequence, PlayingSequences::iterator& sequenceIteratorOut);
|
|
|
|
static void DoNodeStaticInitialisation();
|
|
void UpdateInternal(const float dt, const bool bPreUpdate);
|
|
|
|
#ifdef UI_ANIMATION_SYSTEM_SUPPORT_EDITING
|
|
virtual EUiAnimNodeType GetNodeTypeFromString(const char* pString) const;
|
|
virtual CUiAnimParamType GetParamTypeFromString(const char* pString) const;
|
|
#endif
|
|
|
|
ISystem* m_pSystem;
|
|
|
|
IUiAnimationCallback* m_pCallback;
|
|
|
|
CTimeValue m_lastUpdateTime;
|
|
|
|
using Sequences = AZStd::vector<AZStd::intrusive_ptr<IUiAnimSequence> >;
|
|
Sequences m_sequences;
|
|
|
|
PlayingSequences m_playingSequences;
|
|
|
|
using TUiAnimationListenerVec = AZStd::vector<IUiAnimationListener*>;
|
|
using TUiAnimationListenerMap = AZStd::map<IUiAnimSequence*, TUiAnimationListenerVec> ;
|
|
|
|
// a container which maps sequences to all interested listeners
|
|
// listeners is a vector (could be a set in case we have a lot of listeners, stl::push_back_unique!)
|
|
TUiAnimationListenerMap m_animationListenerMap;
|
|
|
|
bool m_bRecording;
|
|
bool m_bPaused;
|
|
|
|
ESequenceStopBehavior m_sequenceStopBehavior;
|
|
|
|
// A sequence which turned on the early animation update last time
|
|
uint32 m_nextSequenceId;
|
|
|
|
void ShowPlayedSequencesDebug();
|
|
};
|