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:56:24 +01:00
|
|
|
#include "BLI_utildefines.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
#include "BLI_math.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
#include "DNA_defaults.h"
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
#include "DNA_object_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_context.h"
|
2010-04-12 22:33:43 +00:00
|
|
|
#include "BKE_deform.h"
|
2018-05-08 17:52:24 +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-08 17:52:24 +02:00
|
|
|
#include "BKE_mesh.h"
|
2022-10-12 20:55:26 -05:00
|
|
|
#include "BKE_mesh_runtime.h"
|
2020-06-10 22:32:06 +10:00
|
|
|
#include "BKE_mesh_wrapper.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "BKE_modifier.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "BKE_screen.h"
|
|
|
|
|
|
|
|
|
|
#include "UI_interface.h"
|
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2018-12-07 15:45:53 +01:00
|
|
|
#include "DEG_depsgraph_query.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"
|
|
|
|
|
|
|
|
|
|
static void initData(ModifierData *md)
|
|
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-10-01 09:38:00 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(cmd, modifier));
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(cmd, DNA_struct_default_get(CastModifierData), modifier);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2018-07-10 12:14:08 +02:00
|
|
|
static bool isDisabled(const struct Scene *UNUSED(scene),
|
|
|
|
|
ModifierData *md,
|
|
|
|
|
bool UNUSED(useRenderParams))
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
2010-04-11 22:12:30 +00:00
|
|
|
short flag;
|
2018-06-17 17:04:27 +02:00
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
flag = cmd->flag & (MOD_CAST_X | MOD_CAST_Y | MOD_CAST_Z);
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if ((cmd->fac == 0.0f) || flag == 0) {
|
2013-06-02 03:59:19 +00:00
|
|
|
return true;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2013-06-02 03:59:19 +00:00
|
|
|
return false;
|
2010-04-11 22:12:30 +00: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
|
|
|
{
|
|
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
|
|
|
|
|
|
|
|
|
/* 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 (cmd->defgrp_name[0] != '\0') {
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2020-10-01 18:05:23 +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
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2020-10-01 18:05:23 +02:00
|
|
|
walk(userData, ob, (ID **)&cmd->object, IDWALK_CB_NOP);
|
2010-04-11 22:12:30 +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
|
|
|
{
|
|
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
|
|
|
|
if (cmd->object != NULL) {
|
2018-02-22 12:54:06 +01:00
|
|
|
DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier");
|
2022-08-04 12:11:31 +02:00
|
|
|
DEG_add_depends_on_transform_relation(ctx->node, "Cast 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-04-11 22:12:30 +00:00
|
|
|
static void sphere_do(CastModifierData *cmd,
|
2019-03-26 11:25:07 +01:00
|
|
|
const ModifierEvalContext *UNUSED(ctx),
|
2018-12-07 15:45:53 +01:00
|
|
|
Object *ob,
|
|
|
|
|
Mesh *mesh,
|
2012-08-23 16:17:47 +00:00
|
|
|
float (*vertexCos)[3],
|
2022-03-28 12:29:47 +11:00
|
|
|
int verts_num)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
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 = NULL;
|
2020-01-27 14:03:24 +01:00
|
|
|
const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
Object *ctrl_ob = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
int i, defgrp_index;
|
2014-01-28 03:52:21 +11:00
|
|
|
bool has_radius = false;
|
2010-04-11 22:12:30 +00:00
|
|
|
short flag, type;
|
2013-03-03 05:43:47 +00:00
|
|
|
float len = 0.0f;
|
|
|
|
|
float fac = cmd->fac;
|
|
|
|
|
float facm = 1.0f - fac;
|
|
|
|
|
const float fac_orig = fac;
|
2010-04-11 22:12:30 +00:00
|
|
|
float vec[3], center[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
float mat[4][4], imat[4][4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
flag = cmd->flag;
|
|
|
|
|
type = cmd->type; /* projection type: sphere or cylinder */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (type == MOD_CAST_TYPE_CYLINDER) {
|
2010-04-11 22:12:30 +00:00
|
|
|
flag &= ~MOD_CAST_Z;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 11:25:07 +01:00
|
|
|
ctrl_ob = cmd->object;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* spherify's center is {0, 0, 0} (the ob's own center in its local
|
2012-03-09 18:28:30 +00:00
|
|
|
* space), by default, but if the user defined a control object,
|
|
|
|
|
* we use its location, transformed to ob's local space */
|
2010-04-11 22:12:30 +00:00
|
|
|
if (ctrl_ob) {
|
2012-03-24 06:24:53 +00:00
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2022-10-24 14:16:37 +02:00
|
|
|
invert_m4_m4(imat, ctrl_ob->object_to_world);
|
|
|
|
|
mul_m4_m4m4(mat, imat, ob->object_to_world);
|
2010-04-11 22:12:30 +00:00
|
|
|
invert_m4_m4(imat, mat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-11-02 14:41:49 +01:00
|
|
|
invert_m4_m4(ob->world_to_object, ob->object_to_world);
|
|
|
|
|
mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* now we check which options the user wants */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* 1) (flag was checked in the "if (ctrl_ob)" block above) */
|
|
|
|
|
/* 2) cmd->radius > 0.0f: only the vertices within this radius from
|
2012-03-09 18:28:30 +00:00
|
|
|
* the center of the effect should be deformed */
|
2019-04-22 09:15:10 +10:00
|
|
|
if (cmd->radius > FLT_EPSILON) {
|
2010-04-11 22:12:30 +00:00
|
|
|
has_radius = 1;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* 3) if we were given a vertex group name,
|
2012-03-09 18:28:30 +00:00
|
|
|
* only those vertices should be affected */
|
2020-03-18 14:14:24 +11:00
|
|
|
if (cmd->defgrp_name[0] != '\0') {
|
|
|
|
|
MOD_get_vgroup(ob, mesh, cmd->defgrp_name, &dvert, &defgrp_index);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (flag & MOD_CAST_SIZE_FROM_RADIUS) {
|
2010-04-11 22:12:30 +00:00
|
|
|
len = cmd->radius;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
len = cmd->size;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (len <= 0) {
|
2022-03-28 12:29:47 +11:00
|
|
|
for (i = 0; i < verts_num; i++) {
|
2010-04-11 22:12:30 +00:00
|
|
|
len += len_v3v3(center, vertexCos[i]);
|
|
|
|
|
}
|
2022-03-28 12:29:47 +11:00
|
|
|
len /= verts_num;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (len == 0.0f) {
|
2010-04-11 22:12:30 +00:00
|
|
|
len = 10.0f;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
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 tmp_co[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
copy_v3_v3(tmp_co, vertexCos[i]);
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ctrl_ob) {
|
|
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2010-04-11 22:12:30 +00:00
|
|
|
mul_m4_v3(mat, tmp_co);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-04-23 23:57:00 +00:00
|
|
|
sub_v3_v3(tmp_co, center);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
copy_v3_v3(vec, tmp_co);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (type == MOD_CAST_TYPE_CYLINDER) {
|
2010-04-11 22:12:30 +00:00
|
|
|
vec[2] = 0.0f;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
if (has_radius) {
|
2019-04-22 09:15:10 +10:00
|
|
|
if (len_v3(vec) > cmd->radius) {
|
2010-04-11 22:12:30 +00:00
|
|
|
continue;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
if (dvert) {
|
2020-03-06 12:50:56 +11:00
|
|
|
const float weight = invert_vgroup ?
|
|
|
|
|
1.0f - BKE_defvert_find_weight(&dvert[i], defgrp_index) :
|
|
|
|
|
BKE_defvert_find_weight(&dvert[i], defgrp_index);
|
2020-01-27 14:03:24 +01:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
if (weight == 0.0f) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
fac = fac_orig * weight;
|
|
|
|
|
facm = 1.0f - fac;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
normalize_v3(vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (flag & MOD_CAST_X) {
|
2012-05-06 13:38:33 +00:00
|
|
|
tmp_co[0] = fac * vec[0] * len + facm * tmp_co[0];
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (flag & MOD_CAST_Y) {
|
2012-05-06 13:38:33 +00:00
|
|
|
tmp_co[1] = fac * vec[1] * len + facm * tmp_co[1];
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (flag & MOD_CAST_Z) {
|
2012-05-06 13:38:33 +00:00
|
|
|
tmp_co[2] = fac * vec[2] * len + facm * tmp_co[2];
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ctrl_ob) {
|
|
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2010-04-11 22:12:30 +00:00
|
|
|
mul_m4_v3(imat, tmp_co);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(tmp_co, center);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
copy_v3_v3(vertexCos[i], tmp_co);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-26 11:25:07 +01:00
|
|
|
static void cuboid_do(CastModifierData *cmd,
|
|
|
|
|
const ModifierEvalContext *UNUSED(ctx),
|
2018-12-07 15:45:53 +01:00
|
|
|
Object *ob,
|
|
|
|
|
Mesh *mesh,
|
2012-08-23 16:17:47 +00:00
|
|
|
float (*vertexCos)[3],
|
2022-03-28 12:29:47 +11:00
|
|
|
int verts_num)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
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 = NULL;
|
2020-03-18 14:14:24 +11:00
|
|
|
int defgrp_index;
|
2020-01-27 14:03:24 +01:00
|
|
|
const bool invert_vgroup = (cmd->flag & MOD_CAST_INVERT_VGROUP) != 0;
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
Object *ctrl_ob = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-18 14:14:24 +11:00
|
|
|
int i;
|
2014-01-28 03:52:21 +11:00
|
|
|
bool has_radius = false;
|
2010-04-11 22:12:30 +00:00
|
|
|
short flag;
|
2013-03-03 05:43:47 +00:00
|
|
|
float fac = cmd->fac;
|
|
|
|
|
float facm = 1.0f - fac;
|
|
|
|
|
const float fac_orig = fac;
|
2010-04-11 22:12:30 +00:00
|
|
|
float min[3], max[3], bb[8][3];
|
|
|
|
|
float center[3] = {0.0f, 0.0f, 0.0f};
|
|
|
|
|
float mat[4][4], imat[4][4];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
flag = cmd->flag;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-26 11:25:07 +01:00
|
|
|
ctrl_ob = cmd->object;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* now we check which options the user wants */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* 1) (flag was checked in the "if (ctrl_ob)" block above) */
|
|
|
|
|
/* 2) cmd->radius > 0.0f: only the vertices within this radius from
|
2012-03-09 18:28:30 +00:00
|
|
|
* the center of the effect should be deformed */
|
2019-04-22 09:15:10 +10:00
|
|
|
if (cmd->radius > FLT_EPSILON) {
|
2010-04-11 22:12:30 +00:00
|
|
|
has_radius = 1;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* 3) if we were given a vertex group name,
|
2012-03-09 18:28:30 +00:00
|
|
|
* only those vertices should be affected */
|
2020-03-18 14:14:24 +11:00
|
|
|
if (cmd->defgrp_name[0] != '\0') {
|
|
|
|
|
MOD_get_vgroup(ob, mesh, cmd->defgrp_name, &dvert, &defgrp_index);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
if (ctrl_ob) {
|
2012-03-24 06:24:53 +00:00
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2022-10-24 14:16:37 +02:00
|
|
|
invert_m4_m4(imat, ctrl_ob->object_to_world);
|
|
|
|
|
mul_m4_m4m4(mat, imat, ob->object_to_world);
|
2010-04-11 22:12:30 +00:00
|
|
|
invert_m4_m4(imat, mat);
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2022-11-02 14:41:49 +01:00
|
|
|
invert_m4_m4(ob->world_to_object, ob->object_to_world);
|
|
|
|
|
mul_v3_m4v3(center, ob->world_to_object, ctrl_ob->object_to_world[3]);
|
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 ((flag & MOD_CAST_SIZE_FROM_RADIUS) && has_radius) {
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2010-04-11 22:12:30 +00:00
|
|
|
min[i] = -cmd->radius;
|
|
|
|
|
max[i] = cmd->radius;
|
|
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else if (!(flag & MOD_CAST_SIZE_FROM_RADIUS) && cmd->size > 0) {
|
|
|
|
|
for (i = 0; i < 3; i++) {
|
2010-04-11 22:12:30 +00:00
|
|
|
min[i] = -cmd->size;
|
|
|
|
|
max[i] = cmd->size;
|
|
|
|
|
}
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-04-11 22:12:30 +00:00
|
|
|
/* get bound box */
|
|
|
|
|
/* We can't use the object's bound box because other modifiers
|
2012-03-09 18:28:30 +00:00
|
|
|
* may have changed the vertex data. */
|
2010-04-11 22:12:30 +00:00
|
|
|
INIT_MINMAX(min, max);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* Cast's center is the ob's own center in its local space,
|
2012-03-09 18:28:30 +00:00
|
|
|
* by default, but if the user defined a control object, we use
|
|
|
|
|
* its location, transformed to ob's local space. */
|
2010-04-11 22:12:30 +00:00
|
|
|
if (ctrl_ob) {
|
|
|
|
|
float vec[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* let the center of the ctrl_ob be part of the bound box: */
|
2012-05-13 11:05:52 +00:00
|
|
|
minmax_v3v3_v3(min, max, center);
|
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
|
|
|
sub_v3_v3v3(vec, vertexCos[i], center);
|
2012-05-13 11:05:52 +00:00
|
|
|
minmax_v3v3_v3(min, max, vec);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2022-03-28 12:29:47 +11:00
|
|
|
for (i = 0; i < verts_num; i++) {
|
2012-05-13 11:05:52 +00:00
|
|
|
minmax_v3v3_v3(min, max, vertexCos[i]);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* we want a symmetric bound box around the origin */
|
2019-04-22 09:15:10 +10:00
|
|
|
if (fabsf(min[0]) > fabsf(max[0])) {
|
2012-07-21 15:27:40 +00:00
|
|
|
max[0] = fabsf(min[0]);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (fabsf(min[1]) > fabsf(max[1])) {
|
2012-07-21 15:27:40 +00:00
|
|
|
max[1] = fabsf(min[1]);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (fabsf(min[2]) > fabsf(max[2])) {
|
2012-07-21 15:27:40 +00:00
|
|
|
max[2] = fabsf(min[2]);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
min[0] = -max[0];
|
|
|
|
|
min[1] = -max[1];
|
|
|
|
|
min[2] = -max[2];
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* building our custom bounding box */
|
|
|
|
|
bb[0][0] = bb[2][0] = bb[4][0] = bb[6][0] = min[0];
|
|
|
|
|
bb[1][0] = bb[3][0] = bb[5][0] = bb[7][0] = max[0];
|
|
|
|
|
bb[0][1] = bb[1][1] = bb[4][1] = bb[5][1] = min[1];
|
|
|
|
|
bb[2][1] = bb[3][1] = bb[6][1] = bb[7][1] = max[1];
|
|
|
|
|
bb[0][2] = bb[1][2] = bb[2][2] = bb[3][2] = min[2];
|
|
|
|
|
bb[4][2] = bb[5][2] = bb[6][2] = bb[7][2] = max[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* ready to apply the effect, one vertex at a time */
|
2022-03-28 12:29:47 +11:00
|
|
|
for (i = 0; i < verts_num; i++) {
|
2010-04-11 22:12:30 +00:00
|
|
|
int octant, coord;
|
2013-03-03 05:43:47 +00:00
|
|
|
float d[3], dmax, apex[3], fbb;
|
2010-04-11 22:12:30 +00:00
|
|
|
float tmp_co[3];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
copy_v3_v3(tmp_co, vertexCos[i]);
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ctrl_ob) {
|
|
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2010-04-11 22:12:30 +00:00
|
|
|
mul_m4_v3(mat, tmp_co);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-04-12 00:36:50 +00:00
|
|
|
sub_v3_v3(tmp_co, center);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
if (has_radius) {
|
2011-03-27 13:49:53 +00:00
|
|
|
if (fabsf(tmp_co[0]) > cmd->radius || fabsf(tmp_co[1]) > cmd->radius ||
|
2012-04-28 06:31:57 +00:00
|
|
|
fabsf(tmp_co[2]) > cmd->radius) {
|
|
|
|
|
continue;
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
if (dvert) {
|
2020-03-06 12:50:56 +11:00
|
|
|
const float weight = invert_vgroup ?
|
|
|
|
|
1.0f - BKE_defvert_find_weight(&dvert[i], defgrp_index) :
|
|
|
|
|
BKE_defvert_find_weight(&dvert[i], defgrp_index);
|
2020-01-27 14:03:24 +01:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
if (weight == 0.0f) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
fac = fac_orig * weight;
|
|
|
|
|
facm = 1.0f - fac;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-20 11:39:03 +11:00
|
|
|
/* The algorithm used to project the vertices to their
|
2013-03-03 05:43:47 +00:00
|
|
|
* bounding box (bb) is pretty simple:
|
|
|
|
|
* for each vertex v:
|
|
|
|
|
* 1) find in which octant v is in;
|
|
|
|
|
* 2) find which outer "wall" of that octant is closer to v;
|
|
|
|
|
* 3) calculate factor (var fbb) to project v to that wall;
|
|
|
|
|
* 4) project. */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* find in which octant this vertex is in */
|
2010-04-11 22:12:30 +00:00
|
|
|
octant = 0;
|
2019-04-22 09:15:10 +10:00
|
|
|
if (tmp_co[0] > 0.0f) {
|
2010-04-11 22:12:30 +00:00
|
|
|
octant += 1;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (tmp_co[1] > 0.0f) {
|
2010-04-11 22:12:30 +00:00
|
|
|
octant += 2;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (tmp_co[2] > 0.0f) {
|
2010-04-11 22:12:30 +00:00
|
|
|
octant += 4;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* apex is the bb's vertex at the chosen octant */
|
2010-04-11 22:12:30 +00:00
|
|
|
copy_v3_v3(apex, bb[octant]);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* find which bb plane is closest to this vertex ... */
|
2010-04-11 22:12:30 +00:00
|
|
|
d[0] = tmp_co[0] / apex[0];
|
|
|
|
|
d[1] = tmp_co[1] / apex[1];
|
|
|
|
|
d[2] = tmp_co[2] / apex[2];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* ... (the closest has the higher (closer to 1) d value) */
|
2010-04-11 22:12:30 +00:00
|
|
|
dmax = d[0];
|
|
|
|
|
coord = 0;
|
|
|
|
|
if (d[1] > dmax) {
|
|
|
|
|
dmax = d[1];
|
|
|
|
|
coord = 1;
|
|
|
|
|
}
|
|
|
|
|
if (d[2] > dmax) {
|
|
|
|
|
/* dmax = d[2]; */ /* commented, we don't need it */
|
|
|
|
|
coord = 2;
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* ok, now we know which coordinate of the vertex to use */
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (fabsf(tmp_co[coord]) < FLT_EPSILON) { /* avoid division by zero */
|
2010-04-11 22:12:30 +00:00
|
|
|
continue;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* finally, this is the factor we wanted, to project the vertex
|
|
|
|
|
* to its bounding box (bb) */
|
2010-04-11 22:12:30 +00:00
|
|
|
fbb = apex[coord] / tmp_co[coord];
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-03-03 05:43:47 +00:00
|
|
|
/* calculate the new vertex position */
|
2019-04-22 09:15:10 +10:00
|
|
|
if (flag & MOD_CAST_X) {
|
2010-04-11 22:12:30 +00:00
|
|
|
tmp_co[0] = facm * tmp_co[0] + fac * tmp_co[0] * fbb;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (flag & MOD_CAST_Y) {
|
2010-04-11 22:12:30 +00:00
|
|
|
tmp_co[1] = facm * tmp_co[1] + fac * tmp_co[1] * fbb;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
|
|
|
|
if (flag & MOD_CAST_Z) {
|
2010-04-11 22:12:30 +00:00
|
|
|
tmp_co[2] = facm * tmp_co[2] + fac * tmp_co[2] * fbb;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (ctrl_ob) {
|
|
|
|
|
if (flag & MOD_CAST_USE_OB_TRANSFORM) {
|
2010-04-11 22:12:30 +00:00
|
|
|
mul_m4_v3(imat, tmp_co);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2010-04-21 12:27:48 +00:00
|
|
|
add_v3_v3(tmp_co, center);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-12 00:36:50 +00:00
|
|
|
copy_v3_v3(vertexCos[i], tmp_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,
|
|
|
|
|
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
|
|
|
{
|
|
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
2018-11-26 11:30:46 +01:00
|
|
|
Mesh *mesh_src = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-27 20:10:41 +01:00
|
|
|
if (ctx->object->type == OB_MESH && cmd->defgrp_name[0] != '\0') {
|
2018-11-26 11:30:46 +01:00
|
|
|
/* mesh_src is only needed for vgroups. */
|
2022-08-12 22:08:48 +10:00
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false);
|
2018-11-26 11:30:46 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
|
2022-03-28 12:29:47 +11:00
|
|
|
cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
2022-03-28 12:29:47 +11:00
|
|
|
sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-11-26 11:30:46 +01:00
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
2018-05-09 17:37:54 +02:00
|
|
|
BKE_id_free(NULL, mesh_src);
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void deformVertsEM(ModifierData *md,
|
2018-05-01 17:33:04 +02:00
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
struct BMEditMesh *editData,
|
2018-05-08 17:52:24 +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
|
|
|
{
|
|
|
|
|
CastModifierData *cmd = (CastModifierData *)md;
|
2020-03-18 14:14:24 +11:00
|
|
|
Mesh *mesh_src = NULL;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-18 14:14:24 +11:00
|
|
|
if (cmd->defgrp_name[0] != '\0') {
|
2022-08-12 22:08:48 +10:00
|
|
|
mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false);
|
2020-03-18 14:14:24 +11:00
|
|
|
}
|
|
|
|
|
|
2022-10-12 20:55:26 -05:00
|
|
|
if (mesh && BKE_mesh_wrapper_type(mesh) == ME_WRAPPER_TYPE_MDATA) {
|
2022-03-28 12:29:47 +11:00
|
|
|
BLI_assert(mesh->totvert == verts_num);
|
2020-03-18 14:14:24 +11: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). */
|
2020-05-25 20:16:42 +10:00
|
|
|
if (mesh_src != NULL) {
|
|
|
|
|
BKE_mesh_wrapper_ensure_mdata(mesh_src);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
if (cmd->type == MOD_CAST_TYPE_CUBOID) {
|
2022-03-28 12:29:47 +11:00
|
|
|
cuboid_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2012-03-24 06:24:53 +00:00
|
|
|
}
|
|
|
|
|
else { /* MOD_CAST_TYPE_SPHERE or MOD_CAST_TYPE_CYLINDER */
|
2022-03-28 12:29:47 +11:00
|
|
|
sphere_do(cmd, ctx, ctx->object, mesh_src, vertexCos, verts_num);
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-03-29 16:08:22 +11:00
|
|
|
if (!ELEM(mesh_src, NULL, mesh)) {
|
2018-05-08 17:52:24 +02:00
|
|
|
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 *row;
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
int toggles_flag = UI_ITEM_R_TOGGLE | UI_ITEM_R_FORCE_BLANK_DECORATE;
|
|
|
|
|
|
|
|
|
|
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
|
|
|
PointerRNA cast_object_ptr = RNA_pointer_get(ptr, "object");
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
uiLayoutSetPropSep(layout, true);
|
|
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "cast_type", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
|
|
|
|
row = uiLayoutRowWithHeading(layout, true, IFACE_("Axis"));
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(row, ptr, "use_x", toggles_flag, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(row, ptr, "use_y", toggles_flag, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(row, ptr, "use_z", toggles_flag, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "factor", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(layout, ptr, "radius", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
|
|
|
|
|
uiItemR(layout, ptr, "use_radius_as_size", 0, 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
|
|
|
uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
|
2020-06-05 10:41:03 -04:00
|
|
|
if (!RNA_pointer_is_null(&cast_object_ptr)) {
|
2020-09-02 14:13:26 -05:00
|
|
|
uiItemR(layout, ptr, "use_transform", 0, NULL, ICON_NONE);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void panelRegister(ARegionType *region_type)
|
|
|
|
|
{
|
|
|
|
|
modifier_panel_register(region_type, eModifierType_Cast, panel_draw);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
ModifierTypeInfo modifierType_Cast = {
|
2023-01-16 12:41:11 +11:00
|
|
|
/*name*/ N_("Cast"),
|
|
|
|
|
/*structName*/ "CastModifierData",
|
|
|
|
|
/*structSize*/ sizeof(CastModifierData),
|
|
|
|
|
/*srna*/ &RNA_CastModifier,
|
|
|
|
|
/*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_CAST,
|
|
|
|
|
|
|
|
|
|
/*copyData*/ BKE_modifier_copydata_generic,
|
|
|
|
|
|
|
|
|
|
/*deformVerts*/ deformVerts,
|
|
|
|
|
/*deformMatrices*/ NULL,
|
|
|
|
|
/*deformVertsEM*/ deformVertsEM,
|
|
|
|
|
/*deformMatricesEM*/ NULL,
|
|
|
|
|
/*modifyMesh*/ NULL,
|
|
|
|
|
/*modifyGeometrySet*/ NULL,
|
|
|
|
|
|
|
|
|
|
/*initData*/ initData,
|
|
|
|
|
/*requiredDataMask*/ requiredDataMask,
|
|
|
|
|
/*freeData*/ NULL,
|
|
|
|
|
/*isDisabled*/ isDisabled,
|
|
|
|
|
/*updateDepsgraph*/ updateDepsgraph,
|
|
|
|
|
/*dependsOnTime*/ NULL,
|
|
|
|
|
/*dependsOnNormals*/ NULL,
|
|
|
|
|
/*foreachIDLink*/ foreachIDLink,
|
|
|
|
|
/*foreachTexLink*/ NULL,
|
|
|
|
|
/*freeRuntimeData*/ NULL,
|
|
|
|
|
/*panelRegister*/ panelRegister,
|
|
|
|
|
/*blendWrite*/ NULL,
|
|
|
|
|
/*blendRead*/ NULL,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|