Refactor: Remove pre-2.8 function to reevaluate a single object
This function replaced the evaluated mesh with a new one with the given custom data type mask. That doesn't work in general anymore for a few reasons: the increased dependence on named attributes (a opposed to custom data types), and the "all or nothing" approach to reevaluating the depsgraph. Other objects might depend on the object's evaluated geometry, so it shouldn't just be replaced. Pushed a bit further, this could give nice simplifications to mesh modifier evaluation. There are two breaking changes, `bmesh_from_object` and BVH tree `FromObject` require the source object to have a proper evaluated mesh now. If this causes a regression, it's likely that the object is missing an update tag when a mode is entered that requires extra evaluated data. Pull Request: https://projects.blender.org/blender/blender/pulls/106186
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "BKE_lib_id.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_mesh_runtime.h"
|
||||
#include "BKE_object.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
#include "DEG_depsgraph_query.h"
|
||||
@@ -1079,7 +1080,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
Object *ob, *ob_eval;
|
||||
struct Depsgraph *depsgraph;
|
||||
struct Scene *scene_eval;
|
||||
Mesh *me_eval;
|
||||
const Mesh *me_eval;
|
||||
BMesh *bm;
|
||||
bool use_cage = false;
|
||||
bool use_fnorm = true;
|
||||
@@ -1134,7 +1135,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
me_eval = mesh_get_eval_deform(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
}
|
||||
else {
|
||||
me_eval = mesh_get_eval_final(depsgraph, scene_eval, ob_eval, &data_masks);
|
||||
me_eval = BKE_object_get_evaluated_mesh(ob_eval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1155,7 +1156,7 @@ static PyObject *bpy_bmesh_from_object(BPy_BMesh *self, PyObject *args, PyObject
|
||||
}));
|
||||
|
||||
if (need_free) {
|
||||
BKE_id_free(NULL, me_eval);
|
||||
BKE_id_free(NULL, (Mesh *)me_eval);
|
||||
}
|
||||
|
||||
Py_RETURN_NONE;
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
# include "BKE_lib_id.h"
|
||||
# include "BKE_mesh.hh"
|
||||
# include "BKE_mesh_runtime.h"
|
||||
# include "BKE_object.h"
|
||||
|
||||
# include "DEG_depsgraph_query.h"
|
||||
|
||||
@@ -1017,13 +1018,13 @@ static PyObject *C_BVHTree_FromBMesh(PyObject * /*cls*/, PyObject *args, PyObjec
|
||||
}
|
||||
|
||||
/* return various derived meshes based on requested settings */
|
||||
static Mesh *bvh_get_mesh(const char *funcname,
|
||||
Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
Object *ob,
|
||||
const bool use_deform,
|
||||
const bool use_cage,
|
||||
bool *r_free_mesh)
|
||||
static const Mesh *bvh_get_mesh(const char *funcname,
|
||||
Depsgraph *depsgraph,
|
||||
Scene *scene,
|
||||
Object *ob,
|
||||
const bool use_deform,
|
||||
const bool use_cage,
|
||||
bool *r_free_mesh)
|
||||
{
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
/* we only need minimum mesh data for topology and vertex locations */
|
||||
@@ -1050,7 +1051,7 @@ static Mesh *bvh_get_mesh(const char *funcname,
|
||||
return mesh_get_eval_deform(depsgraph, scene, ob_eval, &data_masks);
|
||||
}
|
||||
|
||||
return mesh_get_eval_final(depsgraph, scene, ob_eval, &data_masks);
|
||||
return BKE_object_get_evaluated_mesh(ob_eval);
|
||||
}
|
||||
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
@@ -1108,7 +1109,7 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
|
||||
Object *ob;
|
||||
Depsgraph *depsgraph;
|
||||
Scene *scene;
|
||||
Mesh *mesh;
|
||||
const Mesh *mesh;
|
||||
bool use_deform = true;
|
||||
bool use_cage = false;
|
||||
bool free_mesh = false;
|
||||
@@ -1190,7 +1191,7 @@ static PyObject *C_BVHTree_FromObject(PyObject * /*cls*/, PyObject *args, PyObje
|
||||
}
|
||||
|
||||
if (free_mesh) {
|
||||
BKE_id_free(nullptr, mesh);
|
||||
BKE_id_free(nullptr, const_cast<Mesh *>(mesh));
|
||||
}
|
||||
|
||||
return bvhtree_CreatePyObject(tree,
|
||||
|
||||
Reference in New Issue
Block a user