2022-02-11 09:07:11 +11:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
* Copyright 2005 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"
|
2022-10-12 20:55:26 -05:00
|
|
|
#include "BKE_editmesh_cache.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
|
|
|
|
#include "BKE_lib_query.h"
|
2023-03-12 22:29:15 +01:00
|
|
|
#include "BKE_mesh.hh"
|
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"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static bool dependsOnTime(Scene * /*scene*/, ModifierData * /*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
|
|
|
}
|
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void foreachIDLink(ModifierData *md, Object *ob, 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);
|
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
|
|
|
}
|
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void foreachTexLink(ModifierData *md, Object *ob, 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;
|
2020-04-11 17:12:56 +02:00
|
|
|
bool need_transform_relation = false;
|
2020-04-10 22:00:21 +02:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if (wmd->objectcenter != nullptr) {
|
2018-02-22 12:54:06 +01:00
|
|
|
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;
|
2018-11-27 21:14:35 +01:00
|
|
|
}
|
2020-04-10 22:00:21 +02:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if (wmd->texture != nullptr) {
|
2018-12-05 17:35:13 +01:00
|
|
|
DEG_add_generic_id_relation(ctx->node, &wmd->texture->id, "Wave Modifier");
|
2020-04-11 17:12:56 +02:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if ((wmd->texmapping == MOD_DISP_MAP_OBJECT) && wmd->map_object != nullptr) {
|
2020-04-11 17:12:56 +02:00
|
|
|
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) {
|
2022-08-04 12:11:31 +02:00
|
|
|
DEG_add_depends_on_transform_relation(ctx->node, "Wave Modifier");
|
2018-12-05 17:35:13 +01: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
|
|
|
}
|
|
|
|
|
|
2022-09-14 14:49:40 -05:00
|
|
|
static void requiredDataMask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
|
|
|
|
|
/* ask for UV coordinates if we need them */
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
if (wmd->texture && wmd->texmapping == MOD_DISP_MAP_UV) {
|
|
|
|
|
r_cddata_masks->fmask |= CD_MASK_MTFACE;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
|
|
|
|
/* ask for vertexgroups if we need them */
|
Refactor CDData masks, to have one mask per mesh elem type.
We already have different storages for cddata of verts, edges etc.,
'simply' do the same for the mask flags we use all around Blender code
to request some data, or limit some operation to some layers, etc.
Reason we need this is that some cddata types (like Normals) are
actually shared between verts/polys/loops, and we don’t want to generate
clnors everytime we request vnors!
As a side note, this also does final fix to T59338, which was the
trigger for this patch (need to request computed loop normals for
another mesh than evaluated one).
Reviewers: brecht, campbellbarton, sergey
Differential Revision: https://developer.blender.org/D4407
2019-03-07 11:13:40 +01:00
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
|
|
|
|
|
|
|
|
|
return (wmd->flag & MOD_WAVE_NORM) != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void waveModifier_do(WaveModifierData *md,
|
2018-12-07 15:45:53 +01:00
|
|
|
const ModifierEvalContext *ctx,
|
2018-05-12 09:21:38 +02:00
|
|
|
Object *ob,
|
|
|
|
|
Mesh *mesh,
|
2018-05-12 08:04:56 +02:00
|
|
|
float (*vertexCos)[3],
|
2022-03-28 12:29:47 +11:00
|
|
|
int verts_num)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
Mesh: Remove redundant custom data pointers
For copy-on-write, we want to share attribute arrays between meshes
where possible. Mutable pointers like `Mesh.mvert` make that difficult
by making ownership vague. They also make code more complex by adding
redundancy.
The simplest solution is just removing them and retrieving layers from
`CustomData` as needed. Similar changes have already been applied to
curves and point clouds (e9f82d3dc7ee, 410a6efb747f). Removing use of
the pointers generally makes code more obvious and more reusable.
Mesh data is now accessed with a C++ API (`Mesh::edges()` or
`Mesh::edges_for_write()`), and a C API (`BKE_mesh_edges(mesh)`).
The CoW changes this commit makes possible are described in T95845
and T95842, and started in D14139 and D14140. The change also simplifies
the ongoing mesh struct-of-array refactors from T95965.
**RNA/Python Access Performance**
Theoretically, accessing mesh elements with the RNA API may become
slower, since the layer needs to be found on every random access.
However, overhead is already high enough that this doesn't make a
noticible differenc, and performance is actually improved in some
cases. Random access can be up to 10% faster, but other situations
might be a bit slower. Generally using `foreach_get/set` are the best
way to improve performance. See the differential revision for more
discussion about Python performance.
Cycles has been updated to use raw pointers and the internal Blender
mesh types, mostly because there is no sense in having this overhead
when it's already compiled with Blender. In my tests this roughly
halves the Cycles mesh creation time (0.19s to 0.10s for a 1 million
face grid).
Differential Revision: https://developer.blender.org/D15488
2022-09-05 11:56:34 -05:00
|
|
|
const MDeformVert *dvert;
|
2010-04-11 22:12:30 +00:00
|
|
|
int defgrp_index;
|
2018-12-07 15:45:53 +01:00
|
|
|
float ctime = DEG_get_ctime(ctx->depsgraph);
|
2022-09-30 14:16:14 +10: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;
|
2022-09-29 18:32:44 -05:00
|
|
|
float(*tex_co)[3] = nullptr;
|
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 */
|
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
|
|
|
|
2023-03-15 14:00:40 -04:00
|
|
|
blender::Span<blender::float3> vert_normals;
|
2022-09-29 18:32:44 -05:00
|
|
|
if ((wmd->flag & MOD_WAVE_NORM) && (mesh != nullptr)) {
|
2023-03-15 14:00:40 -04:00
|
|
|
vert_normals = mesh->vert_normals();
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if (wmd->objectcenter != nullptr) {
|
2010-04-11 22:12:30 +00:00
|
|
|
float mat[4][4];
|
|
|
|
|
/* get the control object's location in local coordinates */
|
2022-11-02 14:41:49 +01:00
|
|
|
invert_m4_m4(ob->world_to_object, ob->object_to_world);
|
|
|
|
|
mul_m4_m4m4(mat, ob->world_to_object, wmd->objectcenter->object_to_world);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
wmd->startx = mat[3][0];
|
|
|
|
|
wmd->starty = mat[3][1];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* get the index of the deform group */
|
2018-06-29 19:02:19 +02:00
|
|
|
MOD_get_vgroup(ob, mesh, wmd->defgrp_name, &dvert, &defgrp_index);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-27 20:36:54 +01:00
|
|
|
if (wmd->damp == 0.0f) {
|
|
|
|
|
wmd->damp = 10.0f;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02: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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (x > wmd->lifetime) {
|
2010-04-11 22:12:30 +00:00
|
|
|
lifefac = x - wmd->lifetime;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (lifefac > wmd->damp) {
|
2012-03-24 06:24:53 +00:00
|
|
|
lifefac = 0.0;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
else {
|
2022-09-30 14:16:14 +10:00
|
|
|
lifefac = float(wmd->height * (1.0f - sqrtf(lifefac / wmd->damp)));
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:25:07 +01:00
|
|
|
Tex *tex_target = wmd->texture;
|
2022-09-29 18:32:44 -05:00
|
|
|
if (mesh != nullptr && tex_target != nullptr) {
|
|
|
|
|
tex_co = static_cast<float(*)[3]>(MEM_malloc_arrayN(verts_num, sizeof(*tex_co), __func__));
|
2018-12-07 15:45:53 +01:00
|
|
|
MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-12-07 15:45:53 +01:00
|
|
|
MOD_init_texture((MappingInfoModifierData *)wmd, ctx);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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 */
|
2018-11-27 20:36:54 +01:00
|
|
|
float falloff_inv = falloff != 0.0f ? 1.0f / falloff : 1.0f;
|
2010-04-11 22:12:30 +00:00
|
|
|
int i;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-03-28 12:29:47 +11:00
|
|
|
for (i = 0; i < verts_num; 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;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* get weights */
|
2012-03-24 06:24:53 +00:00
|
|
|
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
|
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02: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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* this way it makes nice circles */
|
|
|
|
|
amplit -= (ctime - wmd->timeoffs) * wmd->speed;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_CYCL) {
|
2022-09-30 14:16:14 +10:00
|
|
|
amplit = float(fmodf(amplit - wmd->width, 2.0f * wmd->width)) + wmd->width;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02: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;
|
2019-04-17 06:17:24 +02: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:
|
|
|
|
|
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
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-28 05:34:11 +00:00
|
|
|
falloff_fac = (1.0f - (dist * falloff_inv));
|
|
|
|
|
CLAMP(falloff_fac, 0.0f, 1.0f);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
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;
|
2022-09-30 14:16:14 +10:00
|
|
|
amplit = float(1.0f / expf(amplit * amplit) - minfac);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Apply texture. */
|
2019-05-31 18:01:51 +02:00
|
|
|
if (tex_co) {
|
2018-12-07 15:45:53 +01:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
2011-04-28 05:34:11 +00:00
|
|
|
TexResult texres;
|
2018-12-07 15:45:53 +01:00
|
|
|
BKE_texture_get_value(scene, tex_target, tex_co[i], &texres, false);
|
2011-04-28 05:34:11 +00:00
|
|
|
amplit *= texres.tin;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-06-26 21:35:18 +10:00
|
|
|
/* Apply weight & falloff. */
|
2011-04-28 05:34:11 +00:00
|
|
|
amplit *= def_weight * falloff_fac;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-03-15 14:00:40 -04:00
|
|
|
if (!vert_normals.is_empty()) {
|
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) {
|
Refactor: Move normals out of MVert, lazy calculation
As described in T91186, this commit moves mesh vertex normals into a
contiguous array of float vectors in a custom data layer, how face
normals are currently stored.
The main interface is documented in `BKE_mesh.h`. Vertex and face
normals are now calculated on-demand and cached, retrieved with an
"ensure" function. Since the logical state of a mesh is now "has
normals when necessary", they can be retrieved from a `const` mesh.
The goal is to use on-demand calculation for all derived data, but
leave room for eager calculation for performance purposes (modifier
evaluation is threaded, but viewport data generation is not).
**Benefits**
This moves us closer to a SoA approach rather than the current AoS
paradigm. Accessing a contiguous `float3` is much more efficient than
retrieving data from a larger struct. The memory requirements for
accessing only normals or vertex locations are smaller, and at the
cost of more memory usage for just normals, they now don't have to
be converted between float and short, which also simplifies code
In the future, the remaining items can be removed from `MVert`,
leaving only `float3`, which has similar benefits (see T93602).
Removing the combination of derived and original data makes it
conceptually simpler to only calculate normals when necessary.
This is especially important now that we have more opportunities
for temporary meshes in geometry nodes.
**Performance**
In addition to the theoretical future performance improvements by
making `MVert == float3`, I've done some basic performance testing
on this patch directly. The data is fairly rough, but it gives an idea
about where things stand generally.
- Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms),
showing that accessing just `MVert` is now more efficient.
- Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight
change that at least shows there is no regression.
- Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small
but observable speedup.
- Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms),
shows that using normals in geometry nodes is faster.
- Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms),
shows that calculating normals is slightly faster now.
- File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB),
Normals are not saved in files, which can help with large meshes.
As for memory usage, it may be slightly more in some cases, but
I didn't observe any difference in the production files I tested.
**Tests**
Some modifiers and cycles test results need to be updated with this
commit, for two reasons:
- The subdivision surface modifier is not responsible for calculating
normals anymore. In master, the modifier creates different normals
than the result of the `Mesh` normal calculation, so this is a bug
fix.
- There are small differences in the results of some modifiers that
use normals because they are not converted to and from `short`
anymore.
**Future improvements**
- Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
already retrieves normals if they are needed anyway.
- Copy normals as part of a better CoW system for attributes.
- Make more areas use lazy instead of eager normal calculation.
- Remove `BKE_mesh_normals_tag_dirty` in more places since that is
now the default state of a new mesh.
- Possibly apply a similar change to derived face corner normals.
Differential Revision: https://developer.blender.org/D12770
2022-01-13 14:37:58 -06:00
|
|
|
co[0] += (lifefac * amplit) * vert_normals[i][0];
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Y) {
|
Refactor: Move normals out of MVert, lazy calculation
As described in T91186, this commit moves mesh vertex normals into a
contiguous array of float vectors in a custom data layer, how face
normals are currently stored.
The main interface is documented in `BKE_mesh.h`. Vertex and face
normals are now calculated on-demand and cached, retrieved with an
"ensure" function. Since the logical state of a mesh is now "has
normals when necessary", they can be retrieved from a `const` mesh.
The goal is to use on-demand calculation for all derived data, but
leave room for eager calculation for performance purposes (modifier
evaluation is threaded, but viewport data generation is not).
**Benefits**
This moves us closer to a SoA approach rather than the current AoS
paradigm. Accessing a contiguous `float3` is much more efficient than
retrieving data from a larger struct. The memory requirements for
accessing only normals or vertex locations are smaller, and at the
cost of more memory usage for just normals, they now don't have to
be converted between float and short, which also simplifies code
In the future, the remaining items can be removed from `MVert`,
leaving only `float3`, which has similar benefits (see T93602).
Removing the combination of derived and original data makes it
conceptually simpler to only calculate normals when necessary.
This is especially important now that we have more opportunities
for temporary meshes in geometry nodes.
**Performance**
In addition to the theoretical future performance improvements by
making `MVert == float3`, I've done some basic performance testing
on this patch directly. The data is fairly rough, but it gives an idea
about where things stand generally.
- Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms),
showing that accessing just `MVert` is now more efficient.
- Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight
change that at least shows there is no regression.
- Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small
but observable speedup.
- Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms),
shows that using normals in geometry nodes is faster.
- Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms),
shows that calculating normals is slightly faster now.
- File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB),
Normals are not saved in files, which can help with large meshes.
As for memory usage, it may be slightly more in some cases, but
I didn't observe any difference in the production files I tested.
**Tests**
Some modifiers and cycles test results need to be updated with this
commit, for two reasons:
- The subdivision surface modifier is not responsible for calculating
normals anymore. In master, the modifier creates different normals
than the result of the `Mesh` normal calculation, so this is a bug
fix.
- There are small differences in the results of some modifiers that
use normals because they are not converted to and from `short`
anymore.
**Future improvements**
- Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
already retrieves normals if they are needed anyway.
- Copy normals as part of a better CoW system for attributes.
- Make more areas use lazy instead of eager normal calculation.
- Remove `BKE_mesh_normals_tag_dirty` in more places since that is
now the default state of a new mesh.
- Possibly apply a similar change to derived face corner normals.
Differential Revision: https://developer.blender.org/D12770
2022-01-13 14:37:58 -06:00
|
|
|
co[1] += (lifefac * amplit) * vert_normals[i][1];
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM_Z) {
|
Refactor: Move normals out of MVert, lazy calculation
As described in T91186, this commit moves mesh vertex normals into a
contiguous array of float vectors in a custom data layer, how face
normals are currently stored.
The main interface is documented in `BKE_mesh.h`. Vertex and face
normals are now calculated on-demand and cached, retrieved with an
"ensure" function. Since the logical state of a mesh is now "has
normals when necessary", they can be retrieved from a `const` mesh.
The goal is to use on-demand calculation for all derived data, but
leave room for eager calculation for performance purposes (modifier
evaluation is threaded, but viewport data generation is not).
**Benefits**
This moves us closer to a SoA approach rather than the current AoS
paradigm. Accessing a contiguous `float3` is much more efficient than
retrieving data from a larger struct. The memory requirements for
accessing only normals or vertex locations are smaller, and at the
cost of more memory usage for just normals, they now don't have to
be converted between float and short, which also simplifies code
In the future, the remaining items can be removed from `MVert`,
leaving only `float3`, which has similar benefits (see T93602).
Removing the combination of derived and original data makes it
conceptually simpler to only calculate normals when necessary.
This is especially important now that we have more opportunities
for temporary meshes in geometry nodes.
**Performance**
In addition to the theoretical future performance improvements by
making `MVert == float3`, I've done some basic performance testing
on this patch directly. The data is fairly rough, but it gives an idea
about where things stand generally.
- Mesh line primitive 4m Verts: 1.16x faster (36 -> 31 ms),
showing that accessing just `MVert` is now more efficient.
- Spring Splash Screen: 1.03-1.06 -> 1.06-1.11 FPS, a very slight
change that at least shows there is no regression.
- Sprite Fright Snail Smoosh: 3.30-3.40 -> 3.42-3.50 FPS, a small
but observable speedup.
- Set Position Node with Scaled Normal: 1.36x faster (53 -> 39 ms),
shows that using normals in geometry nodes is faster.
- Normal Calculation 1.6m Vert Cube: 1.19x faster (25 -> 21 ms),
shows that calculating normals is slightly faster now.
- File Size of 1.6m Vert Cube: 1.03x smaller (214.7 -> 208.4 MB),
Normals are not saved in files, which can help with large meshes.
As for memory usage, it may be slightly more in some cases, but
I didn't observe any difference in the production files I tested.
**Tests**
Some modifiers and cycles test results need to be updated with this
commit, for two reasons:
- The subdivision surface modifier is not responsible for calculating
normals anymore. In master, the modifier creates different normals
than the result of the `Mesh` normal calculation, so this is a bug
fix.
- There are small differences in the results of some modifiers that
use normals because they are not converted to and from `short`
anymore.
**Future improvements**
- Remove `ModifierTypeInfo::dependsOnNormals`. Code in each modifier
already retrieves normals if they are needed anyway.
- Copy normals as part of a better CoW system for attributes.
- Make more areas use lazy instead of eager normal calculation.
- Remove `BKE_mesh_normals_tag_dirty` in more places since that is
now the default state of a new mesh.
- Possibly apply a similar change to derived face corner normals.
Differential Revision: https://developer.blender.org/D12770
2022-01-13 14:37:58 -06:00
|
|
|
co[2] += (lifefac * amplit) * vert_normals[i][2];
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* move along local z axis */
|
|
|
|
|
co[2] += lifefac * amplit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-27 20:36:54 +01:00
|
|
|
MEM_SAFE_FREE(tex_co);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-05-12 08:04:56 +02:00
|
|
|
static void deformVerts(ModifierData *md,
|
2018-05-12 08:21:07 +02:00
|
|
|
const ModifierEvalContext *ctx,
|
2018-05-12 09:21:38 +02:00
|
|
|
Mesh *mesh,
|
2018-05-12 08:04:56 +02:00
|
|
|
float (*vertexCos)[3],
|
2022-03-28 12:29:47 +11:00
|
|
|
int verts_num)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2022-09-29 18:32:44 -05:00
|
|
|
Mesh *mesh_src = nullptr;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2018-11-27 20:36:54 +01:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM) {
|
2022-09-29 18:32:44 -05:00
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, vertexCos, verts_num, false);
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
2022-09-29 18:32:44 -05:00
|
|
|
else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, mesh, nullptr, verts_num, false);
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2022-03-28 12:29:47 +11:00
|
|
|
waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if (!ELEM(mesh_src, nullptr, mesh)) {
|
|
|
|
|
BKE_id_free(nullptr, mesh_src);
|
2018-11-27 20:10:41 +01:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void deformVertsEM(ModifierData *md,
|
2018-05-01 17:33:04 +02:00
|
|
|
const ModifierEvalContext *ctx,
|
2022-09-29 18:32:44 -05:00
|
|
|
BMEditMesh *editData,
|
2018-05-12 09:21:38 +02:00
|
|
|
Mesh *mesh,
|
|
|
|
|
float (*vertexCos)[3],
|
2022-03-28 12:29:47 +11:00
|
|
|
int verts_num)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
|
|
|
|
WaveModifierData *wmd = (WaveModifierData *)md;
|
2022-09-29 18:32:44 -05:00
|
|
|
Mesh *mesh_src = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-27 20:36:54 +01:00
|
|
|
if (wmd->flag & MOD_WAVE_NORM) {
|
2022-08-12 22:08:48 +10:00
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, verts_num, false);
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
2022-09-29 18:32:44 -05:00
|
|
|
else if (wmd->texture != nullptr || wmd->defgrp_name[0] != '\0') {
|
|
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, nullptr, verts_num, false);
|
2018-11-27 20:36:54 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-02-09 11:30:25 +11:00
|
|
|
/* TODO(@ideasman42): use edit-mode data only (remove this line). */
|
2022-09-29 18:32:44 -05:00
|
|
|
if (mesh_src != nullptr) {
|
2020-05-25 20:16:42 +10:00
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-28 12:29:47 +11:00
|
|
|
waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
if (!ELEM(mesh_src, nullptr, mesh)) {
|
2022-08-12 21:45:21 +10:00
|
|
|
/* Important not to free `vertexCos` owned by the caller. */
|
2022-10-12 20:55:26 -05:00
|
|
|
EditMeshData *edit_data = mesh_src->runtime->edit_data;
|
2022-08-12 21:45:21 +10:00
|
|
|
if (edit_data->vertexCos == vertexCos) {
|
2022-09-29 18:32:44 -05:00
|
|
|
edit_data->vertexCos = nullptr;
|
2022-08-12 21:45:21 +10:00
|
|
|
}
|
|
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
BKE_id_free(nullptr, mesh_src);
|
2018-11-27 20:10:41 +01:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void panel_draw(const bContext * /*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"));
|
2022-09-29 18:32:44 -05:00
|
|
|
uiItemR(
|
|
|
|
|
row, ptr, "use_x", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE);
|
|
|
|
|
uiItemR(
|
|
|
|
|
row, ptr, "use_y", UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE, nullptr, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
uiItemR(layout, ptr, "use_cyclic", 0, nullptr, 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);
|
2022-07-15 14:12:34 +02:00
|
|
|
uiItemR(col, ptr, "falloff_radius", 0, IFACE_("Falloff"), ICON_NONE);
|
2022-09-29 18:32:44 -05:00
|
|
|
uiItemR(col, ptr, "height", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "width", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "narrowness", UI_ITEM_R_SLIDER, nullptr, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
modifier_vgroup_ui(layout, ptr, &ob_ptr, "vertex_group", "invert_vertex_group", nullptr);
|
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
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void position_panel_draw(const bContext * /*C*/, Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
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);
|
2022-07-15 14:12:34 +02:00
|
|
|
uiItemR(col, ptr, "start_position_x", 0, IFACE_("Start Position X"), ICON_NONE);
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(col, ptr, "start_position_y", 0, "Y", ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2022-10-03 17:37:25 -05:00
|
|
|
static void time_panel_draw(const bContext * /*C*/, Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *col;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, false);
|
2022-07-15 14:12:34 +02:00
|
|
|
uiItemR(col, ptr, "time_offset", 0, IFACE_("Offset"), ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "lifetime", 0, IFACE_("Life"), ICON_NONE);
|
|
|
|
|
uiItemR(col, ptr, "damping_time", 0, IFACE_("Damping"), ICON_NONE);
|
2022-09-29 18:32:44 -05:00
|
|
|
uiItemR(col, ptr, "speed", UI_ITEM_R_SLIDER, nullptr, 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
|
|
|
|
2022-09-29 18:32:44 -05:00
|
|
|
uiTemplateID(layout, C, ptr, "texture", "texture.new", nullptr, nullptr, 0, ICON_NONE, nullptr);
|
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");
|
2022-09-29 18:32:44 -05:00
|
|
|
uiItemPointerR(col, ptr, "uv_layer", &obj_data_ptr, "uv_layers", nullptr, 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(
|
2022-09-29 18:32:44 -05:00
|
|
|
region_type, "position", "Start Position", nullptr, position_panel_draw, panel_type);
|
|
|
|
|
modifier_subpanel_register(region_type, "time", "Time", nullptr, time_panel_draw, panel_type);
|
2020-06-05 10:41:03 -04:00
|
|
|
modifier_subpanel_register(
|
2022-09-29 18:32:44 -05:00
|
|
|
region_type, "texture", "Texture", nullptr, texture_panel_draw, panel_type);
|
2020-06-05 10:41:03 -04:00
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
ModifierTypeInfo modifierType_Wave = {
|
2023-01-16 12:41:11 +11:00
|
|
|
/*name*/ N_("Wave"),
|
|
|
|
|
/*structName*/ "WaveModifierData",
|
|
|
|
|
/*structSize*/ sizeof(WaveModifierData),
|
|
|
|
|
/*srna*/ &RNA_WaveModifier,
|
|
|
|
|
/*type*/ eModifierTypeType_OnlyDeform,
|
|
|
|
|
/*flags*/ eModifierTypeFlag_AcceptsCVs | eModifierTypeFlag_AcceptsVertexCosOnly |
|
2012-05-06 13:38:33 +00:00
|
|
|
eModifierTypeFlag_SupportsEditmode,
|
2023-01-16 12:41:11 +11:00
|
|
|
/*icon*/ ICON_MOD_WAVE,
|
|
|
|
|
|
|
|
|
|
/*copyData*/ BKE_modifier_copydata_generic,
|
|
|
|
|
|
|
|
|
|
/*deformVerts*/ deformVerts,
|
|
|
|
|
/*deformMatrices*/ nullptr,
|
|
|
|
|
/*deformVertsEM*/ deformVertsEM,
|
|
|
|
|
/*deformMatricesEM*/ nullptr,
|
|
|
|
|
/*modifyMesh*/ nullptr,
|
|
|
|
|
/*modifyGeometrySet*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*initData*/ initData,
|
|
|
|
|
/*requiredDataMask*/ requiredDataMask,
|
|
|
|
|
/*freeData*/ nullptr,
|
|
|
|
|
/*isDisabled*/ nullptr,
|
|
|
|
|
/*updateDepsgraph*/ updateDepsgraph,
|
|
|
|
|
/*dependsOnTime*/ dependsOnTime,
|
|
|
|
|
/*dependsOnNormals*/ dependsOnNormals,
|
|
|
|
|
/*foreachIDLink*/ foreachIDLink,
|
|
|
|
|
/*foreachTexLink*/ foreachTexLink,
|
|
|
|
|
/*freeRuntimeData*/ nullptr,
|
|
|
|
|
/*panelRegister*/ panelRegister,
|
|
|
|
|
/*blendWrite*/ nullptr,
|
|
|
|
|
/*blendRead*/ nullptr,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|