Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.cc2
-rw-r--r--source/blender/blenkernel/intern/attribute.cc186
-rw-r--r--source/blender/blenkernel/intern/attribute_access.cc15
-rw-r--r--source/blender/blenkernel/intern/customdata.cc183
-rw-r--r--source/blender/blenkernel/intern/data_transfer.c6
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c71
-rw-r--r--source/blender/blenkernel/intern/editmesh_tangent.c10
-rw-r--r--source/blender/blenkernel/intern/fluid.c13
-rw-r--r--source/blender/blenkernel/intern/geometry_component_mesh.cc21
-rw-r--r--source/blender/blenkernel/intern/layer_utils.c2
-rw-r--r--source/blender/blenkernel/intern/mesh.cc20
-rw-r--r--source/blender/blenkernel/intern/mesh_convert.cc28
-rw-r--r--source/blender/blenkernel/intern/mesh_evaluate.cc18
-rw-r--r--source/blender/blenkernel/intern/mesh_legacy_convert.cc41
-rw-r--r--source/blender/blenkernel/intern/mesh_mapping.c28
-rw-r--r--source/blender/blenkernel/intern/mesh_merge_customdata.cc20
-rw-r--r--source/blender/blenkernel/intern/mesh_mirror.c20
-rw-r--r--source/blender/blenkernel/intern/mesh_tangent.c44
-rw-r--r--source/blender/blenkernel/intern/mesh_validate.cc10
-rw-r--r--source/blender/blenkernel/intern/object_dupli.cc16
-rw-r--r--source/blender/blenkernel/intern/object_update.c2
-rw-r--r--source/blender/blenkernel/intern/paint_canvas.cc4
-rw-r--r--source/blender/blenkernel/intern/pbvh_pixels.cc13
-rw-r--r--source/blender/blenkernel/intern/subdiv_converter_mesh.c4
-rw-r--r--source/blender/blenkernel/intern/subdiv_eval.c14
-rw-r--r--source/blender/blenkernel/intern/subdiv_mesh.c14
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c24
27 files changed, 586 insertions, 243 deletions
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/attribute.cc
index 639e190a2c6..d6188936a08 100644
--- a/source/blender/blenkernel/intern/attribute.cc
+++ b/source/blender/blenkernel/intern/attribute.cc
@@ -162,7 +162,27 @@ bool BKE_id_attribute_rename(ID *id,
}
char result_name[MAX_CUSTOMDATA_LAYER_NAME];
+
BKE_id_attribute_calc_unique_name(id, new_name, result_name);
+
+ if (layer->type == CD_PROP_FLOAT2) {
+ /* Scan for and rename uv sublayers layers. */
+ std::string old_vertsel_layer_name = UV_sublayer_name(layer->name, UV_VERTSEL_NAME);
+ std::string old_edgesel_layer_name = UV_sublayer_name(layer->name, UV_EDGESEL_NAME);
+ std::string old_pinned_layer_name = UV_sublayer_name(layer->name, UV_PINNED_NAME);
+
+ std::string new_vertsel_layer_name = UV_sublayer_name(result_name, UV_VERTSEL_NAME);
+ std::string new_edgesel_layer_name = UV_sublayer_name(result_name, UV_EDGESEL_NAME);
+ std::string new_pinned_layer_name = UV_sublayer_name(result_name, UV_PINNED_NAME);
+
+ BKE_id_attribute_rename(
+ id, old_vertsel_layer_name.c_str(), new_vertsel_layer_name.c_str(), reports);
+ BKE_id_attribute_rename(
+ id, old_edgesel_layer_name.c_str(), new_edgesel_layer_name.c_str(), reports);
+ BKE_id_attribute_rename(
+ id, old_pinned_layer_name.c_str(), new_pinned_layer_name.c_str(), reports);
+ }
+
BLI_strncpy_utf8(layer->name, result_name, sizeof(layer->name));
return true;
@@ -567,6 +587,26 @@ CustomDataLayer *BKE_id_attribute_from_index(ID *id,
return nullptr;
}
+static CustomDataLayer *attribute_from_layerindex(ID *id,
+ const int lookup_index,
+ const eAttrDomain domain,
+ const eCustomDataMask layer_mask)
+{
+ DomainInfo info[ATTR_DOMAIN_NUM];
+ get_domains(id, info);
+
+ CustomData *customdata = info[domain].customdata;
+
+ BLI_assert(lookup_index >= 0);
+ BLI_assert(lookup_index < customdata->totlayer);
+
+ if (!(layer_mask & CD_TYPE_AS_MASK(customdata->layers[lookup_index].type))) {
+ return nullptr;
+ }
+
+ return customdata->layers + lookup_index;
+}
+
/** Get list of domain types but with ATTR_DOMAIN_FACE and
* ATTR_DOMAIN_CORNER swapped.
*/
@@ -620,6 +660,43 @@ int BKE_id_attribute_to_index(const ID *id,
return -1;
}
+static int attribute_to_layerindex(const struct ID *id,
+ const CustomDataLayer *layer,
+ const eAttrDomainMask domain_mask,
+ const eCustomDataMask layer_mask)
+{
+ if (!layer) {
+ return -1;
+ }
+
+ DomainInfo info[ATTR_DOMAIN_NUM];
+ eAttrDomain domains[ATTR_DOMAIN_NUM];
+ get_domains_types(domains);
+ get_domains(id, info);
+
+ for (int i = 0; i < ATTR_DOMAIN_NUM; i++) {
+ if (!(domain_mask & (1 << domains[i])) || !info[domains[i]].customdata) {
+ continue;
+ }
+
+ const CustomData *cdata = info[domains[i]].customdata;
+ for (int j = 0; j < cdata->totlayer; j++) {
+ const CustomDataLayer *layer_iter = cdata->layers + j;
+
+ if (!(CD_TYPE_AS_MASK(layer_iter->type) & layer_mask) ||
+ (layer_iter->flag & CD_FLAG_TEMPORARY)) {
+ continue;
+ }
+
+ if (layer == layer_iter) {
+ return j;
+ }
+ }
+ }
+
+ return -1;
+}
+
CustomDataLayer *BKE_id_attribute_subset_active_get(const ID *id,
int active_flag,
eAttrDomainMask domain_mask,
@@ -781,3 +858,112 @@ void BKE_id_attribute_copy_domains_temp(short id_type,
*((short *)r_id->name) = id_type;
}
+
+UVMap_Data BKE_id_attributes_create_uvmap_layers(struct ID *id,
+ char const *name,
+ struct ReportList *reports,
+ uint32_t needed_layer_flags)
+{
+ UVMap_Data data;
+
+ bool needvertsel = needed_layer_flags & MLOOPUV_VERTSEL;
+ bool neededgesel = needed_layer_flags & MLOOPUV_EDGESEL;
+ bool needpinned = needed_layer_flags & MLOOPUV_PINNED;
+
+ CustomDataLayer *uvlayer = BKE_id_attribute_new(
+ id, name, CD_PROP_FLOAT2, ATTR_DOMAIN_CORNER, reports);
+
+ data.uv = (float(*)[2])uvlayer->data;
+
+ data.uv_index = attribute_to_layerindex(
+ id, uvlayer, ATTR_DOMAIN_MASK_CORNER, CD_MASK_PROP_FLOAT2);
+
+ std::string vertsel_name = UV_sublayer_name(uvlayer->name, UV_VERTSEL_NAME);
+ std::string edgesel_name = UV_sublayer_name(uvlayer->name, UV_EDGESEL_NAME);
+ std::string pinned_name = UV_sublayer_name(uvlayer->name, UV_PINNED_NAME);
+
+ //! martijn still need to handle if one of the sublayer names is already taken.
+
+ if (needvertsel) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, vertsel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.vertsel = (bool *)layer->data;
+ }
+ else {
+ data.vertsel = nullptr;
+ ;
+ }
+ if (neededgesel) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, edgesel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.edgesel = (bool *)layer->data;
+ }
+ else {
+ data.edgesel = nullptr;
+ }
+ if (needpinned) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, pinned_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.pinned = (bool *)layer->data;
+ }
+ else {
+ data.pinned = nullptr;
+ }
+
+ return data;
+}
+
+UVMap_Data BKE_id_attributes_ensure_uvmap_layers_index(struct ID *id,
+ const int index_of_uvmap,
+ struct ReportList *reports,
+ uint32_t needed_layer_flags)
+{
+ UVMap_Data data;
+
+ const bool needvertsel = needed_layer_flags & MLOOPUV_VERTSEL;
+ const bool neededgesel = needed_layer_flags & MLOOPUV_EDGESEL;
+ const bool needpinned = needed_layer_flags & MLOOPUV_PINNED;
+
+ CustomDataLayer *uvlayer = attribute_from_layerindex(
+ id, index_of_uvmap, ATTR_DOMAIN_CORNER, CD_MASK_PROP_FLOAT2);
+
+ data.uv_index = attribute_to_layerindex(
+ id, uvlayer, ATTR_DOMAIN_MASK_CORNER, CD_MASK_PROP_FLOAT2);
+ data.uv = (float(*)[2])uvlayer->data;
+
+ std::string vertsel_name = UV_sublayer_name(uvlayer->name, UV_VERTSEL_NAME);
+ std::string edgesel_name = UV_sublayer_name(uvlayer->name, UV_EDGESEL_NAME);
+ std::string pinned_name = UV_sublayer_name(uvlayer->name, UV_PINNED_NAME);
+
+ CustomDataLayer *vslayer = BKE_id_attribute_find(
+ id, vertsel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER);
+ data.vertsel = vslayer ? (bool *)vslayer->data : nullptr;
+
+ CustomDataLayer *eslayer = BKE_id_attribute_find(
+ id, edgesel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER);
+ data.edgesel = eslayer ? (bool *)eslayer->data : nullptr;
+
+ CustomDataLayer *pnlayer = BKE_id_attribute_find(
+ id, pinned_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER);
+ data.pinned = pnlayer ? (bool *)pnlayer->data : nullptr;
+
+ if (needvertsel && data.vertsel == nullptr) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, vertsel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.vertsel = (bool *)layer->data;
+ }
+
+ if (neededgesel && data.edgesel == nullptr) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, edgesel_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.edgesel = (bool *)layer->data;
+ }
+
+ if (needpinned && data.pinned == nullptr) {
+ CustomDataLayer *layer = BKE_id_attribute_new(
+ id, pinned_name.c_str(), CD_PROP_BOOL, ATTR_DOMAIN_CORNER, reports);
+ data.pinned = (bool *)layer->data;
+ }
+
+ return data;
+}
diff --git a/source/blender/blenkernel/intern/attribute_access.cc b/source/blender/blenkernel/intern/attribute_access.cc
index 1af3cde1821..7ffb572e71b 100644
--- a/source/blender/blenkernel/intern/attribute_access.cc
+++ b/source/blender/blenkernel/intern/attribute_access.cc
@@ -56,7 +56,20 @@ const char *no_procedural_access_message =
bool allow_procedural_attribute_access(StringRef attribute_name)
{
- return !attribute_name.startswith(".selection");
+ if (attribute_name.startswith(".selection")) {
+ 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 --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index b12eafa9cef..3291cdc8a48 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -1055,7 +1055,6 @@ static void layerInterp_mloopuv(const void **sources,
void *dest)
{
float uv[2];
- int flag = 0;
zero_v2(uv);
@@ -1063,14 +1062,10 @@ static void layerInterp_mloopuv(const void **sources,
const float interp_weight = weights[i];
const MLoopUV *src = static_cast<const MLoopUV *>(sources[i]);
madd_v2_v2fl(uv, src->uv, interp_weight);
- if (interp_weight > 0.0f) {
- flag |= src->flag;
- }
}
/* Delay writing to the destination in case dest is in sources. */
copy_v2_v2(((MLoopUV *)dest)->uv, uv);
- ((MLoopUV *)dest)->flag = flag;
}
static bool layerValidate_mloopuv(void *data, const uint totitems, const bool do_fixes)
@@ -1593,6 +1588,50 @@ static bool layerValidate_propfloat2(void *data, const uint totitems, const bool
return has_errors;
}
+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);
+
+ return len_squared_v2v2(luv1, luv2) < 0.00001f;
+}
+
+static void layerInitMinMax_propfloat2(void *vmin, void *vmax)
+{
+ float *min = static_cast<float *>(vmin);
+ float *max = static_cast<float *>(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);
+}
+
+static void layerCopyValue_propfloat2(const void *source,
+ void *dest,
+ const int mixmode,
+ const float mixfactor)
+{
+ const float *luv1 = static_cast<const float *>(source);
+ float *luv2 = static_cast<float *>(dest);
+
+ /* We only support a limited subset of advanced mixing here -
+ * namely the mixfactor interpolation. */
+
+ if (mixmode == CDT_MIX_NOMIX) {
+ copy_v2_v2(luv2, luv1);
+ }
+ else {
+ interp_v2_v2v2(luv2, luv2, luv1, mixfactor);
+ }
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -1991,10 +2030,12 @@ static const LayerTypeInfo LAYERTYPEINFO[CD_NUMTYPES] = {
nullptr,
nullptr,
layerValidate_propfloat2,
- nullptr,
+ layerEqual_propfloat2,
layerMultiply_propfloat2,
- nullptr,
- layerAdd_propfloat2},
+ layerInitMinMax_propfloat2,
+ layerAdd_propfloat2,
+ layerDoMinMax_propfloat2,
+ layerCopyValue_propfloat2},
/* 50: CD_PROP_BOOL */
{sizeof(bool),
"bool",
@@ -3381,7 +3422,7 @@ void *CustomData_get(const CustomData *data, int index, int type)
return POINTER_OFFSET(data->layers[layer_index].data, offset);
}
-
+/* index is the element in the layer, n is the n'th layer of this type */
void *CustomData_get_n(const CustomData *data, int type, int index, int n)
{
BLI_assert(index >= 0 && n >= 0);
@@ -3450,7 +3491,18 @@ int CustomData_get_n_offset(const CustomData *data, int type, int n)
return data->layers[layer_index].offset;
}
-bool CustomData_set_layer_name(const CustomData *data, int type, int n, const char *name)
+int CustomData_get_named_offset(const struct CustomData *data, int type, const char *name)
+{
+ /* get the layer index of the active layer of type */
+ int layer_index = CustomData_get_named_layer_index(data, type, name);
+ if (layer_index == -1) {
+ return -1;
+ }
+
+ return data->layers[layer_index].offset;
+}
+
+bool CustomData_set_layer_name(CustomData *data, int type, int n, const char *name)
{
/* get the layer index of the first layer of type */
const int layer_index = CustomData_get_layer_index_n(data, type, n);
@@ -3521,17 +3573,17 @@ void CustomData_bmesh_update_active_layers(CustomData *fdata, CustomData *ldata)
{
int act;
- if (CustomData_has_layer(ldata, CD_MLOOPUV)) {
- act = CustomData_get_active_layer(ldata, CD_MLOOPUV);
+ if (CustomData_has_layer(ldata, CD_PROP_FLOAT2)) {
+ act = CustomData_get_active_layer(ldata, CD_PROP_FLOAT2);
CustomData_set_layer_active(fdata, CD_MTFACE, act);
- act = CustomData_get_render_layer(ldata, CD_MLOOPUV);
+ act = CustomData_get_render_layer(ldata, CD_PROP_FLOAT2);
CustomData_set_layer_render(fdata, CD_MTFACE, act);
- act = CustomData_get_clone_layer(ldata, CD_MLOOPUV);
+ act = CustomData_get_clone_layer(ldata, CD_PROP_FLOAT2);
CustomData_set_layer_clone(fdata, CD_MTFACE, act);
- act = CustomData_get_stencil_layer(ldata, CD_MLOOPUV);
+ act = CustomData_get_stencil_layer(ldata, CD_PROP_FLOAT2);
CustomData_set_layer_stencil(fdata, CD_MTFACE, act);
}
@@ -5280,6 +5332,107 @@ void CustomData_blend_read(BlendDataReader *reader, CustomData *data, int count)
/** \} */
/* -------------------------------------------------------------------- */
+/** \name Custom Data UVmap Handling
+ * \{ */
+
+std::string UV_sublayer_name(char const *layername, char const *prefix)
+{
+ /* If you change the naming scheme here, change it as well in BM_uv_layer_ensure_sublayer() . */
+ return "." + std::string(prefix) + "." + std::string(layername);
+}
+
+UVMap_Data CustomData_get_uvmap_data(const CustomData *ldata, char const *name)
+{
+
+ UVMap_Data data;
+ if (name) {
+ data.uv_index = CustomData_get_named_layer_index(ldata, CD_PROP_FLOAT2, name);
+ }
+ else {
+ data.uv_index = CustomData_get_layer_index(ldata, CD_PROP_FLOAT2);
+ }
+
+ data.uv = data.uv_index == -1 ? nullptr : (float(*)[2])ldata->layers[data.uv_index].data;
+
+ if (data.uv == nullptr) {
+ data.vertsel = data.edgesel = data.pinned = nullptr;
+ return data;
+ }
+
+ std::string vertsel_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_VERTSEL_NAME);
+ std::string edgesel_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_EDGESEL_NAME);
+ std::string pinned_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_PINNED_NAME);
+
+ int vertsel_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, vertsel_name.c_str());
+ int edgesel_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, edgesel_name.c_str());
+ int pinned_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, pinned_name.c_str());
+
+ data.vertsel = vertsel_index == -1 ? nullptr : (bool *)ldata->layers[vertsel_index].data;
+ data.edgesel = edgesel_index == -1 ? nullptr : (bool *)ldata->layers[edgesel_index].data;
+ data.pinned = pinned_index == -1 ? nullptr : (bool *)ldata->layers[pinned_index].data;
+
+ return data;
+}
+
+UVMap_Data CustomData_get_uvmap_data_n(const CustomData *ldata, const int n)
+{
+
+ UVMap_Data data;
+ data.uv_index = CustomData_get_layer_index_n(ldata, CD_PROP_FLOAT2, n);
+
+ if (data.uv_index < 0) {
+ data.uv = nullptr;
+ data.vertsel = data.edgesel = data.pinned = nullptr;
+ return data;
+ }
+
+ std::string vertsel_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_VERTSEL_NAME);
+ std::string edgesel_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_EDGESEL_NAME);
+ std::string pinned_name = UV_sublayer_name(ldata->layers[data.uv_index].name, UV_PINNED_NAME);
+
+ int vertsel_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, vertsel_name.c_str());
+ int edgesel_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, edgesel_name.c_str());
+ int pinned_index = CustomData_get_named_layer_index(ldata, CD_PROP_BOOL, pinned_name.c_str());
+
+ data.vertsel = vertsel_index == -1 ? nullptr : (bool *)ldata->layers[vertsel_index].data;
+ data.edgesel = edgesel_index == -1 ? nullptr : (bool *)ldata->layers[edgesel_index].data;
+ data.pinned = pinned_index == -1 ? nullptr : (bool *)ldata->layers[pinned_index].data;
+
+ return data;
+}
+
+UVMap_Offsets CustomData_get_uvmap_offsets(const CustomData *ldata, char const *name)
+{
+
+ UVMap_Offsets offsets;
+ int index;
+ if (name) {
+ index = CustomData_get_named_layer_index(ldata, CD_PROP_FLOAT2, name);
+ }
+ else {
+ index = CustomData_get_layer_index(ldata, CD_PROP_FLOAT2);
+ }
+
+ if (index < 0) {
+ offsets.uv = offsets.vertsel = offsets.pinned = offsets.edgesel = -1;
+ return offsets;
+ }
+
+ offsets.uv = ldata->layers[index].offset;
+ std::string vertsel_name = UV_sublayer_name(ldata->layers[index].name, UV_VERTSEL_NAME);
+ std::string edgesel_name = UV_sublayer_name(ldata->layers[index].name, UV_EDGESEL_NAME);
+ std::string pinned_name = UV_sublayer_name(ldata->layers[index].name, UV_PINNED_NAME);
+
+ offsets.vertsel = CustomData_get_named_offset(ldata, CD_PROP_BOOL, vertsel_name.c_str());
+ offsets.edgesel = CustomData_get_named_offset(ldata, CD_PROP_BOOL, edgesel_name.c_str());
+ offsets.pinned = CustomData_get_named_offset(ldata, CD_PROP_BOOL, pinned_name.c_str());
+
+ return offsets;
+}
+
+/** \} */
+
+/* -------------------------------------------------------------------- */
/** \name Custom Data Debugging
* \{ */
diff --git a/source/blender/blenkernel/intern/data_transfer.c b/source/blender/blenkernel/intern/data_transfer.c
index 17a74b5564a..e1b43fdcecd 100644
--- a/source/blender/blenkernel/intern/data_transfer.c
+++ b/source/blender/blenkernel/intern/data_transfer.c
@@ -67,7 +67,7 @@ void BKE_object_data_transfer_dttypes_to_cdmask(const int dtdata_types,
r_data_masks->vmask |= CD_MASK_MDEFORMVERT; /* Exception for vgroups :/ */
}
else if (cddata_type == CD_FAKE_UV) {
- r_data_masks->lmask |= CD_MASK_MLOOPUV;
+ r_data_masks->lmask |= CD_MASK_PROP_FLOAT2;
}
else if (cddata_type == CD_FAKE_LNOR) {
r_data_masks->vmask |= CD_MASK_NORMAL;
@@ -1107,7 +1107,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
else if (elem_type == ME_LOOP) {
if (cddata_type == CD_FAKE_UV) {
- cddata_type = CD_MLOOPUV;
+ cddata_type = CD_PROP_FLOAT2;
}
else if (cddata_type == CD_FAKE_LNOR) {
/* Pre-process should have generated it,
@@ -1146,7 +1146,7 @@ static bool data_transfer_layersmapping_generate(ListBase *r_map,
}
else if (elem_type == ME_POLY) {
if (cddata_type == CD_FAKE_UV) {
- cddata_type = CD_MLOOPUV;
+ cddata_type = CD_PROP_FLOAT2;
}
if (!(cddata_type & CD_FAKE)) {
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 423e76fce8c..b8d8ebe7dba 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -1468,7 +1468,7 @@ typedef struct DynamicPaintSetInitColorData {
const DynamicPaintSurface *surface;
const MLoop *mloop;
- const MLoopUV *mloopuv;
+ const float (*mloopuv)[2];
const MLoopTri *mlooptri;
const MLoopCol *mloopcol;
struct ImagePool *pool;
@@ -1486,7 +1486,7 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(
const MLoop *mloop = data->mloop;
const MLoopTri *mlooptri = data->mlooptri;
- const MLoopUV *mloopuv = data->mloopuv;
+ const float(*mloopuv)[2] = data->mloopuv;
struct ImagePool *pool = data->pool;
Tex *tex = data->surface->init_texture;
@@ -1499,8 +1499,8 @@ static void dynamic_paint_set_init_color_tex_to_vcol_cb(
const unsigned int vert = mloop[mlooptri[i].tri[j]].v;
/* remap to [-1.0, 1.0] */
- uv[0] = mloopuv[mlooptri[i].tri[j]].uv[0] * 2.0f - 1.0f;
- uv[1] = mloopuv[mlooptri[i].tri[j]].uv[1] * 2.0f - 1.0f;
+ uv[0] = mloopuv[mlooptri[i].tri[j]][0] * 2.0f - 1.0f;
+ uv[1] = mloopuv[mlooptri[i].tri[j]][1] * 2.0f - 1.0f;
multitex_ext_safe(tex, uv, &texres, pool, scene_color_manage, false);
@@ -1520,7 +1520,7 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(
PaintPoint *pPoint = (PaintPoint *)sData->type_data;
const MLoopTri *mlooptri = data->mlooptri;
- const MLoopUV *mloopuv = data->mloopuv;
+ const float(*mloopuv)[2] = data->mloopuv;
Tex *tex = data->surface->init_texture;
ImgSeqFormatData *f_data = (ImgSeqFormatData *)sData->format_data;
const int samples = (data->surface->flags & MOD_DPAINT_ANTIALIAS) ? 5 : 1;
@@ -1534,7 +1534,7 @@ static void dynamic_paint_set_init_color_tex_to_imseq_cb(
/* collect all uvs */
for (int j = 3; j--;) {
- copy_v2_v2(&uv[j * 3], mloopuv[mlooptri[f_data->uv_p[i].tri_index].tri[j]].uv);
+ copy_v2_v2(&uv[j * 3], mloopuv[mlooptri[f_data->uv_p[i].tri_index].tri[j]]);
}
/* interpolate final uv pos */
@@ -1615,8 +1615,9 @@ static void dynamicPaint_setInitialColor(const Scene *scene, DynamicPaintSurface
}
/* get uv map */
- CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, surface->init_layername, uvname);
- const MLoopUV *mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
+ CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, surface->init_layername, uvname);
+ const float(*mloopuv)[2] = CustomData_get_layer_named(&mesh->ldata, CD_PROP_FLOAT2, uvname);
+
if (!mloopuv) {
return;
}
@@ -2187,7 +2188,7 @@ typedef struct DynamicPaintCreateUVSurfaceData {
Vec3f *tempWeights;
const MLoopTri *mlooptri;
- const MLoopUV *mloopuv;
+ const float (*mloopuv)[2];
const MLoop *mloop;
const int tottri;
@@ -2205,7 +2206,7 @@ static void dynamic_paint_create_uv_surface_direct_cb(
Vec3f *tempWeights = data->tempWeights;
const MLoopTri *mlooptri = data->mlooptri;
- const MLoopUV *mloopuv = data->mloopuv;
+ const float(*mloopuv)[2] = data->mloopuv;
const MLoop *mloop = data->mloop;
const int tottri = data->tottri;
@@ -2258,9 +2259,9 @@ static void dynamic_paint_create_uv_surface_direct_cb(
continue;
}
- const float *uv1 = mloopuv[mlooptri[i].tri[0]].uv;
- const float *uv2 = mloopuv[mlooptri[i].tri[1]].uv;
- const float *uv3 = mloopuv[mlooptri[i].tri[2]].uv;
+ const float *uv1 = mloopuv[mlooptri[i].tri[0]];
+ const float *uv2 = mloopuv[mlooptri[i].tri[1]];
+ const float *uv3 = mloopuv[mlooptri[i].tri[2]];
/* If point is inside the face */
if (isect_point_tri_v2(point[sample], uv1, uv2, uv3) != 0) {
@@ -2300,7 +2301,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(
Vec3f *tempWeights = data->tempWeights;
const MLoopTri *mlooptri = data->mlooptri;
- const MLoopUV *mloopuv = data->mloopuv;
+ const float(*mloopuv)[2] = data->mloopuv;
const MLoop *mloop = data->mloop;
uint32_t *active_points = data->active_points;
@@ -2341,9 +2342,9 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(
if (tempPoints[ind].neighbor_pixel == -1 && tempPoints[ind].tri_index != -1) {
float uv[2];
const int i = tempPoints[ind].tri_index;
- const float *uv1 = mloopuv[mlooptri[i].tri[0]].uv;
- const float *uv2 = mloopuv[mlooptri[i].tri[1]].uv;
- const float *uv3 = mloopuv[mlooptri[i].tri[2]].uv;
+ const float *uv1 = mloopuv[mlooptri[i].tri[0]];
+ const float *uv2 = mloopuv[mlooptri[i].tri[1]];
+ const float *uv3 = mloopuv[mlooptri[i].tri[2]];
/* tri index */
/* There is a low possibility of actually having a neighbor point which tri is
@@ -2387,7 +2388,7 @@ static void dynamic_paint_create_uv_surface_neighbor_cb(
#undef JITTER_SAMPLES
static float dist_squared_to_looptri_uv_edges(const MLoopTri *mlooptri,
- const MLoopUV *mloopuv,
+ const float (*mloopuv)[2],
int tri_index,
const float point[2])
{
@@ -2398,8 +2399,8 @@ static float dist_squared_to_looptri_uv_edges(const MLoopTri *mlooptri,
for (int i = 0; i < 3; i++) {
const float dist_squared = dist_squared_to_line_segment_v2(
point,
- mloopuv[mlooptri[tri_index].tri[(i + 0)]].uv,
- mloopuv[mlooptri[tri_index].tri[(i + 1) % 3]].uv);
+ mloopuv[mlooptri[tri_index].tri[(i + 0)]],
+ mloopuv[mlooptri[tri_index].tri[(i + 1) % 3]]);
if (dist_squared < min_distance) {
min_distance = dist_squared;
@@ -2512,7 +2513,7 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
{
const MLoop *mloop = data->mloop;
const MLoopTri *mlooptri = data->mlooptri;
- const MLoopUV *mloopuv = data->mloopuv;
+ const float(*mloopuv)[2] = data->mloopuv;
const unsigned int *loop_idx = mlooptri[tri_index].tri;
@@ -2525,9 +2526,9 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
float uv0[2], uv1[2], uv2[2];
- copy_v2_v2(uv0, mloopuv[loop_idx[(edge_idx + 0)]].uv);
- copy_v2_v2(uv1, mloopuv[loop_idx[(edge_idx + 1) % 3]].uv);
- copy_v2_v2(uv2, mloopuv[loop_idx[(edge_idx + 2) % 3]].uv);
+ copy_v2_v2(uv0, mloopuv[loop_idx[(edge_idx + 0)]]);
+ copy_v2_v2(uv1, mloopuv[loop_idx[(edge_idx + 1) % 3]]);
+ copy_v2_v2(uv2, mloopuv[loop_idx[(edge_idx + 2) % 3]]);
/* Verify the target point is on the opposite side of the edge from the third triangle
* vertex, to ensure that we always move closer to the goal point. */
@@ -2578,13 +2579,13 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa
/* Allow for swapped vertex order */
if (overt0 == vert0 && overt1 == vert1) {
found_other = true;
- copy_v2_v2(ouv0, mloopuv[other_loop_idx[(j + 0)]].uv);
- copy_v2_v2(ouv1, mloopuv[other_loop_idx[(j + 1) % 3]].uv);
+ copy_v2_v2(ouv0, mloopuv[other_loop_idx[(j + 0)]]);
+ copy_v2_v2(ouv1, mloopuv[other_loop_idx[(j + 1) % 3]]);
}
else if (overt0 == vert1 && overt1 == vert0) {
found_other = true;
- copy_v2_v2(ouv1, mloopuv[other_loop_idx[(j + 0)]].uv);
- copy_v2_v2(ouv0, mloopuv[other_loop_idx[(j + 1) % 3]].uv);
+ copy_v2_v2(ouv1, mloopuv[other_loop_idx[(j + 0)]]);
+ copy_v2_v2(ouv0, mloopuv[other_loop_idx[(j + 1) % 3]]);
}
if (found_other) {
@@ -2807,7 +2808,7 @@ int dynamicPaint_createUVSurface(Scene *scene,
PaintUVPoint *tempPoints = NULL;
Vec3f *tempWeights = NULL;
const MLoopTri *mlooptri = NULL;
- const MLoopUV *mloopuv = NULL;
+ const float(*mloopuv)[2] = NULL;
const MLoop *mloop = NULL;
Bounds2D *faceBB = NULL;
@@ -2828,9 +2829,9 @@ int dynamicPaint_createUVSurface(Scene *scene,
const int tottri = BKE_mesh_runtime_looptri_len(mesh);
/* get uv map */
- if (CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
- CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, surface->uvlayer_name, uvname);
- mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
+ if (CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
+ CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, surface->uvlayer_name, uvname);
+ mloopuv = CustomData_get_layer_named(&mesh->ldata, CD_PROP_FLOAT2, uvname);
}
/* Check for validity */
@@ -2889,11 +2890,11 @@ int dynamicPaint_createUVSurface(Scene *scene,
if (!error) {
for (int i = 0; i < tottri; i++) {
- copy_v2_v2(faceBB[i].min, mloopuv[mlooptri[i].tri[0]].uv);
- copy_v2_v2(faceBB[i].max, mloopuv[mlooptri[i].tri[0]].uv);
+ copy_v2_v2(faceBB[i].min, mloopuv[mlooptri[i].tri[0]]);
+ copy_v2_v2(faceBB[i].max, mloopuv[mlooptri[i].tri[0]]);
for (int j = 1; j < 3; j++) {
- minmax_v2v2_v2(faceBB[i].min, faceBB[i].max, mloopuv[mlooptri[i].tri[j]].uv);
+ minmax_v2v2_v2(faceBB[i].min, faceBB[i].max, mloopuv[mlooptri[i].tri[j]]);
}
}
diff --git a/source/blender/blenkernel/intern/editmesh_tangent.c b/source/blender/blenkernel/intern/editmesh_tangent.c
index 0a3107eee24..cc99a0e4bab 100644
--- a/source/blender/blenkernel/intern/editmesh_tangent.c
+++ b/source/blender/blenkernel/intern/editmesh_tangent.c
@@ -364,7 +364,7 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
/* NOTE: we assume we do have tessellated loop normals at this point
* (in case it is object-enabled), have to check this is valid. */
mesh2tangent->precomputedLoopNormals = loop_normals;
- mesh2tangent->cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_MLOOPUV, n);
+ mesh2tangent->cd_loop_uv_offset = CustomData_get_n_offset(&bm->ldata, CD_PROP_FLOAT2, n);
/* needed for indexing loop-tangents */
int htype_index = BM_LOOP;
@@ -380,8 +380,8 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
else {
/* Fill the resulting tangent_mask */
int uv_ind = CustomData_get_named_layer_index(
- &bm->ldata, CD_MLOOPUV, loopdata_out->layers[index].name);
- int uv_start = CustomData_get_layer_index(&bm->ldata, CD_MLOOPUV);
+ &bm->ldata, CD_PROP_FLOAT2, loopdata_out->layers[index].name);
+ int uv_start = CustomData_get_layer_index(&bm->ldata, CD_PROP_FLOAT2);
BLI_assert(uv_ind != -1 && uv_start != -1);
BLI_assert(uv_ind - uv_start < MAX_MTFACE);
tangent_mask_curr |= 1 << (uv_ind - uv_start);
@@ -415,7 +415,7 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
*tangent_mask_curr_p = tangent_mask_curr;
- int act_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, act_uv_n);
+ int act_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_PROP_FLOAT2, act_uv_n);
if (act_uv_index >= 0) {
int tan_index = CustomData_get_named_layer_index(
loopdata_out, CD_TANGENT, bm->ldata.layers[act_uv_index].name);
@@ -423,7 +423,7 @@ void BKE_editmesh_loop_tangent_calc(BMEditMesh *em,
} /* else tangent has been built from orco */
/* Update render layer index */
- int ren_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_MLOOPUV, ren_uv_n);
+ int ren_uv_index = CustomData_get_layer_index_n(&bm->ldata, CD_PROP_FLOAT2, ren_uv_n);
if (ren_uv_index >= 0) {
int tan_index = CustomData_get_named_layer_index(
loopdata_out, CD_TANGENT, bm->ldata.layers[ren_uv_index].name);
diff --git a/source/blender/blenkernel/intern/fluid.c b/source/blender/blenkernel/intern/fluid.c
index 0fc09803088..12d7acd4e88 100644
--- a/source/blender/blenkernel/intern/fluid.c
+++ b/source/blender/blenkernel/intern/fluid.c
@@ -1805,7 +1805,7 @@ static void sample_mesh(FluidFlowSettings *ffs,
const float (*vert_normals)[3],
const MLoop *mloop,
const MLoopTri *mlooptri,
- const MLoopUV *mloopuv,
+ const float (*mloopuv)[2],
float *influence_map,
float *velocity_map,
int index,
@@ -1924,9 +1924,9 @@ static void sample_mesh(FluidFlowSettings *ffs,
}
else if (mloopuv) {
const float *uv[3];
- uv[0] = mloopuv[mlooptri[f_index].tri[0]].uv;
- uv[1] = mloopuv[mlooptri[f_index].tri[1]].uv;
- uv[2] = mloopuv[mlooptri[f_index].tri[2]].uv;
+ uv[0] = mloopuv[mlooptri[f_index].tri[0]];
+ uv[1] = mloopuv[mlooptri[f_index].tri[1]];
+ uv[2] = mloopuv[mlooptri[f_index].tri[2]];
interp_v2_v2v2v2(tex_co, UNPACK3(uv), weights);
@@ -1999,7 +1999,7 @@ typedef struct EmitFromDMData {
const float (*vert_normals)[3];
const MLoop *mloop;
const MLoopTri *mlooptri;
- const MLoopUV *mloopuv;
+ const float (*mloopuv)[2];
const MDeformVert *dvert;
int defgrp_index;
@@ -2091,7 +2091,8 @@ static void emit_from_mesh(
const MLoopTri *mlooptri = BKE_mesh_runtime_looptri_ensure(me);
const int numverts = me->totvert;
const MDeformVert *dvert = CustomData_get_layer(&me->vdata, CD_MDEFORMVERT);
- const MLoopUV *mloopuv = CustomData_get_layer_named(&me->ldata, CD_MLOOPUV, ffs->uvlayer_name);
+ const float(*mloopuv)[2] = CustomData_get_layer_named(
+ &me->ldata, CD_PROP_FLOAT2, ffs->uvlayer_name);
if (ffs->flags & FLUID_FLOW_INITVELOCITY) {
vert_vel = MEM_callocN(sizeof(float[3]) * numverts, "manta_flow_velocity");
diff --git a/source/blender/blenkernel/intern/geometry_component_mesh.cc b/source/blender/blenkernel/intern/geometry_component_mesh.cc
index 436868ba375..547a7fcfaeb 100644
--- a/source/blender/blenkernel/intern/geometry_component_mesh.cc
+++ b/source/blender/blenkernel/intern/geometry_component_mesh.cc
@@ -863,16 +863,6 @@ static void set_shade_smooth(MPoly &mpoly, bool value)
SET_FLAG_FROM_TEST(mpoly.flag, value, ME_SMOOTH);
}
-static float2 get_loop_uv(const MLoopUV &uv)
-{
- return float2(uv.uv);
-}
-
-static void set_loop_uv(MLoopUV &uv, float2 co)
-{
- copy_v2_v2(uv.uv, co);
-}
-
static float get_crease(const MEdge &edge)
{
return edge.crease / 255.0f;
@@ -1241,14 +1231,6 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
make_derived_write_attribute<MEdge, float, get_crease, set_crease>,
nullptr);
- static NamedLegacyCustomDataProvider uvs(
- ATTR_DOMAIN_CORNER,
- CD_PROP_FLOAT2,
- CD_MLOOPUV,
- corner_access,
- make_derived_read_attribute<MLoopUV, float2, get_loop_uv>,
- make_derived_write_attribute<MLoopUV, float2, get_loop_uv, set_loop_uv>);
-
static VertexGroupsAttributeProvider vertex_groups;
static CustomDataAttributeProvider corner_custom_data(ATTR_DOMAIN_CORNER, corner_access);
static CustomDataAttributeProvider point_custom_data(ATTR_DOMAIN_POINT, point_access);
@@ -1257,8 +1239,7 @@ static ComponentAttributeProviders create_attribute_providers_for_mesh()
return ComponentAttributeProviders(
{&position, &id, &material_index, &shade_smooth, &normal, &crease},
- {&uvs,
- &corner_custom_data,
+ {&corner_custom_data,
&vertex_groups,
&point_custom_data,
&edge_custom_data,
diff --git a/source/blender/blenkernel/intern/layer_utils.c b/source/blender/blenkernel/intern/layer_utils.c
index 0903c2a2cac..a67a8cead31 100644
--- a/source/blender/blenkernel/intern/layer_utils.c
+++ b/source/blender/blenkernel/intern/layer_utils.c
@@ -161,7 +161,7 @@ bool BKE_view_layer_filter_edit_mesh_has_uvs(const Object *ob, void *UNUSED(user
const Mesh *me = ob->data;
const BMEditMesh *em = me->edit_mesh;
if (em != NULL) {
- if (CustomData_get_offset(&em->bm->ldata, CD_MLOOPUV) != -1) {
+ if (CustomData_get_offset(&em->bm->ldata, CD_PROP_FLOAT2) != -1) {
return true;
}
}
diff --git a/source/blender/blenkernel/intern/mesh.cc b/source/blender/blenkernel/intern/mesh.cc
index cf05dc0404e..1652344d474 100644
--- a/source/blender/blenkernel/intern/mesh.cc
+++ b/source/blender/blenkernel/intern/mesh.cc
@@ -449,14 +449,22 @@ static int customdata_compare(
for (int i = 0; i < c1->totlayer; i++) {
l1 = &c1->layers[i];
if ((CD_TYPE_AS_MASK(l1->type) & cd_mask_all_attr) && l1->anonymous_id == nullptr) {
- layer_count1++;
+ if (l1->name[0] != '.') //! martijn. this only added to be able to use the old test files
+ //! in the tests. should be removed once the test file is updated
+ {
+ layer_count1++;
+ }
}
}
for (int i = 0; i < c2->totlayer; i++) {
l2 = &c2->layers[i];
if ((CD_TYPE_AS_MASK(l2->type) & cd_mask_all_attr) && l2->anonymous_id == nullptr) {
- layer_count2++;
+ if (l2->name[0] != '.') //! martijn. this only added to be able to use the old test files
+ //! in the tests. should be removed once the test file is updated
+ {
+ layer_count2++;
+ }
}
}
@@ -747,7 +755,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
* Callers could also check but safer to do here - campbell */
}
else {
- const int tottex_original = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
+ const int tottex_original = CustomData_number_of_layers(&me->ldata, CD_PROP_FLOAT2);
const int totcol_original = CustomData_number_of_layers(&me->ldata, CD_PROP_BYTE_COLOR);
const int tottex_tessface = CustomData_number_of_layers(&me->fdata, CD_MTFACE);
@@ -766,7 +774,7 @@ static void mesh_ensure_tessellation_customdata(Mesh *me)
* some info to help troubleshoot what's going on. */
printf(
"%s: warning! Tessellation uvs or vcol data got out of sync, "
- "had to reset!\n CD_MTFACE: %d != CD_MLOOPUV: %d || CD_MCOL: %d != "
+ "had to reset!\n CD_MTFACE: %d != CD_PROP_FLOAT2: %d || CD_MCOL: %d != "
"CD_PROP_BYTE_COLOR: "
"%d\n",
__func__,
@@ -851,7 +859,7 @@ bool BKE_mesh_clear_facemap_customdata(struct Mesh *me)
}
/**
- * This ensures grouped custom-data (e.g. #CD_MLOOPUV and #CD_MTFACE, or
+ * This ensures grouped custom-data (e.g. #CD_PROP_FLOAT2 and #CD_MTFACE, or
* #CD_PROP_BYTE_COLOR and #CD_MCOL) have the same relative active/render/clone/mask indices.
*
* NOTE(@campbellbarton): that for undo mesh data we want to skip 'ensure_tess_cd' call since
@@ -884,7 +892,7 @@ void BKE_mesh_update_customdata_pointers(Mesh *me, const bool do_ensure_tess_cd)
me->mloop = (MLoop *)CustomData_get_layer(&me->ldata, CD_MLOOP);
me->mloopcol = (MLoopCol *)CustomData_get_layer(&me->ldata, CD_PROP_BYTE_COLOR);
- me->mloopuv = (MLoopUV *)CustomData_get_layer(&me->ldata, CD_MLOOPUV);
+ me->mloopuv = (float(*)[2])CustomData_get_layer(&me->ldata, CD_PROP_FLOAT2);
}
bool BKE_mesh_has_custom_loop_normals(Mesh *me)
diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc
index 923d2703960..a60c3dae8a1 100644
--- a/source/blender/blenkernel/intern/mesh_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_convert.cc
@@ -207,14 +207,14 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
int *r_totedge,
MLoop **r_allloop,
MPoly **r_allpoly,
- MLoopUV **r_alluv,
+ float (**r_alluv)[2],
int *r_totloop,
int *r_totpoly)
{
MVert *mvert;
MPoly *mpoly;
MLoop *mloop;
- MLoopUV *mloopuv = nullptr;
+ float(*mloopuv)[2] = nullptr;
MEdge *medge;
const float *data;
int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0;
@@ -269,8 +269,8 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
*r_allpoly = mpoly = (MPoly *)MEM_calloc_arrayN(totpoly, sizeof(MPoly), "nurbs_init mloop");
if (r_alluv) {
- *r_alluv = mloopuv = (MLoopUV *)MEM_calloc_arrayN(
- totpoly, sizeof(MLoopUV[4]), "nurbs_init mloopuv");
+ *r_alluv = mloopuv = (float(*)[2])MEM_calloc_arrayN(
+ totpoly, sizeof(float[2]) * 4, "nurbs_init mloopuv");
}
/* verts and faces */
@@ -352,8 +352,8 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
if (mloopuv) {
for (int i = 0; i < 3; i++, mloopuv++) {
- mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1);
- mloopuv->uv[1] = 0.0f;
+ (*mloopuv)[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1);
+ (*mloopuv)[1] = 0.0f;
}
}
@@ -429,15 +429,15 @@ static int mesh_nurbs_displist_to_mdata(const Curve *cu,
/* find uv based on vertex index into grid array */
int v = mloop[i].v - startvert;
- mloopuv->uv[0] = (v / dl->nr) / (float)orco_sizev;
- mloopuv->uv[1] = (v % dl->nr) / (float)orco_sizeu;
+ (*mloopuv)[0] = (v / dl->nr) / (float)orco_sizev;
+ (*mloopuv)[1] = (v % dl->nr) / (float)orco_sizeu;
/* cyclic correction */
- if ((ELEM(i, 1, 2)) && mloopuv->uv[0] == 0.0f) {
- mloopuv->uv[0] = 1.0f;
+ if ((ELEM(i, 1, 2)) && (*mloopuv)[0] == 0.0f) {
+ (*mloopuv)[0] = 1.0f;
}
- if ((ELEM(i, 0, 1)) && mloopuv->uv[1] == 0.0f) {
- mloopuv->uv[1] = 1.0f;
+ if ((ELEM(i, 0, 1)) && (*mloopuv)[1] == 0.0f) {
+ (*mloopuv)[1] = 1.0f;
}
}
}
@@ -492,7 +492,7 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *
MEdge *alledge;
MLoop *allloop;
MPoly *allpoly;
- MLoopUV *alluv = nullptr;
+ float(*alluv)[2] = nullptr;
int totvert, totedge, totloop, totpoly;
if (mesh_nurbs_displist_to_mdata(cu,
@@ -527,7 +527,7 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase *
if (alluv) {
const char *uvname = "UVMap";
- CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, totloop, uvname);
+ CustomData_add_layer_named(&mesh->ldata, CD_PROP_FLOAT2, CD_ASSIGN, alluv, totloop, uvname);
}
mesh_copy_texture_space_from_curve_type(cu, mesh);
diff --git a/source/blender/blenkernel/intern/mesh_evaluate.cc b/source/blender/blenkernel/intern/mesh_evaluate.cc
index 7d26262a504..80d4a169836 100644
--- a/source/blender/blenkernel/intern/mesh_evaluate.cc
+++ b/source/blender/blenkernel/intern/mesh_evaluate.cc
@@ -20,6 +20,7 @@
#include "BLI_edgehash.h"
#include "BLI_index_range.hh"
#include "BLI_math.h"
+#include "BLI_math_vec_types.hh"
#include "BLI_span.hh"
#include "BLI_utildefines.h"
@@ -219,22 +220,9 @@ float BKE_mesh_calc_area(const Mesh *me)
return total_area;
}
-float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const MLoopUV *uv_array)
+float BKE_mesh_calc_poly_uv_area(const MPoly *mpoly, const float (*uv_array)[2])
{
-
- int i, l_iter = mpoly->loopstart;
- float area;
- float(*vertexcos)[2] = (float(*)[2])BLI_array_alloca(vertexcos, (size_t)mpoly->totloop);
-
- /* pack vertex cos into an array for area_poly_v2 */
- for (i = 0; i < mpoly->totloop; i++, l_iter++) {
- copy_v2_v2(vertexcos[i], uv_array[l_iter].uv);
- }
-
- /* finally calculate the area */
- area = area_poly_v2(vertexcos, (uint)mpoly->totloop);
-
- return area;
+ return area_poly_v2(uv_array + mpoly->loopstart, (uint)mpoly->totloop);
}
static float UNUSED_FUNCTION(mesh_calc_poly_volume_centroid)(const MPoly *mpoly,
diff --git a/source/blender/blenkernel/intern/mesh_legacy_convert.cc b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
index 479dd6a012a..0d0d554390c 100644
--- a/source/blender/blenkernel/intern/mesh_legacy_convert.cc
+++ b/source/blender/blenkernel/intern/mesh_legacy_convert.cc
@@ -16,6 +16,7 @@
#include "BLI_edgehash.h"
#include "BLI_math.h"
+#include "BLI_math_vec_types.hh"
#include "BLI_memarena.h"
#include "BLI_polyfill_2d.h"
#include "BLI_utildefines.h"
@@ -44,17 +45,18 @@ static void bm_corners_to_loops_ex(ID *id,
for (int i = 0; i < numTex; i++) {
const MTFace *texface = (const MTFace *)CustomData_get_n(fdata, CD_MTFACE, findex, i);
- MLoopUV *mloopuv = (MLoopUV *)CustomData_get_n(ldata, CD_MLOOPUV, loopstart, i);
- copy_v2_v2(mloopuv->uv, texface->uv[0]);
- mloopuv++;
- copy_v2_v2(mloopuv->uv, texface->uv[1]);
- mloopuv++;
- copy_v2_v2(mloopuv->uv, texface->uv[2]);
- mloopuv++;
+ blender::float2 *uv = static_cast<blender::float2 *>(
+ CustomData_get_n(ldata, CD_PROP_FLOAT2, loopstart, i));
+ copy_v2_v2((float *)uv, texface->uv[0]);
+ uv++;
+ copy_v2_v2((float *)uv, texface->uv[1]);
+ uv++;
+ copy_v2_v2((float *)uv, texface->uv[2]);
+ uv++;
if (mf->v4) {
- copy_v2_v2(mloopuv->uv, texface->uv[3]);
- mloopuv++;
+ copy_v2_v2((float *)uv, texface->uv[3]);
+ uv++;
}
}
@@ -135,7 +137,7 @@ static void CustomData_to_bmeshpoly(CustomData *fdata, CustomData *ldata, int to
for (int i = 0; i < fdata->totlayer; i++) {
if (fdata->layers[i].type == CD_MTFACE) {
CustomData_add_layer_named(
- ldata, CD_MLOOPUV, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
+ ldata, CD_PROP_FLOAT2, CD_CALLOC, nullptr, totloop, fdata->layers[i].name);
}
else if (fdata->layers[i].type == CD_MCOL) {
CustomData_add_layer_named(
@@ -307,16 +309,16 @@ static void CustomData_bmesh_do_versions_update_active_layers(CustomData *fdata,
if (CustomData_has_layer(fdata, CD_MTFACE)) {
act = CustomData_get_active_layer(fdata, CD_MTFACE);
- CustomData_set_layer_active(ldata, CD_MLOOPUV, act);
+ CustomData_set_layer_active(ldata, CD_PROP_FLOAT2, act);
act = CustomData_get_render_layer(fdata, CD_MTFACE);
- CustomData_set_layer_render(ldata, CD_MLOOPUV, act);
+ CustomData_set_layer_render(ldata, CD_PROP_FLOAT2, act);
act = CustomData_get_clone_layer(fdata, CD_MTFACE);
- CustomData_set_layer_clone(ldata, CD_MLOOPUV, act);
+ CustomData_set_layer_clone(ldata, CD_PROP_FLOAT2, act);
act = CustomData_get_stencil_layer(fdata, CD_MTFACE);
- CustomData_set_layer_stencil(ldata, CD_MLOOPUV, act);
+ CustomData_set_layer_stencil(ldata, CD_PROP_FLOAT2, act);
}
if (CustomData_has_layer(fdata, CD_MCOL)) {
@@ -384,7 +386,7 @@ static void mesh_loops_to_tessdata(CustomData *fdata,
* we could be ~25% quicker with dedicated code.
* The issue is, unless having two different functions with nearly the same code,
* there's not much ways to solve this. Better IMHO to live with it for now (sigh). */
- const int numUV = CustomData_number_of_layers(ldata, CD_MLOOPUV);
+ const int numUV = CustomData_number_of_layers(ldata, CD_PROP_FLOAT2);
const int numCol = CustomData_number_of_layers(ldata, CD_PROP_BYTE_COLOR);
const bool hasPCol = CustomData_has_layer(ldata, CD_PREVIEW_MLOOPCOL);
const bool hasOrigSpace = CustomData_has_layer(ldata, CD_ORIGSPACE_MLOOP);
@@ -396,12 +398,13 @@ static void mesh_loops_to_tessdata(CustomData *fdata,
for (i = 0; i < numUV; i++) {
MTFace *texface = (MTFace *)CustomData_get_layer_n(fdata, CD_MTFACE, i);
- const MLoopUV *mloopuv = (const MLoopUV *)CustomData_get_layer_n(ldata, CD_MLOOPUV, i);
+ const blender::float2 *uv = static_cast<const blender::float2 *>(
+ CustomData_get_layer_n(ldata, CD_PROP_FLOAT2, i));
for (findex = 0, pidx = polyindices, lidx = loopindices; findex < num_faces;
pidx++, lidx++, findex++, texface++) {
for (j = (mface ? mface[findex].v4 : (*lidx)[3]) ? 4 : 3; j--;) {
- copy_v2_v2(texface->uv[j], mloopuv[(*lidx)[j]].uv);
+ copy_v2_v2(texface->uv[j], uv[(*lidx)[j]]);
}
}
}
@@ -812,7 +815,7 @@ static bool check_matching_legacy_layer_counts(CustomData *fdata, CustomData *ld
((a_num += CustomData_number_of_layers(l_a, t_a)) == \
(b_num += CustomData_number_of_layers(l_b, t_b)))
- if (!LAYER_CMP(ldata, CD_MLOOPUV, fdata, CD_MTFACE)) {
+ if (!LAYER_CMP(ldata, CD_PROP_FLOAT2, fdata, CD_MTFACE)) {
return false;
}
if (!LAYER_CMP(ldata, CD_PROP_BYTE_COLOR, fdata, CD_MCOL)) {
@@ -845,7 +848,7 @@ void BKE_mesh_add_mface_layers(CustomData *fdata, CustomData *ldata, int total)
BLI_assert(!check_matching_legacy_layer_counts(fdata, ldata, false));
for (int i = 0; i < ldata->totlayer; i++) {
- if (ldata->layers[i].type == CD_MLOOPUV) {
+ if (ldata->layers[i].type == CD_PROP_FLOAT2) {
CustomData_add_layer_named(
fdata, CD_MTFACE, CD_CALLOC, nullptr, total, ldata->layers[i].name);
}
diff --git a/source/blender/blenkernel/intern/mesh_mapping.c b/source/blender/blenkernel/intern/mesh_mapping.c
index 9c4098e2db6..5f619d1cda4 100644
--- a/source/blender/blenkernel/intern/mesh_mapping.c
+++ b/source/blender/blenkernel/intern/mesh_mapping.c
@@ -30,7 +30,7 @@
/* ngon version wip, based on BM_uv_vert_map_create */
UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
const MLoop *mloop,
- const MLoopUV *mloopuv,
+ const float (*mloopuv)[2],
uint totpoly,
uint totvert,
const float limit[2],
@@ -91,7 +91,7 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
vmap->vert[mloop[mp->loopstart + i].v] = buf;
if (use_winding) {
- copy_v2_v2(tf_uv[i], mloopuv[mpoly[a].loopstart + i].uv);
+ copy_v2_v2(tf_uv[i], mloopuv[mpoly[a].loopstart + i]);
}
buf++;
@@ -116,14 +116,14 @@ UvVertMap *BKE_mesh_uv_vert_map_create(const MPoly *mpoly,
v->next = newvlist;
newvlist = v;
- uv = mloopuv[mpoly[v->poly_index].loopstart + v->loop_of_poly_index].uv;
+ uv = mloopuv[mpoly[v->poly_index].loopstart + v->loop_of_poly_index];
lastv = NULL;
iterv = vlist;
while (iterv) {
next = iterv->next;
- uv2 = mloopuv[mpoly[iterv->poly_index].loopstart + iterv->loop_of_poly_index].uv;
+ uv2 = mloopuv[mpoly[iterv->poly_index].loopstart + iterv->loop_of_poly_index];
sub_v2_v2v2(uvdiff, uv2, uv);
if (fabsf(uv[0] - uv2[0]) < limit[0] && fabsf(uv[1] - uv2[1]) < limit[1] &&
@@ -928,7 +928,7 @@ void BKE_mesh_loop_islands_add(MeshIslandStore *island_store,
*/
typedef struct MeshCheckIslandBoundaryUv {
const MLoop *loops;
- const MLoopUV *luvs;
+ const float (*luvs)[2];
const MeshElemMap *edge_loop_map;
} MeshCheckIslandBoundaryUv;
@@ -943,27 +943,27 @@ static bool mesh_check_island_boundary_uv(const MPoly *UNUSED(mp),
if (user_data) {
const MeshCheckIslandBoundaryUv *data = 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);
const uint v1 = loops[edge_to_loops->indices[0]].v;
const uint v2 = loops[edge_to_loops->indices[1]].v;
- const float *uvco_v1 = luvs[edge_to_loops->indices[0]].uv;
- const float *uvco_v2 = luvs[edge_to_loops->indices[1]].uv;
+ const float *uvco_v1 = luvs[edge_to_loops->indices[0]];
+ const float *uvco_v2 = luvs[edge_to_loops->indices[1]];
for (int i = 2; i < edge_to_loops->count; i += 2) {
if (loops[edge_to_loops->indices[i]].v == v1) {
- if (!equals_v2v2(uvco_v1, luvs[edge_to_loops->indices[i]].uv) ||
- !equals_v2v2(uvco_v2, luvs[edge_to_loops->indices[i + 1]].uv)) {
+ if (!equals_v2v2(uvco_v1, luvs[edge_to_loops->indices[i]]) ||
+ !equals_v2v2(uvco_v2, luvs[edge_to_loops->indices[i + 1]])) {
return true;
}
}
else {
BLI_assert(loops[edge_to_loops->indices[i]].v == v2);
UNUSED_VARS_NDEBUG(v2);
- if (!equals_v2v2(uvco_v2, luvs[edge_to_loops->indices[i]].uv) ||
- !equals_v2v2(uvco_v1, luvs[edge_to_loops->indices[i + 1]].uv)) {
+ if (!equals_v2v2(uvco_v2, luvs[edge_to_loops->indices[i]]) ||
+ !equals_v2v2(uvco_v1, luvs[edge_to_loops->indices[i + 1]])) {
return true;
}
}
@@ -983,7 +983,7 @@ static bool mesh_calc_islands_loop_poly_uv(MVert *UNUSED(verts),
const int totpoly,
MLoop *loops,
const int totloop,
- const MLoopUV *luvs,
+ const float (*luvs)[2],
MeshIslandStore *r_island_store)
{
int *poly_groups = NULL;
@@ -1147,7 +1147,7 @@ bool BKE_mesh_calc_islands_loop_poly_uvmap(MVert *verts,
const int totpoly,
MLoop *loops,
const int totloop,
- const MLoopUV *luvs,
+ const float (*luvs)[2],
MeshIslandStore *r_island_store)
{
BLI_assert(luvs != NULL);
diff --git a/source/blender/blenkernel/intern/mesh_merge_customdata.cc b/source/blender/blenkernel/intern/mesh_merge_customdata.cc
index 7bc429954b0..327dcaa5bbf 100644
--- a/source/blender/blenkernel/intern/mesh_merge_customdata.cc
+++ b/source/blender/blenkernel/intern/mesh_merge_customdata.cc
@@ -16,6 +16,7 @@
#include "BKE_customdata.h"
#include "BKE_mesh.h"
#include "BKE_mesh_mapping.h"
+#include "BLI_math_vec_types.hh"
#include "BLI_memarena.h"
#include "BLI_strict_flags.h"
@@ -57,7 +58,8 @@ 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<MLoopUV *> mloopuv_layers)
+static void merge_uvs_for_vertex(const Span<int> loops_for_vert,
+ Span<blender::float2 *> mloopuv_layers)
{
if (loops_for_vert.size() <= 1) {
return;
@@ -65,14 +67,14 @@ static void merge_uvs_for_vertex(const Span<int> loops_for_vert, Span<MLoopUV *>
/* 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 (MLoopUV *mloopuv : mloopuv_layers) {
+ for (blender::float2 *mloopuv : mloopuv_layers) {
BLI_assert(loops_merge.is_empty());
loops_merge.extend_unchecked(loops_for_vert);
while (loops_merge.size() > 1) {
uint i_last = (uint)loops_merge.size() - 1;
- const float *uv_src = mloopuv[loops_merge[0]].uv;
+ const float *uv_src = mloopuv[loops_merge[0]];
for (uint i = 1; i <= i_last;) {
- float *uv_dst = mloopuv[loops_merge[i]].uv;
+ float *uv_dst = mloopuv[loops_merge[i]];
switch (compare_v2_classify(uv_src, uv_dst)) {
case CMP_CLOSE: {
uv_dst[0] = uv_src[0];
@@ -106,7 +108,7 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *me)
if (me->totloop == 0) {
return;
}
- const int mloopuv_layers_num = CustomData_number_of_layers(&me->ldata, CD_MLOOPUV);
+ const int mloopuv_layers_num = CustomData_number_of_layers(&me->ldata, CD_PROP_FLOAT2);
if (mloopuv_layers_num == 0) {
return;
}
@@ -116,14 +118,16 @@ void BKE_mesh_merge_customdata_for_apply_modifier(Mesh *me)
BKE_mesh_vert_loop_map_create(
&vert_to_loop, &vert_map_mem, me->mpoly, me->mloop, me->totvert, me->totpoly, me->totloop);
- Vector<MLoopUV *> mloopuv_layers;
+ Vector<blender::float2 *> mloopuv_layers;
mloopuv_layers.reserve(mloopuv_layers_num);
for (int a = 0; a < mloopuv_layers_num; a++) {
- MLoopUV *mloopuv = static_cast<MLoopUV *>(CustomData_get_layer_n(&me->ldata, CD_MLOOPUV, a));
+ blender::float2 *mloopuv = static_cast<blender::float2 *>(
+ CustomData_get_layer_n(&me->ldata, CD_PROP_FLOAT2, a));
mloopuv_layers.append_unchecked(mloopuv);
}
- Span<MLoopUV *> mloopuv_layers_as_span = mloopuv_layers.as_span();
+ Span<blender::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) {
MeshElemMap &loops_for_vert = vert_to_loop[v_index];
diff --git a/source/blender/blenkernel/intern/mesh_mirror.c b/source/blender/blenkernel/intern/mesh_mirror.c
index 715a1c9daf9..ed24ea85ce2 100644
--- a/source/blender/blenkernel/intern/mesh_mirror.c
+++ b/source/blender/blenkernel/intern/mesh_mirror.c
@@ -356,33 +356,33 @@ Mesh *BKE_mesh_mirror_apply_mirror_on_axis_for_modifier(MirrorModifierData *mmd,
/* If set, flip around center of each tile. */
const bool do_mirr_udim = (mmd->flag & MOD_MIR_MIRROR_UDIM) != 0;
- const int totuv = CustomData_number_of_layers(&result->ldata, CD_MLOOPUV);
+ const int totuv = CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2);
for (a = 0; a < totuv; a++) {
- MLoopUV *dmloopuv = CustomData_get_layer_n(&result->ldata, CD_MLOOPUV, a);
+ float(*dmloopuv)[2] = CustomData_get_layer_n(&result->ldata, CD_PROP_FLOAT2, a);
int j = maxLoops;
dmloopuv += j; /* second set of loops only */
for (; j-- > 0; dmloopuv++) {
if (do_mirr_u) {
- float u = dmloopuv->uv[0];
+ float u = (*dmloopuv)[0];
if (do_mirr_udim) {
- dmloopuv->uv[0] = ceilf(u) - fmodf(u, 1.0f) + mmd->uv_offset[0];
+ (*dmloopuv)[0] = ceilf(u) - fmodf(u, 1.0f) + mmd->uv_offset[0];
}
else {
- dmloopuv->uv[0] = 1.0f - u + mmd->uv_offset[0];
+ (*dmloopuv)[0] = 1.0f - u + mmd->uv_offset[0];
}
}
if (do_mirr_v) {
- float v = dmloopuv->uv[1];
+ float v = (*dmloopuv)[1];
if (do_mirr_udim) {
- dmloopuv->uv[1] = ceilf(v) - fmodf(v, 1.0f) + mmd->uv_offset[1];
+ (*dmloopuv)[1] = ceilf(v) - fmodf(v, 1.0f) + mmd->uv_offset[1];
}
else {
- dmloopuv->uv[1] = 1.0f - v + mmd->uv_offset[1];
+ (*dmloopuv)[1] = 1.0f - v + mmd->uv_offset[1];
}
}
- dmloopuv->uv[0] += mmd->uv_offset_copy[0];
- dmloopuv->uv[1] += mmd->uv_offset_copy[1];
+ (*dmloopuv)[0] += mmd->uv_offset_copy[0];
+ (*dmloopuv)[1] += mmd->uv_offset_copy[1];
}
}
}
diff --git a/source/blender/blenkernel/intern/mesh_tangent.c b/source/blender/blenkernel/intern/mesh_tangent.c
index a677a0d6ebb..a2b8f5080d3 100644
--- a/source/blender/blenkernel/intern/mesh_tangent.c
+++ b/source/blender/blenkernel/intern/mesh_tangent.c
@@ -40,7 +40,7 @@ typedef struct {
const MPoly *mpolys; /* faces */
const MLoop *mloops; /* faces's vertices */
const MVert *mverts; /* vertices */
- const MLoopUV *luvs; /* texture coordinates */
+ const float (*luvs)[2]; /* texture coordinates */
const float (*lnors)[3]; /* loops' normals */
float (*tangents)[4]; /* output tangents */
int num_polys; /* number of polygons */
@@ -75,7 +75,7 @@ static void get_texture_coordinate(const SMikkTSpaceContext *pContext,
const int vert_idx)
{
BKEMeshToTangent *p_mesh = (BKEMeshToTangent *)pContext->m_pUserData;
- copy_v2_v2(r_uv, p_mesh->luvs[p_mesh->mpolys[face_idx].loopstart + vert_idx].uv);
+ copy_v2_v2(r_uv, p_mesh->luvs[p_mesh->mpolys[face_idx].loopstart + vert_idx]);
}
static void get_normal(const SMikkTSpaceContext *pContext,
@@ -104,7 +104,7 @@ void BKE_mesh_calc_loop_tangent_single_ex(const MVert *mverts,
const MLoop *mloops,
float (*r_looptangent)[4],
const float (*loopnors)[3],
- const MLoopUV *loopuvs,
+ const float (*loopuvs)[2],
const int UNUSED(numLoops),
const MPoly *mpolys,
const int numPolys,
@@ -155,14 +155,14 @@ void BKE_mesh_calc_loop_tangent_single(Mesh *mesh,
float (*r_looptangents)[4],
ReportList *reports)
{
- const MLoopUV *loopuvs;
+ float(*loopuvs)[2];
/* Check we have valid texture coordinates first! */
if (uvmap) {
- loopuvs = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvmap);
+ loopuvs = CustomData_get_layer_named(&mesh->ldata, CD_PROP_FLOAT2, uvmap);
}
else {
- loopuvs = CustomData_get_layer(&mesh->ldata, CD_MLOOPUV);
+ loopuvs = CustomData_get_layer(&mesh->ldata, CD_PROP_FLOAT2);
}
if (!loopuvs) {
BKE_reportf(reports,
@@ -204,10 +204,10 @@ typedef struct {
const float (*precomputedFaceNormals)[3];
const float (*precomputedLoopNormals)[3];
const MLoopTri *looptri;
- const MLoopUV *mloopuv; /* texture coordinates */
- const MPoly *mpoly; /* indices */
- const MLoop *mloop; /* indices */
- const MVert *mvert; /* vertex coordinates */
+ const float (*mloopuv)[2]; /* texture coordinates */
+ const MPoly *mpoly; /* indices */
+ const MLoop *mloop; /* indices */
+ const MVert *mvert; /* vertex coordinates */
const float (*vert_normals)[3];
const float (*orco)[3];
float (*tangent)[4]; /* destination */
@@ -316,7 +316,7 @@ static void dm_ts_GetTextureCoordinate(const SMikkTSpaceContext *pContext,
finally:
if (pMesh->mloopuv != NULL) {
- const float *uv = pMesh->mloopuv[loop_index].uv;
+ const float *uv = pMesh->mloopuv[loop_index];
copy_v2_v2(r_uv, uv);
}
else {
@@ -451,7 +451,7 @@ void BKE_mesh_add_loop_tangent_named_layer_for_uv(CustomData *uv_data,
const char *layer_name)
{
if (CustomData_get_named_layer_index(tan_data, CD_TANGENT, layer_name) == -1 &&
- CustomData_get_named_layer_index(uv_data, CD_MLOOPUV, layer_name) != -1) {
+ CustomData_get_named_layer_index(uv_data, CD_PROP_FLOAT2, layer_name) != -1) {
CustomData_add_layer_named(tan_data, CD_TANGENT, CD_CALLOC, NULL, numLoopData, layer_name);
}
}
@@ -469,15 +469,15 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
short *rtangent_mask)
{
/* Active uv in viewport */
- int layer_index = CustomData_get_layer_index(loopData, CD_MLOOPUV);
- *ract_uv_n = CustomData_get_active_layer(loopData, CD_MLOOPUV);
+ int layer_index = CustomData_get_layer_index(loopData, CD_PROP_FLOAT2);
+ *ract_uv_n = CustomData_get_active_layer(loopData, CD_PROP_FLOAT2);
ract_uv_name[0] = 0;
if (*ract_uv_n != -1) {
strcpy(ract_uv_name, loopData->layers[*ract_uv_n + layer_index].name);
}
/* Active tangent in render */
- *rren_uv_n = CustomData_get_render_layer(loopData, CD_MLOOPUV);
+ *rren_uv_n = CustomData_get_render_layer(loopData, CD_PROP_FLOAT2);
rren_uv_name[0] = 0;
if (*rren_uv_n != -1) {
strcpy(rren_uv_name, loopData->layers[*rren_uv_n + layer_index].name);
@@ -505,9 +505,9 @@ void BKE_mesh_calc_loop_tangent_step_0(const CustomData *loopData,
}
*rtangent_mask = 0;
- const int uv_layer_num = CustomData_number_of_layers(loopData, CD_MLOOPUV);
+ const int uv_layer_num = CustomData_number_of_layers(loopData, CD_PROP_FLOAT2);
for (int n = 0; n < uv_layer_num; n++) {
- const char *name = CustomData_get_layer_name(loopData, CD_MLOOPUV, n);
+ const char *name = CustomData_get_layer_name(loopData, CD_PROP_FLOAT2, n);
bool add = false;
for (int i = 0; i < tangent_names_count; i++) {
if (tangent_names[i][0] && STREQ(tangent_names[i], name)) {
@@ -646,7 +646,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
mesh2tangent->orco = NULL;
mesh2tangent->mloopuv = CustomData_get_layer_named(
- loopdata, CD_MLOOPUV, loopdata_out->layers[index].name);
+ loopdata, CD_PROP_FLOAT2, loopdata_out->layers[index].name);
/* Fill the resulting tangent_mask */
if (!mesh2tangent->mloopuv) {
@@ -659,8 +659,8 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
}
else {
int uv_ind = CustomData_get_named_layer_index(
- loopdata, CD_MLOOPUV, loopdata_out->layers[index].name);
- int uv_start = CustomData_get_layer_index(loopdata, CD_MLOOPUV);
+ loopdata, CD_PROP_FLOAT2, loopdata_out->layers[index].name);
+ int uv_start = CustomData_get_layer_index(loopdata, CD_PROP_FLOAT2);
BLI_assert(uv_ind != -1 && uv_start != -1);
BLI_assert(uv_ind - uv_start < MAX_MTFACE);
tangent_mask_curr |= (short)(1 << (uv_ind - uv_start));
@@ -689,7 +689,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
/* Update active layer index */
int act_uv_index = (act_uv_n != -1) ?
- CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, act_uv_n) :
+ CustomData_get_layer_index_n(loopdata, CD_PROP_FLOAT2, act_uv_n) :
-1;
if (act_uv_index != -1) {
int tan_index = CustomData_get_named_layer_index(
@@ -699,7 +699,7 @@ void BKE_mesh_calc_loop_tangent_ex(const MVert *mvert,
/* Update render layer index */
int ren_uv_index = (ren_uv_n != -1) ?
- CustomData_get_layer_index_n(loopdata, CD_MLOOPUV, ren_uv_n) :
+ CustomData_get_layer_index_n(loopdata, CD_PROP_FLOAT2, ren_uv_n) :
-1;
if (ren_uv_index != -1) {
int tan_index = CustomData_get_named_layer_index(
diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc
index 9b2697ecc84..311121cb3ed 100644
--- a/source/blender/blenkernel/intern/mesh_validate.cc
+++ b/source/blender/blenkernel/intern/mesh_validate.cc
@@ -1016,7 +1016,7 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata,
is_valid &= mesh_validate_customdata(
pdata, mask.pmask, totpoly, do_verbose, do_fixes, &is_change_p);
- const int tot_uvloop = CustomData_number_of_layers(ldata, CD_MLOOPUV);
+ const int tot_uvloop = CustomData_number_of_layers(ldata, CD_PROP_FLOAT2);
const int tot_vcolloop = CustomData_number_of_layers(ldata, CD_PROP_BYTE_COLOR);
if (tot_uvloop > MAX_MTFACE) {
PRINT_ERR(
@@ -1034,12 +1034,12 @@ bool BKE_mesh_validate_all_customdata(CustomData *vdata,
}
/* check indices of clone/stencil */
- if (do_fixes && CustomData_get_clone_layer(ldata, CD_MLOOPUV) >= tot_uvloop) {
- CustomData_set_layer_clone(ldata, CD_MLOOPUV, 0);
+ if (do_fixes && CustomData_get_clone_layer(ldata, CD_PROP_FLOAT2) >= tot_uvloop) {
+ CustomData_set_layer_clone(ldata, CD_PROP_FLOAT2, 0);
is_change_l = true;
}
- if (do_fixes && CustomData_get_stencil_layer(ldata, CD_MLOOPUV) >= tot_uvloop) {
- CustomData_set_layer_stencil(ldata, CD_MLOOPUV, 0);
+ if (do_fixes && CustomData_get_stencil_layer(ldata, CD_PROP_FLOAT2) >= tot_uvloop) {
+ CustomData_set_layer_stencil(ldata, CD_PROP_FLOAT2, 0);
is_change_l = true;
}
diff --git a/source/blender/blenkernel/intern/object_dupli.cc b/source/blender/blenkernel/intern/object_dupli.cc
index 407a2c8955c..0e400f0025f 100644
--- a/source/blender/blenkernel/intern/object_dupli.cc
+++ b/source/blender/blenkernel/intern/object_dupli.cc
@@ -923,7 +923,7 @@ struct FaceDupliData_Mesh {
const MLoop *mloop;
const MVert *mvert;
const float (*orco)[3];
- const MLoopUV *mloopuv;
+ const float (*mloopuv)[2];
};
struct FaceDupliData_EditMesh {
@@ -1073,7 +1073,7 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx,
const MLoop *mloop = fdd->mloop;
const MVert *mvert = fdd->mvert;
const float(*orco)[3] = fdd->orco;
- const MLoopUV *mloopuv = fdd->mloopuv;
+ const float(*mloopuv)[2] = fdd->mloopuv;
const int totface = fdd->totface;
const bool use_scale = fdd->params.use_scale;
int a;
@@ -1098,7 +1098,7 @@ static void make_child_duplis_faces_from_mesh(const DupliContext *ctx,
}
if (mloopuv) {
for (int j = 0; j < mp->totloop; j++) {
- madd_v2_v2fl(dob->uv, mloopuv[mp->loopstart + j].uv, w);
+ madd_v2_v2fl(dob->uv, mloopuv[mp->loopstart + j], w);
}
}
}
@@ -1158,7 +1158,7 @@ static void make_duplis_faces(const DupliContext *ctx)
FaceDupliData_Params fdd_params = {ctx, (parent->transflag & OB_DUPLIFACES_SCALE) != 0};
if (em != nullptr) {
- const int uv_idx = CustomData_get_render_layer(&em->bm->ldata, CD_MLOOPUV);
+ const int uv_idx = CustomData_get_render_layer(&em->bm->ldata, CD_PROP_FLOAT2);
FaceDupliData_EditMesh fdd{};
fdd.params = fdd_params;
fdd.em = em;
@@ -1166,20 +1166,20 @@ static void make_duplis_faces(const DupliContext *ctx)
fdd.has_orco = (vert_coords != nullptr);
fdd.has_uvs = (uv_idx != -1);
fdd.cd_loop_uv_offset = (uv_idx != -1) ?
- CustomData_get_n_offset(&em->bm->ldata, CD_MLOOPUV, uv_idx) :
+ CustomData_get_n_offset(&em->bm->ldata, CD_PROP_FLOAT2, uv_idx) :
-1;
make_child_duplis(ctx, &fdd, make_child_duplis_faces_from_editmesh);
}
else {
- const int uv_idx = CustomData_get_render_layer(&me_eval->ldata, CD_MLOOPUV);
+ const int uv_idx = CustomData_get_render_layer(&me_eval->ldata, CD_PROP_FLOAT2);
FaceDupliData_Mesh fdd{};
fdd.params = fdd_params;
fdd.totface = me_eval->totpoly;
fdd.mpoly = me_eval->mpoly;
fdd.mloop = me_eval->mloop;
fdd.mvert = me_eval->mvert;
- fdd.mloopuv = (uv_idx != -1) ? (const MLoopUV *)CustomData_get_layer_n(
- &me_eval->ldata, CD_MLOOPUV, uv_idx) :
+ fdd.mloopuv = (uv_idx != -1) ? (const float(*)[2])CustomData_get_layer_n(
+ &me_eval->ldata, CD_PROP_FLOAT2, uv_idx) :
nullptr;
fdd.orco = (const float(*)[3])CustomData_get_layer(&me_eval->vdata, CD_ORCO);
diff --git a/source/blender/blenkernel/intern/object_update.c b/source/blender/blenkernel/intern/object_update.c
index 8ff02c7e698..6ce684d0eeb 100644
--- a/source/blender/blenkernel/intern/object_update.c
+++ b/source/blender/blenkernel/intern/object_update.c
@@ -162,7 +162,7 @@ void BKE_object_handle_data_update(Depsgraph *depsgraph, Scene *scene, Object *o
#endif
if (DEG_get_mode(depsgraph) == DAG_EVAL_RENDER) {
/* Always compute UVs, vertex colors as orcos for render. */
- cddata_masks.lmask |= CD_MASK_MLOOPUV | CD_MASK_PROP_BYTE_COLOR;
+ cddata_masks.lmask |= CD_MASK_PROP_FLOAT2 | CD_MASK_PROP_BYTE_COLOR;
cddata_masks.vmask |= CD_MASK_ORCO | CD_MASK_PROP_COLOR;
}
makeDerivedMesh(depsgraph, scene, ob, &cddata_masks); /* was CD_MASK_BAREMESH */
diff --git a/source/blender/blenkernel/intern/paint_canvas.cc b/source/blender/blenkernel/intern/paint_canvas.cc
index b72418d88c0..5eed6e15467 100644
--- a/source/blender/blenkernel/intern/paint_canvas.cc
+++ b/source/blender/blenkernel/intern/paint_canvas.cc
@@ -80,7 +80,7 @@ int BKE_paint_canvas_uvmap_layer_index_get(const struct PaintModeSettings *setti
}
const Mesh *mesh = static_cast<Mesh *>(ob->data);
- return CustomData_get_active_layer_index(&mesh->ldata, CD_MLOOPUV);
+ return CustomData_get_active_layer_index(&mesh->ldata, CD_PROP_FLOAT2);
}
case PAINT_CANVAS_SOURCE_MATERIAL: {
/* Use uv map of the canvas. */
@@ -98,7 +98,7 @@ int BKE_paint_canvas_uvmap_layer_index_get(const struct PaintModeSettings *setti
}
const Mesh *mesh = static_cast<Mesh *>(ob->data);
- return CustomData_get_named_layer_index(&mesh->ldata, CD_MLOOPUV, slot->uvname);
+ return CustomData_get_named_layer_index(&mesh->ldata, CD_PROP_FLOAT2, slot->uvname);
}
}
return -1;
diff --git a/source/blender/blenkernel/intern/pbvh_pixels.cc b/source/blender/blenkernel/intern/pbvh_pixels.cc
index 49397797c0d..256327ee1c1 100644
--- a/source/blender/blenkernel/intern/pbvh_pixels.cc
+++ b/source/blender/blenkernel/intern/pbvh_pixels.cc
@@ -108,7 +108,7 @@ struct EncodePixelsUserData {
ImageUser *image_user;
PBVH *pbvh;
Vector<PBVHNode *> *nodes;
- const MLoopUV *ldata_uv;
+ const float2 *ldata_uv;
};
static void do_encode_pixels(void *__restrict userdata,
@@ -136,9 +136,9 @@ static void do_encode_pixels(void *__restrict userdata,
for (int triangle_index = 0; triangle_index < triangles.size(); triangle_index++) {
const MLoopTri *lt = &pbvh->looptri[node->prim_indices[triangle_index]];
float2 uvs[3] = {
- float2(data->ldata_uv[lt->tri[0]].uv) - tile_offset,
- float2(data->ldata_uv[lt->tri[1]].uv) - tile_offset,
- float2(data->ldata_uv[lt->tri[2]].uv) - tile_offset,
+ data->ldata_uv[lt->tri[0]] - tile_offset,
+ data->ldata_uv[lt->tri[1]] - tile_offset,
+ data->ldata_uv[lt->tri[2]] - tile_offset,
};
const float minv = clamp_f(min_fff(uvs[0].y, uvs[1].y, uvs[2].y), 0.0f, 1.0f);
@@ -283,8 +283,9 @@ static void update_pixels(PBVH *pbvh, Mesh *mesh, Image *image, ImageUser *image
return;
}
- const MLoopUV *ldata_uv = static_cast<const MLoopUV *>(
- CustomData_get_layer(&mesh->ldata, CD_MLOOPUV));
+ const float2 *ldata_uv = static_cast<float2 *>(
+ CustomData_get_layer(&mesh->ldata, CD_PROP_FLOAT2));
+
if (ldata_uv == nullptr) {
return;
}
diff --git a/source/blender/blenkernel/intern/subdiv_converter_mesh.c b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
index 12a5f00a68b..43cd0f3ab02 100644
--- a/source/blender/blenkernel/intern/subdiv_converter_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_converter_mesh.c
@@ -186,7 +186,7 @@ static int get_num_uv_layers(const OpenSubdiv_Converter *converter)
{
ConverterStorage *storage = converter->user_data;
const Mesh *mesh = storage->mesh;
- return CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV);
+ return CustomData_number_of_layers(&mesh->ldata, CD_PROP_FLOAT2);
}
static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int layer_index)
@@ -195,7 +195,7 @@ static void precalc_uv_layer(const OpenSubdiv_Converter *converter, const int la
const Mesh *mesh = storage->mesh;
const MPoly *mpoly = mesh->mpoly;
const MLoop *mloop = mesh->mloop;
- const MLoopUV *mloopuv = CustomData_get_layer_n(&mesh->ldata, CD_MLOOPUV, layer_index);
+ const float(*mloopuv)[2] = CustomData_get_layer_n(&mesh->ldata, CD_PROP_FLOAT2, layer_index);
const int num_poly = mesh->totpoly;
const int num_vert = mesh->totvert;
const float limit[2] = {STD_UV_CONNECT_LIMIT, STD_UV_CONNECT_LIMIT};
diff --git a/source/blender/blenkernel/intern/subdiv_eval.c b/source/blender/blenkernel/intern/subdiv_eval.c
index 841b47818f1..52acf39cc61 100644
--- a/source/blender/blenkernel/intern/subdiv_eval.c
+++ b/source/blender/blenkernel/intern/subdiv_eval.c
@@ -125,7 +125,7 @@ static void set_coarse_positions(Subdiv *subdiv,
typedef struct FaceVaryingDataFromUVContext {
OpenSubdiv_TopologyRefiner *topology_refiner;
const Mesh *mesh;
- const MLoopUV *mloopuv;
+ const float (*mloopuv)[2];
float (*buffer)[2];
int layer_index;
} FaceVaryingDataFromUVContext;
@@ -139,7 +139,7 @@ static void set_face_varying_data_from_uv_task(void *__restrict userdata,
const int layer_index = ctx->layer_index;
const Mesh *mesh = ctx->mesh;
const MPoly *mpoly = &mesh->mpoly[face_index];
- const MLoopUV *mluv = &ctx->mloopuv[mpoly->loopstart];
+ const float(*mluv)[2] = &ctx->mloopuv[mpoly->loopstart];
/* TODO(sergey): OpenSubdiv's C-API converter can change winding of
* loops of a face, need to watch for that, to prevent wrong UVs assigned.
@@ -148,19 +148,19 @@ static void set_face_varying_data_from_uv_task(void *__restrict userdata,
const int *uv_indices = topology_refiner->getFaceFVarValueIndices(
topology_refiner, face_index, layer_index);
for (int vertex_index = 0; vertex_index < num_face_vertices; vertex_index++, mluv++) {
- copy_v2_v2(ctx->buffer[uv_indices[vertex_index]], mluv->uv);
+ copy_v2_v2(ctx->buffer[uv_indices[vertex_index]], *mluv);
}
}
static void set_face_varying_data_from_uv(Subdiv *subdiv,
const Mesh *mesh,
- const MLoopUV *mloopuv,
+ const float (*mloopuv)[2],
const int layer_index)
{
OpenSubdiv_TopologyRefiner *topology_refiner = subdiv->topology_refiner;
OpenSubdiv_Evaluator *evaluator = subdiv->evaluator;
const int num_faces = topology_refiner->getNumFaces(topology_refiner);
- const MLoopUV *mluv = mloopuv;
+ const float(*mluv)[2] = mloopuv;
const int num_fvar_values = topology_refiner->getNumFVarValues(topology_refiner, layer_index);
/* Use a temporary buffer so we do not upload UVs one at a time to the GPU. */
@@ -248,9 +248,9 @@ bool BKE_subdiv_eval_refine_from_mesh(Subdiv *subdiv,
/* Set coordinates of base mesh vertices. */
set_coarse_positions(subdiv, mesh, coarse_vertex_cos);
/* Set face-varying data to UV maps. */
- const int num_uv_layers = CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV);
+ const int num_uv_layers = CustomData_number_of_layers(&mesh->ldata, CD_PROP_FLOAT2);
for (int layer_index = 0; layer_index < num_uv_layers; layer_index++) {
- const MLoopUV *mloopuv = CustomData_get_layer_n(&mesh->ldata, CD_MLOOPUV, layer_index);
+ const float(*mloopuv)[2] = CustomData_get_layer_n(&mesh->ldata, CD_PROP_FLOAT2, layer_index);
set_face_varying_data_from_uv(subdiv, mesh, mloopuv, layer_index);
}
/* Set vertex data to orco. */
diff --git a/source/blender/blenkernel/intern/subdiv_mesh.c b/source/blender/blenkernel/intern/subdiv_mesh.c
index 433bad34479..9458b081767 100644
--- a/source/blender/blenkernel/intern/subdiv_mesh.c
+++ b/source/blender/blenkernel/intern/subdiv_mesh.c
@@ -28,6 +28,7 @@
/* -------------------------------------------------------------------- */
/** \name Subdivision Context
* \{ */
+typedef float uvtype[2];
typedef struct SubdivMeshContext {
const SubdivToMeshSettings *settings;
@@ -39,12 +40,15 @@ typedef struct SubdivMeshContext {
int *edge_origindex;
int *loop_origindex;
int *poly_origindex;
+
/* UV layers interpolation. */
int num_uv_layers;
- MLoopUV *uv_layers[MAX_MTFACE];
+ uvtype *uv_layers[MAX_MTFACE];
+
/* Original coordinates (ORCO) interpolation. */
float (*orco)[3];
float (*cloth_orco)[3];
+
/* Per-subdivided vertex counter of averaged values. */
int *accumulated_counters;
bool have_displacement;
@@ -53,10 +57,10 @@ typedef struct SubdivMeshContext {
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_MLOOPUV);
+ 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] = CustomData_get_layer_n(
- &subdiv_mesh->ldata, CD_MLOOPUV, layer_index);
+ &subdiv_mesh->ldata, CD_PROP_FLOAT2, layer_index);
}
}
@@ -850,8 +854,8 @@ static void subdiv_eval_uv_layer(SubdivMeshContext *ctx,
Subdiv *subdiv = ctx->subdiv;
const int mloop_index = subdiv_loop - ctx->subdiv_mesh->mloop;
for (int layer_index = 0; layer_index < ctx->num_uv_layers; layer_index++) {
- MLoopUV *subdiv_loopuv = &ctx->uv_layers[layer_index][mloop_index];
- BKE_subdiv_eval_face_varying(subdiv, layer_index, ptex_face_index, u, v, subdiv_loopuv->uv);
+ float(*subdiv_loopuv)[2] = &ctx->uv_layers[layer_index][mloop_index];
+ BKE_subdiv_eval_face_varying(subdiv, layer_index, ptex_face_index, u, v, *subdiv_loopuv);
}
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index efabb4f039a..adf9289a557 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -262,7 +262,7 @@ static void get_face_uv_map_vert(
static int ss_sync_from_uv(CCGSubSurf *ss,
CCGSubSurf *origss,
DerivedMesh *dm,
- const MLoopUV *mloopuv)
+ const float (*mloopuv)[2])
{
MPoly *mpoly = dm->getPolyArray(dm);
MLoop *mloop = dm->getLoopArray(dm);
@@ -311,7 +311,7 @@ static int ss_sync_from_uv(CCGSubSurf *ss,
int loopid = mpoly[v->poly_index].loopstart + v->loop_of_poly_index;
CCGVertHDL vhdl = POINTER_FROM_INT(loopid);
- copy_v2_v2(uv, mloopuv[loopid].uv);
+ copy_v2_v2(uv, mloopuv[loopid]);
ccgSubSurf_syncVert(ss, vhdl, uv, seam, &ssv);
}
@@ -386,11 +386,11 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
{
CCGFaceIterator fi;
int index, gridSize, gridFaces, /*edgeSize,*/ totface, x, y, S;
- const MLoopUV *dmloopuv = CustomData_get_layer_n(&dm->loopData, CD_MLOOPUV, n);
- /* need to update both CD_MTFACE & CD_MLOOPUV, hrmf, we could get away with
+ const float(*dmloopuv)[2] = CustomData_get_layer_n(&dm->loopData, CD_PROP_FLOAT2, n);
+ /* need to update both CD_MTFACE & CD_PROP_FLOAT2, hrmf, we could get away with
* just tface except applying the modifier then looses subsurf UV */
MTFace *tface = CustomData_get_layer_n(&result->faceData, CD_MTFACE, n);
- MLoopUV *mloopuv = CustomData_get_layer_n(&result->loopData, CD_MLOOPUV, n);
+ float(*mloopuv)[2] = CustomData_get_layer_n(&result->loopData, CD_PROP_FLOAT2, n);
if (!dmloopuv || (!tface && !mloopuv)) {
return;
@@ -420,7 +420,7 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
/* load coordinates from uvss into tface */
MTFace *tf = tface;
- MLoopUV *mluv = mloopuv;
+ float(*mluv)[2] = mloopuv;
for (index = 0; index < totface; index++) {
CCGFace *f = faceMap[index];
@@ -445,10 +445,10 @@ static void set_subsurf_legacy_uv(CCGSubSurf *ss, DerivedMesh *dm, DerivedMesh *
}
if (mluv) {
- copy_v2_v2(mluv[0].uv, a);
- copy_v2_v2(mluv[1].uv, d);
- copy_v2_v2(mluv[2].uv, c);
- copy_v2_v2(mluv[3].uv, b);
+ copy_v2_v2(mluv[0], a);
+ copy_v2_v2(mluv[1], d);
+ copy_v2_v2(mluv[2], c);
+ copy_v2_v2(mluv[3], b);
mluv += 4;
}
}
@@ -1807,8 +1807,8 @@ static void set_ccgdm_all_geometry(CCGDerivedMesh *ccgdm,
if (useSubsurfUv) {
CustomData *ldata = &ccgdm->dm.loopData;
CustomData *dmldata = &dm->loopData;
- int numlayer = CustomData_number_of_layers(ldata, CD_MLOOPUV);
- int dmnumlayer = CustomData_number_of_layers(dmldata, CD_MLOOPUV);
+ int numlayer = CustomData_number_of_layers(ldata, CD_PROP_FLOAT2);
+ int dmnumlayer = CustomData_number_of_layers(dmldata, CD_PROP_FLOAT2);
for (i = 0; i < numlayer && i < dmnumlayer; i++) {
set_subsurf_uv(ss, dm, &ccgdm->dm, i);