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