Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorDaniel Genrich <daniel.genrich@gmx.net>2010-01-25 18:10:14 +0300
committerDaniel Genrich <daniel.genrich@gmx.net>2010-01-25 18:10:14 +0300
commit83dfade37a746043dfc8d38f57514706d8505352 (patch)
tree71d291a00799e67ecc6d39a5c5fc2117037a1328 /source
parent4b71eaa4d14af6f43c15f97d8bf70506afad724b (diff)
Smoke: The well known Miika Hämäläinen (aka MiikaH) patch (http://blenderartists.org/forum/showthread.php?t=158317&page=42)
* Better (and windows enabled) OpenMP handling (> 2x-5x speed) * More Volumetric Texture mapping options (heat, etc) <-- Matt if that's not to your liking, just revert that part, it's separate anyway * Initial velocity taken from particle settings (no more slow starting) * Option to select compression method (there seem to be a bug in my high compression usage, at least it's been reported to result in exploding smoke - better use low compression for the time being) It's been tested since a while but as usual please report any (new!) bugs. ;-)
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/pointcache.c9
-rw-r--r--source/blender/blenkernel/intern/smoke.c23
-rw-r--r--source/blender/makesdna/DNA_smoke_types.h8
-rw-r--r--source/blender/makesdna/DNA_texture_types.h7
-rw-r--r--source/blender/makesrna/intern/rna_smoke.c24
-rw-r--r--source/blender/makesrna/intern/rna_texture.c12
-rw-r--r--source/blender/render/intern/source/voxeldata.c55
7 files changed, 121 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c
index b31131554bd..9bdc700c313 100644
--- a/source/blender/blenkernel/intern/pointcache.c
+++ b/source/blender/blenkernel/intern/pointcache.c
@@ -710,7 +710,9 @@ static int ptcache_write_smoke(PTCacheFile *pf, void *smoke_v)
unsigned char *obstacles;
unsigned int in_len = sizeof(float)*(unsigned int)res;
unsigned char *out = (unsigned char *)MEM_callocN(LZO_OUT_LEN(in_len)*4, "pointcache_lzo_buffer");
- int mode = res >= 1000000 ? 2 : 1;
+ //int mode = res >= 1000000 ? 2 : 1;
+ int mode=1; // light
+ if (sds->cache_comp == SM_CACHE_HEAVY) mode=2; // heavy
smoke_export(sds->fluid, &dt, &dx, &dens, &densold, &heat, &heatold, &vx, &vy, &vz, &vxold, &vyold, &vzold, &obstacles);
@@ -753,7 +755,10 @@ static int ptcache_write_smoke_turbulence(PTCacheFile *pf, void *smoke_v)
smoke_turbulence_get_res(sds->wt, res_big_array);
res_big = res_big_array[0]*res_big_array[1]*res_big_array[2];
- mode = res_big >= 1000000 ? 2 : 1;
+ //mode = res_big >= 1000000 ? 2 : 1;
+ mode = 1; // light
+ if (sds->cache_high_comp == SM_CACHE_HEAVY) mode=2; // heavy
+
in_len_big = sizeof(float) * (unsigned int)res_big;
smoke_turbulence_export(sds->wt, &dens, &densold, &tcu, &tcv, &tcw);
diff --git a/source/blender/blenkernel/intern/smoke.c b/source/blender/blenkernel/intern/smoke.c
index 0a106b1920d..e921dadb9ba 100644
--- a/source/blender/blenkernel/intern/smoke.c
+++ b/source/blender/blenkernel/intern/smoke.c
@@ -872,11 +872,13 @@ static void smoke_calc_domain(Scene *scene, Object *ob, SmokeModifierData *smd)
heat[index] = sfs->temp;
density[index] = sfs->density;
- /*
+
+ // Uses particle velocity as initial velocity for smoke
+ if(smd->domain->flags & MOD_SMOKE_INITVELOCITY) {
velocity_x[index] = pa->state.vel[0];
velocity_y[index] = pa->state.vel[1];
velocity_z[index] = pa->state.vel[2];
- */
+ }
// obstacle[index] |= 2;
// we need different handling for the high-res feature
@@ -1396,8 +1398,9 @@ static void get_cell(float *p0, int res[3], float dx, float *pos, int *cell, int
static void smoke_calc_transparency(float *result, float *input, float *p0, float *p1, int res[3], float dx, float *light, bresenham_callback cb, float correct)
{
- int x, y, z;
+ int z;
float bv[6];
+ int slabsize=res[0]*res[1];
memset(result, -1, sizeof(float)*res[0]*res[1]*res[2]); // x
bv[0] = p0[0];
@@ -1409,19 +1412,20 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
bv[4] = p0[2];
bv[5] = p1[2];
-#pragma omp parallel for schedule(static) private(y, z)
- for(x = 0; x < res[0]; x++)
+#pragma omp parallel for schedule(static,1)
+ for(z = 0; z < res[2]; z++)
+ {
+ size_t index = z*slabsize;
+ int x,y;
+
for(y = 0; y < res[1]; y++)
- for(z = 0; z < res[2]; z++)
+ for(x = 0; x < res[0]; x++, index++)
{
float voxelCenter[3];
- size_t index;
float pos[3];
int cell[3];
float tRay = 1.0;
- index = smoke_get_index(x, res[0], y, res[1], z);
-
if(result[index] >= 0.0f)
continue;
voxelCenter[0] = p0[0] + dx * x + dx * 0.5;
@@ -1446,5 +1450,6 @@ static void smoke_calc_transparency(float *result, float *input, float *p0, floa
// #pragma omp critical
result[index] = tRay;
}
+ }
}
diff --git a/source/blender/makesdna/DNA_smoke_types.h b/source/blender/makesdna/DNA_smoke_types.h
index 6cf308aa0ad..08cd1ba2994 100644
--- a/source/blender/makesdna/DNA_smoke_types.h
+++ b/source/blender/makesdna/DNA_smoke_types.h
@@ -33,6 +33,8 @@
#define MOD_SMOKE_HIGHRES (1<<1) /* enable high resolution */
#define MOD_SMOKE_DISSOLVE (1<<2) /* let smoke dissolve */
#define MOD_SMOKE_DISSOLVE_LOG (1<<3) /* using 1/x for dissolve */
+#define MOD_SMOKE_INITVELOCITY (1<<4) /* passes particles speed to
+ the smoke*/
/* noise */
#define MOD_SMOKE_NOISEWAVE (1<<0)
@@ -41,6 +43,10 @@
/* viewsettings */
#define MOD_SMOKE_VIEW_SHOWBIG (1<<0)
+/* cache compression */
+#define SM_CACHE_LIGHT 0
+#define SM_CACHE_HEAVY 1
+
typedef struct SmokeDomainSettings {
struct SmokeModifierData *smd; /* for fast RNA access */
struct FLUID_3D *fluid;
@@ -73,6 +79,8 @@ typedef struct SmokeDomainSettings {
int res_wt[3];
float dx_wt;
int v3dnum;
+ int cache_comp;
+ int cache_high_comp;
struct PointCache *point_cache[2]; /* definition is in DNA_object_force.h */
struct ListBase ptcaches[2];
struct EffectorWeights *effector_weights;
diff --git a/source/blender/makesdna/DNA_texture_types.h b/source/blender/makesdna/DNA_texture_types.h
index eac7a97f0c0..76651cbc551 100644
--- a/source/blender/makesdna/DNA_texture_types.h
+++ b/source/blender/makesdna/DNA_texture_types.h
@@ -184,7 +184,7 @@ typedef struct VoxelData {
short file_format;
short flag;
short extend;
- short pad;
+ short smoked_type;
struct Object *object; /* for rendering smoke sims */
float int_multiplier;
@@ -546,5 +546,10 @@ typedef struct TexMapping {
#define TEX_VD_IMAGE_SEQUENCE 3
#define TEX_VD_SMOKE 4
+/* smoke data types */
+#define TEX_VD_SMOKEDENSITY 0
+#define TEX_VD_SMOKEHEAT 1
+#define TEX_VD_SMOKEVEL 2
+
#endif
diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c
index 11b1e80865e..c72bf24e3c8 100644
--- a/source/blender/makesrna/intern/rna_smoke.c
+++ b/source/blender/makesrna/intern/rna_smoke.c
@@ -117,6 +117,11 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
/* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */
{0, NULL, 0, NULL, NULL}};
+ static EnumPropertyItem smoke_cache_comp_items[] = {
+ {SM_CACHE_HEAVY, "CACHEHEAVY", 0, "Heavy (Very slow)", "Effective but slow compression."},
+ {SM_CACHE_LIGHT, "CACHELIGHT", 0, "Light (Fast)", "Fast but not so effective compression."},
+ {0, NULL, 0, NULL, NULL}};
+
srna = RNA_def_struct(brna, "SmokeDomainSettings", NULL);
RNA_def_struct_ui_text(srna, "Domain Settings", "Smoke domain settings.");
RNA_def_struct_sdna(srna, "SmokeDomainSettings");
@@ -201,6 +206,11 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed");
RNA_def_property_update(prop, 0, NULL);
+ prop= RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_INITVELOCITY);
+ RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits it's velocity from the emitter particle.");
+ RNA_def_property_update(prop, 0, NULL);
+
prop= RNA_def_property(srna, "dissolve_smoke", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE);
RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time.");
@@ -221,10 +231,24 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "point_cache[1]");
RNA_def_property_ui_text(prop, "Point Cache", "");
+ prop= RNA_def_property(srna, "smoke_cache_comp", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "cache_comp");
+ RNA_def_property_enum_items(prop, smoke_cache_comp_items);
+ RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used.");
+ RNA_def_property_update(prop, 0, NULL);
+
+ prop= RNA_def_property(srna, "smoke_cache_high_comp", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "cache_high_comp");
+ RNA_def_property_enum_items(prop, smoke_cache_comp_items);
+ RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used.");
+ RNA_def_property_update(prop, 0, NULL);
+
+
prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "EffectorWeights");
RNA_def_property_clear_flag(prop, PROP_EDITABLE);
RNA_def_property_ui_text(prop, "Effector Weights", "");
+
}
static void rna_def_smoke_flow_settings(BlenderRNA *brna)
diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c
index c352ec79735..f4b081b273e 100644
--- a/source/blender/makesrna/intern/rna_texture.c
+++ b/source/blender/makesrna/intern/rna_texture.c
@@ -1726,6 +1726,12 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna)
{TEX_REPEAT, "REPEAT", 0, "Repeat", "Causes the image to repeat horizontally and vertically"},
{0, NULL, 0, NULL, NULL}};
+ static EnumPropertyItem smoked_type_items[] = {
+ {TEX_VD_SMOKEDENSITY, "SMOKEDENSITY", 0, "Density", "Use smoke density as texture data."},
+ {TEX_VD_SMOKEHEAT, "SMOKEHEAT", 0, "Heat", "Use smoke heat as texture data. Values from -2.0 to 2.0 are used."},
+ {TEX_VD_SMOKEVEL, "SMOKEVEL", 0, "Velocity", "Use smoke velocity as texture data."},
+ {0, NULL, 0, NULL, NULL}};
+
srna= RNA_def_struct(brna, "VoxelData", NULL);
RNA_def_struct_sdna(srna, "VoxelData");
RNA_def_struct_ui_text(srna, "VoxelData", "Voxel data settings.");
@@ -1735,6 +1741,12 @@ static void rna_def_texture_voxeldata(BlenderRNA *brna)
RNA_def_property_enum_items(prop, interpolation_type_items);
RNA_def_property_ui_text(prop, "Interpolation", "Method to interpolate/smooth values between voxel cells");
RNA_def_property_update(prop, 0, "rna_Texture_update");
+
+ prop= RNA_def_property(srna, "smoke_data_type", PROP_ENUM, PROP_NONE);
+ RNA_def_property_enum_sdna(prop, NULL, "smoked_type");
+ RNA_def_property_enum_items(prop, smoked_type_items);
+ RNA_def_property_ui_text(prop, "Source", "Simulation value to be used as a texture.");
+ RNA_def_property_update(prop, 0, "rna_Texture_update");
prop= RNA_def_property(srna, "extension", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "extend");
diff --git a/source/blender/render/intern/source/voxeldata.c b/source/blender/render/intern/source/voxeldata.c
index 381e6322254..1a220f6e9b1 100644
--- a/source/blender/render/intern/source/voxeldata.c
+++ b/source/blender/render/intern/source/voxeldata.c
@@ -165,16 +165,61 @@ void init_frame_smoke(Render *re, VoxelData *vd, Tex *tex)
if( (md = (ModifierData *)modifiers_findByType(ob, eModifierType_Smoke)) )
{
SmokeModifierData *smd = (SmokeModifierData *)md;
+
if(smd->domain && smd->domain->fluid) {
- if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
- smoke_turbulence_get_res(smd->domain->wt, vd->resol);
- vd->dataset = smoke_turbulence_get_density(smd->domain->wt);
- } else {
+ if (vd->smoked_type == TEX_VD_SMOKEHEAT) {
+ int totRes;
+ float *heat;
+ int i;
+
+ VECCOPY(vd->resol, smd->domain->res);
+ totRes = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]);
+
+ // scaling heat values from -2.0-2.0 to 0.0-1.0
+ vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
+
+
+ heat = smoke_get_heat(smd->domain->fluid);
+
+ for (i=0; i<totRes; i++)
+ {
+ vd->dataset[i] = (heat[i]+2.0f)/4.0f;
+ }
+
+ //vd->dataset = smoke_get_heat(smd->domain->fluid);
+ }
+ else if (vd->smoked_type == TEX_VD_SMOKEVEL) {
+ int totRes;
+ float *xvel, *yvel, *zvel;
+ int i;
+
VECCOPY(vd->resol, smd->domain->res);
- vd->dataset = smoke_get_density(smd->domain->fluid);
+ totRes = (vd->resol[0])*(vd->resol[1])*(vd->resol[2]);
+
+ // scaling heat values from -2.0-2.0 to 0.0-1.0
+ vd->dataset = MEM_mapallocN(sizeof(float)*(totRes), "smoke data");
+
+ xvel = smoke_get_velocity_x(smd->domain->fluid);
+ yvel = smoke_get_velocity_y(smd->domain->fluid);
+ zvel = smoke_get_velocity_z(smd->domain->fluid);
+
+ for (i=0; i<totRes; i++)
+ {
+ vd->dataset[i] = sqrt(xvel[i]*xvel[i] + yvel[i]*yvel[i] + zvel[i]*zvel[i])*3.0f;
+ }
+
}
+ else {
+ if (smd->domain->flags & MOD_SMOKE_HIGHRES) {
+ smoke_turbulence_get_res(smd->domain->wt, vd->resol);
+ vd->dataset = smoke_turbulence_get_density(smd->domain->wt);
+ } else {
+ VECCOPY(vd->resol, smd->domain->res);
+ vd->dataset = smoke_get_density(smd->domain->fluid);
+ }
+ } // end of fluid condition
}
}
}