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:
authorBastien Montagne <montagne29@wanadoo.fr>2018-11-27 22:36:54 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-11-27 23:17:06 +0300
commit013a5c8b7742626b6c4223e7e4235ec6ecb5ab39 (patch)
treecd7161e4d8be48250bef662eb3e9fe1205330f85 /source/blender/modifiers/intern/MOD_wave.c
parent930a3813fe16f7b818c7a69cdb5a7b96d52b268c (diff)
MOD_wave: fix various issues.
Missing dependsOnNormal callback, potential usage of NULL mesh pointer, style...
Diffstat (limited to 'source/blender/modifiers/intern/MOD_wave.c')
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 0849b268f7f..553f552bb0a 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -142,6 +142,13 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
return dataMask;
}
+static bool dependsOnNormals(ModifierData *md)
+{
+ WaveModifierData *wmd = (WaveModifierData *)md;
+
+ return (wmd->flag & MOD_WAVE_NORM) != 0;
+}
+
static void waveModifier_do(
WaveModifierData *md,
Depsgraph *depsgraph,
@@ -160,8 +167,9 @@ static void waveModifier_do(
const float falloff = wmd->falloff;
float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
- if ((wmd->flag & MOD_WAVE_NORM) && (ob->type == OB_MESH))
+ if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) {
mvert = mesh->mvert;
+ }
if (wmd->objectcenter) {
float mat[4][4];
@@ -176,7 +184,9 @@ static void waveModifier_do(
/* get the index of the deform group */
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
- if (wmd->damp == 0) wmd->damp = 10.0f;
+ if (wmd->damp == 0.0f) {
+ wmd->damp = 10.0f;
+ }
if (wmd->lifetime != 0.0f) {
float x = ctime - wmd->timeoffs;
@@ -189,9 +199,8 @@ static void waveModifier_do(
}
}
- if (wmd->texture) {
- tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co),
- "waveModifier_do tex_co");
+ if (mesh != NULL && wmd->texture) {
+ tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co");
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ob, mesh, vertexCos, tex_co);
MOD_init_texture(depsgraph, wmd->texture);
@@ -199,7 +208,7 @@ static void waveModifier_do(
if (lifefac != 0.0f) {
/* avoid divide by zero checks within the loop */
- float falloff_inv = falloff ? 1.0f / falloff : 1.0f;
+ float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f;
int i;
for (i = 0; i < numVerts; i++) {
@@ -295,7 +304,7 @@ static void waveModifier_do(
}
}
- if (wmd->texture) MEM_freeN(tex_co);
+ MEM_SAFE_FREE(tex_co);
}
static void deformVerts(
@@ -304,13 +313,15 @@ static void deformVerts(
float (*vertexCos)[3],
int numVerts)
{
- Mesh *mesh_src = mesh;
WaveModifierData *wmd = (WaveModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (wmd->flag & MOD_WAVE_NORM)
+ if (wmd->flag & MOD_WAVE_NORM) {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, numVerts, true, false);
- else if (wmd->texture || wmd->defgrp_name[0])
+ }
+ else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
+ }
waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
@@ -324,13 +335,15 @@ static void deformVertsEM(
struct BMEditMesh *editData,
Mesh *mesh, float (*vertexCos)[3], int numVerts)
{
- Mesh *mesh_src = mesh;
WaveModifierData *wmd = (WaveModifierData *)md;
+ Mesh *mesh_src = NULL;
- if (wmd->flag & MOD_WAVE_NORM)
+ if (wmd->flag & MOD_WAVE_NORM) {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, numVerts, true, false);
- else if (wmd->texture || wmd->defgrp_name[0])
+ }
+ else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') {
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
+ }
waveModifier_do(wmd, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts);
@@ -369,7 +382,7 @@ ModifierTypeInfo modifierType_Wave = {
/* isDisabled */ NULL,
/* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ dependsOnTime,
- /* dependsOnNormals */ NULL,
+ /* dependsOnNormals */ dependsOnNormals,
/* foreachObjectLink */ foreachObjectLink,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ foreachTexLink,