Cleanup: Wrap object runtime eval members into own struct
This commit is contained in:
parent
a01244cade
commit
9abbf73d3f
|
@ -341,15 +341,16 @@ void BKE_object_free_derived_caches(Object *ob)
|
|||
ob->derivedDeform = NULL;
|
||||
}
|
||||
|
||||
if (ob->mesh_eval != NULL) {
|
||||
if (ob->runtime.mesh_eval != NULL) {
|
||||
Mesh *mesh_eval = ob->runtime.mesh_eval;
|
||||
/* Restore initial pointer. */
|
||||
ob->data = ob->mesh_eval->id.orig_id;
|
||||
ob->data = mesh_eval->id.orig_id;
|
||||
/* Evaluated mesh points to edit mesh, but does not own it. */
|
||||
ob->mesh_eval->edit_btmesh = NULL;
|
||||
BKE_mesh_free(ob->mesh_eval);
|
||||
BKE_libblock_free_data(&ob->mesh_eval->id, false);
|
||||
MEM_freeN(ob->mesh_eval);
|
||||
ob->mesh_eval = NULL;
|
||||
mesh_eval->edit_btmesh = NULL;
|
||||
BKE_mesh_free(mesh_eval);
|
||||
BKE_libblock_free_data(&mesh_eval->id, false);
|
||||
MEM_freeN(mesh_eval);
|
||||
ob->runtime.mesh_eval = NULL;
|
||||
}
|
||||
|
||||
BKE_object_free_curve_cache(ob);
|
||||
|
@ -2837,8 +2838,7 @@ int BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc,
|
|||
Mesh *BKE_object_get_evaluated_mesh(const Depsgraph *depsgraph, Object *ob)
|
||||
{
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
|
||||
return ob_eval->mesh_eval;
|
||||
return ob_eval->runtime.mesh_eval;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -350,7 +350,7 @@ void BKE_object_eval_uber_data(Depsgraph *depsgraph,
|
|||
* explicit way to query final object evaluated data and know for sure
|
||||
* who owns the newly created mesh datablock.
|
||||
*/
|
||||
ob->mesh_eval = new_mesh;
|
||||
ob->runtime.mesh_eval = new_mesh;
|
||||
/* TODO(sergey): This is kind of compatibility thing, so all render
|
||||
* engines can use object->data for mesh data for display. This is
|
||||
* something what we might want to change in the future.
|
||||
|
|
|
@ -756,8 +756,8 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
|
|||
{
|
||||
Object *object = (Object *)id_cow;
|
||||
/* Store evaluated mesh, make sure we don't free it. */
|
||||
mesh_eval = object->mesh_eval;
|
||||
object->mesh_eval = NULL;
|
||||
mesh_eval = object->runtime.mesh_eval;
|
||||
object->runtime.mesh_eval = NULL;
|
||||
/* Currently object update will override actual object->data
|
||||
* to an evaluated version. Need to make sure we don't have
|
||||
* data set to evaluated one before free anything.
|
||||
|
@ -792,7 +792,7 @@ ID *deg_update_copy_on_write_datablock(const Depsgraph *depsgraph,
|
|||
if (id_type == ID_OB) {
|
||||
Object *object = (Object *)id_cow;
|
||||
if (mesh_eval != NULL) {
|
||||
object->mesh_eval = mesh_eval;
|
||||
object->runtime.mesh_eval = mesh_eval;
|
||||
/* Do same thing as object update: override actual object data
|
||||
* pointer with evaluated datablock.
|
||||
*/
|
||||
|
|
|
@ -143,6 +143,14 @@ typedef struct ObjectDisplay {
|
|||
int flag;
|
||||
} ObjectDisplay;
|
||||
|
||||
/* Not saved in file! */
|
||||
typedef struct Object_Runtime {
|
||||
/* Mesh structure created during object evaluation.
|
||||
* It has all modifiers applied.
|
||||
*/
|
||||
struct Mesh *mesh_eval;
|
||||
} Object_Runtime;
|
||||
|
||||
typedef struct Object {
|
||||
ID id;
|
||||
struct AnimData *adt; /* animation data (must be immediately after id for utilities to use it) */
|
||||
|
@ -299,10 +307,8 @@ typedef struct Object {
|
|||
int pad6;
|
||||
int select_color;
|
||||
|
||||
/* Mesh structure created during object evaluation.
|
||||
* It has all modifiers applied.
|
||||
*/
|
||||
struct Mesh *mesh_eval;
|
||||
/* Runtime evaluation data. */
|
||||
Object_Runtime runtime;
|
||||
|
||||
/* Object Display */
|
||||
struct ObjectDisplay display;
|
||||
|
|
Loading…
Reference in New Issue