Smoke: Make Smoke density available to python via rna.
authorDaniel Genrich <daniel.genrich@gmx.net>
Tue, 5 Jun 2012 22:43:29 +0000 (22:43 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Tue, 5 Jun 2012 22:43:29 +0000 (22:43 +0000)
source/blender/makesrna/intern/CMakeLists.txt
source/blender/makesrna/intern/SConscript
source/blender/makesrna/intern/rna_smoke.c

index e7f9977d04063ff0423c9de43f57d18f4ea369d9..82c0757456d2ca2aa17ff98f2044e7cf7163ae9d 100644 (file)
@@ -209,6 +209,10 @@ if(WITH_FFTW3)
        add_definitions(-DWITH_FFTW3)
 endif()
 
+if(WITH_MOD_SMOKE)
+       add_definitions(-DWITH_SMOKE)
+endif()
+
 if(WITH_MOD_OCEANSIM)
        add_definitions(-DWITH_OCEANSIM)
 endif()
@@ -253,6 +257,7 @@ blender_include_dirs(
        ../../../../intern/cycles/blender
        ../../../../intern/guardedalloc
        ../../../../intern/memutil
+       ../../../../intern/smoke/extern
 )
 
 blender_include_dirs_sys(
index 99fab18b4bfc7960b64e268634a1a619c20d1c9f..d26de50fae0f603887a6f367c1b9a05bc3d4cac0 100644 (file)
@@ -35,7 +35,11 @@ incs += ' ../../windowmanager ../../editors/include ../../blenfont'
 incs += ' ../../render/extern/include ../../bmesh'
 incs += ' #/intern/audaspace/intern #/intern/cycles/blender'
 incs += ' #/extern/glew/include '
+incs += ' #/intern/smoke/extern'
 
+if env['WITH_BF_SMOKE']:
+    defs.append('WITH_SMOKE')
+    
 if env['WITH_BF_OPENEXR']:
     defs.append('WITH_OPENEXR')
 
index 19925546de3a31457773fbc480ab69d8f5f0adee..f13f9406689603a12a36ca9a4c17fb47a86b7717 100644 (file)
@@ -51,6 +51,8 @@
 #include "BKE_depsgraph.h"
 #include "BKE_particle.h"
 
+#include "smoke_API.h"
+
 
 static void rna_Smoke_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
 {
@@ -111,6 +113,35 @@ static char *rna_SmokeCollSettings_path(PointerRNA *ptr)
        return BLI_sprintfN("modifiers[\"%s\"].coll_settings", md->name);
 }
 
+static int rna_SmokeModifier_density_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
+{
+       SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
+
+       if (settings->fluid)
+       {
+               float *density = smoke_get_density(settings->fluid);
+               unsigned int size = settings->res[0] * settings->res[1] * settings->res[2];
+
+               if(density)
+                       length[0] = size;
+               else
+                       length[0] = 0;
+       }
+       else
+               length[0] = 0; // No smoke domain created yet
+
+       return length[0];
+}
+
+static void rna_SmokeModifier_density_get(PointerRNA *ptr, float *values)
+{
+       SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data;
+       float *density = smoke_get_density(settings->fluid);
+       unsigned int size = settings->res[0] * settings->res[1] * settings->res[2];
+
+       memcpy(values, density, size * sizeof(float));
+}
+
 #else
 
 static void rna_def_smoke_domain_settings(BlenderRNA *brna)
@@ -282,6 +313,33 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
        RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid");
        RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset");
 
+       prop = RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_array(prop, 32);
+       RNA_def_property_flag(prop, PROP_DYNAMIC);
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_dynamic_array_funcs(prop, "rna_SmokeModifier_density_get_length");
+       RNA_def_property_float_funcs(prop, "rna_SmokeModifier_density_get", NULL, NULL);
+       RNA_def_property_ui_text(prop, "Density", "Smoke density");
+
+       prop = RNA_def_property(srna, "dx", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "dx");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "dx", "Cell Size");
+
+       prop = RNA_def_property(srna, "p0", PROP_FLOAT, PROP_XYZ);
+       RNA_def_property_float_sdna(prop, NULL, "p0");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "p0", "Start point");
+
+       prop = RNA_def_property(srna, "scale", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_float_sdna(prop, NULL, "scale");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "scale", "Domain scale factor");
+
+       prop = RNA_def_property(srna, "res", PROP_INT, PROP_XYZ);
+       RNA_def_property_int_sdna(prop, NULL, "res");
+       RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "res", "Smoke Grid Resolution");
 }
 
 static void rna_def_smoke_flow_settings(BlenderRNA *brna)