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) 2004-2005 by Blender Foundation 17 * All rights reserved. 18 */ 19 20 /** \file 21 * \ingroup DNA 22 */ 23 24 #pragma once 25 26 #include "DNA_defs.h" 27 #include "DNA_listBase.h" 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif 32 33 /* pd->forcefield: Effector Fields types */ 34 typedef enum ePFieldType { 35 /** (this is used for general effector weight). */ 36 PFIELD_NULL = 0, 37 /** Force away/towards a point depending on force strength. */ 38 PFIELD_FORCE = 1, 39 /** Force around the effector normal. */ 40 PFIELD_VORTEX = 2, 41 /** Force from the cross product of effector normal and point velocity. */ 42 PFIELD_MAGNET = 3, 43 /** Force away and towards a point depending which side of the effector normal the point is. */ 44 PFIELD_WIND = 4, 45 /** Force along curve for dynamics, a shaping curve for hair paths. */ 46 PFIELD_GUIDE = 5, 47 /** Force based on texture values calculated at point coordinates. */ 48 PFIELD_TEXTURE = 6, 49 /** Force of a harmonic (damped) oscillator. */ 50 PFIELD_HARMONIC = 7, 51 /** Force away/towards a point depending on point charge. */ 52 PFIELD_CHARGE = 8, 53 /** Force due to a Lennard-Jones potential. */ 54 PFIELD_LENNARDJ = 9, 55 /** Defines predator / goal for boids. */ 56 PFIELD_BOID = 10, 57 /** Force defined by BLI_gTurbulence. */ 58 PFIELD_TURBULENCE = 11, 59 /** Linear & quadratic drag. */ 60 PFIELD_DRAG = 12, 61 /** Force based on fluid simulation velocities. */ 62 PFIELD_FLUIDFLOW = 13, 63 64 /* Keep last. */ 65 NUM_PFIELD_TYPES, 66 } ePFieldType; 67 68 typedef struct PartDeflect { 69 /** General settings flag. */ 70 int flag; 71 /** Deflection flag - does mesh deflect particles. */ 72 short deflect; 73 /** Force field type, do the vertices attract / repel particles? */ 74 short forcefield; 75 /** Fall-off type. */ 76 short falloff; 77 /** Point, plane or surface. */ 78 short shape; 79 /** Texture effector. */ 80 short tex_mode; 81 /** For curve guide. */ 82 short kink, kink_axis; 83 short zdir; 84 85 /* Main effector values */ 86 /** The strength of the force (+ or - ). */ 87 float f_strength; 88 /** Damping ratio of the harmonic effector. */ 89 float f_damp; 90 /** 91 * How much force is converted into "air flow", i.e. 92 * force used as the velocity of surrounding medium. */ 93 float f_flow; 94 /** How much force is reduced when acting parallel to a surface, e.g. cloth. */ 95 float f_wind_factor; 96 97 char _pad0[4]; 98 99 /** Noise size for noise effector, restlength for harmonic effector. */ 100 float f_size; 101 102 /* fall-off */ 103 /** The power law - real gravitation is 2 (square). */ 104 float f_power; 105 /** If indicated, use this maximum. */ 106 float maxdist; 107 /** If indicated, use this minimum. */ 108 float mindist; 109 /** Radial fall-off power. */ 110 float f_power_r; 111 /** Radial versions of above. */ 112 float maxrad; 113 float minrad; 114 115 /* particle collisions */ 116 /** Damping factor for particle deflection. */ 117 float pdef_damp; 118 /** Random element of damping for deflection. */ 119 float pdef_rdamp; 120 /** Chance of particle passing through mesh. */ 121 float pdef_perm; 122 /** Friction factor for particle deflection. */ 123 float pdef_frict; 124 /** Random element of friction for deflection. */ 125 float pdef_rfrict; 126 /** Surface particle stickiness. */ 127 float pdef_stickness; 128 129 /** Used for forces. */ 130 float absorption; 131 132 /* softbody collisions */ 133 /** Damping factor for softbody deflection. */ 134 float pdef_sbdamp; 135 /** Inner face thickness for softbody deflection. */ 136 float pdef_sbift; 137 /** Outer face thickness for softbody deflection. */ 138 float pdef_sboft; 139 140 /* guide curve, same as for particle child effects */ 141 float clump_fac, clump_pow; 142 float kink_freq, kink_shape, kink_amp, free_end; 143 144 /* texture effector */ 145 /** Used for calculating partial derivatives. */ 146 float tex_nabla; 147 /** Texture of the texture effector. */ 148 struct Tex *tex; 149 150 /* effector noise */ 151 /** Random noise generator for e.g. wind. */ 152 struct RNG *rng; 153 /** Noise of force. */ 154 float f_noise; 155 /** Noise random seed. */ 156 int seed; 157 158 /* Display Size */ 159 /** Runtime only : start of the curve or draw scale. */ 160 float drawvec1[4]; 161 /** Runtime only : end of the curve. */ 162 float drawvec2[4]; 163 /** Runtime only. */ 164 float drawvec_falloff_min[3]; 165 char _pad1[4]; 166 /** Runtime only. */ 167 float drawvec_falloff_max[3]; 168 char _pad2[4]; 169 170 /** Force source object. */ 171 struct Object *f_source; 172 173 /** Friction of cloth collisions. */ 174 float pdef_cfrict; 175 char _pad[4]; 176 } PartDeflect; 177 178 typedef struct EffectorWeights { 179 /** Only use effectors from this group of objects. */ 180 struct Collection *group; 181 182 /** Effector type specific weights. */ 183 float weight[14]; 184 float global_gravity; 185 short flag, rt[3]; 186 char _pad[4]; 187 } EffectorWeights; 188 189 /* EffectorWeights->flag */ 190 #define EFF_WEIGHT_DO_HAIR 1 191 192 typedef struct SBVertex { 193 float vec[4]; 194 } SBVertex; 195 196 /* Container for data that is shared among CoW copies. 197 * 198 * This is placed in a separate struct so that values can be changed 199 * without having to update all CoW copies. */ 200 typedef struct SoftBody_Shared { 201 struct PointCache *pointcache; 202 struct ListBase ptcaches; 203 } SoftBody_Shared; 204 205 typedef struct SoftBody { 206 /* dynamic data */ 207 int totpoint, totspring; 208 /** Not saved in file. */ 209 struct BodyPoint *bpoint; 210 /** Not saved in file. */ 211 struct BodySpring *bspring; 212 char _pad; 213 char msg_lock; 214 short msg_value; 215 216 /* part of UI: */ 217 218 /* general options */ 219 /** Softbody mass of *vertex*. */ 220 float nodemass; 221 /** 222 * Along with it introduce mass painting 223 * starting to fix old bug .. nastiness that VG are indexes 224 * rather find them by name tag to find it -> jow20090613. 225 * MAX_VGROUP_NAME */ 226 char namedVG_Mass[64]; 227 /** Softbody amount of gravitaion to apply. */ 228 float grav; 229 /** Friction to env. */ 230 float mediafrict; 231 /** Error limit for ODE solver. */ 232 float rklimit; 233 /** User control over simulation speed. */ 234 float physics_speed; 235 236 /* goal */ 237 /** Softbody goal springs. */ 238 float goalspring; 239 /** Softbody goal springs friction. */ 240 float goalfrict; 241 /** Quick limits for goal. */ 242 float mingoal; 243 float maxgoal; 244 /** Default goal for vertices without vgroup. */ 245 float defgoal; 246 /** Index starting at 1. */ 247 short vertgroup; 248 /** 249 * Starting to fix old bug .. nastiness that VG are indexes 250 * rather find them by name tag to find it -> jow20090613. 251 * MAX_VGROUP_NAME */ 252 char namedVG_Softgoal[64]; 253 254 short fuzzyness; 255 256 /* springs */ 257 /** Softbody inner springs. */ 258 float inspring; 259 /** Softbody inner springs friction. */ 260 float infrict; 261 /** 262 * Along with it introduce Spring_K painting 263 * starting to fix old bug .. nastiness that VG are indexes 264 * rather find them by name tag to find it -> jow20090613. 265 * MAX_VGROUP_NAME 266 */ 267 char namedVG_Spring_K[64]; 268 269 /* baking */ 270 int sfra, efra; 271 int interval; 272 /** Local==1: use local coords for baking. */ 273 short local, solverflags; 274 275 /* -- these must be kept for backwards compatibility -- */ 276 /** Array of size totpointkey. */ 277 SBVertex **keys; 278 /** If totpointkey != totpoint or totkey!- (efra-sfra)/interval -> free keys. */ 279 int totpointkey, totkey; 280 /* ---------------------------------------------------- */ 281 float secondspring; 282 283 /* self collision*/ 284 /** Fixed collision ball size if > 0. */ 285 float colball; 286 /** Cooling down collision response. */ 287 float balldamp; 288 /** Pressure the ball is loaded with. */ 289 float ballstiff; 290 short sbc_mode; 291 short aeroedge; 292 short minloops; 293 short maxloops; 294 short choke; 295 short solver_ID; 296 short plastic; 297 short springpreload; 298 299 /** Scratchpad/cache on live time not saved in file. */ 300 struct SBScratch *scratch; 301 float shearstiff; 302 float inpush; 303 304 struct SoftBody_Shared *shared; 305 /** Moved to SoftBody_Shared. */ 306 struct PointCache *pointcache DNA_DEPRECATED; 307 /** Moved to SoftBody_Shared. */ 308 struct ListBase ptcaches DNA_DEPRECATED; 309 310 struct Collection *collision_group; 311 312 struct EffectorWeights *effector_weights; 313 /* reverse esimated obmatrix .. no need to store in blend file .. how ever who cares */ 314 float lcom[3]; 315 float lrot[3][3]; 316 float lscale[3][3]; 317 318 int last_frame; 319 } SoftBody; 320 321 /* pd->flag: various settings */ 322 #define PFIELD_USEMAX (1 << 0) 323 /*#define PDEFLE_DEFORM (1 << 1)*/ /*UNUSED*/ 324 /** TODO: do_versions for below */ 325 #define PFIELD_GUIDE_PATH_ADD (1 << 2) 326 /** used for do_versions */ 327 #define PFIELD_PLANAR (1 << 3) 328 #define PDEFLE_KILL_PART (1 << 4) 329 /** used for do_versions */ 330 #define PFIELD_POSZ (1 << 5) 331 #define PFIELD_TEX_OBJECT (1 << 6) 332 /** used for turbulence */ 333 #define PFIELD_GLOBAL_CO (1 << 6) 334 #define PFIELD_TEX_2D (1 << 7) 335 /** used for harmonic force */ 336 #define PFIELD_MULTIPLE_SPRINGS (1 << 7) 337 #define PFIELD_USEMIN (1 << 8) 338 #define PFIELD_USEMAXR (1 << 9) 339 #define PFIELD_USEMINR (1 << 10) 340 #define PFIELD_TEX_ROOTCO (1 << 11) 341 /** used for do_versions */ 342 #define PFIELD_SURFACE (1 << 12) 343 #define PFIELD_VISIBILITY (1 << 13) 344 #define PFIELD_DO_LOCATION (1 << 14) 345 #define PFIELD_DO_ROTATION (1 << 15) 346 /** apply curve weights */ 347 #define PFIELD_GUIDE_PATH_WEIGHT (1 << 16) 348 /** multiply smoke force by density */ 349 #define PFIELD_SMOKE_DENSITY (1 << 17) 350 /** used for (simple) force */ 351 #define PFIELD_GRAVITATION (1 << 18) 352 /** Enable cloth collision side detection based on normal. */ 353 #define PFIELD_CLOTH_USE_CULLING (1 << 19) 354 /** Replace collision direction with collider normal. */ 355 #define PFIELD_CLOTH_USE_NORMAL (1 << 20) 356 357 /* pd->falloff */ 358 #define PFIELD_FALL_SPHERE 0 359 #define PFIELD_FALL_TUBE 1 360 #define PFIELD_FALL_CONE 2 361 362 /* pd->shape */ 363 #define PFIELD_SHAPE_POINT 0 364 #define PFIELD_SHAPE_PLANE 1 365 #define PFIELD_SHAPE_SURFACE 2 366 #define PFIELD_SHAPE_POINTS 3 367 #define PFIELD_SHAPE_LINE 4 368 369 /* pd->tex_mode */ 370 #define PFIELD_TEX_RGB 0 371 #define PFIELD_TEX_GRAD 1 372 #define PFIELD_TEX_CURL 2 373 374 /* pd->zdir */ 375 #define PFIELD_Z_BOTH 0 376 #define PFIELD_Z_POS 1 377 #define PFIELD_Z_NEG 2 378 379 /* ob->softflag */ 380 #define OB_SB_ENABLE 1 /* deprecated, use modifier */ 381 #define OB_SB_GOAL 2 382 #define OB_SB_EDGES 4 383 #define OB_SB_QUADS 8 384 #define OB_SB_POSTDEF 16 385 // #define OB_SB_REDO 32 386 // #define OB_SB_BAKESET 64 387 // #define OB_SB_BAKEDO 128 388 // #define OB_SB_RESET 256 389 #define OB_SB_SELF 512 390 #define OB_SB_FACECOLL 1024 391 #define OB_SB_EDGECOLL 2048 392 /* #define OB_SB_COLLFINAL 4096 */ /* deprecated */ 393 /* #define OB_SB_BIG_UI 8192 */ /* deprecated */ 394 #define OB_SB_AERO_ANGLE 16384 395 396 /* sb->solverflags */ 397 #define SBSO_MONITOR 1 398 #define SBSO_OLDERR 2 399 #define SBSO_ESTIMATEIPO 4 400 401 /* sb->sbc_mode */ 402 #define SBC_MODE_MANUAL 0 403 #define SBC_MODE_AVG 1 404 #define SBC_MODE_MIN 2 405 #define SBC_MODE_MAX 3 406 #define SBC_MODE_AVGMINMAX 4 407 408 #ifdef __cplusplus 409 } 410 #endif 411