|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_fluidsim.c 37441 2011-06-12 23:51:30Z genscher $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributor(s): Blender Foundation (2008). 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include <stdlib.h> 00031 00032 #include "RNA_define.h" 00033 00034 #include "rna_internal.h" 00035 00036 #include "DNA_object_fluidsim.h" 00037 00038 #include "WM_api.h" 00039 #include "WM_types.h" 00040 00041 #ifdef RNA_RUNTIME 00042 00043 #include "MEM_guardedalloc.h" 00044 00045 #include "DNA_scene_types.h" 00046 #include "DNA_particle_types.h" 00047 00048 #include "BKE_depsgraph.h" 00049 #include "BKE_fluidsim.h" 00050 #include "BKE_global.h" 00051 #include "BKE_main.h" 00052 #include "BKE_modifier.h" 00053 #include "BKE_particle.h" 00054 #include "BKE_pointcache.h" 00055 00056 static StructRNA* rna_FluidSettings_refine(struct PointerRNA *ptr) 00057 { 00058 FluidsimSettings *fss= (FluidsimSettings*)ptr->data; 00059 00060 switch(fss->type) { 00061 case OB_FLUIDSIM_DOMAIN: 00062 return &RNA_DomainFluidSettings; 00063 case OB_FLUIDSIM_FLUID: 00064 return &RNA_FluidFluidSettings; 00065 case OB_FLUIDSIM_OBSTACLE: 00066 return &RNA_ObstacleFluidSettings; 00067 case OB_FLUIDSIM_INFLOW: 00068 return &RNA_InflowFluidSettings; 00069 case OB_FLUIDSIM_OUTFLOW: 00070 return &RNA_OutflowFluidSettings; 00071 case OB_FLUIDSIM_PARTICLE: 00072 return &RNA_ParticleFluidSettings; 00073 case OB_FLUIDSIM_CONTROL: 00074 return &RNA_ControlFluidSettings; 00075 default: 00076 return &RNA_FluidSettings; 00077 } 00078 } 00079 00080 static void rna_fluid_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00081 { 00082 Object *ob= ptr->id.data; 00083 00084 DAG_id_tag_update(&ob->id, OB_RECALC_DATA); 00085 WM_main_add_notifier(NC_OBJECT|ND_MODIFIER, ob); 00086 } 00087 00088 static int fluidsim_find_lastframe(FluidsimSettings *fss) 00089 { 00090 char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR]; 00091 int curFrame = 1; 00092 00093 BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath); 00094 BLI_path_abs(targetDir, G.main->name); 00095 00096 do { 00097 BLI_strncpy(targetFile, targetDir, sizeof(targetFile)); 00098 BLI_path_frame(targetFile, curFrame++, 0); 00099 } while(BLI_exist(targetFile)); 00100 00101 return curFrame - 1; 00102 } 00103 00104 static void rna_fluid_find_enframe(Main *bmain, Scene *scene, PointerRNA *ptr) 00105 { 00106 Object *ob= ptr->id.data; 00107 FluidsimModifierData *fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim); 00108 00109 if(fluidmd->fss->flag & OB_FLUIDSIM_REVERSE) { 00110 fluidmd->fss->lastgoodframe = fluidsim_find_lastframe(fluidmd->fss); 00111 } 00112 else { 00113 fluidmd->fss->lastgoodframe = -1; 00114 } 00115 rna_fluid_update(bmain, scene, ptr); 00116 } 00117 00118 static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA *ptr) 00119 { 00120 Object *ob= (Object*)ptr->id.data; 00121 FluidsimModifierData *fluidmd; 00122 ParticleSystemModifierData *psmd; 00123 ParticleSystem *psys; 00124 ParticleSettings *part; 00125 00126 fluidmd= (FluidsimModifierData*)modifiers_findByType(ob, eModifierType_Fluidsim); 00127 fluidmd->fss->flag &= ~OB_FLUIDSIM_REVERSE; // clear flag 00128 00129 /* remove fluidsim particle system */ 00130 if(fluidmd->fss->type & OB_FLUIDSIM_PARTICLE) { 00131 for(psys=ob->particlesystem.first; psys; psys=psys->next) 00132 if(psys->part->type == PART_FLUID) 00133 break; 00134 00135 if(ob->type == OB_MESH && !psys) { 00136 /* add particle system */ 00137 part= psys_new_settings("ParticleSettings", bmain); 00138 psys= MEM_callocN(sizeof(ParticleSystem), "particle_system"); 00139 00140 part->type= PART_FLUID; 00141 psys->part= part; 00142 psys->pointcache= BKE_ptcache_add(&psys->ptcaches); 00143 psys->flag |= PSYS_ENABLED; 00144 sprintf(psys->name, "FluidParticles"); 00145 BLI_addtail(&ob->particlesystem,psys); 00146 00147 /* add modifier */ 00148 psmd= (ParticleSystemModifierData*)modifier_new(eModifierType_ParticleSystem); 00149 sprintf(psmd->modifier.name, "FluidParticleSystem" ); 00150 psmd->psys= psys; 00151 BLI_addtail(&ob->modifiers, psmd); 00152 modifier_unique_name(&ob->modifiers, (ModifierData *)psmd); 00153 } 00154 } 00155 else { 00156 for(psys=ob->particlesystem.first; psys; psys=psys->next) { 00157 if(psys->part->type == PART_FLUID) { 00158 /* clear modifier */ 00159 psmd= psys_get_modifier(ob, psys); 00160 BLI_remlink(&ob->modifiers, psmd); 00161 modifier_free((ModifierData *)psmd); 00162 00163 /* clear particle system */ 00164 BLI_remlink(&ob->particlesystem, psys); 00165 psys_free(ob, psys); 00166 } 00167 } 00168 } 00169 00170 rna_fluid_update(bmain, scene, ptr); 00171 } 00172 00173 static void rna_DomainFluidSettings_memory_estimate_get(PointerRNA *ptr, char *value) 00174 { 00175 #ifdef DISABLE_ELBEEM 00176 value[0]= '\0'; 00177 #else 00178 Object *ob= (Object*)ptr->id.data; 00179 FluidsimSettings *fss= (FluidsimSettings*)ptr->data; 00180 00181 fluid_estimate_memory(ob, fss, value); 00182 #endif 00183 } 00184 00185 static int rna_DomainFluidSettings_memory_estimate_length(PointerRNA *ptr) 00186 { 00187 return 32; 00188 } 00189 00190 static char *rna_FluidSettings_path(PointerRNA *ptr) 00191 { 00192 FluidsimSettings *fss = (FluidsimSettings*)ptr->data; 00193 ModifierData *md= (ModifierData *)fss->fmd; 00194 00195 return BLI_sprintfN("modifiers[\"%s\"].settings", md->name); 00196 } 00197 00198 static void rna_FluidMeshVertex_data_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) 00199 { 00200 FluidsimSettings *fss = (FluidsimSettings*)ptr->data; 00201 rna_iterator_array_begin(iter, fss->meshVelocities, sizeof(float)*3, fss->totvert, 0, NULL); 00202 } 00203 00204 static int rna_FluidMeshVertex_data_length(PointerRNA *ptr) 00205 { 00206 FluidsimSettings *fss = (FluidsimSettings*)ptr->data; 00207 return fss->totvert; 00208 } 00209 00210 #else 00211 00212 static void rna_def_fluidsim_slip(StructRNA *srna) 00213 { 00214 PropertyRNA *prop; 00215 00216 static EnumPropertyItem slip_items[] = { 00217 {OB_FSBND_NOSLIP, "NOSLIP", 0, "No Slip", "Obstacle causes zero normal and tangential velocity (=sticky). Default for all. Only option for moving objects"}, 00218 {OB_FSBND_PARTSLIP, "PARTIALSLIP", 0, "Partial Slip", "Mix between no-slip and free-slip. Non moving objects only!"}, 00219 {OB_FSBND_FREESLIP, "FREESLIP", 0, "Free Slip", "Obstacle only causes zero normal velocity (=not sticky). Non moving objects only!"}, 00220 {0, NULL, 0, NULL, NULL}}; 00221 00222 prop= RNA_def_property(srna, "slip_type", PROP_ENUM, PROP_NONE); 00223 RNA_def_property_enum_bitflag_sdna(prop, NULL, "typeFlags"); 00224 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00225 RNA_def_property_enum_items(prop, slip_items); 00226 RNA_def_property_ui_text(prop, "Slip Type", ""); 00227 00228 prop= RNA_def_property(srna, "partial_slip_factor", PROP_FLOAT, PROP_NONE); 00229 RNA_def_property_float_sdna(prop, NULL, "partSlipValue"); 00230 RNA_def_property_range(prop, 0.0f, 1.0f); 00231 RNA_def_property_ui_text(prop, "Partial Slip Amount", "Amount of mixing between no- and free-slip, 0 is no slip and 1 is free slip"); 00232 } 00233 00234 static void rna_def_fluid_mesh_vertices(BlenderRNA *brna) 00235 { 00236 StructRNA *srna; 00237 PropertyRNA *prop; 00238 00239 srna= RNA_def_struct(brna, "FluidMeshVertex", NULL); 00240 RNA_def_struct_sdna(srna, "FluidVertexVelocity"); 00241 RNA_def_struct_ui_text(srna, "Fluid Mesh Vertex", "Vertex of a simulated fluid mesh"); 00242 RNA_def_struct_ui_icon(srna, ICON_VERTEXSEL); 00243 00244 prop= RNA_def_property(srna, "velocity", PROP_FLOAT, PROP_VELOCITY); 00245 RNA_def_property_array(prop, 3); 00246 RNA_def_property_float_sdna(prop, NULL, "vel"); 00247 RNA_def_property_ui_text(prop, "Velocity", ""); 00248 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00249 } 00250 00251 00252 static void rna_def_fluidsim_domain(BlenderRNA *brna) 00253 { 00254 StructRNA *srna; 00255 PropertyRNA *prop; 00256 00257 static EnumPropertyItem quality_items[] = { 00258 {OB_FSDOM_GEOM, "GEOMETRY", 0, "Geometry", "Display geometry"}, 00259 {OB_FSDOM_PREVIEW, "PREVIEW", 0, "Preview", "Display preview quality results"}, 00260 {OB_FSDOM_FINAL, "FINAL", 0, "Final", "Display final quality results"}, 00261 {0, NULL, 0, NULL, NULL}}; 00262 00263 static EnumPropertyItem viscosity_items[] = { 00264 {1, "MANUAL", 0, "Manual", "Manual viscosity settings"}, 00265 {2, "WATER", 0, "Water", "Viscosity of 1.0 * 10^-6"}, 00266 {3, "OIL", 0, "Oil", "Viscosity of 5.0 * 10^-5"}, 00267 {4, "HONEY", 0, "Honey", "Viscosity of 2.0 * 10^-3"}, 00268 {0, NULL, 0, NULL, NULL}}; 00269 00270 srna= RNA_def_struct(brna, "DomainFluidSettings", "FluidSettings"); 00271 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00272 RNA_def_struct_ui_text(srna, "Domain Fluid Simulation Settings", "Fluid simulation settings for the domain of a fluid simulation"); 00273 00274 /* standard settings */ 00275 00276 prop= RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE); 00277 RNA_def_property_int_sdna(prop, NULL, "resolutionxyz"); 00278 RNA_def_property_range(prop, 1, 1024); 00279 RNA_def_property_ui_text(prop, "Resolution", "Domain resolution in X,Y and Z direction"); 00280 00281 prop= RNA_def_property(srna, "preview_resolution", PROP_INT, PROP_NONE); 00282 RNA_def_property_int_sdna(prop, NULL, "previewresxyz"); 00283 RNA_def_property_range(prop, 1, 100); 00284 RNA_def_property_ui_text(prop, "Preview Resolution", "Preview resolution in X,Y and Z direction"); 00285 00286 prop= RNA_def_property(srna, "viewport_display_mode", PROP_ENUM, PROP_NONE); 00287 RNA_def_property_enum_sdna(prop, NULL, "guiDisplayMode"); 00288 RNA_def_property_enum_items(prop, quality_items); 00289 RNA_def_property_ui_text(prop, "Viewport Display Mode", "How to display the mesh in the viewport"); 00290 RNA_def_property_update(prop, 0, "rna_fluid_update"); 00291 00292 prop= RNA_def_property(srna, "render_display_mode", PROP_ENUM, PROP_NONE); 00293 RNA_def_property_enum_sdna(prop, NULL, "renderDisplayMode"); 00294 RNA_def_property_enum_items(prop, quality_items); 00295 RNA_def_property_ui_text(prop, "Render Display Mode", "How to display the mesh for rendering"); 00296 00297 prop= RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); 00298 RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); 00299 RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse fluid frames"); 00300 RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); 00301 00302 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00303 RNA_def_property_string_maxlength(prop, 240); 00304 RNA_def_property_string_sdna(prop, NULL, "surfdataPath"); 00305 RNA_def_property_ui_text(prop, "Path", "Directory (and/or filename prefix) to store baked fluid simulation files in"); 00306 RNA_def_property_update(prop, 0, "rna_fluid_update"); 00307 00308 prop= RNA_def_property(srna, "memory_estimate", PROP_STRING, PROP_NONE); 00309 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00310 RNA_def_property_string_funcs(prop, "rna_DomainFluidSettings_memory_estimate_get", "rna_DomainFluidSettings_memory_estimate_length", NULL); 00311 RNA_def_property_ui_text(prop, "Memory Estimate", "Estimated amount of memory needed for baking the domain"); 00312 00313 /* advanced settings */ 00314 prop= RNA_def_property(srna, "gravity", PROP_FLOAT, PROP_ACCELERATION); 00315 RNA_def_property_float_sdna(prop, NULL, "grav"); 00316 RNA_def_property_array(prop, 3); 00317 RNA_def_property_range(prop, -1000.1, 1000.1); 00318 RNA_def_property_ui_text(prop, "Gravity", "Gravity in X, Y and Z direction"); 00319 00320 prop= RNA_def_property(srna, "use_time_override", PROP_BOOLEAN, PROP_NONE); 00321 RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_OVERRIDE_TIME); 00322 RNA_def_property_ui_text(prop, "Override Time", "Use a custom start and end time (in seconds) instead of the scene's timeline"); 00323 00324 prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); 00325 RNA_def_property_float_sdna(prop, NULL, "animStart"); 00326 RNA_def_property_range(prop, 0, 100); 00327 RNA_def_property_ui_text(prop, "Start Time", "Simulation time of the first blender frame (in seconds)"); 00328 00329 prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); 00330 RNA_def_property_float_sdna(prop, NULL, "animEnd"); 00331 RNA_def_property_range(prop, 0, 100); 00332 RNA_def_property_ui_text(prop, "End Time", "Simulation time of the last blender frame (in seconds)"); 00333 00334 prop= RNA_def_property(srna, "simulation_scale", PROP_FLOAT, PROP_NONE); 00335 RNA_def_property_float_sdna(prop, NULL, "realsize"); 00336 RNA_def_property_range(prop, 0.001, 10); 00337 RNA_def_property_ui_text(prop, "Real World Size", "Size of the simulation domain in metres"); 00338 00339 prop= RNA_def_property(srna, "viscosity_preset", PROP_ENUM, PROP_NONE); 00340 RNA_def_property_enum_sdna(prop, NULL, "viscosityMode"); 00341 RNA_def_property_enum_items(prop, viscosity_items); 00342 RNA_def_property_ui_text(prop, "Viscosity Preset", "Set viscosity of the fluid to a preset value, or use manual input"); 00343 00344 prop= RNA_def_property(srna, "viscosity_base", PROP_FLOAT, PROP_NONE); 00345 RNA_def_property_float_sdna(prop, NULL, "viscosityValue"); 00346 RNA_def_property_range(prop, 0, 10); 00347 RNA_def_property_ui_text(prop, "Viscosity Base", "Viscosity setting: value that is multiplied by 10 to the power of (exponent*-1)"); 00348 00349 prop= RNA_def_property(srna, "viscosity_exponent", PROP_INT, PROP_NONE); 00350 RNA_def_property_int_sdna(prop, NULL, "viscosityExponent"); 00351 RNA_def_property_range(prop, 0, 10); 00352 RNA_def_property_ui_text(prop, "Viscosity Exponent", "Negative exponent for the viscosity value (to simplify entering small values e.g. 5*10^-6.)"); 00353 00354 prop= RNA_def_property(srna, "grid_levels", PROP_INT, PROP_NONE); 00355 RNA_def_property_int_sdna(prop, NULL, "maxRefine"); 00356 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00357 RNA_def_property_range(prop, -1, 4); 00358 RNA_def_property_ui_text(prop, "Grid Levels", "Number of coarsened grids to use (-1 for automatic)"); 00359 00360 prop= RNA_def_property(srna, "compressibility", PROP_FLOAT, PROP_NONE); 00361 RNA_def_property_float_sdna(prop, NULL, "gstar"); 00362 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00363 RNA_def_property_range(prop, 0.001, 0.1); 00364 RNA_def_property_ui_text(prop, "Compressibility", "Allowed compressibility due to gravitational force for standing fluid. (directly affects simulation step size)"); 00365 00366 /* domain boundary settings */ 00367 00368 rna_def_fluidsim_slip(srna); 00369 00370 prop= RNA_def_property(srna, "surface_smooth", PROP_FLOAT, PROP_NONE); 00371 RNA_def_property_float_sdna(prop, NULL, "surfaceSmoothing"); 00372 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00373 RNA_def_property_range(prop, 0.0, 5.0); 00374 RNA_def_property_ui_text(prop, "Surface Smoothing", "Amount of surface smoothing. A value of 0 is off, 1 is normal smoothing and more than 1 is extra smoothing"); 00375 00376 prop= RNA_def_property(srna, "surface_subdivisions", PROP_INT, PROP_NONE); 00377 RNA_def_property_int_sdna(prop, NULL, "surfaceSubdivs"); 00378 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00379 RNA_def_property_range(prop, 0, 5); 00380 RNA_def_property_ui_text(prop, "Surface Subdivisions", "Number of isosurface subdivisions. This is necessary for the inclusion of particles into the surface generation. Warning - can lead to longer computation times!"); 00381 00382 prop= RNA_def_property(srna, "use_speed_vectors", PROP_BOOLEAN, PROP_NONE); 00383 RNA_def_property_boolean_negative_sdna(prop, NULL, "domainNovecgen", 0); 00384 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00385 RNA_def_property_ui_text(prop, "Generate Speed Vectors", "Generate speed vectors for vector blur"); 00386 00387 /* no collision object surface */ 00388 prop= RNA_def_property(srna, "surface_noobs", PROP_BOOLEAN, PROP_NONE); 00389 RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSSG_NOOBS); 00390 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00391 RNA_def_property_ui_text(prop, "Hide fluid surface", ""); 00392 00393 /* particles */ 00394 00395 prop= RNA_def_property(srna, "tracer_particles", PROP_INT, PROP_NONE); 00396 RNA_def_property_int_sdna(prop, NULL, "generateTracers"); 00397 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00398 RNA_def_property_range(prop, 0, 10000); 00399 RNA_def_property_ui_text(prop, "Tracer Particles", "Number of tracer particles to generate"); 00400 00401 prop= RNA_def_property(srna, "generate_particles", PROP_FLOAT, PROP_NONE); 00402 RNA_def_property_float_sdna(prop, NULL, "generateParticles"); 00403 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00404 RNA_def_property_range(prop, 0.0, 10.0); 00405 RNA_def_property_ui_text(prop, "Generate Particles", "Amount of particles to generate (0=off, 1=normal, >1=more)"); 00406 00407 /* simulated fluid mesh data */ 00408 prop= RNA_def_property(srna, "fluid_mesh_vertices", PROP_COLLECTION, PROP_NONE); 00409 RNA_def_property_struct_type(prop, "FluidMeshVertex"); 00410 RNA_def_property_ui_text(prop, "Fluid Mesh Vertices", "Vertices of the fluid mesh generated by simulation"); 00411 RNA_def_property_collection_funcs(prop, "rna_FluidMeshVertex_data_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", "rna_FluidMeshVertex_data_length", 0, 0); 00412 rna_def_fluid_mesh_vertices(brna); 00413 } 00414 00415 static void rna_def_fluidsim_volume(StructRNA *srna) 00416 { 00417 PropertyRNA *prop; 00418 00419 static EnumPropertyItem volume_type_items[] = { 00420 {1, "VOLUME", 0, "Volume", "Use only the inner volume of the mesh"}, 00421 {2, "SHELL", 0, "Shell", "Use only the outer shell of the mesh"}, 00422 {3, "BOTH", 0, "Both", "Use both the inner volume and the outer shell of the mesh"}, 00423 {0, NULL, 0, NULL, NULL}}; 00424 00425 prop= RNA_def_property(srna, "volume_initialization", PROP_ENUM, PROP_NONE); 00426 RNA_def_property_enum_bitflag_sdna(prop, NULL, "volumeInitType"); 00427 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00428 RNA_def_property_enum_items(prop, volume_type_items); 00429 RNA_def_property_ui_text(prop, "Volume Initialization", "Volume initialization type"); 00430 00431 prop= RNA_def_property(srna, "use_animated_mesh", PROP_BOOLEAN, PROP_NONE); 00432 RNA_def_property_boolean_sdna(prop, NULL, "domainNovecgen", 0); 00433 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00434 RNA_def_property_ui_text(prop, "Export Animated Mesh", "Export this mesh as an animated one. Slower, only use if really necessary (e.g. armatures or parented objects), animated pos/rot/scale IPOs do not require it"); 00435 } 00436 00437 static void rna_def_fluidsim_active(StructRNA *srna) 00438 { 00439 PropertyRNA *prop; 00440 00441 prop= RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE); 00442 RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_ACTIVE); 00443 RNA_def_property_ui_text(prop, "Enabled", "Object contributes to the fluid simulation"); 00444 } 00445 00446 static void rna_def_fluidsim_fluid(BlenderRNA *brna) 00447 { 00448 StructRNA *srna; 00449 PropertyRNA *prop; 00450 00451 srna= RNA_def_struct(brna, "FluidFluidSettings", "FluidSettings"); 00452 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00453 RNA_def_struct_ui_text(srna, "Fluid Fluid Simulation Settings", "Fluid simulation settings for the fluid in the simulation"); 00454 00455 rna_def_fluidsim_active(srna); 00456 rna_def_fluidsim_volume(srna); 00457 00458 prop= RNA_def_property(srna, "initial_velocity", PROP_FLOAT, PROP_VELOCITY); 00459 RNA_def_property_float_sdna(prop, NULL, "iniVelx"); 00460 RNA_def_property_array(prop, 3); 00461 RNA_def_property_range(prop, -1000.1, 1000.1); 00462 RNA_def_property_ui_text(prop, "Initial Velocity", "Initial velocity of fluid"); 00463 } 00464 00465 static void rna_def_fluidsim_obstacle(BlenderRNA *brna) 00466 { 00467 StructRNA *srna; 00468 PropertyRNA *prop; 00469 00470 srna= RNA_def_struct(brna, "ObstacleFluidSettings", "FluidSettings"); 00471 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00472 RNA_def_struct_ui_text(srna, "Obstacle Fluid Simulation Settings", "Fluid simulation settings for obstacles in the simulation"); 00473 00474 rna_def_fluidsim_active(srna); 00475 rna_def_fluidsim_volume(srna); 00476 rna_def_fluidsim_slip(srna); 00477 00478 prop= RNA_def_property(srna, "impact_factor", PROP_FLOAT, PROP_NONE); 00479 RNA_def_property_float_sdna(prop, NULL, "surfaceSmoothing"); 00480 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00481 RNA_def_property_range(prop, -2.0, 10.0); 00482 RNA_def_property_ui_text(prop, "Impact Factor", "This is an unphysical value for moving objects - it controls the impact an obstacle has on the fluid, =0 behaves a bit like outflow (deleting fluid), =1 is default, while >1 results in high forces. Can be used to tweak total mass"); 00483 } 00484 00485 static void rna_def_fluidsim_inflow(BlenderRNA *brna) 00486 { 00487 StructRNA *srna; 00488 PropertyRNA *prop; 00489 00490 srna= RNA_def_struct(brna, "InflowFluidSettings", "FluidSettings"); 00491 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00492 RNA_def_struct_ui_text(srna, "Inflow Fluid Simulation Settings", "Fluid simulation settings for objects adding fluids in the simulation"); 00493 00494 rna_def_fluidsim_active(srna); 00495 rna_def_fluidsim_volume(srna); 00496 00497 prop= RNA_def_property(srna, "inflow_velocity", PROP_FLOAT, PROP_VELOCITY); 00498 RNA_def_property_float_sdna(prop, NULL, "iniVelx"); 00499 RNA_def_property_array(prop, 3); 00500 RNA_def_property_range(prop, -1000.1, 1000.1); 00501 RNA_def_property_ui_text(prop, "Inflow Velocity", "Initial velocity of fluid"); 00502 00503 prop= RNA_def_property(srna, "use_local_coords", PROP_BOOLEAN, PROP_NONE); 00504 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00505 RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSINFLOW_LOCALCOORD); 00506 RNA_def_property_ui_text(prop, "Local Coordinates", "Use local coordinates for inflow. (e.g. for rotating objects)"); 00507 } 00508 00509 static void rna_def_fluidsim_outflow(BlenderRNA *brna) 00510 { 00511 StructRNA *srna; 00512 00513 srna= RNA_def_struct(brna, "OutflowFluidSettings", "FluidSettings"); 00514 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00515 RNA_def_struct_ui_text(srna, "Outflow Fluid Simulation Settings", "Fluid simulation settings for objects removing fluids from the simulation"); 00516 00517 rna_def_fluidsim_active(srna); 00518 rna_def_fluidsim_volume(srna); 00519 } 00520 00521 static void rna_def_fluidsim_particle(BlenderRNA *brna) 00522 { 00523 StructRNA *srna; 00524 PropertyRNA *prop; 00525 00526 srna= RNA_def_struct(brna, "ParticleFluidSettings", "FluidSettings"); 00527 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00528 RNA_def_struct_ui_text(srna, "Particle Fluid Simulation Settings", "Fluid simulation settings for objects storing fluid particles generated by the simulation"); 00529 00530 prop= RNA_def_property(srna, "use_drops", PROP_BOOLEAN, PROP_NONE); 00531 RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSPART_DROP); 00532 RNA_def_property_ui_text(prop, "Drops", "Show drop particles"); 00533 00534 prop= RNA_def_property(srna, "use_floats", PROP_BOOLEAN, PROP_NONE); 00535 RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSPART_FLOAT); 00536 RNA_def_property_ui_text(prop, "Floats", "Show floating foam particles"); 00537 00538 prop= RNA_def_property(srna, "show_tracer", PROP_BOOLEAN, PROP_NONE); 00539 RNA_def_property_boolean_sdna(prop, NULL, "typeFlags", OB_FSPART_TRACER); 00540 RNA_def_property_ui_text(prop, "Tracer", "Show tracer particles"); 00541 00542 prop= RNA_def_property(srna, "particle_influence", PROP_FLOAT, PROP_NONE); 00543 RNA_def_property_float_sdna(prop, NULL, "particleInfSize"); 00544 RNA_def_property_range(prop, 0.0, 2.0); 00545 RNA_def_property_ui_text(prop, "Particle Influence", "Amount of particle size scaling: 0=off (all same size), 1=full (range 0.2-2.0), >1=stronger"); 00546 00547 prop= RNA_def_property(srna, "alpha_influence", PROP_FLOAT, PROP_NONE); 00548 RNA_def_property_float_sdna(prop, NULL, "particleInfAlpha"); 00549 RNA_def_property_range(prop, 0.0, 2.0); 00550 RNA_def_property_ui_text(prop, "Alpha Influence", "Amount of particle alpha change, inverse of size influence: 0=off (all same alpha), 1=full. (large particles get lower alphas, smaller ones higher values)"); 00551 00552 prop= RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); 00553 RNA_def_property_string_maxlength(prop, 240); 00554 RNA_def_property_string_sdna(prop, NULL, "surfdataPath"); 00555 RNA_def_property_ui_text(prop, "Path", "Directory (and/or filename prefix) to store and load particles from"); 00556 RNA_def_property_update(prop, 0, "rna_fluid_update"); 00557 } 00558 00559 static void rna_def_fluidsim_control(BlenderRNA *brna) 00560 { 00561 StructRNA *srna; 00562 PropertyRNA *prop; 00563 00564 srna= RNA_def_struct(brna, "ControlFluidSettings", "FluidSettings"); 00565 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00566 RNA_def_struct_ui_text(srna, "Control Fluid Simulation Settings", "Fluid simulation settings for objects controlling the motion of fluid in the simulation"); 00567 00568 rna_def_fluidsim_active(srna); 00569 00570 prop= RNA_def_property(srna, "start_time", PROP_FLOAT, PROP_TIME); 00571 RNA_def_property_float_sdna(prop, NULL, "cpsTimeStart"); 00572 RNA_def_property_range(prop, 0.0, 100.0); 00573 RNA_def_property_ui_text(prop, "Start Time", "Specifies time when the control particles are activated"); 00574 00575 prop= RNA_def_property(srna, "end_time", PROP_FLOAT, PROP_TIME); 00576 RNA_def_property_float_sdna(prop, NULL, "cpsTimeEnd"); 00577 RNA_def_property_range(prop, 0.0, 100.0); 00578 RNA_def_property_ui_text(prop, "End Time", "Specifies time when the control particles are deactivated"); 00579 00580 prop= RNA_def_property(srna, "attraction_strength", PROP_FLOAT, PROP_NONE); 00581 RNA_def_property_float_sdna(prop, NULL, "attractforceStrength"); 00582 RNA_def_property_range(prop, -10.0, 10.0); 00583 RNA_def_property_ui_text(prop, "Attraction Strength", "Force strength for directional attraction towards the control object"); 00584 00585 prop= RNA_def_property(srna, "attraction_radius", PROP_FLOAT, PROP_NONE); 00586 RNA_def_property_float_sdna(prop, NULL, "attractforceRadius"); 00587 RNA_def_property_range(prop, 0.0, 10.0); 00588 RNA_def_property_ui_text(prop, "Attraction Radius", "Specifies the force field radius around the control object"); 00589 00590 prop= RNA_def_property(srna, "velocity_strength", PROP_FLOAT, PROP_NONE); 00591 RNA_def_property_float_sdna(prop, NULL, "velocityforceStrength"); 00592 RNA_def_property_range(prop, 0.0, 10.0); 00593 RNA_def_property_ui_text(prop, "Velocity Strength", "Force strength of how much of the control object's velocity is influencing the fluid velocity"); 00594 00595 prop= RNA_def_property(srna, "velocity_radius", PROP_FLOAT, PROP_NONE); 00596 RNA_def_property_float_sdna(prop, NULL, "velocityforceRadius"); 00597 RNA_def_property_range(prop, 0.0, 10.0); 00598 RNA_def_property_ui_text(prop, "Velocity Radius", "Specifies the force field radius around the control object"); 00599 00600 prop= RNA_def_property(srna, "quality", PROP_FLOAT, PROP_NONE); 00601 RNA_def_property_float_sdna(prop, NULL, "cpsQuality"); 00602 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00603 RNA_def_property_range(prop, 5.0, 100.0); 00604 RNA_def_property_ui_text(prop, "Quality", "Specifies the quality which is used for object sampling. (higher = better but slower)"); 00605 00606 prop= RNA_def_property(srna, "use_reverse_frames", PROP_BOOLEAN, PROP_NONE); 00607 RNA_def_property_boolean_sdna(prop, NULL, "flag", OB_FLUIDSIM_REVERSE); 00608 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00609 RNA_def_property_ui_text(prop, "Reverse Frames", "Reverse control object movement"); 00610 RNA_def_property_update(prop, 0, "rna_fluid_find_enframe"); 00611 } 00612 00613 void RNA_def_fluidsim(BlenderRNA *brna) 00614 { 00615 StructRNA *srna; 00616 PropertyRNA *prop; 00617 00618 static EnumPropertyItem prop_fluid_type_items[] = { 00619 {OB_FLUIDSIM_ENABLE, "NONE", 0, "None", ""}, 00620 {OB_FLUIDSIM_DOMAIN, "DOMAIN", 0, "Domain", "Bounding box of this object represents the computational domain of the fluid simulation"}, 00621 {OB_FLUIDSIM_FLUID, "FLUID", 0, "Fluid", "Object represents a volume of fluid in the simulation"}, 00622 {OB_FLUIDSIM_OBSTACLE, "OBSTACLE", 0, "Obstacle", "Object is a fixed obstacle"}, 00623 {OB_FLUIDSIM_INFLOW, "INFLOW", 0, "Inflow", "Object adds fluid to the simulation"}, 00624 {OB_FLUIDSIM_OUTFLOW, "OUTFLOW", 0, "Outflow", "Object removes fluid from the simulation"}, 00625 {OB_FLUIDSIM_PARTICLE, "PARTICLE", 0, "Particle", "Object is made a particle system to display particles generated by a fluidsim domain object"}, 00626 {OB_FLUIDSIM_CONTROL, "CONTROL", 0, "Control", "Object is made a fluid control mesh, which influences the fluid"}, 00627 {0, NULL, 0, NULL, NULL}}; 00628 00629 00630 srna= RNA_def_struct(brna, "FluidSettings", NULL); 00631 RNA_def_struct_sdna(srna, "FluidsimSettings"); 00632 RNA_def_struct_refine_func(srna, "rna_FluidSettings_refine"); 00633 RNA_def_struct_path_func(srna, "rna_FluidSettings_path"); 00634 RNA_def_struct_ui_text(srna, "Fluid Simulation Settings", "Fluid simulation settings for an object taking part in the simulation"); 00635 00636 prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); 00637 RNA_def_property_enum_bitflag_sdna(prop, NULL, "type"); 00638 RNA_def_property_enum_items(prop, prop_fluid_type_items); 00639 RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); 00640 RNA_def_property_ui_text(prop, "Type", "Type of participation in the fluid simulation"); 00641 RNA_def_property_update(prop, 0, "rna_FluidSettings_update_type"); 00642 00643 //prop= RNA_def_property(srna, "ipo", PROP_POINTER, PROP_NONE); 00644 //RNA_def_property_ui_text(prop, "IPO Curves", "IPO curves used by fluid simulation settings"); 00645 00646 /* types */ 00647 00648 rna_def_fluidsim_domain(brna); 00649 rna_def_fluidsim_fluid(brna); 00650 rna_def_fluidsim_obstacle(brna); 00651 rna_def_fluidsim_inflow(brna); 00652 rna_def_fluidsim_outflow(brna); 00653 rna_def_fluidsim_particle(brna); 00654 rna_def_fluidsim_control(brna); 00655 } 00656 00657 00658 #endif