diff options
author | Hans Goudey <h.goudey@me.com> | 2021-11-05 19:51:34 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2021-11-05 19:51:34 +0300 |
commit | 1bc655c5aa644c1b3b933f9e372ec5b5b504c0d5 (patch) | |
tree | 1005a6c1e2a530062f89a2d16556bc2946167ee9 /source/blender/blenkernel/intern/object.cc | |
parent | c473b2ce8bdbf8fa42d9780de035d34cb8d0e8a5 (diff) |
Fix T92815: Incorrect handling of evaluated meshes from curves
Evaluated meshes from curves are presented to render engines as
separate instance objects now, just like evaluated meshes from other
object types like point clouds and volumes. For that reason, cycles
should not consider curve objects as geometry (previously it did,
meaning it retrieved a second mesh from the curve object as well
as the temporary evaluated mesh geometry).
Further, avoid adding a curve object's evaluated mesh as data_eval,
since that is special behavior for meshes that is arbitrary. Adding an
evaluated mesh there but not an evalauted pointcloud is arbitrary,
for example. Retrieve the evaluated mesh in from the geometry set
in BKE_object_get_evaluated_mesh now, to support that change.
This gets us closer to a place where all of an object's evaluated data
is stored in geometry_set_eval, and we just have helper functions
to access specific geometry components.
Differential Revision: https://developer.blender.org/D13118
Diffstat (limited to 'source/blender/blenkernel/intern/object.cc')
-rw-r--r-- | source/blender/blenkernel/intern/object.cc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index fc25153b3ff..9073fd6adbb 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -96,6 +96,7 @@ #include "BKE_fcurve.h" #include "BKE_fcurve_driver.h" #include "BKE_geometry_set.h" +#include "BKE_geometry_set.hh" #include "BKE_global.h" #include "BKE_gpencil.h" #include "BKE_gpencil_geom.h" @@ -4559,8 +4560,28 @@ bool BKE_object_obdata_texspace_get(Object *ob, short **r_texflag, float **r_loc /** Get evaluated mesh for given object. */ Mesh *BKE_object_get_evaluated_mesh(const Object *object) { + /* First attempt to retrieve the evaluated mesh from the evaluated geometry set. Most + * object types either store it there or add a reference to it if it's owned elsewhere. */ + GeometrySet *geometry_set_eval = object->runtime.geometry_set_eval; + if (geometry_set_eval) { + /* Some areas expect to be able to modify the evaluated mesh. Theoretically this should be + * avoided, or at least protected with a lock, so a const mesh could be returned from this + * function. */ + Mesh *mesh = geometry_set_eval->get_mesh_for_write(); + if (mesh) { + return mesh; + } + } + + /* Some object types do not yet add the evaluated mesh to an evaluated geometry set, if they do + * not support evaluating to multiple data types. Eventually this should be removed, when all + * object types use #geometry_set_eval. */ ID *data_eval = object->runtime.data_eval; - return (data_eval && GS(data_eval->name) == ID_ME) ? (Mesh *)data_eval : nullptr; + if (data_eval && GS(data_eval->name) == ID_ME) { + return reinterpret_cast<Mesh *>(data_eval); + } + + return nullptr; } /** |