Mesh: merge `mesh_create_eval_final_{view,render}` functions

Functions `mesh_create_eval_final_view()` and
`mesh_create_eval_final_render()` were doing the exact same thing,
except for a hack introduced in d3eb9dddd6 (2012-10-08, Better fix for
T32846: dupligroup messes up particle instancing on rendering) that
appears to be no longer necessary. Besides that, these functions had
confusing names. Their functionality changed over time, and whether to
do for-render or for-viewport evaluation is now actually determined by
the depsgraph evaluation mode. This means that the `..._render` function
could evaluate a mesh with viewport settings, and vice versa.

The functions are now merged into `mesh_create_eval_final()`, and the
hack has been removed. The `OB_NO_PSYS_UPDATE` flag has been removed
entirely (instead of keeping it around as deprecated flag), because it
was always only temporarily set on objects during mesh evaluation and
thus not saved to the blend file.

No expected functional changes as far as users are concerned.
This commit is contained in:
Sybren A. Stüvel 2020-08-18 12:58:48 +02:00
parent e371378c8b
commit fc5eab3570
9 changed files with 8 additions and 43 deletions

View File

@ -71,7 +71,7 @@ struct Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph,
struct Object *ob,
const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_final_render(struct Depsgraph *depsgraph,
struct Mesh *mesh_create_eval_final(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
const struct CustomData_MeshMasks *dataMask);
@ -82,11 +82,6 @@ struct Mesh *mesh_create_eval_final_index_render(struct Depsgraph *depsgraph,
const struct CustomData_MeshMasks *dataMask,
int index);
struct Mesh *mesh_create_eval_final_view(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,
const struct CustomData_MeshMasks *dataMask);
struct Mesh *mesh_create_eval_no_deform(struct Depsgraph *depsgraph,
struct Scene *scene,
struct Object *ob,

View File

@ -1991,7 +1991,7 @@ Mesh *mesh_get_eval_deform(struct Depsgraph *depsgraph,
return ob->runtime.mesh_deform_eval;
}
Mesh *mesh_create_eval_final_render(Depsgraph *depsgraph,
Mesh *mesh_create_eval_final(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
const CustomData_MeshMasks *dataMask)
@ -2016,26 +2016,6 @@ Mesh *mesh_create_eval_final_index_render(Depsgraph *depsgraph,
return final;
}
Mesh *mesh_create_eval_final_view(Depsgraph *depsgraph,
Scene *scene,
Object *ob,
const CustomData_MeshMasks *dataMask)
{
Mesh *final;
/* XXX hack
* psys modifier updates particle state when called during dupli-list generation,
* which can lead to wrong transforms. This disables particle system modifier execution.
*/
ob->transflag |= OB_NO_PSYS_UPDATE;
mesh_calc_modifiers(depsgraph, scene, ob, 1, false, dataMask, -1, false, false, NULL, &final);
ob->transflag &= ~OB_NO_PSYS_UPDATE;
return final;
}
Mesh *mesh_create_eval_no_deform(Depsgraph *depsgraph,
Scene *scene,
Object *ob,

View File

@ -1111,15 +1111,7 @@ static Mesh *mesh_new_from_mesh_object_with_layers(Depsgraph *depsgraph, Object
Scene *scene = DEG_get_evaluated_scene(depsgraph);
CustomData_MeshMasks mask = CD_MASK_MESH;
Mesh *result;
if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
result = mesh_create_eval_final_render(depsgraph, scene, &object_for_eval, &mask);
}
else {
result = mesh_create_eval_final_view(depsgraph, scene, &object_for_eval, &mask);
}
Mesh *result = mesh_create_eval_final(depsgraph, scene, &object_for_eval, &mask);
return result;
}

View File

@ -107,7 +107,7 @@ static void object_force_modifier_update_for_bind(Depsgraph *depsgraph, Object *
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
BKE_object_eval_reset(ob_eval);
if (ob->type == OB_MESH) {
Mesh *me_eval = mesh_create_eval_final_view(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
Mesh *me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &CD_MASK_BAREMESH);
BKE_mesh_eval_delete(me_eval);
}
else if (ob->type == OB_LATTICE) {

View File

@ -4037,7 +4037,7 @@ static bool proj_paint_state_mesh_eval_init(const bContext *C, ProjPaintState *p
/* Workaround for subsurf selection, try the display mesh first */
if (ps->source == PROJ_SRC_IMAGE_CAM) {
/* using render mesh, assume only camera was rendered from */
ps->me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &cddata_masks);
ps->me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &cddata_masks);
ps->me_eval_free = true;
}
else {

View File

@ -537,8 +537,6 @@ enum {
OB_TRANSFLAG_UNUSED_12 = 1 << 12, /* cleared */
/* runtime constraints disable */
OB_NO_CONSTRAINTS = 1 << 13,
/* hack to work around particle issue */
OB_NO_PSYS_UPDATE = 1 << 14,
OB_DUPLI = OB_DUPLIVERTS | OB_DUPLICOLLECTION | OB_DUPLIFACES | OB_DUPLIPARTS,
};

View File

@ -219,7 +219,7 @@ static void deformVerts(ModifierData *md,
psmd->totdmedge = psmd->mesh_final->totedge;
psmd->totdmface = psmd->mesh_final->totface;
if (!(ctx->object->transflag & OB_NO_PSYS_UPDATE)) {
{
struct Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
psmd->flag &= ~eParticleSystemFlag_psys_updated;
particle_system_update(

View File

@ -1134,7 +1134,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
return NULL;
}
me_eval = mesh_create_eval_final_render(depsgraph, scene_eval, ob_eval, &data_masks);
me_eval = mesh_create_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
}
else {
if (use_cage) {

View File

@ -1053,7 +1053,7 @@ static Mesh *bvh_get_mesh(const char *funcname,
}
*r_free_mesh = true;
return mesh_create_eval_final_render(depsgraph, scene, ob, &data_masks);
return mesh_create_eval_final(depsgraph, scene, ob, &data_masks);
}
if (ob_eval != NULL) {
if (use_cage) {