Blender  V2.93
MOD_softbody.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2005 by the Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include <stdio.h>
25 
26 #include "BLI_utildefines.h"
27 
28 #include "BLT_translation.h"
29 
30 #include "DNA_mesh_types.h"
31 #include "DNA_object_force_types.h"
32 #include "DNA_scene_types.h"
33 #include "DNA_screen_types.h"
34 
35 #include "BKE_context.h"
36 #include "BKE_layer.h"
37 #include "BKE_particle.h"
38 #include "BKE_screen.h"
39 #include "BKE_softbody.h"
40 
41 #include "UI_interface.h"
42 #include "UI_resources.h"
43 
44 #include "RNA_access.h"
45 
46 #include "DEG_depsgraph.h"
47 #include "DEG_depsgraph_build.h"
48 #include "DEG_depsgraph_physics.h"
49 #include "DEG_depsgraph_query.h"
50 
51 #include "MOD_modifiertypes.h"
52 #include "MOD_ui_common.h"
53 
54 static void deformVerts(ModifierData *UNUSED(md),
55  const ModifierEvalContext *ctx,
56  Mesh *UNUSED(derivedData),
57  float (*vertexCos)[3],
58  int numVerts)
59 {
62  ctx->depsgraph, scene, ctx->object, DEG_get_ctime(ctx->depsgraph), vertexCos, numVerts);
63 }
64 
66 {
67  return true;
68 }
69 
71 {
72  if (ctx->object->soft) {
73  /* Actual code uses ccd_build_deflector_hash */
75  ctx->object,
78  NULL,
79  "Softbody Collision");
81  ctx->node, ctx->object, ctx->object->soft->effector_weights, true, 0, "Softbody Field");
82  }
83  /* We need own transformation as well. */
84  DEG_add_modifier_to_transform_relation(ctx->node, "SoftBody Modifier");
85 }
86 
87 static void panel_draw(const bContext *UNUSED(C), Panel *panel)
88 {
89  uiLayout *layout = panel->layout;
90 
92 
93  uiItemL(layout, IFACE_("Settings are inside the Physics tab"), ICON_NONE);
94 
95  modifier_panel_end(layout, ptr);
96 }
97 
98 static void panelRegister(ARegionType *region_type)
99 {
101 }
102 
104  /* name */ "Softbody",
105  /* structName */ "SoftbodyModifierData",
106  /* structSize */ sizeof(SoftbodyModifierData),
107  /* srna */ &RNA_SoftBodyModifier,
108  /* type */ eModifierTypeType_OnlyDeform,
112  /* icon */ ICON_MOD_SOFT,
113 
114  /* copyData */ NULL,
115 
116  /* deformVerts */ deformVerts,
117  /* deformMatrices */ NULL,
118  /* deformVertsEM */ NULL,
119  /* deformMatricesEM */ NULL,
120  /* modifyMesh */ NULL,
121  /* modifyHair */ NULL,
122  /* modifyGeometrySet */ NULL,
123  /* modifyVolume */ NULL,
124 
125  /* initData */ NULL,
126  /* requiredDataMask */ NULL,
127  /* freeData */ NULL,
128  /* isDisabled */ NULL,
129  /* updateDepsgraph */ updateDepsgraph,
130  /* dependsOnTime */ dependsOnTime,
131  /* dependsOnNormals */ NULL,
132  /* foreachIDLink */ NULL,
133  /* foreachTexLink */ NULL,
134  /* freeRuntimeData */ NULL,
135  /* panelRegister */ panelRegister,
136  /* blendWrite */ NULL,
137  /* blendRead */ NULL,
138 };
@ eModifierTypeFlag_Single
Definition: BKE_modifier.h:107
@ eModifierTypeFlag_UsesPointCache
Definition: BKE_modifier.h:104
@ eModifierTypeFlag_AcceptsCVs
Definition: BKE_modifier.h:81
@ eModifierTypeFlag_AcceptsVertexCosOnly
Definition: BKE_modifier.h:114
@ eModifierTypeFlag_RequiresOriginalData
Definition: BKE_modifier.h:98
@ eModifierTypeType_OnlyDeform
Definition: BKE_modifier.h:58
void sbObjectStep(struct Depsgraph *depsgraph, struct Scene *scene, struct Object *ob, float cfra, float(*vertexCos)[3], int numVerts)
Definition: softbody.c:3538
#define UNUSED(x)
#define IFACE_(msgid)
void DEG_add_modifier_to_transform_relation(struct DepsNodeHandle *node_handle, const char *description)
void DEG_add_collision_relations(struct DepsNodeHandle *handle, struct Object *object, struct Collection *collection, unsigned int modifier_type, DEG_CollobjFilterFunction filter_function, const char *name)
void DEG_add_forcefield_relations(struct DepsNodeHandle *handle, struct Object *object, struct EffectorWeights *eff, bool add_absorption, int skip_forcefield, const char *name)
float DEG_get_ctime(const Depsgraph *graph)
struct Scene * DEG_get_evaluated_scene(const struct Depsgraph *graph)
struct SoftbodyModifierData SoftbodyModifierData
@ eModifierType_Collision
@ eModifierType_Softbody
static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx)
Definition: MOD_softbody.c:70
static void deformVerts(ModifierData *UNUSED(md), const ModifierEvalContext *ctx, Mesh *UNUSED(derivedData), float(*vertexCos)[3], int numVerts)
Definition: MOD_softbody.c:54
static bool dependsOnTime(ModifierData *UNUSED(md))
Definition: MOD_softbody.c:65
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
Definition: MOD_softbody.c:87
static void panelRegister(ARegionType *region_type)
Definition: MOD_softbody.c:98
ModifierTypeInfo modifierType_Softbody
Definition: MOD_softbody.c:103
PointerRNA * modifier_panel_get_property_pointers(Panel *panel, PointerRNA *r_ob_ptr)
void modifier_panel_end(uiLayout *layout, PointerRNA *ptr)
PanelType * modifier_panel_register(ARegionType *region_type, ModifierType type, PanelDrawFn draw)
StructRNA RNA_SoftBodyModifier
#define C
Definition: RandGen.cpp:39
void uiItemL(uiLayout *layout, const char *name, int icon)
Scene scene
struct Depsgraph * depsgraph
Definition: BKE_modifier.h:153
struct Object * object
Definition: BKE_modifier.h:154
struct DepsNodeHandle * node
Definition: BKE_modifier.h:147
struct SoftBody * soft
struct uiLayout * layout
struct Collection * collision_group
struct EffectorWeights * effector_weights
PointerRNA * ptr
Definition: wm_files.c:3157