From 56407432a6aae92dc272f7c8b37fc664e8d2108d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Mon, 14 Feb 2022 16:35:25 +0100 Subject: Fix T94479: GPU Subdivision surface modifier does not apply to Cycles renders Since now we delegate the evaluation of the last subsurf modifier in the stack to the draw code, Cycles does not get a subdivided mesh anymore. This is because the subdivision wrapper for generating a CPU side subdivision is never created as it is only ever created via `BKE_object_get_evaluated_mesh` which Cycles does not call (rather, it accesses the Mesh either via `object.data()`, or via `object.to_mesh()`). This ensures that a subdivision wrapper is created when accessing the object data or converting an Object to a Mesh via the RNA/Python API. Reviewed by: brecht Differential Revision: https://developer.blender.org/D14048 --- source/blender/makesrna/intern/rna_object.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index a098693459b..207cde4b866 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -345,6 +345,7 @@ const EnumPropertyItem rna_enum_object_axis_items[] = { # include "BKE_key.h" # include "BKE_material.h" # include "BKE_mesh.h" +# include "BKE_mesh_wrapper.h" # include "BKE_modifier.h" # include "BKE_object.h" # include "BKE_particle.h" @@ -524,6 +525,17 @@ void rna_Object_data_update(Main *bmain, Scene *scene, PointerRNA *ptr) rna_Object_internal_update_data_dependency(bmain, scene, ptr); } +static PointerRNA rna_Object_data_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->data; + if (ob->type == OB_MESH) { + Mesh *me = (Mesh *)ob->data; + me = BKE_mesh_wrapper_ensure_subdivision(ob, me); + return rna_pointer_inherit_refine(ptr, &RNA_Mesh, me); + } + return rna_pointer_inherit_refine(ptr, &RNA_ID, ob->data); +} + static void rna_Object_data_set(PointerRNA *ptr, PointerRNA value, struct ReportList *reports) { Object *ob = (Object *)ptr->data; @@ -3055,8 +3067,11 @@ static void rna_def_object(BlenderRNA *brna) prop = RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ID"); - RNA_def_property_pointer_funcs( - prop, NULL, "rna_Object_data_set", "rna_Object_data_typef", "rna_Object_data_poll"); + RNA_def_property_pointer_funcs(prop, + "rna_Object_data_get", + "rna_Object_data_set", + "rna_Object_data_typef", + "rna_Object_data_poll"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_UNLINK); RNA_def_property_ui_text(prop, "Data", "Object data"); RNA_def_property_update(prop, 0, "rna_Object_data_update"); -- cgit v1.2.3