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:
authorHans Goudey <h.goudey@me.com>2022-08-17 20:59:10 +0300
committerHans Goudey <h.goudey@me.com>2022-08-17 20:59:10 +0300
commit37eea2253295602fbff4ba255fdb2ee8f1826df3 (patch)
treeee939acc8d0f5a395064692a2e65a289f4210a31 /source/blender/modifiers/intern
parentf08ea76db591a1ca60715f19f3465da57b26f64e (diff)
Initial patch from Martijn Versteegh
Diffstat (limited to 'source/blender/modifiers/intern')
-rw-r--r--source/blender/modifiers/intern/MOD_array.c8
-rw-r--r--source/blender/modifiers/intern/MOD_dynamicpaint.c4
-rw-r--r--source/blender/modifiers/intern/MOD_ocean.c24
-rw-r--r--source/blender/modifiers/intern/MOD_screw.c26
-rw-r--r--source/blender/modifiers/intern/MOD_util.c11
-rw-r--r--source/blender/modifiers/intern/MOD_uvproject.c20
-rw-r--r--source/blender/modifiers/intern/MOD_uvwarp.c18
7 files changed, 55 insertions, 56 deletions
diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c
index 569b0fd0fda..1cec1aa16c2 100644
--- a/source/blender/modifiers/intern/MOD_array.c
+++ b/source/blender/modifiers/intern/MOD_array.c
@@ -665,9 +665,9 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
/* handle UVs */
if (chunk_nloops > 0 && is_zero_v2(amd->uv_offset) == false) {
- const int totuv = CustomData_number_of_layers(&result->ldata, CD_MLOOPUV);
+ const int totuv = CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2);
for (i = 0; i < totuv; i++) {
- MLoopUV *dmloopuv = CustomData_get_layer_n(&result->ldata, CD_MLOOPUV, i);
+ float(*dmloopuv)[2] = CustomData_get_layer_n(&result->ldata, CD_PROP_FLOAT2, i);
dmloopuv += chunk_nloops;
for (c = 1; c < count; c++) {
const float uv_offset[2] = {
@@ -676,8 +676,8 @@ static Mesh *arrayModifier_doArray(ArrayModifierData *amd,
};
int l_index = chunk_nloops;
for (; l_index-- != 0; dmloopuv++) {
- dmloopuv->uv[0] += uv_offset[0];
- dmloopuv->uv[1] += uv_offset[1];
+ (*dmloopuv)[0] += uv_offset[0];
+ (*dmloopuv)[1] += uv_offset[1];
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c
index 4afb81c04a9..40fe773efaf 100644
--- a/source/blender/modifiers/intern/MOD_dynamicpaint.c
+++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c
@@ -83,10 +83,10 @@ static void requiredDataMask(Object *UNUSED(ob),
if (pmd->canvas) {
DynamicPaintSurface *surface = pmd->canvas->surfaces.first;
for (; surface; surface = surface->next) {
- /* UV's: #CD_MLOOPUV. */
+ /* UV's: #CD_PROP_FLOAT2. */
if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ ||
surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE) {
- r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
+ r_cddata_masks->lmask |= CD_MASK_PROP_FLOAT2;
}
/* Vertex Colors: #CD_PROP_BYTE_COLOR. */
if (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c
index ea9049200cc..a69be131078 100644
--- a/source/blender/modifiers/intern/MOD_ocean.c
+++ b/source/blender/modifiers/intern/MOD_ocean.c
@@ -160,7 +160,7 @@ typedef struct GenerateOceanGeometryData {
MVert *mverts;
MPoly *mpolys;
MLoop *mloops;
- MLoopUV *mloopuvs;
+ float (*mloopuvs)[2];
int res_x, res_y;
int rx, ry;
@@ -223,22 +223,22 @@ static void generate_ocean_geometry_uvs(void *__restrict userdata,
for (x = 0; x < gogd->res_x; x++) {
const int i = y * gogd->res_x + x;
- MLoopUV *luv = &gogd->mloopuvs[i * 4];
+ float(*luv)[2] = &gogd->mloopuvs[i * 4];
- luv->uv[0] = x * gogd->ix;
- luv->uv[1] = y * gogd->iy;
+ (*luv)[0] = x * gogd->ix;
+ (*luv)[1] = y * gogd->iy;
luv++;
- luv->uv[0] = (x + 1) * gogd->ix;
- luv->uv[1] = y * gogd->iy;
+ (*luv)[0] = (x + 1) * gogd->ix;
+ (*luv)[1] = y * gogd->iy;
luv++;
- luv->uv[0] = (x + 1) * gogd->ix;
- luv->uv[1] = (y + 1) * gogd->iy;
+ (*luv)[0] = (x + 1) * gogd->ix;
+ (*luv)[1] = (y + 1) * gogd->iy;
luv++;
- luv->uv[0] = x * gogd->ix;
- luv->uv[1] = (y + 1) * gogd->iy;
+ (*luv)[0] = x * gogd->ix;
+ (*luv)[1] = (y + 1) * gogd->iy;
luv++;
}
}
@@ -290,9 +290,9 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd, Mesh *mesh_orig, co
BKE_mesh_calc_edges(result, false, false);
/* add uvs */
- if (CustomData_number_of_layers(&result->ldata, CD_MLOOPUV) < MAX_MTFACE) {
+ if (CustomData_number_of_layers(&result->ldata, CD_PROP_FLOAT2) < MAX_MTFACE) {
gogd.mloopuvs = CustomData_add_layer(
- &result->ldata, CD_MLOOPUV, CD_CALLOC, NULL, polys_num * 4);
+ &result->ldata, CD_PROP_FLOAT2, CD_CALLOC, NULL, polys_num * 4);
if (gogd.mloopuvs) { /* unlikely to fail */
gogd.ix = 1.0 / gogd.rx;
diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c
index 9588b9acd3b..dfb422adbae 100644
--- a/source/blender/modifiers/intern/MOD_screw.c
+++ b/source/blender/modifiers/intern/MOD_screw.c
@@ -211,8 +211,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
uint *vert_loop_map = NULL; /* orig vert to orig loop */
/* UV Coords */
- const uint mloopuv_layers_tot = (uint)CustomData_number_of_layers(&mesh->ldata, CD_MLOOPUV);
- MLoopUV **mloopuv_layers = BLI_array_alloca(mloopuv_layers, mloopuv_layers_tot);
+ const uint mloopuv_layers_tot = (uint)CustomData_number_of_layers(&mesh->ldata, CD_PROP_FLOAT2);
+ float(**mloopuv_layers)[2] = BLI_array_alloca(mloopuv_layers, mloopuv_layers_tot);
float uv_u_scale;
float uv_v_minmax[2] = {FLT_MAX, -FLT_MAX};
float uv_v_range_inv;
@@ -408,7 +408,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
if (mloopuv_layers_tot) {
uint uv_lay;
for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) {
- mloopuv_layers[uv_lay] = CustomData_get_layer_n(&result->ldata, CD_MLOOPUV, (int)uv_lay);
+ mloopuv_layers[uv_lay] = CustomData_get_layer_n(&result->ldata, CD_PROP_FLOAT2, (int)uv_lay);
}
if (ltmd->flag & MOD_SCREW_UV_STRETCH_V) {
@@ -1011,12 +1011,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const float uv_u_offset_a = (float)(step)*uv_u_scale;
const float uv_u_offset_b = (float)(step + 1) * uv_u_scale;
for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) {
- MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index];
+ float(*mluv)[2] = &mloopuv_layers[uv_lay][l_index];
- mluv[quad_ord[0]].uv[0] += uv_u_offset_a;
- mluv[quad_ord[1]].uv[0] += uv_u_offset_a;
- mluv[quad_ord[2]].uv[0] += uv_u_offset_b;
- mluv[quad_ord[3]].uv[0] += uv_u_offset_b;
+ mluv[quad_ord[0]][0] += uv_u_offset_a;
+ mluv[quad_ord[1]][0] += uv_u_offset_a;
+ mluv[quad_ord[2]][0] += uv_u_offset_b;
+ mluv[quad_ord[3]][0] += uv_u_offset_b;
}
}
}
@@ -1028,12 +1028,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const float uv_u_offset_a = (float)(step)*uv_u_scale;
const float uv_u_offset_b = (float)(step + 1) * uv_u_scale;
for (uv_lay = 0; uv_lay < mloopuv_layers_tot; uv_lay++) {
- MLoopUV *mluv = &mloopuv_layers[uv_lay][l_index];
+ float(*mluv)[2] = &mloopuv_layers[uv_lay][l_index];
- copy_v2_fl2(mluv[quad_ord[0]].uv, uv_u_offset_a, uv_v_offset_a);
- copy_v2_fl2(mluv[quad_ord[1]].uv, uv_u_offset_a, uv_v_offset_b);
- copy_v2_fl2(mluv[quad_ord[2]].uv, uv_u_offset_b, uv_v_offset_b);
- copy_v2_fl2(mluv[quad_ord[3]].uv, uv_u_offset_b, uv_v_offset_a);
+ copy_v2_fl2(mluv[quad_ord[0]], uv_u_offset_a, uv_v_offset_a);
+ copy_v2_fl2(mluv[quad_ord[1]], uv_u_offset_a, uv_v_offset_b);
+ copy_v2_fl2(mluv[quad_ord[2]], uv_u_offset_b, uv_v_offset_b);
+ copy_v2_fl2(mluv[quad_ord[3]], uv_u_offset_b, uv_v_offset_a);
}
}
}
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index 575182a846b..1633f2400a6 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -93,16 +93,15 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
/* UVs need special handling, since they come from faces */
if (texmapping == MOD_DISP_MAP_UV) {
- if (CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
+ if (CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
MPoly *mpoly = mesh->mpoly;
MPoly *mp;
MLoop *mloop = mesh->mloop;
BLI_bitmap *done = BLI_BITMAP_NEW(verts_num, __func__);
const int polys_num = mesh->totpoly;
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
-
- CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, dmd->uvlayer_name, uvname);
- const MLoopUV *mloop_uv = CustomData_get_layer_named(&mesh->ldata, CD_MLOOPUV, uvname);
+ CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, dmd->uvlayer_name, uvname);
+ const float(*mloop_uv)[2] = CustomData_get_layer_named(&mesh->ldata, CD_PROP_FLOAT2, uvname);
/* verts are given the UV from the first face that uses them */
for (i = 0, mp = mpoly; i < polys_num; i++, mp++) {
@@ -114,8 +113,8 @@ void MOD_get_texture_coords(MappingInfoModifierData *dmd,
if (!BLI_BITMAP_TEST(done, vidx)) {
/* remap UVs from [0, 1] to [-1, 1] */
- r_texco[vidx][0] = (mloop_uv[lidx].uv[0] * 2.0f) - 1.0f;
- r_texco[vidx][1] = (mloop_uv[lidx].uv[1] * 2.0f) - 1.0f;
+ r_texco[vidx][0] = (mloop_uv[lidx][0] * 2.0f) - 1.0f;
+ r_texco[vidx][1] = (mloop_uv[lidx][1] * 2.0f) - 1.0f;
BLI_BITMAP_ENABLE(done, vidx);
}
diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c
index 0474d3e47e6..b9eba7efcd6 100644
--- a/source/blender/modifiers/intern/MOD_uvproject.c
+++ b/source/blender/modifiers/intern/MOD_uvproject.c
@@ -57,7 +57,7 @@ static void requiredDataMask(Object *UNUSED(ob),
CustomData_MeshMasks *r_cddata_masks)
{
/* ask for UV coordinates */
- r_cddata_masks->lmask |= CD_MASK_MLOOPUV;
+ r_cddata_masks->lmask |= CD_MASK_PROP_FLOAT2;
}
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
@@ -97,7 +97,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
Mesh *mesh)
{
float(*coords)[3], (*co)[3];
- MLoopUV *mloop_uv;
+ float(*mloop_uv)[2];
int i, verts_num, polys_num, loops_num;
MPoly *mpoly, *mp;
MLoop *mloop;
@@ -122,13 +122,13 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* Create a new layer if no UV Maps are available
* (e.g. if a preceding modifier could not preserve it). */
- if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
+ if (!CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
CustomData_add_layer_named(
- &mesh->ldata, CD_MLOOPUV, CD_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
+ &mesh->ldata, CD_PROP_FLOAT2, CD_DEFAULT, NULL, mesh->totloop, umd->uvlayer_name);
}
/* make sure we're using an existing layer */
- CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname);
+ CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, umd->uvlayer_name, uvname);
/* calculate a projection matrix and normal for each projector */
for (i = 0; i < projectors_num; i++) {
@@ -189,7 +189,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
/* make sure we are not modifying the original UV map */
mloop_uv = CustomData_duplicate_referenced_layer_named(
- &mesh->ldata, CD_MLOOPUV, uvname, loops_num);
+ &mesh->ldata, CD_PROP_FLOAT2, uvname, loops_num);
coords = BKE_mesh_vert_coords_alloc(mesh, &verts_num);
@@ -216,7 +216,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
do {
uint lidx = mp->loopstart + fidx;
uint vidx = mloop[lidx].v;
- BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], projectors[0].uci);
+ BLI_uvproject_from_camera(mloop_uv[lidx], coords[vidx], projectors[0].uci);
} while (fidx--);
}
else {
@@ -225,7 +225,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
do {
uint lidx = mp->loopstart + fidx;
uint vidx = mloop[lidx].v;
- copy_v2_v2(mloop_uv[lidx].uv, coords[vidx]);
+ copy_v2_v2(mloop_uv[lidx], coords[vidx]);
} while (fidx--);
}
}
@@ -259,7 +259,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
do {
uint lidx = mp->loopstart + fidx;
uint vidx = mloop[lidx].v;
- BLI_uvproject_from_camera(mloop_uv[lidx].uv, coords[vidx], best_projector->uci);
+ BLI_uvproject_from_camera(mloop_uv[lidx], coords[vidx], best_projector->uci);
} while (fidx--);
}
else {
@@ -267,7 +267,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd,
do {
uint lidx = mp->loopstart + fidx;
uint vidx = mloop[lidx].v;
- mul_v2_project_m4_v3(mloop_uv[lidx].uv, best_projector->projmat, coords[vidx]);
+ mul_v2_project_m4_v3(mloop_uv[lidx], best_projector->projmat, coords[vidx]);
} while (fidx--);
}
}
diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c
index c33b25c38e3..7ad59e0ffb5 100644
--- a/source/blender/modifiers/intern/MOD_uvwarp.c
+++ b/source/blender/modifiers/intern/MOD_uvwarp.c
@@ -83,7 +83,7 @@ static void matrix_from_obj_pchan(float mat[4][4], Object *ob, const char *bonen
typedef struct UVWarpData {
MPoly *mpoly;
MLoop *mloop;
- MLoopUV *mloopuv;
+ float (*mloopuv)[2];
MDeformVert *dvert;
int defgrp_index;
@@ -100,7 +100,7 @@ static void uv_warp_compute(void *__restrict userdata,
const MPoly *mp = &data->mpoly[i];
const MLoop *ml = &data->mloop[mp->loopstart];
- MLoopUV *mluv = &data->mloopuv[mp->loopstart];
+ float(*mluv)[2] = &data->mloopuv[mp->loopstart];
const MDeformVert *dvert = data->dvert;
const int defgrp_index = data->defgrp_index;
@@ -116,13 +116,13 @@ static void uv_warp_compute(void *__restrict userdata,
1.0f - BKE_defvert_find_weight(&dvert[ml->v], defgrp_index) :
BKE_defvert_find_weight(&dvert[ml->v], defgrp_index);
- uv_warp_from_mat4_pair(uv, mluv->uv, warp_mat);
- interp_v2_v2v2(mluv->uv, mluv->uv, uv, weight);
+ uv_warp_from_mat4_pair(uv, (*mluv), warp_mat);
+ interp_v2_v2v2((*mluv), (*mluv), uv, weight);
}
}
else {
for (l = 0; l < mp->totloop; l++, ml++, mluv++) {
- uv_warp_from_mat4_pair(mluv->uv, mluv->uv, warp_mat);
+ uv_warp_from_mat4_pair((*mluv), (*mluv), warp_mat);
}
}
}
@@ -133,7 +133,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
int polys_num, loops_num;
MPoly *mpoly;
MLoop *mloop;
- MLoopUV *mloopuv;
+ float(*mloopuv)[2];
MDeformVert *dvert;
int defgrp_index;
char uvname[MAX_CUSTOMDATA_LAYER_NAME];
@@ -143,7 +143,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
const bool invert_vgroup = (umd->flag & MOD_UVWARP_INVERT_VGROUP) != 0;
/* make sure there are UV Maps available */
- if (!CustomData_has_layer(&mesh->ldata, CD_MLOOPUV)) {
+ if (!CustomData_has_layer(&mesh->ldata, CD_PROP_FLOAT2)) {
return mesh;
}
@@ -194,7 +194,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
translate_m4(warp_mat, -umd->center[0], -umd->center[1], 0.0f);
/* make sure we're using an existing layer */
- CustomData_validate_layer_name(&mesh->ldata, CD_MLOOPUV, umd->uvlayer_name, uvname);
+ CustomData_validate_layer_name(&mesh->ldata, CD_PROP_FLOAT2, umd->uvlayer_name, uvname);
polys_num = mesh->totpoly;
loops_num = mesh->totloop;
@@ -203,7 +203,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh *
mloop = mesh->mloop;
/* make sure we are not modifying the original UV map */
mloopuv = CustomData_duplicate_referenced_layer_named(
- &mesh->ldata, CD_MLOOPUV, uvname, loops_num);
+ &mesh->ldata, CD_PROP_FLOAT2, uvname, loops_num);
MOD_get_vgroup(ctx->object, mesh, umd->vgroup_name, &dvert, &defgrp_index);
UVWarpData data = {