[Bf-blender-cvs] [37eea225329] refactor-mesh-uv-map-generic: Initial patch from Martijn Versteegh
Hans Goudey
noreply at git.blender.org
Fri Aug 26 04:34:48 CEST 2022
Commit: 37eea2253295602fbff4ba255fdb2ee8f1826df3
Author: Hans Goudey
Date: Wed Aug 17 13:59:10 2022 -0400
Branches: refactor-mesh-uv-map-generic
https://developer.blender.org/rB37eea2253295602fbff4ba255fdb2ee8f1826df3
Initial patch from Martijn Versteegh
===================================================================
M release/scripts/startup/bl_ui/properties_data_mesh.py
M source/blender/blenkernel/BKE_attribute.h
M source/blender/blenkernel/BKE_customdata.h
M source/blender/blenkernel/BKE_mesh.h
M source/blender/blenkernel/BKE_mesh_mapping.h
M source/blender/blenkernel/BKE_mesh_tangent.h
M source/blender/blenkernel/intern/DerivedMesh.cc
M source/blender/blenkernel/intern/attribute.cc
M source/blender/blenkernel/intern/attribute_access.cc
M source/blender/blenkernel/intern/customdata.cc
M source/blender/blenkernel/intern/data_transfer.c
M source/blender/blenkernel/intern/dynamicpaint.c
M source/blender/blenkernel/intern/editmesh_tangent.c
M source/blender/blenkernel/intern/fluid.c
M source/blender/blenkernel/intern/geometry_component_mesh.cc
M source/blender/blenkernel/intern/layer_utils.c
M source/blender/blenkernel/intern/mesh.cc
M source/blender/blenkernel/intern/mesh_convert.cc
M source/blender/blenkernel/intern/mesh_evaluate.cc
M source/blender/blenkernel/intern/mesh_legacy_convert.cc
M source/blender/blenkernel/intern/mesh_mapping.c
M source/blender/blenkernel/intern/mesh_merge_customdata.cc
M source/blender/blenkernel/intern/mesh_mirror.c
M source/blender/blenkernel/intern/mesh_tangent.c
M source/blender/blenkernel/intern/mesh_validate.cc
M source/blender/blenkernel/intern/object_dupli.cc
M source/blender/blenkernel/intern/object_update.c
M source/blender/blenkernel/intern/paint_canvas.cc
M source/blender/blenkernel/intern/pbvh_pixels.cc
M source/blender/blenkernel/intern/subdiv_converter_mesh.c
M source/blender/blenkernel/intern/subdiv_eval.c
M source/blender/blenkernel/intern/subdiv_mesh.c
M source/blender/blenkernel/intern/subsurf_ccg.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/blenloader/intern/versioning_300.c
M source/blender/blenloader/intern/versioning_defaults.c
M source/blender/bmesh/bmesh_class.h
M source/blender/bmesh/intern/bmesh_interp.c
M source/blender/bmesh/intern/bmesh_interp.h
M source/blender/bmesh/intern/bmesh_polygon.c
M source/blender/bmesh/intern/bmesh_query_uv.c
M source/blender/bmesh/operators/bmo_join_triangles.c
M source/blender/bmesh/operators/bmo_mirror.c
M source/blender/bmesh/operators/bmo_primitive.c
M source/blender/bmesh/operators/bmo_utils.c
M source/blender/bmesh/tools/bmesh_bevel.c
M source/blender/bmesh/tools/bmesh_decimate_dissolve.c
M source/blender/bmesh/tools/bmesh_path_uv.c
M source/blender/draw/engines/overlay/overlay_edit_uv.c
M source/blender/draw/engines/workbench/workbench_engine.c
M source/blender/draw/intern/draw_cache_impl_mesh.cc
M source/blender/draw/intern/draw_cache_impl_particles.c
M source/blender/draw/intern/mesh_extractors/extract_mesh.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh.hh
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edit_data.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_data.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_angle.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edituv_stretch_area.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_edituv_data.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_fdots_uv.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc
M source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc
M source/blender/editors/curves/intern/curves_ops.cc
M source/blender/editors/geometry/geometry_attributes.cc
M source/blender/editors/include/ED_uvedit.h
M source/blender/editors/mesh/editmesh_select.c
M source/blender/editors/mesh/editmesh_utils.c
M source/blender/editors/mesh/mesh_data.cc
M source/blender/editors/mesh/meshtools.cc
M source/blender/editors/object/object_add.cc
M source/blender/editors/object/object_bake_api.c
M source/blender/editors/object/object_data_transfer.c
M source/blender/editors/sculpt_paint/paint_image_proj.c
M source/blender/editors/sculpt_paint/paint_utils.c
M source/blender/editors/sculpt_paint/sculpt_uv.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/editors/transform/transform_convert_mesh_uv.c
M source/blender/editors/uvedit/uvedit_buttons.c
M source/blender/editors/uvedit/uvedit_intern.h
M source/blender/editors/uvedit/uvedit_islands.c
M source/blender/editors/uvedit/uvedit_ops.c
M source/blender/editors/uvedit/uvedit_path.c
M source/blender/editors/uvedit/uvedit_rip.c
M source/blender/editors/uvedit/uvedit_select.c
M source/blender/editors/uvedit/uvedit_smart_stitch.c
M source/blender/editors/uvedit/uvedit_unwrap_ops.c
M source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp
M source/blender/gpu/intern/gpu_buffers.c
M source/blender/io/alembic/exporter/abc_writer_mesh.cc
M source/blender/io/alembic/intern/abc_customdata.cc
M source/blender/io/alembic/intern/abc_customdata.h
M source/blender/io/alembic/intern/abc_reader_mesh.cc
M source/blender/io/collada/EffectExporter.cpp
M source/blender/io/collada/GeometryExporter.cpp
M source/blender/io/collada/InstanceWriter.cpp
M source/blender/io/collada/MeshImporter.cpp
M source/blender/io/collada/MeshImporter.h
M source/blender/io/collada/collada_utils.cpp
M source/blender/io/usd/intern/usd_reader_mesh.cc
M source/blender/io/usd/intern/usd_writer_abstract.cc
M source/blender/io/usd/intern/usd_writer_mesh.cc
M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
M source/blender/io/wavefront_obj/tests/obj_importer_tests.cc
M source/blender/makesdna/DNA_mesh_types.h
M source/blender/makesdna/DNA_meshdata_types.h
M source/blender/makesrna/intern/rna_mesh.c
M source/blender/makesrna/intern/rna_modifier.c
M source/blender/makesrna/intern/rna_object.c
M source/blender/makesrna/intern/rna_particle.c
M source/blender/modifiers/intern/MOD_array.c
M source/blender/modifiers/intern/MOD_dynamicpaint.c
M source/blender/modifiers/intern/MOD_ocean.c
M source/blender/modifiers/intern/MOD_screw.c
M source/blender/modifiers/intern/MOD_util.c
M source/blender/modifiers/intern/MOD_uvproject.c
M source/blender/modifiers/intern/MOD_uvwarp.c
M source/blender/nodes/geometry/nodes/node_geo_mesh_primitive_ico_sphere.cc
M source/blender/python/bmesh/bmesh_py_types_customdata.c
M source/blender/python/bmesh/bmesh_py_types_meshdata.c
M source/blender/python/bmesh/bmesh_py_types_meshdata.h
M source/blender/render/RE_bake.h
M source/blender/render/RE_texture_margin.h
M source/blender/render/intern/bake.c
M source/blender/render/intern/multires_bake.c
M source/blender/render/intern/texture_margin.cc
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_data_mesh.py b/release/scripts/startup/bl_ui/properties_data_mesh.py
index 80b9b773d9b..93784f9b007 100644
--- a/release/scripts/startup/bl_ui/properties_data_mesh.py
+++ b/release/scripts/startup/bl_ui/properties_data_mesh.py
@@ -580,7 +580,6 @@ class DATA_PT_mesh_attributes(MeshButtonsPanel, Panel):
# Built-in names.
{"position": None, "material_index": None, "shade_smooth": None, "normal": None, "crease": None},
mesh.attributes,
- mesh.uv_layers,
ob.vertex_groups,
):
for name in collection.keys():
diff --git a/source/blender/blenkernel/BKE_attribute.h b/source/blender/blenkernel/BKE_attribute.h
index 13eefd27bec..610be64adf6 100644
--- a/source/blender/blenkernel/BKE_attribute.h
+++ b/source/blender/blenkernel/BKE_attribute.h
@@ -99,7 +99,10 @@ CustomDataLayer *BKE_id_attribute_from_index(struct ID *id,
eAttrDomainMask domain_mask,
eCustomDataMask layer_mask);
-/** Layer is allowed to be nullptr; if so -1 (layer not found) will be returned. */
+/** Layer is allowed to be nullptr; if so -1 (layer not found) will be returned.
+ * Returns the index in the list of attributes of the same type on the same domain.
+ * note: this is *not* the CustomData layer index.
+ */
int BKE_id_attribute_to_index(const struct ID *id,
const CustomDataLayer *layer,
eAttrDomainMask domain_mask,
@@ -138,6 +141,15 @@ struct CustomDataLayer *BKE_id_attributes_color_find(const struct ID *id, const
bool BKE_id_attribute_calc_unique_name(struct ID *id, const char *name, char *outname);
+UVMap_Data BKE_id_attributes_create_uvmap_layers(struct ID *id,
+ char const *name,
+ struct ReportList *reports,
+ uint32_t needed_layer_flags);
+UVMap_Data BKE_id_attributes_ensure_uvmap_layers_index(struct ID *id,
+ int index_of_uvmap,
+ struct ReportList *reports,
+ uint32_t needed_layer_flags);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/blenkernel/BKE_customdata.h b/source/blender/blenkernel/BKE_customdata.h
index 010fbb27172..da6a6917957 100644
--- a/source/blender/blenkernel/BKE_customdata.h
+++ b/source/blender/blenkernel/BKE_customdata.h
@@ -397,7 +397,7 @@ void *CustomData_bmesh_get_n(const struct CustomData *data, void *block, int typ
*/
void *CustomData_bmesh_get_layer_n(const struct CustomData *data, void *block, int n);
-bool CustomData_set_layer_name(const struct CustomData *data, int type, int n, const char *name);
+bool CustomData_set_layer_name(struct CustomData *data, int type, int n, const char *name);
const char *CustomData_get_layer_name(const struct CustomData *data, int type, int n);
/**
@@ -409,6 +409,7 @@ void *CustomData_get_layer_n(const struct CustomData *data, int type, int n);
void *CustomData_get_layer_named(const struct CustomData *data, int type, const char *name);
int CustomData_get_offset(const struct CustomData *data, int type);
int CustomData_get_n_offset(const struct CustomData *data, int type, int n);
+int CustomData_get_named_offset(const struct CustomData *data, int type, const char *name);
int CustomData_get_layer_index(const struct CustomData *data, int type);
int CustomData_get_layer_index_n(const struct CustomData *data, int type, int n);
@@ -712,6 +713,45 @@ void CustomData_blend_write(BlendWriter *writer,
void CustomData_blend_read(struct BlendDataReader *reader, struct CustomData *data, int count);
+/* Uvmap related customdata offsets for BMesh.
+ */
+typedef struct UVMap_Offsets {
+ int uv;
+ int vertsel;
+ int edgesel;
+ int pinned;
+} UVMap_Offsets;
+
+/* UV related CustomData pointers.
+ * The data pointers point directly to the CustomData arrays.
+ * The uv_index is also stored for on-demand creation of the bool datalayers.
+ */
+typedef struct UVMap_Data {
+ int uv_index;
+ float (*uv)[2];
+ bool *vertsel;
+ bool *edgesel;
+ bool *pinned;
+} UVMap_Data;
+
+#define UV_VERTSEL_NAME "vs"
+#define UV_EDGESEL_NAME "es"
+#define UV_PINNED_NAME "pn"
+
+#ifdef __cplusplus
+
+std::string UV_sublayer_name(char const *layername, char const *prefix);
+
+#endif
+/* get a descriptor containing offsets for all needed layers for the uvmap
+ * \param name: Optional layer name. When name is NULL, the default layer is returned
+ * \param offsets: Output parameter that will be filled with the offsets
+
+ */
+UVMap_Offsets CustomData_get_uvmap_offsets(const struct CustomData *data, char const *name);
+UVMap_Data CustomData_get_uvmap_data(const struct CustomData *data, char const *name);
+UVMap_Data CustomData_get_uvmap_data_n(const struct CustomData *data, int n);
+
#ifndef NDEBUG
struct DynStr;
/** Use to inspect mesh data when debugging. */
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h
index 17f541b362e..884b3bc6475 100644
--- a/source/blender/blenkernel/BKE_mesh.h
+++ b/source/blender/blenkernel/BKE_mesh.h
@@ -30,7 +30,6 @@ struct MEdge;
struct MFace;
struct MLoop;
struct MLoopTri;
-struct MLoopUV;
struct MPoly;
struct MVert;
struct Main;
@@ -739,7 +738,7 @@ float BKE_mesh_calc_poly_area(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const struct MVert *mvarray);
float BKE_mesh_calc_area(const struct Mesh *me);
-float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const struct MLoopUV *uv_array);
+float BKE_mesh_calc_poly_uv_area(const struct MPoly *mpoly, const float (*uv_array)[2]);
void BKE_mesh_calc_poly_angles(const struct MPoly *mpoly,
const struct MLoop *loopstart,
const struct MVert *mvarray,
diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h
index c58bcbea242..7d76168364a 100644
--- a/source/blender/blenkernel/BKE_mesh_mapping.h
+++ b/source/blender/blenkernel/BKE_mesh_mapping.h
@@ -13,7 +13,6 @@ extern "C" {
struct MEdge;
struct MLoop;
struct MLoopTri;
-struct MLoopUV;
struct MPoly;
struct MVert;
@@ -78,7 +77,7 @@ typedef struct MeshElemMap {
/* mapping */
UvVertMap *BKE_mesh_uv_vert_map_create(const struct MPoly *mpoly,
const struct MLoop *mloop,
- const struct MLoopUV *mloopuv,
+ const float (*mloopuv)[2],
unsigned int totpoly,
unsigned int totvert,
const float limit[2],
@@ -262,7 +261,7 @@ bool BKE_mesh_calc_islands_loop_poly_edgeseam(struct MVert *verts,
/**
* Calculate UV islands.
*
- * \note If no MLoopUV layer is passed, we only consider edges tagged as seams as UV boundaries.
+ * \note If no UV layer is passed, we only consider edges tagged as seams as UV boundaries.
* This has the advantages of simplicity, and being valid/common to all UV maps.
* However, it means actual UV islands without matching UV seams will not be handled correctly.
* If a valid UV layer is passed as \a luvs parameter,
@@ -280,7 +279,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(struct MVert *verts,
int totpoly,
struct MLoop *loops,
int totloop,
- const struct MLoopUV *luvs,
+ const float (*luvs)[2],
MeshIslandStore *r_island_store);
/**
@@ -305,10 +304,7 @@ int *BKE_mesh_calc_smoothgroups(const struct MEdge *medge,
((CHECK_TYPE_ANY( \
_tri, unsigned int *, int *, int[3], const unsigned int *, const int *, const int[3]), \
CHECK_TYPE_ANY(_v, unsigned int, const unsigned int, int, const int)), \
- (((_tri)[0] == _v) ? 0 : \
- ((_tri)[1] == _v) ? 1 : \
- ((_tri)[2] == _v) ? 2 : \
- -1))
+ (((_tri)[0] == _v) ? 0 : ((_tri)[1] == _v) ? 1 : ((_tri)[2] == _v) ? 2 : -1))
#ifdef __cplusplus
}
diff --git a/source/blender/blenkernel/BKE_mesh_tangent.h b/source/blender/blenkernel/BKE_mesh_tangent.h
index 58142653a90..54089fa67e8 100644
--- a/source/blender/blenkernel/BKE_mesh_tangent.h
+++ b/source/blender/blenkernel/BKE_mesh_tangent.h
@@ -22,7 +22,7 @@ void BKE_mesh_calc_loop_tangent_single_ex(const struct MVert *mverts,
const struct MLoop *mloops,
float (*r_looptangent)[4],
const float (*loopnors)[3],
- const struct MLoopUV *loopuv,
+ const float (*loopuv)[2],
int numLoops,
const struct MPoly *mpolys,
int numPolys,
diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc
index a29d8726f21..16c2a39ef3f 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.cc
+++ b/source/blender/blenkernel/intern/DerivedMesh.cc
@@ -1769,7 +1769,7 @@ static void object_get_datamask(const Depsgraph *depsgraph,
/* check if we need tfaces & mcols due to face select or texture paint */
if ((ob->mode & OB_MODE_TEXTURE_PAINT) || editing) {
- r_mask->lmask |= CD_MASK_MLOOPUV | CD_MASK_PROP_BYTE_COLOR;
+ r_mask->lmask |= CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_BYTE_COLOR;
r_mask->fmask |= CD_MASK_MTFACE;
}
diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attrib
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list