Fix T66610: Planar Track extremely laggy when 3D View is open

The issue was caused by modifications to planar track tagging clip for
copy-on-write, which was invalidating its cache and forcing current
frame in 3D viewport to be re-load.

Ideal solution would be to share movie cache across original and
evaluated movie clips which will reduce memory usage. However, doing
such ownership changes so close to the code freeze is not something
comfortable to do.
This commit is contained in:
Sergey Sharybin
2019-07-09 15:43:42 +02:00
parent fd48ef25a0
commit 32f591c0a3

View File

@@ -1334,6 +1334,50 @@ void ObjectRuntimeBackup::restore_pose_channel_runtime_data(Object *object)
}
}
/* Backup of movie clip runtime data. */
class MovieClipBackup {
public:
MovieClipBackup();
void reset();
void init_from_movieclip(MovieClip *movieclip);
void restore_to_movieclip(MovieClip *movieclip);
struct anim *anim;
struct MovieClipCache *cache;
};
MovieClipBackup::MovieClipBackup()
{
reset();
}
void MovieClipBackup::reset()
{
anim = NULL;
cache = NULL;
}
void MovieClipBackup::init_from_movieclip(MovieClip *movieclip)
{
anim = movieclip->anim;
cache = movieclip->cache;
/* Clear pointers stored in the movie clip, so they are not freed when copied-on-written
* datablock is freed for re-allocation. */
movieclip->anim = NULL;
movieclip->cache = NULL;
}
void MovieClipBackup::restore_to_movieclip(MovieClip *movieclip)
{
movieclip->anim = anim;
movieclip->cache = cache;
reset();
}
class RuntimeBackup {
public:
RuntimeBackup() : drawdata_ptr(NULL)
@@ -1352,6 +1396,7 @@ class RuntimeBackup {
ObjectRuntimeBackup object_backup;
DrawDataList drawdata_backup;
DrawDataList *drawdata_ptr;
MovieClipBackup movieclip_backup;
};
void RuntimeBackup::init_from_id(ID *id)
@@ -1370,6 +1415,9 @@ void RuntimeBackup::init_from_id(ID *id)
case ID_SO:
sound_backup.init_from_sound(reinterpret_cast<bSound *>(id));
break;
case ID_MC:
movieclip_backup.init_from_movieclip(reinterpret_cast<MovieClip *>(id));
break;
default:
break;
}
@@ -1395,6 +1443,9 @@ void RuntimeBackup::restore_to_id(ID *id)
case ID_SO:
sound_backup.restore_to_sound(reinterpret_cast<bSound *>(id));
break;
case ID_MC:
movieclip_backup.restore_to_movieclip(reinterpret_cast<MovieClip *>(id));
break;
default:
break;
}