From 286c2ca80be4ae46dc220ada2fcc5bf636d5ff49 Mon Sep 17 00:00:00 2001 From: Daniel Genrich Date: Thu, 20 Aug 2009 00:33:59 +0000 Subject: Smoke: * cache for low res (deactivating high res for now) * new way of view3d rendering of smoke (no longer 3 axes) -using 3dtexture now (introduced into gpu/intern) * introducing LZO and LZMA libs into extern (makefiles missing for now) * reducing memory usage after simulating for the frame ended (freeing temporary buffers) * splitting smoke into 2 modifier for the cache-sake (it cannot handle more than 1 cache on the same modifier-index) * no color on gui anymore * fixing non-power-of-2 resolutions (hopefully) * fixing select-deselect of domain drawing bug * fixing drawobject.c coding style (making Ton happy) ;-) HINT #1: If scons doesn't work -> cmakefiles are up-to-date, couldn't test scons (but i tried to mantain them, too) CODERS HINT #1: we really need a way to disable adding all modifiers through "Add Modifiers" dropdown! WARNING #1: before applying this commit, deactivate your SMOKE DOMAIN in your old files and save them then. You can open them then savely after that. WARNING #2: File and cache format of smoke can be changed, this is not final! --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_modifier.c | 70 +++++++++++++++++++++- source/blender/makesrna/intern/rna_smoke.c | 85 ++++++++++----------------- 3 files changed, 98 insertions(+), 58 deletions(-) (limited to 'source/blender/makesrna') diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index e08bc734242..e4fe92317d4 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -387,6 +387,7 @@ extern StructRNA RNA_SmokeCollSettings; extern StructRNA RNA_SmokeDomainSettings; extern StructRNA RNA_SmokeFlowSettings; extern StructRNA RNA_SmokeModifier; +extern StructRNA RNA_SmokeHRModifier; extern StructRNA RNA_SmoothModifier; extern StructRNA RNA_SoftBodyModifier; extern StructRNA RNA_SoftBodySettings; diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 837158b9ec8..f2c8e404a52 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -68,6 +68,7 @@ EnumPropertyItem modifier_type_items[] ={ {eModifierType_Shrinkwrap, "SHRINKWRAP", ICON_MOD_SHRINKWRAP, "Shrinkwrap", ""}, {eModifierType_SimpleDeform, "SIMPLE_DEFORM", ICON_MOD_SIMPLEDEFORM, "Simple Deform", ""}, {eModifierType_Smoke, "SMOKE", 0, "Smoke", ""}, + {eModifierType_SmokeHR, "SMOKE_HR", 0, "SmokeHR", ""}, {eModifierType_Smooth, "SMOOTH", ICON_MOD_SMOOTH, "Smooth", ""}, {eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""}, {eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""}, @@ -156,6 +157,8 @@ static StructRNA* rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_SurfaceModifier; case eModifierType_Smoke: return &RNA_SmokeModifier; + case eModifierType_SmokeHR: + return &RNA_SmokeHRModifier; default: return &RNA_Modifier; } @@ -181,19 +184,30 @@ static void rna_Smoke_set_type(bContext *C, PointerRNA *ptr) { SmokeModifierData *smd= (SmokeModifierData *)ptr->data; Object *ob= (Object*)ptr->id.data; + + // nothing changed + if((smd->type & MOD_SMOKE_TYPE_DOMAIN) && smd->domain) + return; smokeModifier_free(smd); // XXX TODO: completely free all 3 pointers smokeModifier_createType(smd); // create regarding of selected type - // particle_system_slot_add_exec(C, NULL); - // particle_system_slot_remove_exec(C, NULL); - if(smd->type == MOD_SMOKE_TYPE_DOMAIN) + if(smd->type & MOD_SMOKE_TYPE_DOMAIN) ob->dt = OB_WIRE; // update dependancy since a domain - other type switch could have happened rna_Modifier_dependency_update(C, ptr); } +static void rna_SmokeHR_reset(bContext *C, PointerRNA *ptr) +{ + // SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; + + // smokeModifier_reset(settings->smd); + + // rna_Smoke_update(C, ptr); +} + static void rna_ExplodeModifier_vgroup_get(PointerRNA *ptr, char *value) { ExplodeModifierData *emd= (ExplodeModifierData*)ptr->data; @@ -1499,6 +1513,55 @@ static void rna_def_modifier_cloth(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Point Cache", ""); } +static void rna_def_modifier_smoke_highresolution(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_noise_type_items[] = { + {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, +#if FFTW3 == 1 + {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, +#endif + /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ + {0, NULL, 0, NULL, NULL}}; + + srna= RNA_def_struct(brna, "SmokeHRModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Smoke High Resolution Modifier", "Smoke high resolution simulation modifier."); + RNA_def_struct_sdna(srna, "SmokeHRModifierData"); + + prop= RNA_def_property(srna, "show_highres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_SHOWHIGHRES); + RNA_def_property_ui_text(prop, "High res", "Show high resolution (using amplification)."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); + + prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "noise"); + RNA_def_property_enum_items(prop, prop_noise_type_items); + RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_SmokeHR_reset"); + + prop= RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "amplify"); + RNA_def_property_range(prop, 1, 10); + RNA_def_property_ui_range(prop, 1, 10, 1, 0); + RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise."); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_SmokeHR_reset"); + + prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "strength"); + RNA_def_property_range(prop, 1.0, 10.0); + RNA_def_property_ui_range(prop, 1.0, 10.0, 1, 2); + RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_SmokeHR_reset"); + + prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache"); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache", ""); + +} + static void rna_def_modifier_smoke(BlenderRNA *brna) { StructRNA *srna; @@ -1915,6 +1978,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_multires(brna); rna_def_modifier_surface(brna); rna_def_modifier_smoke(brna); + rna_def_modifier_smoke_highresolution(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 6f1babb495a..a119eefa62c 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -78,11 +78,28 @@ static void rna_Smoke_reset_dependancy(bContext *C, PointerRNA *ptr) rna_Smoke_dependency_update(C, ptr); } +static void rna_Smoke_enable_HR(bContext *C, PointerRNA *ptr) +{ + SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; + Object *ob = (Object*)ptr->id.data; + + if(settings->flags & MOD_SMOKE_HIGHRES) + BLI_addtail(&ob->modifiers, modifier_new(eModifierType_SmokeHR)); + else + { + ModifierData *tmd = modifiers_findByType(ob, eModifierType_SmokeHR); + if(tmd) { + BLI_remlink(&ob->modifiers, tmd); + modifier_free(tmd); + } + } +} + static void rna_Smoke_redraw(bContext *C, PointerRNA *ptr) { SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; - settings->flags |= MOD_SMOKE_VIEW_REDRAWNICE; + // settings->flags |= MOD_SMOKE_VIEW_REDRAWNICE; } static char *rna_SmokeDomainSettings_path(PointerRNA *ptr) @@ -116,14 +133,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) StructRNA *srna; PropertyRNA *prop; - static EnumPropertyItem prop_noise_type_items[] = { - {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, -#if FFTW3 == 1 - {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, -#endif - /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ - {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"); @@ -136,56 +145,19 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Max Res", "Maximal resolution used in the fluid domain."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "omega"); - RNA_def_property_range(prop, 0.02, 1.0); - RNA_def_property_ui_range(prop, 0.02, 1.0, 0.02, 2); - RNA_def_property_ui_text(prop, "Color", "Smoke color (0 = black, 1 = white)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Smoke_redraw"); - - prop= RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "amplify"); - RNA_def_property_range(prop, 1, 10); - RNA_def_property_ui_range(prop, 1, 10, 1, 0); - RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - - prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); - RNA_def_property_ui_text(prop, "High res", "Enable high resolution (using amplification)."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - - prop= RNA_def_property(srna, "viewhighres", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_VIEW_USEBIG); - RNA_def_property_ui_text(prop, "Show High Resolution", "Show high resolution (using amplification)."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_redraw"); - - prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_sdna(prop, NULL, "noise"); - RNA_def_property_enum_items(prop, prop_noise_type_items); - RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - - prop= RNA_def_property(srna, "visibility", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "visibility"); - RNA_def_property_range(prop, 1, 15); - RNA_def_property_ui_range(prop, 1, 15, 1, 0); - RNA_def_property_ui_text(prop, "Display", "How much of the resolution should be shown during preview (every 2nd, 3rd, etc)."); - RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Smoke_redraw"); - prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "alpha"); RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Gravity", "Higher value results in sinking smoke"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); prop= RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "beta"); RNA_def_property_range(prop, -5.0, 5.0); RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); RNA_def_property_ui_text(prop, "Heat", "Higher value results in faster rising smoke."); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); prop= RNA_def_property(srna, "coll_group", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); @@ -208,13 +180,6 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this group."); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); - prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "strength"); - RNA_def_property_range(prop, 1.0, 10.0); - RNA_def_property_ui_range(prop, 1.0, 10.0, 1, 2); - RNA_def_property_ui_text(prop, "Strength", "Strength of wavelet noise"); - RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); - prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "diss_speed"); RNA_def_property_range(prop, 1.0, 100.0); @@ -222,6 +187,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, NC_OBJECT|ND_MODIFIER, NULL); + prop= RNA_def_property(srna, "highres", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); + RNA_def_property_ui_text(prop, "High Resolution Smoke", "Enable high resolution smoke"); + RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_enable_HR"); + 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."); @@ -231,6 +201,11 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG); RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x "); RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, NULL); + + prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NEVER_NULL); + RNA_def_property_pointer_sdna(prop, NULL, "point_cache"); + RNA_def_property_struct_type(prop, "PointCache"); + RNA_def_property_ui_text(prop, "Point Cache", ""); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) -- cgit v1.2.3