Commit: 4c1c2c43a146ec2664bc118d9e4e872bff417adc Author: Hans Goudey Date: Mon Sep 5 21:51:14 2022 -0500 Branches: refactor-mesh-uv-map-generic https://developer.blender.org/rB4c1c2c43a146ec2664bc118d9e4e872bff417adc
Fixes after merge, cleanup =================================================================== M source/blender/blenkernel/BKE_mesh_legacy_convert.h M source/blender/blenkernel/intern/customdata.cc M source/blender/blenkernel/intern/mesh_legacy_convert.cc M source/blender/blenkernel/intern/mesh_merge_customdata.cc M source/blender/blenkernel/intern/pbvh_pixels.cc M source/blender/blenkernel/intern/subdiv_mesh.cc M source/blender/blenloader/intern/versioning_defaults.c M source/blender/bmesh/intern/bmesh_query_uv.h M source/blender/editors/mesh/mesh_data.cc M source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp M source/blender/makesdna/DNA_meshdata_types.h M source/blender/render/intern/texture_margin.cc =================================================================== diff --git a/source/blender/blenkernel/BKE_mesh_legacy_convert.h b/source/blender/blenkernel/BKE_mesh_legacy_convert.h index cf39132481d..0a47c665300 100644 --- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h +++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h @@ -44,12 +44,6 @@ void BKE_mesh_legacy_convert_hide_layers_to_flags(struct Mesh *mesh); */ void BKE_mesh_legacy_convert_flags_to_hide_layers(struct Mesh *mesh); -#endif - -#ifdef __cplusplus -extern "C" { -#endif - /** * Move material indices from a generic attribute to #MPoly. */ @@ -60,6 +54,12 @@ void BKE_mesh_legacy_convert_material_indices_to_mpoly(struct Mesh *mesh); */ void BKE_mesh_legacy_convert_mpoly_to_material_indices(struct Mesh *mesh); +#endif + +#ifdef __cplusplus +extern "C" { +#endif + /** * Recreate #MFace Tessellation. * diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 472efd52102..c7b6f718907 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -58,6 +58,7 @@ /* only for customdata_data_transfer_interp_normal_normals */ #include "data_transfer_intern.h" +using blender::float2; using blender::IndexRange; using blender::Set; using blender::Span; @@ -1517,27 +1518,25 @@ static bool layerValidate_propfloat2(void *data, const uint totitems, const bool static bool layerEqual_propfloat2(const void *data1, const void *data2) { - const float *luv1 = static_cast<const float *>(data1); - const float *luv2 = static_cast<const float *>(data2); + const float2 &a = *static_cast<const float2 *>(data1); + const float2 &b = *static_cast<const float2 *>(data2); - return len_squared_v2v2(luv1, luv2) < 0.00001f; + return blender::math::distance_squared(a, b) < 0.00001f; } static void layerInitMinMax_propfloat2(void *vmin, void *vmax) { - float *min = static_cast<float *>(vmin); - float *max = static_cast<float *>(vmax); - + float2 &min = *static_cast<float2 *>(vmin); + float2 &max = *static_cast<float2 *>(vmax); INIT_MINMAX2(min, max); } static void layerDoMinMax_propfloat2(const void *data, void *vmin, void *vmax) { - const float *luv = static_cast<const float *>(data); - float *min = static_cast<float *>(vmin); - float *max = static_cast<float *>(vmax); - - minmax_v2v2_v2(min, max, luv); + const float2 &value = *static_cast<const float2 *>(data); + float2 &a = *static_cast<float2 *>(vmin); + float2 &b = *static_cast<float2 *>(vmax); + blender::math::min_max(value, a, b); } static void layerCopyValue_propfloat2(const void *source, @@ -1545,17 +1544,16 @@ static void layerCopyValue_propfloat2(const void *source, const int mixmode, const float mixfactor) { - const float *luv1 = static_cast<const float *>(source); - float *luv2 = static_cast<float *>(dest); + const float2 &a = *static_cast<const float2 *>(source); + float2 &b = *static_cast<float2 *>(dest); - /* We only support a limited subset of advanced mixing here - + /* We only support a limited subset of advanced mixing here- * namely the mixfactor interpolation. */ - if (mixmode == CDT_MIX_NOMIX) { - copy_v2_v2(luv2, luv1); + b = a; } else { - interp_v2_v2v2(luv2, luv2, luv1, mixfactor); + b = blender::math::interpolate(b, a, mixfactor); } } @@ -3515,6 +3513,7 @@ bool CustomData_set_layer_name(CustomData *data, const int type, const int n, co const char *CustomData_get_layer_name(const CustomData *data, const int type, const int n) { const int layer_index = CustomData_get_layer_index_n(data, type, n); + return (layer_index == -1) ? nullptr : data->layers[layer_index].name; } diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc index af3c51758b9..afd15407b1a 100644 --- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc +++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc @@ -50,15 +50,15 @@ static void bm_corners_to_loops_ex(ID *id, blender::float2 *uv = static_cast<blender::float2 *>( CustomData_get_n(ldata, CD_PROP_FLOAT2, loopstart, i)); - copy_v2_v2((float *)uv, texface->uv[0]); + copy_v2_v2(*uv, texface->uv[0]); uv++; - copy_v2_v2((float *)uv, texface->uv[1]); + copy_v2_v2(*uv, texface->uv[1]); uv++; - copy_v2_v2((float *)uv, texface->uv[2]); + copy_v2_v2(*uv, texface->uv[2]); uv++; if (mf->v4) { - copy_v2_v2((float *)uv, texface->uv[3]); + copy_v2_v2(*uv, texface->uv[3]); uv++; } } diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc index a255431151c..d85ed2fd1cf 100644 --- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc +++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc @@ -58,8 +58,7 @@ static int compare_v2_classify(const float uv_a[2], const float uv_b[2]) return CMP_APART; } -static void merge_uvs_for_vertex(const Span<int> loops_for_vert, - Span<blender::float2 *> mloopuv_layers) +static void merge_uvs_for_vertex(const Span<int> loops_for_vert, Span<float2 *> mloopuv_layers) { if (loops_for_vert.size() <= 1) { return; @@ -67,7 +66,7 @@ static void merge_uvs_for_vertex(const Span<int> loops_for_vert, /* Manipulate a copy of the loop indices, de-duplicating UV's per layer. */ Vector<int, 32> loops_merge; loops_merge.reserve(loops_for_vert.size()); - for (blender::float2 *mloopuv : mloopuv_layers) { + for (float2 *mloopuv : mloopuv_layers) { BLI_assert(loops_merge.is_empty()); loops_merge.extend_unchecked(loops_for_vert); while (loops_merge.size() > 1) { @@ -123,15 +122,14 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *me) me->totpoly, me->totloop); - Vector<blender::float2 *> mloopuv_layers; + Vector<float2 *> mloopuv_layers; mloopuv_layers.reserve(mloopuv_layers_num); for (int a = 0; a < mloopuv_layers_num; a++) { - blender::float2 *mloopuv = static_cast<blender::float2 *>( - CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, a)); + float2 *mloopuv = static_cast<float2 *>(CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, a)); mloopuv_layers.append_unchecked(mloopuv); } - Span<blender::float2 *> mloopuv_layers_as_span = mloopuv_layers.as_span(); + Span<float2 *> mloopuv_layers_as_span = mloopuv_layers.as_span(); threading::parallel_for(IndexRange(me->totvert), 1024, [&](IndexRange range) { for (const int64_t v_index : range) { diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc index 6dcc1e4f836..f3e9bb169ef 100644 --- a/source/blender/blenkernel/intern/pbvh_pixels.cc +++ b/source/blender/blenkernel/intern/pbvh_pixels.cc @@ -284,7 +284,7 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image return; } - const float2 *ldata_uv = static_cast<float2 *>( + const float2 *ldata_uv = static_cast<const float2 *>( CustomData_get_layer(&mesh->ldata, CD_PROP_FLOAT2)); if (ldata_uv == nullptr) { diff --git a/source/blender/blenkernel/intern/subdiv_mesh.cc b/source/blender/blenkernel/intern/subdiv_mesh.cc index 2107fd3127e..11e3ae5b293 100644 --- a/source/blender/blenkernel/intern/subdiv_mesh.cc +++ b/source/blender/blenkernel/intern/subdiv_mesh.cc @@ -26,6 +26,8 @@ #include "MEM_guardedalloc.h" +using blender::float2; + /* -------------------------------------------------------------------- */ /** \name Subdivision Context * \{ */ @@ -52,7 +54,7 @@ struct SubdivMeshContext { int *poly_origindex; /* UV layers interpolation. */ int num_uv_layers; - blender::float2 *uv_layers[MAX_MTFACE]; + float2 *uv_layers[MAX_MTFACE]; /* Original coordinates (ORCO) interpolation. */ float (*orco)[3]; @@ -67,7 +69,7 @@ static void subdiv_mesh_ctx_cache_uv_layers(SubdivMeshContext *ctx) Mesh *subdiv_mesh = ctx->subdiv_mesh; ctx->num_uv_layers = CustomData_number_of_layers(&subdiv_mesh->ldata, CD_PROP_FLOAT2); for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) { - ctx->uv_layers[layer_index] = static_cast<blender::float2 *>( + ctx->uv_layers[layer_index] = static_cast<float2 *>( CustomData_get_layer_n(&subdiv_mesh->ldata, CD_PROP_FLOAT2, layer_index)); } } diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c index 812e8fd3401..f9179bc7b34 100644 --- a/source/blender/blenloader/intern/versioning_defaults.c +++ b/source/blender/blenloader/intern/versioning_defaults.c @@ -353,7 +353,7 @@ static void blo_update_defaults_scene(Main *bmain, Scene *scene) {0.625, 0.75}, {0.375, 0.75}, {0.375, 0.25}, {0.625, 0.25}, {0.625, 0.50}, {0.375, 0.50}, }; float(*mloopuv)[2] = CustomData_get_layer(&me->ldata, CD_MLOOPUV); - memcpy(mloopuv, uv_values, sizeof(float[2]) * ARRAY_SIZE(uv_values)); + memcpy(mloopuv, uv_values, sizeof(float[2]) * me->totloop); } /* Make sure that the curve profile is initialized */ diff --git a/source/blender/bmesh/intern/bmesh_query_uv.h b/source/blender/bmesh/intern/bmesh_query_uv.h index 669a04a7eb6..00d326290bb 100644 --- a/source/blender/bmesh/intern/bmesh_query_uv.h +++ b/source/blender/bmesh/intern/bmesh_query_uv.h @@ -7,7 +7,7 @@ */ /** - * Get a descriptor containing offsets for layers used for user interaction with the active UV map. + * Retrieve the custom data offsets for layers used for user interaction with the active UV map. */ BMUVOffsets BM_uv_map_get_offsets(const BMesh *bm); diff --git a/source/blender/editors/mesh/mesh_data.cc b/source/blender/editors/mesh/mesh_data.cc index e4637878fbf..adf90e61c7f 100644 --- a/source/blender/editors/mesh/mesh_data.cc +++ b/source/blender/editors/mesh/mesh_data.cc @@ -34,6 +34,8 @@ #include "WM_api.h" #include "WM_types.h" +#include "BLT_translation.h" + #include "ED_mesh.h" #include "ED_ @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs