[Bf-blender-cvs] [0cd3412d4cd] blender2.8: Mod_util: Add back vcos parameter to get_texture_coords_mesh().
Bastien Montagne
noreply at git.blender.org
Tue May 8 12:01:21 CEST 2018
Commit: 0cd3412d4cd401f1683356e8a1476dbf5ccd28d1
Author: Bastien Montagne
Date: Tue May 8 11:57:34 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB0cd3412d4cd401f1683356e8a1476dbf5ccd28d1
Mod_util: Add back vcos parameter to get_texture_coords_mesh().
Now we use vcos when provided, and fall back to mesh vertices' co
otherwise.
Deform modifiers usually do not have up-to-date coordinates in Mesh
itself, only in given vcos array!
===================================================================
M source/blender/modifiers/intern/MOD_util.c
M source/blender/modifiers/intern/MOD_util.h
M source/blender/modifiers/intern/MOD_weightvg_util.c
===================================================================
diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c
index fd3f9e91b9e..195043c8ff8 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -72,10 +72,12 @@ void modifier_init_texture(const Scene *scene, Tex *tex)
}
/* TODO to be renamed to get_texture_coords once we are done with moving modifiers to Mesh. */
+/** \param cos may be NULL, in which case we use directly mesh vertices' coordinates. */
void get_texture_coords_mesh(
MappingInfoModifierData *dmd,
Object *ob,
Mesh *mesh,
+ float (*cos)[3],
float (*r_texco)[3])
{
const int numVerts = mesh->totvert;
@@ -135,16 +137,19 @@ void get_texture_coords_mesh(
for (i = 0; i < numVerts; ++i, ++mv, ++r_texco) {
switch (texmapping) {
case MOD_DISP_MAP_LOCAL:
- copy_v3_v3(*r_texco, mv->co);
+ copy_v3_v3(*r_texco, cos != NULL ? *cos : mv->co);
break;
case MOD_DISP_MAP_GLOBAL:
- mul_v3_m4v3(*r_texco, ob->obmat, mv->co);
+ mul_v3_m4v3(*r_texco, ob->obmat, cos != NULL ? *cos : mv->co);
break;
case MOD_DISP_MAP_OBJECT:
- mul_v3_m4v3(*r_texco, ob->obmat, mv->co);
+ mul_v3_m4v3(*r_texco, ob->obmat, cos != NULL ? *cos : mv->co);
mul_m4_v3(mapob_imat, *r_texco);
break;
}
+ if (cos != NULL) {
+ cos++;
+ }
}
}
diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h
index c3858084354..eba32c3cfde 100644
--- a/source/blender/modifiers/intern/MOD_util.h
+++ b/source/blender/modifiers/intern/MOD_util.h
@@ -48,6 +48,7 @@ void get_texture_coords_mesh(
struct MappingInfoModifierData *dmd,
struct Object *ob,
struct Mesh *mesh,
+ float (*cos)[3],
float (*r_texco)[3]);
void modifier_vgroup_cache(struct ModifierData *md, float (*vertexCos)[3]);
struct DerivedMesh *get_cddm(struct Object *ob, struct BMEditMesh *em, struct DerivedMesh *dm,
diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c
index bb8ccb8899e..c309bb8dbce 100644
--- a/source/blender/modifiers/intern/MOD_weightvg_util.c
+++ b/source/blender/modifiers/intern/MOD_weightvg_util.c
@@ -145,7 +145,7 @@ void weightvg_do_mask(const int num, const int *indices, float *org_w, const flo
t_map.texmapping = tex_mapping;
tex_co = MEM_calloc_arrayN(numVerts, sizeof(*tex_co), "WeightVG Modifier, TEX mode, tex_co");
- get_texture_coords_mesh(&t_map, ob, mesh, tex_co);
+ get_texture_coords_mesh(&t_map, ob, mesh, NULL, tex_co);
modifier_init_texture(scene, texture);
More information about the Bf-blender-cvs
mailing list