2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2005 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
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
|
|
|
*/
|
|
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
#include <cstring>
|
2011-02-25 13:57:17 +00:00
|
|
|
|
2019-02-25 11:56:24 +01:00
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_listbase.h"
|
|
|
|
|
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "BLT_translation.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_cloth_types.h"
|
2020-10-01 12:56:34 -05:00
|
|
|
#include "DNA_defaults.h"
|
2014-05-15 14:18:35 +02:00
|
|
|
#include "DNA_key_types.h"
|
2018-05-18 17:32:22 +02:00
|
|
|
#include "DNA_mesh_types.h"
|
2020-12-15 10:47:58 +11:00
|
|
|
#include "DNA_object_force_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
#include "DNA_object_types.h"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "DNA_scene_types.h"
|
2020-06-05 10:41:03 -04:00
|
|
|
#include "DNA_screen_types.h"
|
2010-08-10 05:41:51 +00:00
|
|
|
|
2010-08-16 05:46:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
2023-08-22 07:27:35 -04:00
|
|
|
#include "BKE_cloth.hh"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "BKE_context.hh"
|
2023-12-26 23:21:19 -05:00
|
|
|
#include "BKE_customdata.hh"
|
2014-08-30 17:54:36 +02:00
|
|
|
#include "BKE_effect.h"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "BKE_global.h"
|
2024-01-30 14:42:07 -05:00
|
|
|
#include "BKE_key.hh"
|
2024-01-15 12:44:04 -05:00
|
|
|
#include "BKE_lib_id.hh"
|
2024-01-18 12:20:42 +01:00
|
|
|
#include "BKE_lib_query.hh"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "BKE_mesh.hh"
|
2023-11-14 09:30:40 +01:00
|
|
|
#include "BKE_modifier.hh"
|
2010-04-11 22:12:30 +00:00
|
|
|
#include "BKE_pointcache.h"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "BKE_screen.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2023-08-05 02:57:52 +02:00
|
|
|
#include "UI_interface.hh"
|
|
|
|
|
#include "UI_resources.hh"
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "RNA_access.hh"
|
2022-03-14 16:54:46 +01:00
|
|
|
#include "RNA_prototypes.h"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2023-09-22 03:18:17 +02:00
|
|
|
#include "DEG_depsgraph_physics.hh"
|
|
|
|
|
#include "DEG_depsgraph_query.hh"
|
2018-06-22 15:03:42 +02:00
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
#include "MOD_ui_common.hh"
|
2024-02-19 15:54:48 +01:00
|
|
|
#include "MOD_util.hh"
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void init_data(ModifierData *md)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2018-06-17 17:04:27 +02:00
|
|
|
|
2020-10-01 12:56:34 -05:00
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(clmd, modifier));
|
|
|
|
|
|
|
|
|
|
MEMCPY_STRUCT_AFTER(clmd, DNA_struct_default_get(ClothModifierData), modifier);
|
|
|
|
|
clmd->sim_parms = DNA_struct_default_alloc(ClothSimSettings);
|
|
|
|
|
clmd->coll_parms = DNA_struct_default_alloc(ClothCollSettings);
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
clmd->point_cache = BKE_ptcache_add(&clmd->ptcaches);
|
2018-06-17 17:04:27 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* check for alloc failing */
|
2019-04-22 09:15:10 +10:00
|
|
|
if (!clmd->sim_parms || !clmd->coll_parms || !clmd->point_cache) {
|
2010-04-11 22:12:30 +00:00
|
|
|
return;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2018-06-17 17:04:27 +02:00
|
|
|
|
2020-10-01 12:56:34 -05:00
|
|
|
if (!clmd->sim_parms->effector_weights) {
|
2023-05-04 18:35:37 +02:00
|
|
|
clmd->sim_parms->effector_weights = BKE_effector_add_weights(nullptr);
|
2020-10-01 12:56:34 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (clmd->point_cache) {
|
|
|
|
|
clmd->point_cache->step = 1;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void deform_verts(ModifierData *md,
|
|
|
|
|
const ModifierEvalContext *ctx,
|
|
|
|
|
Mesh *mesh,
|
2023-11-14 10:54:57 +01:00
|
|
|
blender::MutableSpan<blender::float3> positions)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2018-06-22 15:03:42 +02:00
|
|
|
Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
/* check for alloc failing */
|
2012-03-06 18:40:15 +00:00
|
|
|
if (!clmd->sim_parms || !clmd->coll_parms) {
|
2023-07-27 12:04:18 +10:00
|
|
|
init_data(md);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (!clmd->sim_parms || !clmd->coll_parms) {
|
2012-05-15 12:26:29 +00:00
|
|
|
return;
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-12-14 13:00:28 +01:00
|
|
|
/* TODO(sergey): For now it actually duplicates logic from DerivedMesh.cc
|
2014-05-15 14:18:35 +02:00
|
|
|
* and needs some more generic solution. But starting experimenting with
|
|
|
|
|
* this so close to the release is not that nice..
|
|
|
|
|
*
|
|
|
|
|
* Also hopefully new cloth system will arrive soon..
|
|
|
|
|
*/
|
2023-05-04 18:35:37 +02:00
|
|
|
if (mesh == nullptr && clmd->sim_parms->shapekey_rest) {
|
2023-07-14 20:57:28 +03:00
|
|
|
KeyBlock *kb = BKE_keyblock_find_by_index(BKE_key_from_object(ctx->object),
|
|
|
|
|
clmd->sim_parms->shapekey_rest);
|
2023-05-04 18:35:37 +02:00
|
|
|
if (kb && kb->data != nullptr) {
|
2014-05-15 14:18:35 +02:00
|
|
|
float(*layerorco)[3];
|
2023-07-07 13:07:15 +02:00
|
|
|
if (!(layerorco = static_cast<float(*)[3]>(
|
2023-12-20 02:21:48 +01:00
|
|
|
CustomData_get_layer_for_write(&mesh->vert_data, CD_CLOTH_ORCO, mesh->verts_num))))
|
2023-01-13 17:21:20 -06:00
|
|
|
{
|
2023-12-20 02:21:48 +01:00
|
|
|
layerorco = static_cast<float(*)[3]>(CustomData_add_layer(
|
|
|
|
|
&mesh->vert_data, CD_CLOTH_ORCO, CD_SET_DEFAULT, mesh->verts_num));
|
2014-05-15 14:18:35 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-11-14 10:54:57 +01:00
|
|
|
memcpy(layerorco, kb->data, sizeof(float[3]) * positions.size());
|
2014-05-15 14:18:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-11-28 12:14:09 -05:00
|
|
|
mesh->vert_positions_for_write().copy_from(positions);
|
2023-12-12 15:38:42 -05:00
|
|
|
mesh->tag_positions_changed();
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-11-14 10:54:57 +01:00
|
|
|
clothModifier_do(clmd,
|
|
|
|
|
ctx->depsgraph,
|
|
|
|
|
scene,
|
|
|
|
|
ctx->object,
|
|
|
|
|
mesh,
|
|
|
|
|
reinterpret_cast<float(*)[3]>(positions.data()));
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void update_depsgraph(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
|
|
|
{
|
|
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2023-05-04 18:35:37 +02:00
|
|
|
if (clmd != nullptr) {
|
2019-07-01 11:32:10 +02:00
|
|
|
if (clmd->coll_parms->flags & CLOTH_COLLSETTINGS_FLAG_ENABLED) {
|
|
|
|
|
DEG_add_collision_relations(ctx->node,
|
|
|
|
|
ctx->object,
|
|
|
|
|
clmd->coll_parms->group,
|
|
|
|
|
eModifierType_Collision,
|
2023-05-04 18:35:37 +02:00
|
|
|
nullptr,
|
2019-07-01 11:32:10 +02:00
|
|
|
"Cloth Collision");
|
|
|
|
|
}
|
2018-06-22 14:42:03 +02:00
|
|
|
DEG_add_forcefield_relations(
|
|
|
|
|
ctx->node, ctx->object, clmd->sim_parms->effector_weights, true, 0, "Cloth Field");
|
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-08-04 12:11:31 +02:00
|
|
|
DEG_add_depends_on_transform_relation(ctx->node, "Cloth 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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void required_data_mask(ModifierData *md, CustomData_MeshMasks *r_cddata_masks)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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 (cloth_uses_vgroup(clmd)) {
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_MDEFORMVERT;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
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 (clmd->sim_parms->shapekey_rest != 0) {
|
|
|
|
|
r_cddata_masks->vmask |= CD_MASK_CLOTH_ORCO;
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void copy_data(const ModifierData *md, ModifierData *target, const int flag)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2018-05-08 15:04:10 +02:00
|
|
|
const ClothModifierData *clmd = (const ClothModifierData *)md;
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *tclmd = (ClothModifierData *)target;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (tclmd->sim_parms) {
|
2019-04-22 09:15:10 +10:00
|
|
|
if (tclmd->sim_parms->effector_weights) {
|
2010-05-06 21:31:16 +00:00
|
|
|
MEM_freeN(tclmd->sim_parms->effector_weights);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
MEM_freeN(tclmd->sim_parms);
|
2010-05-06 21:31:16 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (tclmd->coll_parms) {
|
2010-04-11 22:12:30 +00:00
|
|
|
MEM_freeN(tclmd->coll_parms);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
BKE_ptcache_free_list(&tclmd->ptcaches);
|
2021-09-28 16:38:24 +02:00
|
|
|
if (flag & LIB_ID_COPY_SET_COPIED_ON_WRITE) {
|
2018-07-04 12:46:03 +02:00
|
|
|
/* Share the cache with the original object's modifier. */
|
|
|
|
|
tclmd->modifier.flag |= eModifierFlag_SharedCaches;
|
|
|
|
|
tclmd->ptcaches = clmd->ptcaches;
|
|
|
|
|
tclmd->point_cache = clmd->point_cache;
|
|
|
|
|
}
|
|
|
|
|
else {
|
2021-11-04 17:15:34 +01:00
|
|
|
const int clmd_point_cache_index = BLI_findindex(&clmd->ptcaches, clmd->point_cache);
|
|
|
|
|
BKE_ptcache_copy_list(&tclmd->ptcaches, &clmd->ptcaches, flag);
|
2023-05-04 18:35:37 +02:00
|
|
|
tclmd->point_cache = static_cast<PointCache *>(
|
|
|
|
|
BLI_findlink(&tclmd->ptcaches, clmd_point_cache_index));
|
2018-07-04 12:46:03 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
tclmd->sim_parms = static_cast<ClothSimSettings *>(MEM_dupallocN(clmd->sim_parms));
|
2019-04-22 09:15:10 +10:00
|
|
|
if (clmd->sim_parms->effector_weights) {
|
2023-05-04 18:35:37 +02:00
|
|
|
tclmd->sim_parms->effector_weights = static_cast<EffectorWeights *>(
|
|
|
|
|
MEM_dupallocN(clmd->sim_parms->effector_weights));
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2023-05-04 18:35:37 +02:00
|
|
|
tclmd->coll_parms = static_cast<ClothCollSettings *>(MEM_dupallocN(clmd->coll_parms));
|
|
|
|
|
tclmd->clothObject = nullptr;
|
|
|
|
|
tclmd->hairdata = nullptr;
|
|
|
|
|
tclmd->solver_result = nullptr;
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static bool depends_on_time(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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void free_data(ModifierData *md)
|
2010-04-11 22:12:30 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-06 18:40:15 +00:00
|
|
|
if (clmd) {
|
2019-01-16 19:41:29 +01:00
|
|
|
if (G.debug & G_DEBUG_SIMDATA) {
|
2010-04-11 22:12:30 +00:00
|
|
|
printf("clothModifier_freeData\n");
|
2019-01-16 19:41:29 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-05-06 13:38:33 +00:00
|
|
|
cloth_free_modifier_extern(clmd);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (clmd->sim_parms) {
|
2019-04-22 09:15:10 +10:00
|
|
|
if (clmd->sim_parms->effector_weights) {
|
2010-04-11 22:12:30 +00:00
|
|
|
MEM_freeN(clmd->sim_parms->effector_weights);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
MEM_freeN(clmd->sim_parms);
|
|
|
|
|
}
|
2019-04-22 09:15:10 +10:00
|
|
|
if (clmd->coll_parms) {
|
2012-10-21 05:46:41 +00:00
|
|
|
MEM_freeN(clmd->coll_parms);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-04 12:46:03 +02:00
|
|
|
if (md->flag & eModifierFlag_SharedCaches) {
|
|
|
|
|
BLI_listbase_clear(&clmd->ptcaches);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
BKE_ptcache_free_list(&clmd->ptcaches);
|
|
|
|
|
}
|
2023-05-04 18:35:37 +02:00
|
|
|
clmd->point_cache = nullptr;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (clmd->hairdata) {
|
2014-11-17 19:44:42 +01:00
|
|
|
MEM_freeN(clmd->hairdata);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-04-22 09:15:10 +10:00
|
|
|
if (clmd->solver_result) {
|
2014-09-20 21:05:46 +02:00
|
|
|
MEM_freeN(clmd->solver_result);
|
2019-04-22 09:15:10 +10:00
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void foreach_ID_link(ModifierData *md, Object *ob, IDWalkFunc walk, void *user_data)
|
2011-06-09 02:47:22 +00:00
|
|
|
{
|
2012-05-06 13:38:33 +00:00
|
|
|
ClothModifierData *clmd = (ClothModifierData *)md;
|
2011-06-09 02:47:22 +00:00
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (clmd->coll_parms) {
|
2023-07-27 12:04:18 +10:00
|
|
|
walk(user_data, ob, (ID **)&clmd->coll_parms->group, IDWALK_CB_NOP);
|
2011-06-09 02:47:22 +00:00
|
|
|
}
|
|
|
|
|
|
2012-03-24 06:24:53 +00:00
|
|
|
if (clmd->sim_parms && clmd->sim_parms->effector_weights) {
|
2023-07-27 12:04:18 +10:00
|
|
|
walk(user_data, ob, (ID **)&clmd->sim_parms->effector_weights->group, IDWALK_CB_USER);
|
2011-06-09 02:47:22 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-04-11 22:12:30 +00:00
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
static void panel_draw(const bContext * /*C*/, Panel *panel)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
uiLayout *layout = panel->layout;
|
|
|
|
|
|
2023-05-04 18:35:37 +02:00
|
|
|
PointerRNA *ptr = modifier_panel_get_property_pointers(panel, nullptr);
|
2020-06-05 10:41:03 -04:00
|
|
|
|
2024-01-11 19:49:03 +01:00
|
|
|
uiItemL(layout, RPT_("Settings are inside the Physics tab"), 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
|
|
|
}
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
static void panel_register(ARegionType *region_type)
|
2020-06-05 10:41:03 -04:00
|
|
|
{
|
|
|
|
|
modifier_panel_register(region_type, eModifierType_Cloth, panel_draw);
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-11 22:12:30 +00:00
|
|
|
ModifierTypeInfo modifierType_Cloth = {
|
2023-07-26 17:08:14 +02:00
|
|
|
/*idname*/ "Cloth",
|
2023-01-16 12:41:11 +11:00
|
|
|
/*name*/ N_("Cloth"),
|
2023-07-27 12:04:18 +10:00
|
|
|
/*struct_name*/ "ClothModifierData",
|
|
|
|
|
/*struct_size*/ sizeof(ClothModifierData),
|
2023-01-16 12:41:11 +11:00
|
|
|
/*srna*/ &RNA_ClothModifier,
|
2023-11-14 10:03:56 +01:00
|
|
|
/*type*/ ModifierTypeType::OnlyDeform,
|
2023-01-16 12:41:11 +11:00
|
|
|
/*flags*/ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_UsesPointCache |
|
2012-05-09 09:24:15 +00:00
|
|
|
eModifierTypeFlag_Single,
|
2023-01-16 12:41:11 +11:00
|
|
|
/*icon*/ ICON_MOD_CLOTH,
|
|
|
|
|
|
2023-07-27 12:04:18 +10:00
|
|
|
/*copy_data*/ copy_data,
|
|
|
|
|
|
|
|
|
|
/*deform_verts*/ deform_verts,
|
|
|
|
|
/*deform_matrices*/ nullptr,
|
|
|
|
|
/*deform_verts_EM*/ nullptr,
|
|
|
|
|
/*deform_matrices_EM*/ nullptr,
|
|
|
|
|
/*modify_mesh*/ nullptr,
|
|
|
|
|
/*modify_geometry_set*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*init_data*/ init_data,
|
|
|
|
|
/*required_data_mask*/ required_data_mask,
|
|
|
|
|
/*free_data*/ free_data,
|
|
|
|
|
/*is_disabled*/ nullptr,
|
|
|
|
|
/*update_depsgraph*/ update_depsgraph,
|
|
|
|
|
/*depends_on_time*/ depends_on_time,
|
|
|
|
|
/*depends_on_normals*/ nullptr,
|
|
|
|
|
/*foreach_ID_link*/ foreach_ID_link,
|
|
|
|
|
/*foreach_tex_link*/ nullptr,
|
|
|
|
|
/*free_runtime_data*/ nullptr,
|
|
|
|
|
/*panel_register*/ panel_register,
|
|
|
|
|
/*blend_write*/ nullptr,
|
|
|
|
|
/*blend_read*/ nullptr,
|
2024-01-18 22:51:30 +01:00
|
|
|
/*foreach_cache*/ nullptr,
|
2010-04-11 22:12:30 +00:00
|
|
|
};
|