diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-23 11:48:51 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-23 11:48:51 +1000 |
commit | 7136c929cea0ddf955ab69a8ff5a4394bedacea8 (patch) | |
tree | d17322f98b5614eadeb086dae70d6fbd81d84934 /source/base | |
parent | ed3793ab004e1c6d21225f34c8369d12f6525334 (diff) |
micro-opt NetworkedAnimator drawables
sort before creating drawables
Diffstat (limited to 'source/base')
-rw-r--r-- | source/base/StarAnimatedPartSet.cpp | 10 | ||||
-rw-r--r-- | source/base/StarAnimatedPartSet.hpp | 85 |
2 files changed, 53 insertions, 42 deletions
diff --git a/source/base/StarAnimatedPartSet.cpp b/source/base/StarAnimatedPartSet.cpp index 9133921..5ffc68f 100644 --- a/source/base/StarAnimatedPartSet.cpp +++ b/source/base/StarAnimatedPartSet.cpp @@ -106,7 +106,7 @@ StringList AnimatedPartSet::states(String const& stateTypeName) const { return m_stateTypes.get(stateTypeName).states.keys(); } -StringList AnimatedPartSet::parts() const { +StringList AnimatedPartSet::partNames() const { return m_parts.keys(); } @@ -148,6 +148,14 @@ AnimatedPartSet::ActivePartInformation const& AnimatedPartSet::activePart(String return part.activePart; } +StringMap<AnimatedPartSet::Part> const& AnimatedPartSet::constParts() const { + return m_parts; +} + +StringMap<AnimatedPartSet::Part>& AnimatedPartSet::parts() { + return m_parts; +} + void AnimatedPartSet::forEachActiveState(function<void(String const&, ActiveStateInformation const&)> callback) const { for (auto const& p : m_stateTypes) { const_cast<AnimatedPartSet*>(this)->freshenActiveState(const_cast<StateType&>(p.second)); diff --git a/source/base/StarAnimatedPartSet.hpp b/source/base/StarAnimatedPartSet.hpp index 8cc2ef3..a608924 100644 --- a/source/base/StarAnimatedPartSet.hpp +++ b/source/base/StarAnimatedPartSet.hpp @@ -56,6 +56,46 @@ public: JsonObject properties; }; + enum AnimationMode { + End, + Loop, + Transition + }; + + struct State { + unsigned frames; + float cycle; + AnimationMode animationMode; + String transitionState; + JsonObject stateProperties; + JsonObject stateFrameProperties; + }; + + struct StateType { + float priority; + bool enabled; + String defaultState; + JsonObject stateTypeProperties; + OrderedHashMap<String, shared_ptr<State const>> states; + + ActiveStateInformation activeState; + State const* activeStatePointer; + bool activeStateDirty; + }; + + struct PartState { + JsonObject partStateProperties; + JsonObject partStateFrameProperties; + }; + + struct Part { + JsonObject partProperties; + StringMap<StringMap<PartState>> partStates; + + ActivePartInformation activePart; + bool activePartDirty; + }; + AnimatedPartSet(); AnimatedPartSet(Json config); @@ -71,7 +111,7 @@ public: // Returns the available states for the given state type. StringList states(String const& stateTypeName) const; - StringList parts() const; + StringList partNames() const; // Sets the active state for this state type. If the state is different than // the previously set state, will start the new states animation off at the @@ -86,6 +126,9 @@ public: ActiveStateInformation const& activeState(String const& stateTypeName) const; ActivePartInformation const& activePart(String const& partName) const; + StringMap<Part> const& constParts() const; + StringMap<Part>& parts(); + // Function will be given the name of each state type, and the // ActiveStateInformation for the active state for that state type. void forEachActiveState(function<void(String const&, ActiveStateInformation const&)> callback) const; @@ -108,46 +151,6 @@ public: void finishAnimations(); private: - enum AnimationMode { - End, - Loop, - Transition - }; - - struct State { - unsigned frames; - float cycle; - AnimationMode animationMode; - String transitionState; - JsonObject stateProperties; - JsonObject stateFrameProperties; - }; - - struct StateType { - float priority; - bool enabled; - String defaultState; - JsonObject stateTypeProperties; - OrderedHashMap<String, shared_ptr<State const>> states; - - ActiveStateInformation activeState; - State const* activeStatePointer; - bool activeStateDirty; - }; - - struct PartState { - JsonObject partStateProperties; - JsonObject partStateFrameProperties; - }; - - struct Part { - JsonObject partProperties; - StringMap<StringMap<PartState>> partStates; - - ActivePartInformation activePart; - bool activePartDirty; - }; - static AnimationMode stringToAnimationMode(String const& string); void freshenActiveState(StateType& stateType); |