Blender V2.61 - r43446

rna_fluidsim.c

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