[Bf-blender-cvs] [257c0616693] refactor-mesh-uv-map-generic: Merge branch 'master' into refactor-mesh-uv-map-generic
Martijn Versteegh
noreply at git.blender.org
Thu Sep 29 20:04:25 CEST 2022
Commit: 257c06166939cab750d4cd37f2f14eaf0e4f319b
Author: Martijn Versteegh
Date: Fri Sep 23 09:37:51 2022 +0200
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB257c06166939cab750d4cd37f2f14eaf0e4f319b
Merge branch 'master' into refactor-mesh-uv-map-generic
===================================================================
===================================================================
diff --cc source/blender/blenkernel/BKE_mesh_legacy_convert.h
index 12e4f32230a,e67aec0b9ce..a51eb06042e
--- a/source/blender/blenkernel/BKE_mesh_legacy_convert.h
+++ b/source/blender/blenkernel/BKE_mesh_legacy_convert.h
@@@ -9,12 -9,6 +9,13 @@@
#include "BLI_utildefines.h"
+#ifdef __cplusplus
+# include "BLI_array.hh"
+# include "BLI_resource_scope.hh"
+# include "BLI_vector.hh"
++# include "DNA_customdata_types.h"
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
diff --cc source/blender/blenkernel/intern/attribute_access.cc
index 70abed9c4db,df7787986db..45f4299ac3c
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@@ -55,22 -58,8 +58,25 @@@ const char *no_procedural_access_messag
bool allow_procedural_attribute_access(StringRef attribute_name)
{
- return !attribute_name.startswith(".sculpt") && !attribute_name.startswith(".selection") &&
- !attribute_name.startswith(".hide");
+ if (attribute_name.startswith(".selection")) {
+ return false;
+ }
++ if (attribute_name.startswith(".sculpt")) {
++ return false;
++ }
+ if (attribute_name.startswith(".hide")) {
+ return false;
+ }
+ if (attribute_name.startswith("." UV_VERTSEL_NAME ".")) {
+ return false;
+ }
+ if (attribute_name.startswith("." UV_EDGESEL_NAME ".")) {
+ return false;
+ }
+ if (attribute_name.startswith("." UV_PINNED_NAME ".")) {
+ return false;
+ }
+ return true;
}
static int attribute_data_type_complexity(const eCustomDataType data_type)
diff --cc source/blender/blenkernel/intern/mesh_mapping.cc
index 8c424c8a0eb,db091361223..d85ccde919b
--- a/source/blender/blenkernel/intern/mesh_mapping.cc
+++ b/source/blender/blenkernel/intern/mesh_mapping.cc
@@@ -927,11 -934,11 +934,11 @@@ void BKE_mesh_loop_islands_add(MeshIsla
* Would make things much more complex though,
* and each UVMap would then need its own mesh mapping, not sure we want that at all!
*/
- typedef struct MeshCheckIslandBoundaryUv {
+ struct MeshCheckIslandBoundaryUv {
const MLoop *loops;
- const MLoopUV *luvs;
+ const float (*luvs)[2];
const MeshElemMap *edge_loop_map;
- } MeshCheckIslandBoundaryUv;
+ };
static bool mesh_check_island_boundary_uv(const MPoly *UNUSED(mp),
const MLoop *ml,
@@@ -942,9 -949,10 +949,10 @@@
void *user_data)
{
if (user_data) {
- const MeshCheckIslandBoundaryUv *data = user_data;
+ const MeshCheckIslandBoundaryUv *data = static_cast<const MeshCheckIslandBoundaryUv *>(
+ user_data);
const MLoop *loops = data->loops;
- const MLoopUV *luvs = data->luvs;
+ const float(*luvs)[2] = data->luvs;
const MeshElemMap *edge_to_loops = &data->edge_loop_map[ml->e];
BLI_assert(edge_to_loops->count >= 2 && (edge_to_loops->count % 2) == 0);
diff --cc source/blender/editors/transform/transform_convert_mesh_uv.c
index fc4f6fad8bf,4f15fc240d3..96bcbaa412a
--- a/source/blender/editors/transform/transform_convert_mesh_uv.c
+++ b/source/blender/editors/transform/transform_convert_mesh_uv.c
@@@ -102,8 -105,7 +106,7 @@@ static void uv_set_connectivity_distanc
BM_ITER_ELEM (l, &liter, f, BM_LOOPS_OF_FACE) {
float dist;
-
- bool uv_vert_sel = BM_ELEM_CD_GET_OPT_BOOL(l, offsets.select_vert);
- bool uv_vert_sel = uvedit_uv_select_test_ex(ts, l, cd_loop_uv_offset);
++ bool uv_vert_sel = uvedit_uv_select_test_ex(ts, l, offsets);
if (uv_vert_sel) {
BLI_LINKSTACK_PUSH(queue, l);
@@@ -175,8 -179,8 +180,8 @@@
continue;
}
- MLoopUV *luv_connected = BM_ELEM_CD_GET_VOID_P(l_connected, cd_loop_uv_offset);
+ float *luv_connected = BM_ELEM_CD_GET_FLOAT_P(l_connected, offsets.uv);
- connected_vert_sel = BM_ELEM_CD_GET_OPT_BOOL(l_connected, offsets.select_vert);
+ connected_vert_sel = BM_elem_flag_test_bool(l_connected, TMP_LOOP_SELECT_TAG);
/* Check if this loop is connected in UV space.
* If the uv loops share the same selection state (if not, they are not connected as
diff --cc source/blender/makesrna/intern/rna_mesh.c
index de3deea28ee,222e4ac0371..fc1e9414e7c
--- a/source/blender/makesrna/intern/rna_mesh.c
+++ b/source/blender/makesrna/intern/rna_mesh.c
@@@ -1587,103 -1597,22 +1600,116 @@@ static int rna_Mesh_poly_normals_length
return mesh->totpoly;
}
+ int rna_Mesh_poly_normals_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr)
+ {
+ const Mesh *mesh = rna_mesh(ptr);
+ if (index < 0 || index >= mesh->totpoly) {
+ return false;
+ }
+ /* Casting away const is okay because this RNA type doesn't allow changing the value. */
+ r_ptr->owner_id = (ID *)&mesh->id;
+ r_ptr->type = &RNA_MeshNormalValue;
+ r_ptr->data = (float *)BKE_mesh_poly_normals_ensure(mesh)[index];
+ return true;
+ }
+
static char *rna_MeshUVLoop_path(const PointerRNA *ptr)
{
- return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_MLOOPUV);
+ return rna_LoopCustomData_data_path(ptr, "uv_layers", CD_PROP_FLOAT2);
+}
+
+static void get_uv_index_and_layer(const PointerRNA *ptr,
+ int *r_uv_map_index,
+ int *r_index_in_attribute)
+{
+ const Mesh *mesh = rna_mesh(ptr);
+ const float(*uv_coord)[2] = (const float(*)[2])ptr->data;
+
+ /* We don't know from which attribute the RNA pointer is from, so we need to scan them all. */
+ const int uv_layers_num = CustomData_number_of_layers(&mesh->ldata, CD_PROP_FLOAT2);
+ for (int layer_i = 0; layer_i < uv_layers_num; layer_i++) {
+ const float(*layer_data)[2] = (float(*)[2])CustomData_get_layer_n(
+ &mesh->ldata, CD_PROP_FLOAT2, layer_i);
+ const ptrdiff_t index = uv_coord - layer_data;
+ if (index >= 0 && index < mesh->totloop) {
+ *r_uv_map_index = layer_i;
+ *r_index_in_attribute = index;
+ return;
+ }
+ }
+
+ BLI_assert_unreachable();
+ return;
+}
+
+static bool rna_MeshUVLoop_select_get(PointerRNA *ptr)
+{
+ const Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ const bool *select = ED_mesh_uv_map_get_vert_selection(mesh, uv_index);
+ return select ? select[corner_index] : false;
+}
+
+static void rna_MeshUVLoop_select_set(PointerRNA *ptr, const bool value)
+{
+ Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ bool *select = ED_mesh_uv_map_ensure_vert_selection(mesh, uv_index);
+ select[corner_index] = value;
+}
+
+static bool rna_MeshUVLoop_select_edge_get(PointerRNA *ptr)
+{
+ const Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ const bool *select_edge = ED_mesh_uv_map_get_edge_selection(mesh, uv_index);
+ return select_edge ? select_edge[corner_index] : false;
+}
+
+static void rna_MeshUVLoop_select_edge_set(PointerRNA *ptr, const bool value)
+{
+ Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ bool *select_edge = ED_mesh_uv_map_ensure_edge_selection(mesh, uv_index);
+ select_edge[corner_index] = value;
+}
+
+static bool rna_MeshUVLoop_pin_uv_get(PointerRNA *ptr)
+{
+ const Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ const bool *pin_uv = ED_mesh_uv_map_get_pin(mesh, uv_index);
+ return pin_uv ? pin_uv[corner_index] : false;
+}
+
+static void rna_MeshUVLoop_pin_uv_set(PointerRNA *ptr, const bool value)
+{
+ Mesh *mesh = rna_mesh(ptr);
+ int uv_index;
+ int corner_index;
+ get_uv_index_and_layer(ptr, &uv_index, &corner_index);
+ bool *pin_uv = ED_mesh_uv_map_ensure_pin(mesh, uv_index);
+ pin_uv[corner_index] = value;
+}
+
+static void rna_MeshUVLoop_uv_get(PointerRNA *ptr, float *value)
+{
+ copy_v2_v2(value, ptr->data);
+}
+
+static void rna_MeshUVLoop_uv_set(PointerRNA *ptr, const float *value)
+{
+ copy_v2_v2(ptr->data, value);
}
static char *rna_MeshLoopColorLayer_path(const PointerRNA *ptr)
diff --cc source/blender/modifiers/intern/MOD_uvproject.c
index 98244e07b72,64e025ea56e..352fb1d3d75
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@@ -52,12 -52,10 +52,10 @@@ static void initData(ModifierData *md
MEMCPY_STRUCT_AFTER(umd, DNA_struct_default_get(UVProjectModifierData), modifier);
}
- static void requiredDataMask(Object *UNUSED(ob),
- ModifierData *UNUSED(md),
- CustomData_MeshMasks *r_cddata_masks)
+ static void requiredDataMask(ModifierData *UNUSED(md), CustomData_MeshMasks *r_cddata_masks)
{
/* ask for UV coordinates */
- r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
+ r_cddata_masks->lmask |= CD_MASK_PROP_FLOAT2;
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
More information about the Bf-blender-cvs
mailing list