Commit: 12722bd354589058a713cf875fa291ed129d6bb5 Author: Hans Goudey Date: Fri Jun 3 15:54:03 2022 +0200 Branches: master https://developer.blender.org/rB12722bd354589058a713cf875fa291ed129d6bb5
Curves: Add surface UV map name property In the latest discussions about curves/hair mesh attachement information (T95776), it was decided to use UV coordinates to store where on the mesh each root is. For that, we have to specify which of the UV map attributes to use for UV lookups. This property isn't used yet, but it will be shortly when refactoring the attachement information in the add brush and the to particle system conversion. Differential Revision: https://developer.blender.org/D15115 =================================================================== M release/scripts/startup/bl_ui/properties_data_curves.py M source/blender/blenkernel/intern/curves.cc M source/blender/makesdna/DNA_curves_types.h M source/blender/makesrna/intern/rna_curves.c =================================================================== diff --git a/release/scripts/startup/bl_ui/properties_data_curves.py b/release/scripts/startup/bl_ui/properties_data_curves.py index 231e6634c68..ed7f6e3697c 100644 --- a/release/scripts/startup/bl_ui/properties_data_curves.py +++ b/release/scripts/startup/bl_ui/properties_data_curves.py @@ -44,6 +44,7 @@ class DATA_PT_curves_surface(DataButtonsPanel, Panel): layout.use_property_split = True layout.prop(ob.data, "surface") + layout.prop(ob.data, "surface_uv_map", text="UV Map") class CURVES_MT_add_attribute(Menu): diff --git a/source/blender/blenkernel/intern/curves.cc b/source/blender/blenkernel/intern/curves.cc index ab9dd702630..589a1a9208e 100644 --- a/source/blender/blenkernel/intern/curves.cc +++ b/source/blender/blenkernel/intern/curves.cc @@ -89,6 +89,10 @@ static void curves_copy_data(Main *UNUSED(bmain), ID *id_dst, const ID *id_src, dst.curve_offsets = static_cast<int *>(MEM_dupallocN(src.curve_offsets)); + if (curves_src->surface_uv_map != nullptr) { + curves_dst->surface_uv_map = BLI_strdup(curves_src->surface_uv_map); + } + dst.runtime = MEM_new<bke::CurvesGeometryRuntime>(__func__); dst.runtime->type_counts = src.runtime->type_counts; @@ -108,6 +112,7 @@ static void curves_free_data(ID *id) BKE_curves_batch_cache_free(curves); MEM_SAFE_FREE(curves->mat); + MEM_SAFE_FREE(curves->surface_uv_map); } static void curves_foreach_id(ID *id, LibraryForeachIDData *data) @@ -148,6 +153,8 @@ static void curves_blend_write(BlendWriter *writer, ID *id, const void *id_addre BLO_write_int32_array(writer, curves->geometry.curve_num + 1, curves->geometry.curve_offsets); + BLO_write_string(writer, curves->surface_uv_map); + BLO_write_pointer_array(writer, curves->totcol, curves->mat); if (curves->adt) { BKE_animdata_blend_write(writer, curves->adt); @@ -167,6 +174,8 @@ static void curves_blend_read_data(BlendDataReader *reader, ID *id) BLO_read_int32_array(reader, curves->geometry.curve_num + 1, &curves->geometry.curve_offsets); + BLO_read_data_address(reader, &curves->surface_uv_map); + curves->geometry.runtime = MEM_new<blender::bke::CurvesGeometryRuntime>(__func__); /* Recalculate curve type count cache that isn't saved in files. */ diff --git a/source/blender/makesdna/DNA_curves_types.h b/source/blender/makesdna/DNA_curves_types.h index 9690c342fdd..ed909c283c4 100644 --- a/source/blender/makesdna/DNA_curves_types.h +++ b/source/blender/makesdna/DNA_curves_types.h @@ -157,6 +157,13 @@ typedef struct Curves { */ struct Object *surface; + /** + * The name of the attribute on the surface #Mesh used to give meaning to the UV attachment + * coordinates stored on each curve. Expected to be a 2D vector attribute on the face corner + * domain. + */ + char *surface_uv_map; + /* Draw Cache. */ void *batch_cache; } Curves; diff --git a/source/blender/makesrna/intern/rna_curves.c b/source/blender/makesrna/intern/rna_curves.c index caefd2f45ff..b50082056bf 100644 --- a/source/blender/makesrna/intern/rna_curves.c +++ b/source/blender/makesrna/intern/rna_curves.c @@ -292,6 +292,14 @@ static void rna_def_curves(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Surface", "Mesh object that the curves can be attached to"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "surface_uv_map", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "surface_uv_map"); + RNA_def_property_ui_text(prop, + "Surface UV Map", + "The name of the attribute on the surface mesh used to define the " + "attachment of each curve"); + RNA_def_property_update(prop, 0, "rna_Curves_update_draw"); + /* Symmetry. */ prop = RNA_def_property(srna, "use_mirror_x", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "symmetry", CURVES_SYMMETRY_X); _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
