2010-04-11 22:12:30 +00:00
|
|
|
/*
|
2011-10-23 17:52:20 +00:00
|
|
|
* 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
|
2020-05-09 17:14:35 +10:00
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2011-10-23 17:52:20 +00:00
|
|
|
* 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.
|
|
|
|
|
*/
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup modifiers
|
2011-02-25 13:57:17 +00:00
|
|
|
*/
|
|
|
|
|
|
2019-02-25 11:39:14 +01:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
#include "BLI_math.h"
|
|
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2018-05-12 09:21:38 +02:00
|
|
|
#include "DNA_mesh_types.h"
|
2010-04-12 00:36:50 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2018-05-12 09:21:38 +02:00
|
|
|
#include "DNA_scene_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_context.h"
|
2013-06-10 18:12:07 +00:00
|
|
|
#include "BKE_deform.h"
|
2018-05-12 09:21:38 +02:00
|
|
|
#include "BKE_editmesh.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
|
|
|
|
#include "BKE_lib_query.h"
|
2018-05-12 09:21:38 +02:00
|
|
|
#include "BKE_mesh.h"
|
2020-06-10 22:32:06 +10:00
|
|
|
#include "BKE_mesh_wrapper.h"
|
2010-06-27 05:39:55 +00:00
|
|
|
#include "BKE_scene.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_screen.h"
|
2013-10-20 13:01:07 +00:00
|
|
|
#include "BKE_texture.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
|
2010-04-12 22:33:43 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
2020-11-09 15:42:38 +01:00
|
|
|
|
|
|
|
|
#include "RE_texture.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
|
#include "MOD_modifiertypes.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "MOD_ui_common.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
#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)
|
|
|
|
|
{
|
2020-10-10 21:38:20 +11:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(wmd, modifier));
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(wmd, DNA_struct_default_get(WaveModifierData), modifier);
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
return true;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void foreachIDLink(ModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
walk(userData, ob, (ID **)&wmd->texture, IDWALK_CB_USER);
|
2020-10-01 18:05:23 +02:00
|
|
|
walk(userData, ob, (ID **)&wmd->objectcenter, IDWALK_CB_NOP);
|
|
|
|
|
walk(userData, ob, (ID **)&wmd->map_object, IDWALK_CB_NOP);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void foreachTexLink(ModifierData *md, Object *ob, TexWalkFunc walk, void *userData)
|
2011-08-12 18:11:22 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
walk(userData, ob, md, "texture");
|
2011-08-12 18:11:22 +00:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2020-04-11 17:12:56 +02:00
|
|
|
bool need_transform_relation = false;
|
2020-04-10 22:00:21 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (wmd->objectcenter != NULL) {
|
|
|
|
|
DEG_add_object_relation(ctx->node, wmd->objectcenter, DEG_OB_COMP_TRANSFORM, "Wave Modifier");
|
2020-04-11 17:12:56 +02:00
|
|
|
need_transform_relation = true;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2020-04-10 22:00:21 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (wmd->texture != NULL) {
|
|
|
|
|
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
|
2020-04-11 17:12:56 +02:00
|
|
|
|
|
|
|
|
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != NULL) {
|
|
|
|
|
MOD_depsgraph_update_object_bone_relation(
|
|
|
|
|
ctx->node, wmd->map_object, wmd->map_bone, "Wave Modifier");
|
|
|
|
|
need_transform_relation = true;
|
|
|
|
|
}
|
|
|
|
|
else if (wmd->texmapping == MOD_DISP_MAP_GLOBAL) {
|
|
|
|
|
need_transform_relation = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (need_transform_relation) {
|
|
|
|
|
DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier");
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void requiredDataMask(Object *UNUSED(ob),
|
|
|
|
|
ModifierData *md,
|
|
|
|
|
CustomData_MeshMasks *r_cddata_masks)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* ask for UV coordinates if we need them */
|
|
|
|
|
if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV) {
|
|
|
|
|
r_cddata_masks->fmask |= CD_MASK_MTFACE;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* ask for vertexgroups if we need them */
|
|
|
|
|
if (wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-27 20:36:54 +01:00
|
|
|
static bool dependsOnNormals(ModifierData *md)
|
|
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2018-11-27 20:36:54 +01:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
return (wmd->flag & MOD_WAVE_NORM) != 0;
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void waveModifier_do(WaveModifierData *md,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
Object *ob,
|
|
|
|
|
Mesh *mesh,
|
|
|
|
|
float (*vertexCos)[3],
|
|
|
|
|
int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
MVert *mvert = NULL;
|
|
|
|
|
MDeformVert *dvert;
|
|
|
|
|
int defgrp_index;
|
|
|
|
|
float ctime = DEG_get_ctime(ctx->depsgraph);
|
|
|
|
|
float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
|
|
|
|
|
float lifefac = wmd->height;
|
|
|
|
|
float(*tex_co)[3] = NULL;
|
|
|
|
|
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 */
|
2020-03-03 18:41:50 +01:00
|
|
|
const bool invert_group = (wmd->flag & MOD_WAVE_INVERT_VGROUP) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
if ((wmd->flag & MOD_WAVE_NORM) && (mesh != NULL)) {
|
|
|
|
|
mvert = mesh->mvert;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wmd->objectcenter != NULL) {
|
|
|
|
|
float mat[4][4];
|
|
|
|
|
/* get the control object's location in local coordinates */
|
|
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
|
mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat);
|
|
|
|
|
|
|
|
|
|
wmd->startx = mat[3][0];
|
|
|
|
|
wmd->starty = mat[3][1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* get the index of the deform group */
|
|
|
|
|
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
|
|
|
|
|
|
|
|
|
|
if (wmd->damp == 0.0f) {
|
|
|
|
|
wmd->damp = 10.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wmd->lifetime != 0.0f) {
|
|
|
|
|
float x = ctime - wmd->timeoffs;
|
|
|
|
|
|
|
|
|
|
if (x > wmd->lifetime) {
|
|
|
|
|
lifefac = x - wmd->lifetime;
|
|
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (lifefac > wmd->damp) {
|
2019-04-17 06:17:24 +02:00
|
|
|
lifefac = 0.0;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2019-04-17 06:17:24 +02:00
|
|
|
lifefac = (float)(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Tex *tex_target = wmd->texture;
|
|
|
|
|
if (mesh != NULL && tex_target != NULL) {
|
|
|
|
|
tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co");
|
|
|
|
|
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
|
|
|
|
|
|
|
|
|
|
MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (lifefac != 0.0f) {
|
|
|
|
|
/* avoid divide by zero checks within the loop */
|
|
|
|
|
float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < numVerts; i++) {
|
|
|
|
|
float *co = vertexCos[i];
|
|
|
|
|
float x = co[0] - wmd->startx;
|
|
|
|
|
float y = co[1] - wmd->starty;
|
|
|
|
|
float amplit = 0.0f;
|
|
|
|
|
float def_weight = 1.0f;
|
|
|
|
|
|
|
|
|
|
/* get weights */
|
|
|
|
|
if (dvert) {
|
2020-03-06 12:50:56 +11:00
|
|
|
def_weight = invert_group ? 1.0f - BKE_defvert_find_weight(&dvert[i], defgrp_index) :
|
|
|
|
|
BKE_defvert_find_weight(&dvert[i], defgrp_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* if this vert isn't in the vgroup, don't deform it */
|
|
|
|
|
if (def_weight == 0.0f) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (wmd_axis) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* this way it makes nice circles */
|
|
|
|
|
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
|
|
|
|
|
|
|
|
|
|
if (wmd->flag & MOD_WAVE_CYCL) {
|
|
|
|
|
amplit = (float)fmodf(amplit - wmd->width, 2.0f * wmd->width) + wmd->width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (falloff != 0.0f) {
|
|
|
|
|
float dist = 0.0f;
|
|
|
|
|
|
|
|
|
|
switch (wmd_axis) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
falloff_fac = (1.0f - (dist * falloff_inv));
|
|
|
|
|
CLAMP(falloff_fac, 0.0f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* GAUSSIAN */
|
|
|
|
|
if ((falloff_fac != 0.0f) && (amplit > -wmd->width) && (amplit < wmd->width)) {
|
|
|
|
|
amplit = amplit * wmd->narrow;
|
|
|
|
|
amplit = (float)(1.0f / expf(amplit * amplit) - minfac);
|
|
|
|
|
|
|
|
|
|
/*apply texture*/
|
2019-05-31 18:01:51 +02:00
|
|
|
if (tex_co) {
|
2019-04-17 06:17:24 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
|
|
|
|
TexResult texres;
|
|
|
|
|
texres.nor = NULL;
|
|
|
|
|
BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
|
|
|
|
|
amplit *= texres.tin;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*apply weight & falloff */
|
|
|
|
|
amplit *= def_weight * falloff_fac;
|
|
|
|
|
|
|
|
|
|
if (mvert) {
|
|
|
|
|
/* move along normals */
|
|
|
|
|
if (wmd->flag & MOD_WAVE_NORM_X) {
|
|
|
|
|
co[0] += (lifefac * amplit) * mvert[i].no[0] / 32767.0f;
|
|
|
|
|
}
|
|
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Y) {
|
|
|
|
|
co[1] += (lifefac * amplit) * mvert[i].no[1] / 32767.0f;
|
|
|
|
|
}
|
|
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Z) {
|
|
|
|
|
co[2] += (lifefac * amplit) * mvert[i].no[2] / 32767.0f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* move along local z axis */
|
|
|
|
|
co[2] += lifefac * amplit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MEM_SAFE_FREE(tex_co);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void deformVerts(ModifierData *md,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
Mesh *mesh,
|
|
|
|
|
float (*vertexCos)[3],
|
|
|
|
|
int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
Mesh *mesh_src = NULL;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
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 != NULL || wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false);
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
|
|
|
|
BKE_id_free(NULL, mesh_src);
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
static void deformVertsEM(ModifierData *md,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
struct BMEditMesh *editData,
|
|
|
|
|
Mesh *mesh,
|
|
|
|
|
float (*vertexCos)[3],
|
|
|
|
|
int numVerts)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
Mesh *mesh_src = NULL;
|
|
|
|
|
|
|
|
|
|
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 != NULL || wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, numVerts, false, false);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-25 20:16:42 +10:00
|
|
|
/* TODO(Campbell): use edit-mode data only (remove this line). */
|
|
|
|
|
if (mesh_src != NULL) {
|
|
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, numVerts);
|
|
|
|
|
|
|
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
|
|
|
|
BKE_id_free(NULL, mesh_src);
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *sub, *row, *col;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
2020-06-22 15:06:13 +02:00
|
|
|
row = uiLayoutRowWithHeading(layout, true, IFACE_("Motion"));
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "use_cyclic", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
row = uiLayoutRowWithHeading(layout, true, IFACE_("Along Normals"));
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(row, ptr, "use_normal", 0, "", ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
sub = uiLayoutRow(row, true);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_normal"));
|
|
|
|
|
uiItemR(sub, ptr, "use_normal_x", UI_ITEM_R_TOGGLE, "X", ICON_NONE);
|
|
|
|
|
uiItemR(sub, ptr, "use_normal_y", UI_ITEM_R_TOGGLE, "Y", ICON_NONE);
|
|
|
|
|
uiItemR(sub, ptr, "use_normal_z", UI_ITEM_R_TOGGLE, "Z", ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "falloff_radius", 0, "Falloff", ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
modifier_panel_end(layout, ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void position_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "start_position_object", 0, IFACE_("Object"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, true);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "start_position_x", 0, "Start Position X", ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "start_position_y", 0, "Y", ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
static void time_panel_draw(const bContext *UNUSED(C), Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "time_offset", 0, "Offset", ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "lifetime", 0, "Life", ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "damping_time", 0, "Damping", ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void texture_panel_draw(const bContext *C, Panel *panel)
|
|
|
|
|
{
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiLayout *col;
|
2020-06-05 10:41:03 -04:00
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
|
|
|
|
PointerRNA ob_ptr;
|
2020-09-02 14:13:26 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, &ob_ptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
int texture_coords = RNA_enum_get(ptr, "texture_coords");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
UI: Redesigned data-block selectors
The previous design is rather old and has a couple of problems:
* Scalability: The current solution of adding little icon buttons next to the
data-block name field doesn't scale well. It only works if there's a small
number of operations. We need to be able to place more items there for better
data-block management. Especially with the introduction of library overrides.
* Discoverability: It's not obvious what some of the icons do. They appear and
disappear, but it's not obvious why some are available at times and others
not.
* Unclear Status: Currently their library status (linked, indirectly linked,
broken link, library override) isn't really clear.
* Unusual behavior: Some of the icon buttons allow Shift or Ctrl clicking to
invoke alternative behaviors. This is not a usual pattern in Blender.
This patch does the following changes:
* Adds a menu to the right of the name button to access all kinds of operations
(create, delete, unlink, user management, library overrides, etc).
* Make good use of the "disabled hint" for tooltips, to explain why buttons are
disabled. The UI team wants to establish this as a good practise.
* Use superimposed icons for duplicate and unlink, rather than extra buttons
(uses less space, looks less distracting and is a nice + consistent design
language).
* Remove fake user and user count button, they are available from the menu now.
* Support tooltips for superimposed icons (committed mouse hover feedback to
master already).
* Slightly increase size of the name button - it was already a bit small
before, and the move from real buttons to superimposed icons reduces usable
space for the name itself.
* More clearly differentiate between duplicate and creating a new data-block.
The latter is only available in the menu.
* Display library status icon on the left (linked, missing library, overridden,
asset)
* Disables "Make Single User" button - in review we weren't sure if there are
good use-cases for it, so better to see if we can remove it.
Note that I do expect some aspects of this design to change still. I think some
changes are problematic, but others disagreed. I will open a feedback thread on
devtalk to see what others think.
Differential Revision: https://developer.blender.org/D8554
Reviewed by: Bastien Montagne
Design discussed and agreed on with the UI team, also see T79959.
2020-12-18 18:12:11 +01:00
|
|
|
uiTemplateID(layout,
|
|
|
|
|
C,
|
|
|
|
|
ptr,
|
|
|
|
|
"texture",
|
|
|
|
|
"texture.new",
|
|
|
|
|
"texture.duplicate",
|
|
|
|
|
NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
0,
|
|
|
|
|
ICON_NONE,
|
|
|
|
|
NULL);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
col = uiLayoutColumn(layout, false);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "texture_coords", 0, IFACE_("Coordinates"), ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
if (texture_coords == MOD_DISP_MAP_OBJECT) {
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "texture_coords_object", 0, IFACE_("Object"), ICON_NONE);
|
|
|
|
|
PointerRNA texture_coords_obj_ptr = RNA_pointer_get(ptr, "texture_coords_object");
|
2020-06-05 10:41:03 -04:00
|
|
|
if (!RNA_pointer_is_null(&texture_coords_obj_ptr) &&
|
|
|
|
|
(RNA_enum_get(&texture_coords_obj_ptr, "type") == OB_ARMATURE)) {
|
|
|
|
|
PointerRNA texture_coords_obj_data_ptr = RNA_pointer_get(&texture_coords_obj_ptr, "data");
|
UI: Small Tweaks to Modifier Layouts for Consistency
These changes are smaller, made based on feedback and a pass on all
the layouts for clarity and consistency. The Multires modifier UI will
be addressed in a separate patch. Here is an overview of the changes:
Renaming Options:
- Build: "Start" -> "Start Frame"
- Curve: "From Radius" -> "Size from Radius"
- Screw: "Calc Order" -> "Calculate Order"
- Displace, Warp, Wave: "Texture Coordinates Object" -> "Object"
Move Mode Toggle to Top & Expand:
- Bevel, Boolean, Normal Edit, Subdivision
Use Columns for Tighter Spacing:
- Displace, Explode, Ocean, Particle Instance, Remesh, Shrinkwrap,
Solidify, Warp, Weighted Normal, Wave
Misc:
- Bevel: Set inactive properties for vertex bevel
- Mesh Sequence Cache: Remove box for cache file
- Skin: Don't align "Mark Loose" and "Clear Loose"
- Array: Expand relative offset subpanel by default
- Array: Move start cap, end cap to a new subpanel
- Bevel: Move width type above width
Differential Revision: https://developer.blender.org/D8115
2020-07-02 10:47:02 -04:00
|
|
|
uiItemPointerR(col,
|
2020-09-02 14:13:26 -05:00
|
|
|
ptr,
|
2020-06-05 10:41:03 -04:00
|
|
|
"texture_coords_bone",
|
|
|
|
|
&texture_coords_obj_data_ptr,
|
|
|
|
|
"bones",
|
|
|
|
|
IFACE_("Bone"),
|
|
|
|
|
ICON_NONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (texture_coords == MOD_DISP_MAP_UV && RNA_enum_get(&ob_ptr, "type") == OB_MESH) {
|
|
|
|
|
PointerRNA obj_data_ptr = RNA_pointer_get(&ob_ptr, "data");
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void panelRegister(ARegionType *region_type)
|
|
|
|
|
{
|
|
|
|
|
PanelType *panel_type = modifier_panel_register(region_type, eModifierType_Wave, panel_draw);
|
|
|
|
|
modifier_subpanel_register(
|
|
|
|
|
region_type, "position", "Start Position", NULL, position_panel_draw, panel_type);
|
|
|
|
|
modifier_subpanel_register(region_type, "time", "Time", NULL, time_panel_draw, panel_type);
|
|
|
|
|
modifier_subpanel_register(
|
|
|
|
|
region_type, "texture", "Texture", NULL, texture_panel_draw, panel_type);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
ModifierTypeInfo modifierType_Wave = {
|
2019-04-17 06:17:24 +02:00
|
|
|
/* name */ "Wave",
|
|
|
|
|
/* structName */ "WaveModifierData",
|
|
|
|
|
/* structSize */ sizeof(WaveModifierData),
|
2020-09-25 12:49:18 +02:00
|
|
|
/* srna */ &RNA_WaveModifier,
|
2019-04-17 06:17:24 +02:00
|
|
|
/* type */ eModifierTypeType_OnlyDeform,
|
2020-04-21 13:09:41 +02:00
|
|
|
/* flags */ eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_AcceptsVertexCosOnly |
|
2019-04-17 06:17:24 +02:00
|
|
|
eModifierTypeFlag_SupportsEditmode,
|
2020-09-25 12:45:30 +02:00
|
|
|
/* icon */ ICON_MOD_WAVE,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-05-08 10:14:02 +02:00
|
|
|
/* copyData */ BKE_modifier_copydata_generic,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* deformVerts */ deformVerts,
|
|
|
|
|
/* deformMatrices */ NULL,
|
|
|
|
|
/* deformVertsEM */ deformVertsEM,
|
|
|
|
|
/* deformMatricesEM */ NULL,
|
2020-04-21 13:09:41 +02:00
|
|
|
/* modifyMesh */ NULL,
|
|
|
|
|
/* modifyHair */ NULL,
|
2020-12-10 14:35:02 +01:00
|
|
|
/* modifyGeometrySet */ NULL,
|
2020-04-21 13:09:41 +02:00
|
|
|
/* modifyVolume */ NULL,
|
2019-04-17 06:17:24 +02:00
|
|
|
|
|
|
|
|
/* initData */ initData,
|
|
|
|
|
/* requiredDataMask */ requiredDataMask,
|
|
|
|
|
/* freeData */ NULL,
|
|
|
|
|
/* isDisabled */ NULL,
|
|
|
|
|
/* updateDepsgraph */ updateDepsgraph,
|
|
|
|
|
/* dependsOnTime */ dependsOnTime,
|
|
|
|
|
/* dependsOnNormals */ dependsOnNormals,
|
|
|
|
|
/* foreachIDLink */ foreachIDLink,
|
|
|
|
|
/* foreachTexLink */ foreachTexLink,
|
|
|
|
|
/* freeRuntimeData */ NULL,
|
2020-06-05 10:41:03 -04:00
|
|
|
/* panelRegister */ panelRegister,
|
2020-06-15 17:37:07 +02:00
|
|
|
/* blendWrite */ NULL,
|
|
|
|
|
/* blendRead */ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|