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-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"
|
2015-10-08 14:21:11 +02:00
|
|
|
#include "BKE_library_query.h"
|
2010-06-27 05:39:55 +00:00
|
|
|
#include "BKE_scene.h"
|
2013-10-20 13:01:07 +00:00
|
|
|
#include "BKE_texture.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"
|
|
|
|
|
2017-11-21 15:40:24 +01:00
|
|
|
#include "DEG_depsgraph.h"
|
2018-04-06 12:07:27 +02:00
|
|
|
#include "DEG_depsgraph_query.h"
|
2017-11-21 15:40:24 +01:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void copyData(ModifierData *md, ModifierData *target)
|
|
|
|
{
|
2013-12-22 04:35:52 +11:00
|
|
|
#if 0
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *) md;
|
|
|
|
WaveModifierData *twmd = (WaveModifierData *) target;
|
Refactor ID copying (and to some extent, ID freeing).
This will allow much finer controll over how we copy data-blocks, from
full copy in Main database, to "lighter" ones (out of Main, inside an
already allocated datablock, etc.).
This commit also transfers a llot of what was previously handled by
per-ID-type custom code to generic ID handling code in BKE_library.
Hopefully will avoid in future inconsistencies and missing bits we had
all over the codebase in the past.
It also adds missing copying handling for a few types, most notably
Scene (which where using a fully customized handling previously).
Note that the type of allocation used during copying (regular in Main,
allocated but outside of Main, or not allocated by ID handling code at
all) is stored in ID's, which allows to handle them correctly when
freeing. This needs to be taken care of with caution when doing 'weird'
unusual things with ID copying and/or allocation!
As a final note, while rather noisy, this commit will hopefully not
break too much existing branches, old 'API' has been kept for the main
part, as a wrapper around new code. Cleaning it up will happen later.
Design task : T51804
Phab Diff: D2714
2017-08-07 16:39:55 +02:00
|
|
|
#endif
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2013-12-22 04:35:52 +11:00
|
|
|
modifier_copyData_generic(md, target);
|
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
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
walk(userData, ob, &wmd->objectcenter, IDWALK_CB_NOP);
|
|
|
|
walk(userData, ob, &wmd->map_object, IDWALK_CB_NOP);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2017-01-31 09:47:59 +01:00
|
|
|
walk(userData, ob, (ID **)&wmd->texture, IDWALK_CB_USER);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
2018-02-22 12:54:06 +01:00
|
|
|
static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
{
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
if (wmd->objectcenter != NULL) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
}
|
|
|
|
if (wmd->map_object != NULL) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, wmd->map_object, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05: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;
|
|
|
|
}
|
|
|
|
|
2017-11-21 15:40:24 +01:00
|
|
|
static void waveModifier_do(WaveModifierData *md,
|
2018-04-06 12:07:27 +02:00
|
|
|
Depsgraph *depsgraph,
|
2017-11-21 15:40:24 +01:00
|
|
|
Object *ob, DerivedMesh *dm,
|
2012-05-06 13:38:33 +00:00
|
|
|
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;
|
2018-04-06 12:07:27 +02:00
|
|
|
float ctime = DEG_get_ctime(depsgraph);
|
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) {
|
2018-01-14 22:14:20 +01:00
|
|
|
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co),
|
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;
|
2013-10-20 13:01:07 +00:00
|
|
|
BKE_texture_get_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
|
|
|
}
|
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
static void deformVerts(ModifierData *md, struct Depsgraph *depsgraph,
|
2017-07-21 11:53:13 +02:00
|
|
|
Object *ob, DerivedMesh *derivedData,
|
2012-05-06 13:38:33 +00:00
|
|
|
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)
|
2013-07-16 08:24:53 +00:00
|
|
|
dm = get_cddm(ob, NULL, dm, vertexCos, false);
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (wmd->texture || wmd->defgrp_name[0])
|
2013-07-16 08:24:53 +00:00
|
|
|
dm = get_dm(ob, NULL, dm, NULL, false, false);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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(
|
2018-04-06 12:07:27 +02:00
|
|
|
ModifierData *md, struct Depsgraph *depsgraph,
|
2017-11-21 15:40:24 +01:00
|
|
|
Object *ob, struct BMEditMesh *editData,
|
2012-05-06 13:38:33 +00:00
|
|
|
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)
|
2013-07-16 08:24:53 +00:00
|
|
|
dm = get_cddm(ob, editData, dm, vertexCos, false);
|
2012-03-24 06:24:53 +00:00
|
|
|
else if (wmd->texture || wmd->defgrp_name[0])
|
2013-07-16 08:24:53 +00:00
|
|
|
dm = get_dm(ob, editData, dm, NULL, false, false);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2018-04-06 12:07:27 +02:00
|
|
|
waveModifier_do(wmd, depsgraph, ob, dm, vertexCos, numVerts);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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 |
|
2016-05-18 22:21:46 +10:00
|
|
|
eModifierTypeFlag_AcceptsLattice |
|
2012-05-06 13:38:33 +00:00
|
|
|
eModifierTypeFlag_SupportsEditmode,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* copyData */ copyData,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
|
|
|
/* deformVerts_DM */ deformVerts,
|
|
|
|
/* deformMatrices_DM */ NULL,
|
|
|
|
/* deformVertsEM_DM */ deformVertsEM,
|
|
|
|
/* deformMatricesEM_DM*/NULL,
|
|
|
|
/* applyModifier_DM */ NULL,
|
|
|
|
/* applyModifierEM_DM */NULL,
|
|
|
|
|
|
|
|
/* deformVerts */ NULL,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* deformMatrices */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
/* deformVertsEM */ NULL,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* deformMatricesEM */ NULL,
|
|
|
|
/* applyModifier */ NULL,
|
|
|
|
/* applyModifierEM */ NULL,
|
2018-04-18 15:45:54 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* initData */ initData,
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
2018-04-04 14:56:32 +02:00
|
|
|
/* freeData */ NULL,
|
2011-03-05 10:29:10 +00:00
|
|
|
/* isDisabled */ NULL,
|
Depsgraph: New dependency graph integration commit
This commit integrates the work done so far on the new dependency graph system,
where goal was to replace legacy depsgraph with the new one, supporting loads of
neat features like:
- More granular dependency relation nature, which solves issues with fake cycles
in the dependencies.
- Move towards all-animatable, by better integration of drivers into the system.
- Lay down some basis for upcoming copy-on-write, overrides and so on.
The new system is living side-by-side with the previous one and disabled by
default, so nothing will become suddenly broken. The way to enable new depsgraph
is to pass `--new-depsgraph` command line argument.
It's a bit early to consider the system production-ready, there are some TODOs
and issues were discovered during the merge period, they'll be addressed ASAP.
But it's important to merge, because it's the only way to attract artists to
really start testing this system.
There are number of assorted documents related on the design of the new system:
* http://wiki.blender.org/index.php/User:Aligorith/GSoC2013_Depsgraph#Design_Documents
* http://wiki.blender.org/index.php/User:Nazg-gul/DependencyGraph
There are also some user-related information online:
* http://code.blender.org/2015/02/blender-dependency-graph-branch-for-users/
* http://code.blender.org/2015/03/more-dependency-graph-tricks/
Kudos to everyone who was involved into the project:
- Joshua "Aligorith" Leung -- design specification, initial code
- Lukas "lukas_t" Toenne -- integrating code into blender, with further fixes
- Sergey "Sergey" "Sharybin" -- some mocking around, trying to wrap up the
project and so
- Bassam "slikdigit" Kurdali -- stressing the new system, reporting all the
issues and recording/writing documentation.
- Everyone else who i forgot to mention here :)
2015-05-12 15:05:57 +05:00
|
|
|
/* updateDepsgraph */ updateDepsgraph,
|
2010-04-11 22:12:30 +00:00
|
|
|
/* 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
|
|
|
};
|