diff options
author | Janne Karhu <jhkarh@gmail.com> | 2010-04-04 16:29:06 +0400 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2010-04-04 16:29:06 +0400 |
commit | c5871b87502cfd35fa14881f1bcadbd5564e658f (patch) | |
tree | 7397e7a403589d31244ecaf7f976e3f532729159 /source/blender/makesrna/intern | |
parent | d574e8b82617c389de85a09fcf9b0f14172466a8 (diff) |
Fluid physics for particles by Raul Fernandez Hernandez (Farsthary) and Stephen Swhitehorn:
This patch add SPH (Smoothed Particle Hydrodynamics)fluid dynamics to the
blender particle system. SPH is an boundless Lagrangian interpolation
technique to solve the fluid motion equations.
From liquids to sand, goo and gases could be simulated using the particle
system.
It features internal viscosity, a double density relaxation that accounts
for surface tension effects, static internal springs for plastic fluids,
and buoyancy for gases.
---------------------------------------
This is a commit of the core fluid physics. Raul will work on proper
documentation soon and more features such as surface extraction from
the particle point cloud and increasing stability by sub-frame calculations
later.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 83 |
1 files changed, 79 insertions, 4 deletions
diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index e2d684ecbfb..4e8776eff6a 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -837,6 +837,74 @@ static void rna_def_particle_dupliweight(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Particle_redo"); } +static void rna_def_fluid_settings(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "SPHFluidSettings", NULL); + RNA_def_struct_ui_text(srna, "SPH Fluid Settings", "Settings for particle fluids physics"); + + /* Fluid settings */ + prop= RNA_def_property(srna, "spring_k", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "spring_k"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Spring", "Spring force constant"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "fluid_radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0.0f, 2.0f); + RNA_def_property_ui_text(prop, "Radius", "Fluid interaction Radius"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "rest_length", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rest_length"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Rest Length", "The Spring Rest Length (factor of interaction radius)"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + /* Viscosity */ + prop= RNA_def_property(srna, "viscosity_omega", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "viscosity_omega"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Viscosity", "Linear viscosity"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "viscosity_beta", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "viscosity_beta"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Square viscosity", "Square viscosity factor"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + /* Double density relaxation */ + prop= RNA_def_property(srna, "stiffness_k", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stiffness_k"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Stiffness ", "Constant K - Stiffness"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "stiffness_knear", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "stiffness_knear"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Repulsion", "Repulsion factor: stiffness_knear"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop= RNA_def_property(srna, "rest_density", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "rest_density"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_ui_text(prop, "Rest Density", "Density"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + /* Buoyancy */ + prop= RNA_def_property(srna, "buoyancy", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "buoyancy"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Buoyancy", ""); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + +} + static void rna_def_particle_settings(BlenderRNA *brna) { StructRNA *srna; @@ -861,6 +929,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) {PART_PHYS_NEWTON, "NEWTON", 0, "Newtonian", ""}, {PART_PHYS_KEYED, "KEYED", 0, "Keyed", ""}, {PART_PHYS_BOIDS, "BOIDS", 0, "Boids", ""}, + {PART_PHYS_FLUID, "FLUID", 0, "Fluid", ""}, {0, NULL, 0, NULL, NULL} }; @@ -1773,9 +1842,14 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_struct_type(prop, "BoidSettings"); RNA_def_property_clear_flag(prop, PROP_EDITABLE); RNA_def_property_ui_text(prop, "Boid Settings", ""); - + + /* Fluid particles */ + prop= RNA_def_property(srna, "fluid", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "SPHFluidSettings"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "SPH Fluid Settings", ""); + /* draw objects & groups */ - prop= RNA_def_property(srna, "dupli_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "dup_group"); RNA_def_property_struct_type(prop, "Group"); @@ -2162,12 +2236,13 @@ void RNA_def_particle(BlenderRNA *brna) rna_def_particle_hair_key(brna); rna_def_particle_key(brna); - + rna_def_fluid_settings(brna); + rna_def_child_particle(brna); rna_def_particle(brna); rna_def_particle_dupliweight(brna); rna_def_particle_system(brna); - rna_def_particle_settings(brna); + rna_def_particle_settings(brna); } #endif |