|
Blender
V2.59
|
00001 /* 00002 * 00003 * $Id: DNA_object_force.h 38235 2011-07-08 13:22:58Z blendix $ 00004 * 00005 * ***** BEGIN GPL LICENSE BLOCK ***** 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software Foundation, 00019 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 * The Original Code is Copyright (C) 2004-2005 by Blender Foundation 00022 * All rights reserved. 00023 * 00024 * The Original Code is: all of this file. 00025 * 00026 * Contributor(s): none yet. 00027 * 00028 * ***** END GPL LICENSE BLOCK ***** 00029 */ 00030 #ifndef DNA_OBJECT_FORCE_H 00031 #define DNA_OBJECT_FORCE_H 00032 00037 #ifdef __cplusplus 00038 extern "C" { 00039 #endif 00040 00041 #include "DNA_listBase.h" 00042 00043 /* pd->forcefield: Effector Fields types */ 00044 typedef enum PFieldType { 00045 PFIELD_NULL = 0, /* (this is used for general effector weight) */ 00046 PFIELD_FORCE, /* Force away/towards a point depending on force strength */ 00047 PFIELD_VORTEX, /* Force around the effector normal */ 00048 PFIELD_MAGNET, /* Force from the cross product of effector normal and point velocity */ 00049 PFIELD_WIND, /* Force away and towards a point depending which side of the effector */ 00050 /* normal the point is */ 00051 PFIELD_GUIDE, /* Force along curve for dynamics, a shaping curve for hair paths */ 00052 PFIELD_TEXTURE, /* Force based on texture values calculated at point coordinates */ 00053 PFIELD_HARMONIC, /* Force of a harmonic (damped) oscillator */ 00054 PFIELD_CHARGE, /* Force away/towards a point depending on point charge */ 00055 PFIELD_LENNARDJ, /* Force due to a Lennard-Jones potential */ 00056 PFIELD_BOID, /* Defines predator / goal for boids */ 00057 PFIELD_TURBULENCE, /* Force defined by BLI_gTurbulence */ 00058 PFIELD_DRAG, /* Linear & quadratic drag */ 00059 NUM_PFIELD_TYPES 00060 } PFieldType; 00061 00062 typedef struct PartDeflect { 00063 int flag; /* general settings flag */ 00064 short deflect; /* Deflection flag - does mesh deflect particles */ 00065 short forcefield; /* Force field type, do the vertices attract / repel particles? */ 00066 short falloff; /* fall-off type */ 00067 short shape; /* point, plane or surface */ 00068 short tex_mode; /* texture effector */ 00069 short kink, kink_axis; /* for curve guide */ 00070 short zdir; 00071 00072 /* Main effector values */ 00073 float f_strength; /* The strength of the force (+ or - ) */ 00074 float f_damp; /* Damping ratio of the harmonic effector. */ 00075 float f_flow; /* How much force is converted into "air flow", i.e. */ 00076 /* force used as the velocity of surrounding medium. */ 00077 00078 float f_size; /* Noise size for noise effector, restlength for harmonic effector */ 00079 00080 /* fall-off */ 00081 float f_power; /* The power law - real gravitation is 2 (square) */ 00082 float maxdist; /* if indicated, use this maximum */ 00083 float mindist; /* if indicated, use this minimum */ 00084 float f_power_r; /* radial fall-off power */ 00085 float maxrad; /* radial versions of above */ 00086 float minrad; 00087 00088 /* particle collisions */ 00089 float pdef_damp; /* Damping factor for particle deflection */ 00090 float pdef_rdamp; /* Random element of damping for deflection */ 00091 float pdef_perm; /* Chance of particle passing through mesh */ 00092 float pdef_frict; /* Friction factor for particle deflection */ 00093 float pdef_rfrict; /* Random element of friction for deflection */ 00094 float pdef_stickness;/* surface particle stickness */ 00095 00096 float absorption; /* used for forces */ 00097 00098 /* softbody collisions */ 00099 float pdef_sbdamp; /* Damping factor for softbody deflection */ 00100 float pdef_sbift; /* inner face thickness for softbody deflection */ 00101 float pdef_sboft; /* outer face thickness for softbody deflection */ 00102 00103 /* guide curve, same as for particle child effects */ 00104 float clump_fac, clump_pow; 00105 float kink_freq, kink_shape, kink_amp, free_end; 00106 00107 /* texture effector */ 00108 float tex_nabla; /* Used for calculating partial derivatives */ 00109 struct Tex *tex; /* Texture of the texture effector */ 00110 00111 /* effector noise */ 00112 struct RNG *rng; /* random noise generator for e.g. wind */ 00113 float f_noise; /* noise of force */ 00114 int seed; /* noise random seed */ 00115 } PartDeflect; 00116 00117 typedef struct EffectorWeights { 00118 struct Group *group; /* only use effectors from this group of objects */ 00119 00120 float weight[13]; /* effector type specific weights */ 00121 float global_gravity; 00122 short flag, rt[3]; 00123 } EffectorWeights; 00124 00125 /* EffectorWeights->flag */ 00126 #define EFF_WEIGHT_DO_HAIR 1 00127 00128 /* Point cache file data types: 00129 * - used as (1<<flag) so poke jahka if you reach the limit of 15 00130 * - to add new data types update: 00131 * * BKE_ptcache_data_size() 00132 * * ptcache_file_init_pointers() 00133 */ 00134 #define BPHYS_DATA_INDEX 0 00135 #define BPHYS_DATA_LOCATION 1 00136 #define BPHYS_DATA_SMOKE_LOW 1 00137 #define BPHYS_DATA_VELOCITY 2 00138 #define BPHYS_DATA_SMOKE_HIGH 2 00139 #define BPHYS_DATA_ROTATION 3 00140 #define BPHYS_DATA_AVELOCITY 4 /* used for particles */ 00141 #define BPHYS_DATA_XCONST 4 /* used for cloth */ 00142 #define BPHYS_DATA_SIZE 5 00143 #define BPHYS_DATA_TIMES 6 00144 #define BPHYS_DATA_BOIDS 7 00145 00146 #define BPHYS_TOT_DATA 8 00147 00148 #define BPHYS_EXTRA_FLUID_SPRINGS 1 00149 00150 typedef struct PTCacheExtra { 00151 struct PTCacheExtra *next, *prev; 00152 unsigned int type, totdata; 00153 void *data; 00154 } PTCacheExtra; 00155 00156 typedef struct PTCacheMem { 00157 struct PTCacheMem *next, *prev; 00158 unsigned int frame, totpoint; 00159 unsigned int data_types, flag; 00160 00161 void *data[8]; /* BPHYS_TOT_DATA */ 00162 void *cur[8]; /* BPHYS_TOT_DATA */ 00163 00164 struct ListBase extradata; 00165 } PTCacheMem; 00166 00167 typedef struct PointCache { 00168 struct PointCache *next, *prev; 00169 int flag; /* generic flag */ 00170 00171 int step; /* The number of frames between cached frames. 00172 * This should probably be an upper bound for a per point adaptive step in the future, 00173 * buf for now it's the same for all points. Without adaptivity this can effect the perceived 00174 * simulation quite a bit though. If for example particles are colliding with a horizontal 00175 * plane (with high damping) they quickly come to a stop on the plane, however there are still 00176 * forces acting on the particle (gravity and collisions), so the particle velocity isn't necessarily 00177 * zero for the whole duration of the frame even if the particle seems stationary. If all simulation 00178 * frames aren't cached (step > 1) these velocities are interpolated into movement for the non-cached 00179 * frames. The result will look like the point is oscillating around the collision location. So for 00180 * now cache step should be set to 1 for accurate reproduction of collisions. 00181 */ 00182 00183 int simframe; /* current frame of simulation (only if SIMULATION_VALID) */ 00184 int startframe; /* simulation start frame */ 00185 int endframe; /* simulation end frame */ 00186 int editframe; /* frame being edited (runtime only) */ 00187 int last_exact; /* last exact frame that's cached */ 00188 00189 /* for external cache files */ 00190 int totpoint; /* number of cached points */ 00191 int index; /* modifier stack index */ 00192 short compression, rt; 00193 00194 char name[64]; 00195 char prev_name[64]; 00196 char info[64]; 00197 char path[240]; /* file path */ 00198 char *cached_frames; /* array of length endframe-startframe+1 with flags to indicate cached frames */ 00199 /* can be later used for other per frame flags too if needed */ 00200 struct ListBase mem_cache; 00201 00202 struct PTCacheEdit *edit; 00203 void (*free_edit)(struct PTCacheEdit *edit); /* free callback */ 00204 } PointCache; 00205 00206 typedef struct SBVertex { 00207 float vec[4]; 00208 } SBVertex; 00209 00210 typedef struct BulletSoftBody { 00211 int flag; /* various boolean options */ 00212 float linStiff; /* linear stiffness 0..1 */ 00213 float angStiff; /* angular stiffness 0..1 */ 00214 float volume; /* volume preservation 0..1 */ 00215 00216 int viterations; /* Velocities solver iterations */ 00217 int piterations; /* Positions solver iterations */ 00218 int diterations; /* Drift solver iterations */ 00219 int citerations; /* Cluster solver iterations */ 00220 00221 float kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */ 00222 float kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */ 00223 float kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */ 00224 float kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ 00225 00226 float kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ 00227 float kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */ 00228 float kVCF; /* Velocities correction factor (Baumgarte) */ 00229 float kDP; /* Damping coefficient [0,1] */ 00230 00231 float kDG; /* Drag coefficient [0,+inf] */ 00232 float kLF; /* Lift coefficient [0,+inf] */ 00233 float kPR; /* Pressure coefficient [-inf,+inf] */ 00234 float kVC; /* Volume conversation coefficient [0,+inf] */ 00235 00236 float kDF; /* Dynamic friction coefficient [0,1] */ 00237 float kMT; /* Pose matching coefficient [0,1] */ 00238 float kCHR; /* Rigid contacts hardness [0,1] */ 00239 float kKHR; /* Kinetic contacts hardness [0,1] */ 00240 00241 float kSHR; /* Soft contacts hardness [0,1] */ 00242 float kAHR; /* Anchors hardness [0,1] */ 00243 int collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */ 00244 int numclusteriterations; /* number of iterations to refine collision clusters*/ 00245 float welding; /* welding limit to remove duplicate/nearby vertices, 0.0..0.01 */ 00246 float margin; /* margin specific to softbody */ 00247 } BulletSoftBody; 00248 00249 /* BulletSoftBody.flag */ 00250 #define OB_BSB_SHAPE_MATCHING 2 00251 #define OB_BSB_UNUSED 4 00252 #define OB_BSB_BENDING_CONSTRAINTS 8 00253 #define OB_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/ 00254 #define OB_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */ 00255 00256 /* BulletSoftBody.collisionflags */ 00257 #define OB_BSB_COL_SDF_RS 2 /* SDF based rigid vs soft */ 00258 #define OB_BSB_COL_CL_RS 4 /* Cluster based rigid vs soft */ 00259 #define OB_BSB_COL_CL_SS 8 /* Cluster based soft vs soft */ 00260 #define OB_BSB_COL_VF_SS 16 /* Vertex/Face based soft vs soft */ 00261 00262 00263 typedef struct SoftBody { 00264 /* dynamic data */ 00265 int totpoint, totspring; 00266 struct BodyPoint *bpoint; /* not saved in file */ 00267 struct BodySpring *bspring; /* not saved in file */ 00268 char pad; 00269 char msg_lock; 00270 short msg_value; 00271 00272 /* part of UI: */ 00273 00274 /* general options */ 00275 float nodemass; /* softbody mass of *vertex* */ 00276 char namedVG_Mass[32]; /* along with it introduce mass painting 00277 starting to fix old bug .. nastyness that VG are indexes 00278 rather find them by name tag to find it -> jow20090613 */ 00279 float grav; /* softbody amount of gravitaion to apply */ 00280 float mediafrict; /* friction to env */ 00281 float rklimit; /* error limit for ODE solver */ 00282 float physics_speed;/* user control over simulation speed */ 00283 00284 /* goal */ 00285 float goalspring; /* softbody goal springs */ 00286 float goalfrict; /* softbody goal springs friction */ 00287 float mingoal; /* quick limits for goal */ 00288 float maxgoal; 00289 float defgoal; /* default goal for vertices without vgroup */ 00290 short vertgroup; /* index starting at 1 */ 00291 char namedVG_Softgoal[32]; /* starting to fix old bug .. nastyness that VG are indexes 00292 rather find them by name tag to find it -> jow20090613 */ 00293 00294 short fuzzyness; /* */ 00295 00296 /* springs */ 00297 float inspring; /* softbody inner springs */ 00298 float infrict; /* softbody inner springs friction */ 00299 char namedVG_Spring_K[32]; /* along with it introduce Spring_K painting 00300 starting to fix old bug .. nastyness that VG are indexes 00301 rather find them by name tag to find it -> jow20090613 */ 00302 00303 /* baking */ 00304 int sfra, efra; 00305 int interval; 00306 short local, solverflags; /* local==1: use local coords for baking */ 00307 00308 /* -- these must be kept for backwards compatibility -- */ 00309 SBVertex **keys; /* array of size totpointkey */ 00310 int totpointkey, totkey; /* if totpointkey != totpoint or totkey!- (efra-sfra)/interval -> free keys */ 00311 /* ---------------------------------------------------- */ 00312 float secondspring; 00313 00314 /* self collision*/ 00315 float colball; /* fixed collision ball size if > 0 */ 00316 float balldamp; /* cooling down collision response */ 00317 float ballstiff; /* pressure the ball is loaded with */ 00318 short sbc_mode; 00319 short aeroedge, 00320 minloops, 00321 maxloops, 00322 choke, 00323 solver_ID, 00324 plastic,springpreload 00325 ; 00326 00327 struct SBScratch *scratch; /* scratch pad/cache on live time not saved in file */ 00328 float shearstiff; 00329 float inpush; 00330 00331 struct PointCache *pointcache; 00332 struct ListBase ptcaches; 00333 00334 struct EffectorWeights *effector_weights; 00335 /* reverse esimated obmatrix .. no need to store in blend file .. how ever who cares */ 00336 float lcom[3]; 00337 float lrot[3][3]; 00338 float lscale[3][3]; 00339 char pad4[4]; 00340 00341 } SoftBody; 00342 00343 00344 /* pd->flag: various settings */ 00345 #define PFIELD_USEMAX 1 00346 /*#define PDEFLE_DEFORM 2*/ /*UNUSED*/ 00347 #define PFIELD_GUIDE_PATH_ADD 4 /* TODO: do_versions for below */ 00348 #define PFIELD_PLANAR 8 /* used for do_versions */ 00349 #define PDEFLE_KILL_PART 16 00350 #define PFIELD_POSZ 32 /* used for do_versions */ 00351 #define PFIELD_TEX_OBJECT 64 00352 #define PFIELD_GLOBAL_CO 64 /* used for turbulence */ 00353 #define PFIELD_TEX_2D 128 00354 #define PFIELD_MULTIPLE_SPRINGS 128 /* used for harmonic force */ 00355 #define PFIELD_USEMIN 256 00356 #define PFIELD_USEMAXR 512 00357 #define PFIELD_USEMINR 1024 00358 #define PFIELD_TEX_ROOTCO 2048 00359 #define PFIELD_SURFACE (1<<12) /* used for do_versions */ 00360 #define PFIELD_VISIBILITY (1<<13) 00361 #define PFIELD_DO_LOCATION (1<<14) 00362 #define PFIELD_DO_ROTATION (1<<15) 00363 #define PFIELD_GUIDE_PATH_WEIGHT (1<<16) /* apply curve weights */ 00364 00365 /* pd->falloff */ 00366 #define PFIELD_FALL_SPHERE 0 00367 #define PFIELD_FALL_TUBE 1 00368 #define PFIELD_FALL_CONE 2 00369 00370 /* pd->shape */ 00371 #define PFIELD_SHAPE_POINT 0 00372 #define PFIELD_SHAPE_PLANE 1 00373 #define PFIELD_SHAPE_SURFACE 2 00374 #define PFIELD_SHAPE_POINTS 3 00375 00376 /* pd->tex_mode */ 00377 #define PFIELD_TEX_RGB 0 00378 #define PFIELD_TEX_GRAD 1 00379 #define PFIELD_TEX_CURL 2 00380 00381 /* pd->zdir */ 00382 #define PFIELD_Z_BOTH 0 00383 #define PFIELD_Z_POS 1 00384 #define PFIELD_Z_NEG 2 00385 00386 /* pointcache->flag */ 00387 #define PTCACHE_BAKED 1 00388 #define PTCACHE_OUTDATED 2 00389 #define PTCACHE_SIMULATION_VALID 4 00390 #define PTCACHE_BAKING 8 00391 //#define PTCACHE_BAKE_EDIT 16 00392 //#define PTCACHE_BAKE_EDIT_ACTIVE 32 00393 #define PTCACHE_DISK_CACHE 64 00394 #define PTCACHE_QUICK_CACHE 128 00395 #define PTCACHE_FRAMES_SKIPPED 256 00396 #define PTCACHE_EXTERNAL 512 00397 #define PTCACHE_READ_INFO 1024 00398 /* dont use the filename of the blendfile the data is linked from (write a local cache) */ 00399 #define PTCACHE_IGNORE_LIBPATH 2048 00400 /* high resolution cache is saved for smoke for backwards compatibility, so set this flag to know it's a "fake" cache */ 00401 #define PTCACHE_FAKE_SMOKE (1<<12) 00402 00403 /* PTCACHE_OUTDATED + PTCACHE_FRAMES_SKIPPED */ 00404 #define PTCACHE_REDO_NEEDED 258 00405 00406 #define PTCACHE_COMPRESS_NO 0 00407 #define PTCACHE_COMPRESS_LZO 1 00408 #define PTCACHE_COMPRESS_LZMA 2 00409 00410 /* ob->softflag */ 00411 #define OB_SB_ENABLE 1 /* deprecated, use modifier */ 00412 #define OB_SB_GOAL 2 00413 #define OB_SB_EDGES 4 00414 #define OB_SB_QUADS 8 00415 #define OB_SB_POSTDEF 16 00416 // #define OB_SB_REDO 32 00417 // #define OB_SB_BAKESET 64 00418 // #define OB_SB_BAKEDO 128 00419 // #define OB_SB_RESET 256 00420 #define OB_SB_SELF 512 00421 #define OB_SB_FACECOLL 1024 00422 #define OB_SB_EDGECOLL 2048 00423 #define OB_SB_COLLFINAL 4096 /* deprecated */ 00424 #define OB_SB_BIG_UI 8192 00425 #define OB_SB_AERO_ANGLE 16384 00426 00427 /* sb->solverflags */ 00428 #define SBSO_MONITOR 1 00429 #define SBSO_OLDERR 2 00430 #define SBSO_ESTIMATEIPO 4 00431 00432 /* sb->sbc_mode */ 00433 #define SBC_MODE_MANUAL 0 00434 #define SBC_MODE_AVG 1 00435 #define SBC_MODE_MIN 2 00436 #define SBC_MODE_MAX 3 00437 #define SBC_MODE_AVGMINMAX 4 00438 00439 #ifdef __cplusplus 00440 } 00441 #endif 00442 00443 #endif 00444