|
Blender
V2.59
|
00001 /* 00002 * $Id: rna_smoke.c 37031 2011-05-31 02:14:25Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * Contributor(s): Daniel Genrich 00021 * 00022 * ***** END GPL LICENSE BLOCK ***** 00023 */ 00024 00030 #include <stdlib.h> 00031 #include <limits.h> 00032 00033 #include "RNA_define.h" 00034 00035 #include "rna_internal.h" 00036 00037 #include "BKE_modifier.h" 00038 #include "BKE_smoke.h" 00039 00040 #include "DNA_modifier_types.h" 00041 #include "DNA_object_force.h" 00042 #include "DNA_object_types.h" 00043 #include "DNA_scene_types.h" 00044 #include "DNA_smoke_types.h" 00045 00046 #include "WM_types.h" 00047 00048 00049 #ifdef RNA_RUNTIME 00050 00051 #include "BKE_context.h" 00052 #include "BKE_depsgraph.h" 00053 #include "BKE_particle.h" 00054 00055 00056 static void rna_Smoke_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) 00057 { 00058 DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); 00059 } 00060 00061 static void rna_Smoke_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) 00062 { 00063 rna_Smoke_update(bmain, scene, ptr); 00064 DAG_scene_sort(bmain, scene); 00065 } 00066 00067 static void rna_Smoke_reset(Main *bmain, Scene *scene, PointerRNA *ptr) 00068 { 00069 SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; 00070 00071 smokeModifier_reset(settings->smd); 00072 00073 if(settings->smd && settings->smd->domain) 00074 settings->point_cache[0]->flag |= PTCACHE_OUTDATED; 00075 00076 rna_Smoke_update(bmain, scene, ptr); 00077 } 00078 00079 static void rna_Smoke_reset_dependancy(Main *bmain, Scene *scene, PointerRNA *ptr) 00080 { 00081 SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; 00082 00083 smokeModifier_reset(settings->smd); 00084 00085 if(settings->smd && settings->smd->domain) 00086 settings->smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; 00087 00088 rna_Smoke_dependency_update(bmain, scene, ptr); 00089 } 00090 00091 static char *rna_SmokeDomainSettings_path(PointerRNA *ptr) 00092 { 00093 SmokeDomainSettings *settings = (SmokeDomainSettings*)ptr->data; 00094 ModifierData *md= (ModifierData *)settings->smd; 00095 00096 return BLI_sprintfN("modifiers[\"%s\"].domain_settings", md->name); 00097 } 00098 00099 static char *rna_SmokeFlowSettings_path(PointerRNA *ptr) 00100 { 00101 SmokeFlowSettings *settings = (SmokeFlowSettings*)ptr->data; 00102 ModifierData *md= (ModifierData *)settings->smd; 00103 00104 return BLI_sprintfN("modifiers[\"%s\"].flow_settings", md->name); 00105 } 00106 00107 static char *rna_SmokeCollSettings_path(PointerRNA *ptr) 00108 { 00109 SmokeCollSettings *settings = (SmokeCollSettings*)ptr->data; 00110 ModifierData *md= (ModifierData *)settings->smd; 00111 00112 return BLI_sprintfN("modifiers[\"%s\"].coll_settings", md->name); 00113 } 00114 00115 #else 00116 00117 static void rna_def_smoke_domain_settings(BlenderRNA *brna) 00118 { 00119 StructRNA *srna; 00120 PropertyRNA *prop; 00121 00122 static EnumPropertyItem prop_noise_type_items[] = { 00123 {MOD_SMOKE_NOISEWAVE, "NOISEWAVE", 0, "Wavelet", ""}, 00124 #if FFTW3 == 1 00125 {MOD_SMOKE_NOISEFFT, "NOISEFFT", 0, "FFT", ""}, 00126 #endif 00127 /* {MOD_SMOKE_NOISECURL, "NOISECURL", 0, "Curl", ""}, */ 00128 {0, NULL, 0, NULL, NULL}}; 00129 00130 static EnumPropertyItem smoke_cache_comp_items[] = { 00131 {SM_CACHE_LIGHT, "CACHELIGHT", 0, "Light", "Fast but not so effective compression"}, 00132 {SM_CACHE_HEAVY, "CACHEHEAVY", 0, "Heavy", "Effective but slow compression"}, 00133 {0, NULL, 0, NULL, NULL}}; 00134 00135 static EnumPropertyItem smoke_domain_colli_items[] = { 00136 {SM_BORDER_OPEN, "BORDEROPEN", 0, "Open", "Smoke doesn't collide with any border"}, 00137 {SM_BORDER_VERTICAL, "BORDERVERTICAL", 0, "Vertically Open", "Smoke doesn't collide with top and bottom sides"}, 00138 {SM_BORDER_CLOSED, "BORDERCLOSED", 0, "Collide All", "Smoke collides with every side"}, 00139 {0, NULL, 0, NULL, NULL}}; 00140 00141 srna = RNA_def_struct(brna, "SmokeDomainSettings", NULL); 00142 RNA_def_struct_ui_text(srna, "Domain Settings", "Smoke domain settings"); 00143 RNA_def_struct_sdna(srna, "SmokeDomainSettings"); 00144 RNA_def_struct_path_func(srna, "rna_SmokeDomainSettings_path"); 00145 00146 prop= RNA_def_property(srna, "resolution_max", PROP_INT, PROP_NONE); 00147 RNA_def_property_int_sdna(prop, NULL, "maxres"); 00148 RNA_def_property_range(prop, 24, 512); 00149 RNA_def_property_ui_range(prop, 24, 512, 2, 0); 00150 RNA_def_property_ui_text(prop, "Max Res", "Maximal resolution used in the fluid domain"); 00151 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00152 00153 prop= RNA_def_property(srna, "amplify", PROP_INT, PROP_NONE); 00154 RNA_def_property_int_sdna(prop, NULL, "amplify"); 00155 RNA_def_property_range(prop, 1, 10); 00156 RNA_def_property_ui_range(prop, 1, 10, 1, 0); 00157 RNA_def_property_ui_text(prop, "Amplification", "Enhance the resolution of smoke by this factor using noise"); 00158 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00159 00160 prop= RNA_def_property(srna, "use_high_resolution", PROP_BOOLEAN, PROP_NONE); 00161 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGHRES); 00162 RNA_def_property_ui_text(prop, "High res", "Enable high resolution (using amplification)"); 00163 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00164 00165 prop= RNA_def_property(srna, "show_high_resolution", PROP_BOOLEAN, PROP_NONE); 00166 RNA_def_property_boolean_sdna(prop, NULL, "viewsettings", MOD_SMOKE_VIEW_SHOWBIG); 00167 RNA_def_property_ui_text(prop, "Show High Resolution", "Show high resolution (using amplification)"); 00168 RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL); 00169 00170 prop= RNA_def_property(srna, "noise_type", PROP_ENUM, PROP_NONE); 00171 RNA_def_property_enum_sdna(prop, NULL, "noise"); 00172 RNA_def_property_enum_items(prop, prop_noise_type_items); 00173 RNA_def_property_ui_text(prop, "Noise Method", "Noise method which is used for creating the high resolution"); 00174 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00175 00176 prop= RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE); 00177 RNA_def_property_float_sdna(prop, NULL, "alpha"); 00178 RNA_def_property_range(prop, -5.0, 5.0); 00179 RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); 00180 RNA_def_property_ui_text(prop, "Density", "How much density effects smoke motion, higher value results in faster rising smoke"); 00181 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00182 00183 prop= RNA_def_property(srna, "beta", PROP_FLOAT, PROP_NONE); 00184 RNA_def_property_float_sdna(prop, NULL, "beta"); 00185 RNA_def_property_range(prop, -5.0, 5.0); 00186 RNA_def_property_ui_range(prop, -5.0, 5.0, 0.02, 5); 00187 RNA_def_property_ui_text(prop, "Heat", "How much heat effects smoke motion, higher value results in faster rising smoke"); 00188 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00189 00190 prop= RNA_def_property(srna, "collision_group", PROP_POINTER, PROP_NONE); 00191 RNA_def_property_pointer_sdna(prop, NULL, "coll_group"); 00192 RNA_def_property_struct_type(prop, "Group"); 00193 RNA_def_property_flag(prop, PROP_EDITABLE); 00194 RNA_def_property_ui_text(prop, "Collision Group", "Limit collisions to this group"); 00195 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); 00196 00197 prop= RNA_def_property(srna, "fluid_group", PROP_POINTER, PROP_NONE); 00198 RNA_def_property_pointer_sdna(prop, NULL, "fluid_group"); 00199 RNA_def_property_struct_type(prop, "Group"); 00200 RNA_def_property_flag(prop, PROP_EDITABLE); 00201 RNA_def_property_ui_text(prop, "Fluid Group", "Limit fluid objects to this group"); 00202 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); 00203 00204 prop= RNA_def_property(srna, "effector_group", PROP_POINTER, PROP_NONE); 00205 RNA_def_property_pointer_sdna(prop, NULL, "eff_group"); 00206 RNA_def_property_struct_type(prop, "Group"); 00207 RNA_def_property_flag(prop, PROP_EDITABLE); 00208 RNA_def_property_ui_text(prop, "Effector Group", "Limit effectors to this group"); 00209 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset_dependancy"); 00210 00211 prop= RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); 00212 RNA_def_property_float_sdna(prop, NULL, "strength"); 00213 RNA_def_property_range(prop, 0.0, 10.0); 00214 RNA_def_property_ui_range(prop, 0.0, 10.0, 1, 2); 00215 RNA_def_property_ui_text(prop, "Strength", "Strength of noise"); 00216 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00217 00218 prop= RNA_def_property(srna, "dissolve_speed", PROP_INT, PROP_NONE); 00219 RNA_def_property_int_sdna(prop, NULL, "diss_speed"); 00220 RNA_def_property_range(prop, 1.0, 10000.0); 00221 RNA_def_property_ui_range(prop, 1.0, 10000.0, 1, 0); 00222 RNA_def_property_ui_text(prop, "Dissolve Speed", "Dissolve Speed"); 00223 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00224 00225 prop= RNA_def_property(srna, "use_dissolve_smoke", PROP_BOOLEAN, PROP_NONE); 00226 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE); 00227 RNA_def_property_ui_text(prop, "Dissolve Smoke", "Enable smoke to disappear over time"); 00228 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00229 00230 prop= RNA_def_property(srna, "use_dissolve_smoke_log", PROP_BOOLEAN, PROP_NONE); 00231 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_DISSOLVE_LOG); 00232 RNA_def_property_ui_text(prop, "Logarithmic dissolve", "Using 1/x "); 00233 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00234 00235 prop= RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE); 00236 RNA_def_property_flag(prop, PROP_NEVER_NULL); 00237 RNA_def_property_pointer_sdna(prop, NULL, "point_cache[0]"); 00238 RNA_def_property_ui_text(prop, "Point Cache", ""); 00239 00240 prop= RNA_def_property(srna, "point_cache_compress_type", PROP_ENUM, PROP_NONE); 00241 RNA_def_property_enum_sdna(prop, NULL, "cache_comp"); 00242 RNA_def_property_enum_items(prop, smoke_cache_comp_items); 00243 RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); 00244 RNA_def_property_update(prop, 0, NULL); 00245 00246 prop= RNA_def_property(srna, "collision_extents", PROP_ENUM, PROP_NONE); 00247 RNA_def_property_enum_sdna(prop, NULL, "border_collisions"); 00248 RNA_def_property_enum_items(prop, smoke_domain_colli_items); 00249 RNA_def_property_ui_text(prop, "Border Collisions", "Selects which domain border will be treated as collision object."); 00250 RNA_def_property_update(prop, 0, NULL); 00251 00252 prop= RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); 00253 RNA_def_property_struct_type(prop, "EffectorWeights"); 00254 RNA_def_property_clear_flag(prop, PROP_EDITABLE); 00255 RNA_def_property_ui_text(prop, "Effector Weights", ""); 00256 00257 prop= RNA_def_property(srna, "smooth_emitter", PROP_BOOLEAN, PROP_NONE); 00258 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_HIGH_SMOOTH); 00259 RNA_def_property_ui_text(prop, "Smooth Emitter", "Smoothens emitted smoke to avoid blockiness."); 00260 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00261 00262 prop= RNA_def_property(srna, "time_scale", PROP_FLOAT, PROP_NONE); 00263 RNA_def_property_float_sdna(prop, NULL, "time_scale"); 00264 RNA_def_property_range(prop, 0.2, 1.5); 00265 RNA_def_property_ui_range(prop, 0.2, 1.5, 0.02, 5); 00266 RNA_def_property_ui_text(prop, "Time Scale", "Adjust simulation speed."); 00267 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00268 00269 prop= RNA_def_property(srna, "vorticity", PROP_FLOAT, PROP_NONE); 00270 RNA_def_property_float_sdna(prop, NULL, "vorticity"); 00271 RNA_def_property_range(prop, 0.01, 4.0); 00272 RNA_def_property_ui_range(prop, 0.01, 4.0, 0.02, 5); 00273 RNA_def_property_ui_text(prop, "Vorticity", "Amount of turbulence/rotation in fluid."); 00274 RNA_def_property_update(prop, NC_OBJECT|ND_MODIFIER, "rna_Smoke_reset"); 00275 00276 } 00277 00278 static void rna_def_smoke_flow_settings(BlenderRNA *brna) 00279 { 00280 StructRNA *srna; 00281 PropertyRNA *prop; 00282 00283 srna = RNA_def_struct(brna, "SmokeFlowSettings", NULL); 00284 RNA_def_struct_ui_text(srna, "Flow Settings", "Smoke flow settings"); 00285 RNA_def_struct_sdna(srna, "SmokeFlowSettings"); 00286 RNA_def_struct_path_func(srna, "rna_SmokeFlowSettings_path"); 00287 00288 prop= RNA_def_property(srna, "density", PROP_FLOAT, PROP_NONE); 00289 RNA_def_property_float_sdna(prop, NULL, "density"); 00290 RNA_def_property_range(prop, 0.001, 1); 00291 RNA_def_property_ui_range(prop, 0.001, 1.0, 1.0, 4); 00292 RNA_def_property_ui_text(prop, "Density", ""); 00293 RNA_def_property_update(prop, 0, NULL); // NC_OBJECT|ND_MODIFIER 00294 00295 prop= RNA_def_property(srna, "temperature", PROP_FLOAT, PROP_NONE); 00296 RNA_def_property_float_sdna(prop, NULL, "temp"); 00297 RNA_def_property_range(prop, -10, 10); 00298 RNA_def_property_ui_range(prop, -10, 10, 1, 1); 00299 RNA_def_property_ui_text(prop, "Temp. Diff.", "Temperature difference to ambient temperature"); 00300 RNA_def_property_update(prop, 0, NULL); 00301 00302 prop= RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); 00303 RNA_def_property_pointer_sdna(prop, NULL, "psys"); 00304 RNA_def_property_struct_type(prop, "ParticleSystem"); 00305 RNA_def_property_flag(prop, PROP_EDITABLE); 00306 RNA_def_property_ui_text(prop, "Particle Systems", "Particle systems emitted from the object"); 00307 RNA_def_property_update(prop, 0, "rna_Smoke_reset_dependancy"); 00308 00309 prop= RNA_def_property(srna, "use_outflow", PROP_BOOLEAN, PROP_NONE); 00310 RNA_def_property_boolean_sdna(prop, NULL, "type", MOD_SMOKE_FLOW_TYPE_OUTFLOW); 00311 RNA_def_property_ui_text(prop, "Outflow", "Deletes smoke from simulation"); 00312 RNA_def_property_update(prop, 0, NULL); 00313 00314 prop= RNA_def_property(srna, "use_absolute", PROP_BOOLEAN, PROP_NONE); 00315 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_ABSOLUTE); 00316 RNA_def_property_ui_text(prop, "Absolute Density", "Only allows given density value in emitter area."); 00317 RNA_def_property_update(prop, 0, NULL); 00318 00319 prop= RNA_def_property(srna, "initial_velocity", PROP_BOOLEAN, PROP_NONE); 00320 RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_INITVELOCITY); 00321 RNA_def_property_ui_text(prop, "Initial Velocity", "Smoke inherits it's velocity from the emitter particle"); 00322 RNA_def_property_update(prop, 0, NULL); 00323 00324 prop= RNA_def_property(srna, "velocity_factor", PROP_FLOAT, PROP_NONE); 00325 RNA_def_property_float_sdna(prop, NULL, "vel_multi"); 00326 RNA_def_property_range(prop, -2.0, 2.0); 00327 RNA_def_property_ui_range(prop, -2.0, 2.0, 0.05, 5); 00328 RNA_def_property_ui_text(prop, "Multiplier", "Multiplier to adjust velocity passed to smoke"); 00329 RNA_def_property_update(prop, 0, NULL); 00330 } 00331 00332 static void rna_def_smoke_coll_settings(BlenderRNA *brna) 00333 { 00334 StructRNA *srna; 00335 00336 srna = RNA_def_struct(brna, "SmokeCollSettings", NULL); 00337 RNA_def_struct_ui_text(srna, "Collision Settings", "Smoke collision settings"); 00338 RNA_def_struct_sdna(srna, "SmokeCollSettings"); 00339 RNA_def_struct_path_func(srna, "rna_SmokeCollSettings_path"); 00340 } 00341 00342 void RNA_def_smoke(BlenderRNA *brna) 00343 { 00344 rna_def_smoke_domain_settings(brna); 00345 rna_def_smoke_flow_settings(brna); 00346 rna_def_smoke_coll_settings(brna); 00347 } 00348 00349 #endif 00350