@@ -2138,3 +2138,73 @@ AnimationMixer::AnimationMixer() {
21382138
21392139AnimationMixer::~AnimationMixer () {
21402140}
2141+
2142+ void AnimatedValuesBackup::set_data (const HashMap<NodePath, AnimationMixer::TrackCache *> p_data) {
2143+ clear_data ();
2144+
2145+ for (const KeyValue<NodePath, AnimationMixer::TrackCache *> &E : p_data) {
2146+ data.insert (E.key , get_cache_copy (E.value ));
2147+ }
2148+ }
2149+
2150+ HashMap<NodePath, AnimationMixer::TrackCache *> AnimatedValuesBackup::get_data () const {
2151+ HashMap<NodePath, AnimationMixer::TrackCache *> ret;
2152+ for (const KeyValue<NodePath, AnimationMixer::TrackCache *> &E : data) {
2153+ ret.insert (E.key , get_cache_copy (E.value ));
2154+ }
2155+ return ret;
2156+ }
2157+
2158+ void AnimatedValuesBackup::clear_data () {
2159+ for (KeyValue<NodePath, AnimationMixer::TrackCache *> &K : data) {
2160+ memdelete (K.value );
2161+ }
2162+ data.clear ();
2163+ }
2164+
2165+ AnimationMixer::TrackCache *AnimatedValuesBackup::get_cache_copy (AnimationMixer::TrackCache *p_cache) const {
2166+ switch (p_cache->type ) {
2167+ case Animation::TYPE_VALUE: {
2168+ AnimationMixer::TrackCacheValue *src = static_cast <AnimationMixer::TrackCacheValue *>(p_cache);
2169+ AnimationMixer::TrackCacheValue *tc = memnew (AnimationMixer::TrackCacheValue);
2170+ memcpy ((void *)tc, (void *)src, sizeof (AnimationMixer::TrackCacheValue));
2171+ return tc;
2172+ }
2173+
2174+ case Animation::TYPE_POSITION_3D:
2175+ case Animation::TYPE_ROTATION_3D:
2176+ case Animation::TYPE_SCALE_3D: {
2177+ AnimationMixer::TrackCacheTransform *src = static_cast <AnimationMixer::TrackCacheTransform *>(p_cache);
2178+ AnimationMixer::TrackCacheTransform *tc = memnew (AnimationMixer::TrackCacheTransform);
2179+ memcpy ((void *)tc, (void *)src, sizeof (AnimationMixer::TrackCacheTransform));
2180+ return tc;
2181+ }
2182+
2183+ case Animation::TYPE_BLEND_SHAPE: {
2184+ AnimationMixer::TrackCacheBlendShape *src = static_cast <AnimationMixer::TrackCacheBlendShape *>(p_cache);
2185+ AnimationMixer::TrackCacheBlendShape *tc = memnew (AnimationMixer::TrackCacheBlendShape);
2186+ memcpy ((void *)tc, (void *)src, sizeof (AnimationMixer::TrackCacheBlendShape));
2187+ return tc;
2188+ }
2189+
2190+ case Animation::TYPE_BEZIER: {
2191+ AnimationMixer::TrackCacheBezier *src = static_cast <AnimationMixer::TrackCacheBezier *>(p_cache);
2192+ AnimationMixer::TrackCacheBezier *tc = memnew (AnimationMixer::TrackCacheBezier);
2193+ memcpy ((void *)tc, (void *)src, sizeof (AnimationMixer::TrackCacheBezier));
2194+ return tc;
2195+ }
2196+
2197+ case Animation::TYPE_AUDIO: {
2198+ AnimationMixer::TrackCacheAudio *src = static_cast <AnimationMixer::TrackCacheAudio *>(p_cache);
2199+ AnimationMixer::TrackCacheAudio *tc = memnew (AnimationMixer::TrackCacheAudio);
2200+ memcpy ((void *)tc, (void *)src, sizeof (AnimationMixer::TrackCacheAudio));
2201+ return tc;
2202+ }
2203+
2204+ case Animation::TYPE_METHOD:
2205+ case Animation::TYPE_ANIMATION: {
2206+ // Nothing to do here.
2207+ } break ;
2208+ }
2209+ return nullptr ;
2210+ }
0 commit comments