2010-04-11 22:12:30 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 by the Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Daniel Dunbar
|
|
|
|
* Ton Roosendaal,
|
|
|
|
* Ben Batt,
|
|
|
|
* Brecht Van Lommel,
|
|
|
|
* Campbell Barton
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
*/
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-02-25 13:57:17 +00:00
|
|
|
/** \file blender/modifiers/intern/MOD_wave.c
|
|
|
|
* \ingroup modifiers
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-09-26 18:51:10 +00:00
|
|
|
#include "BLI_string.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2013-06-10 18:12:07 +00:00
|
|
|
#include "BKE_deform.h"
|
2010-04-12 22:33:43 +00:00
|
|
|
#include "BKE_DerivedMesh.h"
|
2013-06-10 18:12:07 +00:00
|
|
|
#include "BKE_library.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "BKE_object.h"
|
2010-06-27 05:39:55 +00:00
|
|
|
#include "BKE_scene.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2010-04-12 22:33:43 +00:00
|
|
|
#include "depsgraph_private.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2010-04-12 22:33:43 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "RE_shader_ext.h"
|
|
|
|
|
|
|
|
#include "MOD_modifiertypes.h"
|
|
|
|
#include "MOD_util.h"
|
|
|
|
|
|
|
|
static void initData(ModifierData *md)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md; // whadya know, moved here from Iraq
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
wmd->flag |= (MOD_WAVE_X | MOD_WAVE_Y | MOD_WAVE_CYCL |
|
|
|
|
MOD_WAVE_NORM_X | MOD_WAVE_NORM_Y | MOD_WAVE_NORM_Z);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
wmd->objectcenter = NULL;
|
|
|
|
wmd->texture = NULL;
|
|
|
|
wmd->map_object = NULL;
|
2012-05-06 13:38:33 +00:00
|
|
|
wmd->height = 0.5f;
|
|
|
|
wmd->width = 1.5f;
|
|
|
|
wmd->speed = 0.25f;
|
|
|
|
wmd->narrow = 1.5f;
|
|
|
|
wmd->lifetime = 0.0f;
|
|
|
|
wmd->damp = 10.0f;
|
|
|
|
wmd->falloff = 0.0f;
|
2012-01-04 06:20:10 +00:00
|
|
|
wmd->texmapping = MOD_DISP_MAP_LOCAL;
|
2010-04-11 22:12:30 +00:00
|
|
|
wmd->defgrp_name[0] = 0;
|
|
|
|
}
|
|
|
|
|
2013-06-10 18:12:07 +00:00
|
|
|
static void freeData(ModifierData *md)
|
|
|
|
{
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
|
|
|
if (wmd->texture) {
|
|
|
|
id_us_min(&wmd->texture->id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
static void copyData(ModifierData *md, ModifierData *target)
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
|
|
|
WaveModifierData *twmd = (WaveModifierData *) target;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
twmd->damp = wmd->damp;
|
|
|
|
twmd->flag = wmd->flag;
|
|
|
|
twmd->height = wmd->height;
|
|
|
|
twmd->lifetime = wmd->lifetime;
|
|
|
|
twmd->narrow = wmd->narrow;
|
|
|
|
twmd->speed = wmd->speed;
|
|
|
|
twmd->startx = wmd->startx;
|
|
|
|
twmd->starty = wmd->starty;
|
|
|
|
twmd->timeoffs = wmd->timeoffs;
|
|
|
|
twmd->width = wmd->width;
|
|
|
|
twmd->falloff = wmd->falloff;
|
|
|
|
twmd->objectcenter = wmd->objectcenter;
|
|
|
|
twmd->texture = wmd->texture;
|
|
|
|
twmd->map_object = wmd->map_object;
|
|
|
|
twmd->texmapping = wmd->texmapping;
|
2012-01-11 08:51:06 +00:00
|
|
|
BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name));
|
2013-06-10 18:12:07 +00:00
|
|
|
|
|
|
|
if (twmd->texture) {
|
|
|
|
id_us_plus(&twmd->texture->id);
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2013-06-02 03:59:19 +00:00
|
|
|
static bool dependsOnTime(ModifierData *UNUSED(md))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2013-06-02 03:59:19 +00:00
|
|
|
return true;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void foreachObjectLink(
|
2012-05-06 13:38:33 +00:00
|
|
|
ModifierData *md, Object *ob,
|
|
|
|
ObjectWalkFunc walk, void *userData)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
walk(userData, ob, &wmd->objectcenter);
|
|
|
|
walk(userData, ob, &wmd->map_object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void foreachIDLink(ModifierData *md, Object *ob,
|
2012-05-06 13:38:33 +00:00
|
|
|
IDWalkFunc walk, void *userData)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
walk(userData, ob, (ID **)&wmd->texture);
|
|
|
|
|
|
|
|
foreachObjectLink(md, ob, (ObjectWalkFunc)walk, userData);
|
|
|
|
}
|
|
|
|
|
2011-08-12 18:11:22 +00:00
|
|
|
static void foreachTexLink(ModifierData *md, Object *ob,
|
2012-05-06 13:38:33 +00:00
|
|
|
TexWalkFunc walk, void *userData)
|
2011-08-12 18:11:22 +00:00
|
|
|
{
|
|
|
|
walk(userData, ob, md, "texture");
|
|
|
|
}
|
|
|
|
|
2010-10-14 06:29:17 +00:00
|
|
|
static void updateDepgraph(ModifierData *md, DagForest *forest,
|
2012-05-06 13:38:33 +00:00
|
|
|
Scene *UNUSED(scene),
|
|
|
|
Object *UNUSED(ob),
|
|
|
|
DagNode *obNode)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->objectcenter) {
|
2010-04-11 22:12:30 +00:00
|
|
|
DagNode *curNode = dag_get_node(forest, wmd->objectcenter);
|
|
|
|
|
|
|
|
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA,
|
2012-05-06 13:38:33 +00:00
|
|
|
"Wave Modifier");
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->map_object) {
|
2010-04-11 22:12:30 +00:00
|
|
|
DagNode *curNode = dag_get_node(forest, wmd->map_object);
|
|
|
|
|
|
|
|
dag_add_relation(forest, curNode, obNode, DAG_RL_OB_DATA,
|
2012-05-06 13:38:33 +00:00
|
|
|
"Wave Modifer");
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-14 06:29:17 +00:00
|
|
|
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
CustomDataMask dataMask = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* ask for UV coordinates if we need them */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV)
|
2010-10-21 01:55:39 +00:00
|
|
|
dataMask |= CD_MASK_MTFACE;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* ask for vertexgroups if we need them */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->defgrp_name[0])
|
2010-10-21 01:55:39 +00:00
|
|
|
dataMask |= CD_MASK_MDEFORMVERT;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
return dataMask;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void waveModifier_do(WaveModifierData *md,
|
2012-05-06 13:38:33 +00:00
|
|
|
Scene *scene, Object *ob, DerivedMesh *dm,
|
|
|
|
float (*vertexCos)[3], int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
2010-04-11 22:12:30 +00:00
|
|
|
MVert *mvert = NULL;
|
2011-07-11 09:15:20 +00:00
|
|
|
MDeformVert *dvert;
|
2010-04-11 22:12:30 +00:00
|
|
|
int defgrp_index;
|
2012-05-05 14:33:36 +00:00
|
|
|
float ctime = BKE_scene_frame_get(scene);
|
2012-05-06 13:38:33 +00:00
|
|
|
float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
|
2010-04-11 22:12:30 +00:00
|
|
|
float lifefac = wmd->height;
|
|
|
|
float (*tex_co)[3] = NULL;
|
2012-05-06 13:38:33 +00:00
|
|
|
const int wmd_axis = wmd->flag & (MOD_WAVE_X | MOD_WAVE_Y);
|
|
|
|
const float falloff = wmd->falloff;
|
|
|
|
float falloff_fac = 1.0f; /* when falloff == 0.0f this stays at 1.0f */
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-10-14 13:08:19 +00:00
|
|
|
if ((wmd->flag & MOD_WAVE_NORM) && (ob->type == OB_MESH))
|
2010-04-11 22:12:30 +00:00
|
|
|
mvert = dm->getVertArray(dm);
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->objectcenter) {
|
2010-04-11 22:12:30 +00:00
|
|
|
float mat[4][4];
|
|
|
|
/* get the control object's location in local coordinates */
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
2013-05-26 18:36:25 +00:00
|
|
|
mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
wmd->startx = mat[3][0];
|
|
|
|
wmd->starty = mat[3][1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the index of the deform group */
|
2011-07-11 09:15:20 +00:00
|
|
|
modifier_get_vgroup(ob, dm, wmd->defgrp_name, &dvert, &defgrp_index);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->damp == 0) wmd->damp = 10.0f;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->lifetime != 0.0f) {
|
2010-04-11 22:12:30 +00:00
|
|
|
float x = ctime - wmd->timeoffs;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (x > wmd->lifetime) {
|
2010-04-11 22:12:30 +00:00
|
|
|
lifefac = x - wmd->lifetime;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (lifefac > wmd->damp) lifefac = 0.0;
|
2012-05-06 13:38:33 +00:00
|
|
|
else lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texture) {
|
2010-04-11 22:12:30 +00:00
|
|
|
tex_co = MEM_mallocN(sizeof(*tex_co) * numVerts,
|
2012-05-06 13:38:33 +00:00
|
|
|
"waveModifier_do tex_co");
|
2012-01-04 06:20:10 +00:00
|
|
|
get_texture_coords((MappingInfoModifierData *)wmd, ob, dm, vertexCos, tex_co, numVerts);
|
2012-04-10 14:11:45 +00:00
|
|
|
|
|
|
|
modifier_init_texture(wmd->modifier.scene, wmd->texture);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (lifefac != 0.0f) {
|
2010-06-03 19:56:13 +00:00
|
|
|
/* avoid divide by zero checks within the loop */
|
2012-05-06 13:38:33 +00:00
|
|
|
float falloff_inv = falloff ? 1.0f / falloff : 1.0f;
|
2010-04-11 22:12:30 +00:00
|
|
|
int i;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
for (i = 0; i < numVerts; i++) {
|
2010-04-11 22:12:30 +00:00
|
|
|
float *co = vertexCos[i];
|
|
|
|
float x = co[0] - wmd->startx;
|
|
|
|
float y = co[1] - wmd->starty;
|
2012-05-06 13:38:33 +00:00
|
|
|
float amplit = 0.0f;
|
|
|
|
float def_weight = 1.0f;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* get weights */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (dvert) {
|
2012-05-06 13:38:33 +00:00
|
|
|
def_weight = defvert_find_weight(&dvert[i], defgrp_index);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/* if this vert isn't in the vgroup, don't deform it */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (def_weight == 0.0f) {
|
2011-04-28 05:34:11 +00:00
|
|
|
continue;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmd_axis) {
|
2012-05-06 13:38:33 +00:00
|
|
|
case MOD_WAVE_X | MOD_WAVE_Y:
|
|
|
|
amplit = sqrtf(x * x + y * y);
|
|
|
|
break;
|
|
|
|
case MOD_WAVE_X:
|
|
|
|
amplit = x;
|
|
|
|
break;
|
|
|
|
case MOD_WAVE_Y:
|
|
|
|
amplit = y;
|
|
|
|
break;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this way it makes nice circles */
|
|
|
|
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_CYCL) {
|
2012-05-06 13:38:33 +00:00
|
|
|
amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) +
|
|
|
|
wmd->width;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (falloff != 0.0f) {
|
2011-04-28 05:34:11 +00:00
|
|
|
float dist = 0.0f;
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (wmd_axis) {
|
2012-05-06 13:38:33 +00:00
|
|
|
case MOD_WAVE_X | MOD_WAVE_Y:
|
|
|
|
dist = sqrtf(x * x + y * y);
|
|
|
|
break;
|
|
|
|
case MOD_WAVE_X:
|
|
|
|
dist = fabsf(x);
|
|
|
|
break;
|
|
|
|
case MOD_WAVE_Y:
|
|
|
|
dist = fabsf(y);
|
|
|
|
break;
|
2011-04-28 05:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
falloff_fac = (1.0f - (dist * falloff_inv));
|
|
|
|
CLAMP(falloff_fac, 0.0f, 1.0f);
|
|
|
|
}
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* GAUSSIAN */
|
2012-03-24 06:24:53 +00:00
|
|
|
if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
|
2010-04-11 22:12:30 +00:00
|
|
|
amplit = amplit * wmd->narrow;
|
2011-03-27 13:49:53 +00:00
|
|
|
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
/*apply texture*/
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texture) {
|
2011-04-28 05:34:11 +00:00
|
|
|
TexResult texres;
|
|
|
|
texres.nor = NULL;
|
Fix #36058: Displace Modifier errors using a baked Image and displace baking inconsistency between 2.67/2.68RC and previous versions
This was in fact really nasty bug, caused by multitex_nodes
function using global variable R (which is a copy of current
renderer). this variable is not initialized to anything
meaningful for until first rendering (preview or final)
happened.
Since multitex_nodes might be used outside of render pipeline,
made it so whether CM is on or off as an argument to functions
multitex_ext_safe and multitex_ext. Now multitex_nodes() is
only shall be used for stuff happening from render pipeline!
Also needed to make some changes to other places, so all the
usages of texture sampling knows for the fact whether CM is
on or off.
And one more change is related on behavior of dispalcement,
wave, warp, weightvg modifiers and smoke. They'll be always
using CM off since texture is used for influence, not for
color.
It's rather bigger patch, but it's mostly straightforward
changes, which we really need to be done.
Reviewed by Brecht, thanks!
2013-07-15 14:47:58 +00:00
|
|
|
get_texture_value(wmd->modifier.scene, wmd->texture, tex_co[i], &texres, false);
|
2011-04-28 05:34:11 +00:00
|
|
|
amplit *= texres.tin;
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2011-04-28 05:34:11 +00:00
|
|
|
/*apply weight & falloff */
|
|
|
|
amplit *= def_weight * falloff_fac;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (mvert) {
|
2010-04-11 22:12:30 +00:00
|
|
|
/* move along normals */
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM_X) {
|
2010-04-11 22:12:30 +00:00
|
|
|
co[0] += (lifefac * amplit) * mvert[i].no[0] / 32767.0f;
|
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Y) {
|
2010-04-11 22:12:30 +00:00
|
|
|
co[1] += (lifefac * amplit) * mvert[i].no[1] / 32767.0f;
|
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Z) {
|
2010-04-11 22:12:30 +00:00
|
|
|
co[2] += (lifefac * amplit) * mvert[i].no[2] / 32767.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* move along local z axis */
|
|
|
|
co[2] += lifefac * amplit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->texture) MEM_freeN(tex_co);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 06:29:17 +00:00
|
|
|
static void deformVerts(ModifierData *md, Object *ob,
|
2012-05-06 13:38:33 +00:00
|
|
|
DerivedMesh *derivedData,
|
|
|
|
float (*vertexCos)[3],
|
|
|
|
int numVerts,
|
2012-05-09 15:00:26 +00:00
|
|
|
ModifierApplyFlag UNUSED(flag))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
DerivedMesh *dm = derivedData;
|
2010-04-11 22:12:30 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM)
|
2012-05-06 13:38:33 +00:00
|
|
|
dm = get_cddm(ob, NULL, dm, vertexCos);
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (wmd->texture || wmd->defgrp_name[0])
|
2012-05-06 13:38:33 +00:00
|
|
|
dm = get_dm(ob, NULL, dm, NULL, 0);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (dm != derivedData)
|
2010-04-11 22:12:30 +00:00
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void deformVertsEM(
|
2012-05-06 13:38:33 +00:00
|
|
|
ModifierData *md, Object *ob, struct BMEditMesh *editData,
|
|
|
|
DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
DerivedMesh *dm = derivedData;
|
2010-04-11 22:12:30 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM)
|
2012-05-06 13:38:33 +00:00
|
|
|
dm = get_cddm(ob, editData, dm, vertexCos);
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (wmd->texture || wmd->defgrp_name[0])
|
2012-05-06 13:38:33 +00:00
|
|
|
dm = get_dm(ob, editData, dm, NULL, 0);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (dm != derivedData)
|
2010-04-11 22:12:30 +00:00
|
|
|
dm->release(dm);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ModifierTypeInfo modifierType_Wave = {
|
|
|
|
/* name */ "Wave",
|
|
|
|
/* structName */ "WaveModifierData",
|
|
|
|
/* structSize */ sizeof(WaveModifierData),
|
|
|
|
/* type */ eModifierTypeType_OnlyDeform,
|
2012-05-06 13:38:33 +00:00
|
|
|
/* flags */ eModifierTypeFlag_AcceptsCVs |
|
|
|
|
eModifierTypeFlag_SupportsEditmode,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* copyData */ copyData,
|
|
|
|
/* deformVerts */ deformVerts,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* deformMatrices */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* deformVertsEM */ deformVertsEM,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* deformMatricesEM */ NULL,
|
|
|
|
/* applyModifier */ NULL,
|
|
|
|
/* applyModifierEM */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* initData */ initData,
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
2013-06-10 18:12:07 +00:00
|
|
|
/* freeData */ freeData,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* isDisabled */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* updateDepgraph */ updateDepgraph,
|
|
|
|
/* dependsOnTime */ dependsOnTime,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* dependsOnNormals */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* foreachObjectLink */ foreachObjectLink,
|
|
|
|
/* foreachIDLink */ foreachIDLink,
|
2011-08-12 18:11:22 +00:00
|
|
|
/* foreachTexLink */ foreachTexLink,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|