diff options
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 105 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 86 |
2 files changed, 171 insertions, 20 deletions
diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index d144ed5f28b..bc3f0733a0d 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -32,8 +32,87 @@ #include "DNA_object_types.h" #include "DNA_object_force.h" +#include "WM_types.h" + #ifdef RNA_RUNTIME +#include "MEM_guardedalloc.h" + +#include "BKE_context.h" +#include "BKE_pointcache.h" + +#include "BLI_blenlib.h" + +static void rna_Cache_toggle_disk_cache(bContext *C, PointerRNA *ptr) +{ + Object *ob = CTX_data_active_object(C); + PointCache *cache = (PointCache*)ptr->data; + PTCacheID *pid = NULL; + ListBase pidlist; + + if(!ob) + return; + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache==cache) + break; + } + + if(pid) + BKE_ptcache_toggle_disk_cache(pid); + + BLI_freelistN(&pidlist); +} + +static void rna_Cache_idname_change(bContext *C, PointerRNA *ptr) +{ + Object *ob = CTX_data_active_object(C); + PointCache *cache = (PointCache*)ptr->data; + PTCacheID *pid = NULL, *pid2; + ListBase pidlist; + int new_name = 1; + char name[80]; + + if(!ob) + return; + + /* TODO: check for proper characters */ + + BKE_ptcache_ids_from_object(&pidlist, ob); + + for(pid=pidlist.first; pid; pid=pid->next) { + if(pid->cache==cache) + pid2 = pid; + else if(strcmp(cache->name, "") && strcmp(cache->name,pid->cache->name)==0) { + /*TODO: report "name exists" to user */ + strcpy(cache->name, cache->prev_name); + new_name = 0; + } + } + + if(new_name) { + if(pid2 && cache->flag & PTCACHE_DISK_CACHE) { + strcpy(name, cache->name); + strcpy(cache->name, cache->prev_name); + + cache->flag &= ~PTCACHE_DISK_CACHE; + + BKE_ptcache_toggle_disk_cache(pid2); + + strcpy(cache->name, name); + + cache->flag |= PTCACHE_DISK_CACHE; + + BKE_ptcache_toggle_disk_cache(pid2); + } + + strcpy(cache->prev_name, cache->name); + } + + BLI_freelistN(&pidlist); +} #else static void rna_def_pointcache(BlenderRNA *brna) @@ -60,6 +139,32 @@ static void rna_def_pointcache(BlenderRNA *brna) prop= RNA_def_property(srna, "baking", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING); + + prop= RNA_def_property(srna, "disk_cache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_DISK_CACHE); + RNA_def_property_ui_text(prop, "Disk Cache", "Save cache files to disk"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache"); + + prop= RNA_def_property(srna, "outdated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_OUTDATED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Cache is outdated", ""); + + prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "name"); + RNA_def_property_ui_text(prop, "Name", "Cache name"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop= RNA_def_property(srna, "autocache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_AUTOCACHE); + RNA_def_property_ui_text(prop, "Auto Cache", "Cache changes automatically"); + //RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_autocache"); + + prop= RNA_def_property(srna, "info", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "info"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Cache Info", "Info on current cache status."); + } static void rna_def_collision(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 8ee71b6fd9e..2c4c75e45eb 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -38,6 +38,7 @@ #include "DNA_scene_types.h" #include "WM_types.h" +#include "WM_api.h" #ifdef RNA_RUNTIME @@ -45,48 +46,93 @@ #include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "BLI_arithb.h" + +/* property update functions */ static void rna_Particle_redo(bContext *C, PointerRNA *ptr) { + Scene *scene = CTX_data_scene(C); ParticleSettings *part; - if(ptr->type==&RNA_ParticleSystem) - part = ((ParticleSystem*)ptr->data)->part; - else + if(ptr->type==&RNA_ParticleSystem) { + ParticleSystem *psys = (ParticleSystem*)ptr->data; + Object *ob = psys_find_object(scene, psys); + + psys->recalc = PSYS_RECALC_REDO; + + if(ob) + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + } + else { part = ptr->id.data; - - psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_REDO); + psys_flush_particle_settings(scene, part, PSYS_RECALC_REDO); + } } static void rna_Particle_reset(bContext *C, PointerRNA *ptr) { + Scene *scene = CTX_data_scene(C); ParticleSettings *part; - if(ptr->type==&RNA_ParticleSystem) - part = ((ParticleSystem*)ptr->data)->part; - else - part = ptr->id.data; - psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_REDO); + if(ptr->type==&RNA_ParticleSystem) { + ParticleSystem *psys = (ParticleSystem*)ptr->data; + Object *ob = psys_find_object(scene, psys); + + psys->recalc = PSYS_RECALC_RESET; + + if(ob) { + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene); + } + } + else { + part = ptr->id.data; + psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET); + //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene); + } } static void rna_Particle_change_type(bContext *C, PointerRNA *ptr) { + Scene *scene = CTX_data_scene(C); ParticleSettings *part; - if(ptr->type==&RNA_ParticleSystem) - part = ((ParticleSystem*)ptr->data)->part; - else - part = ptr->id.data; - psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE|PSYS_RECALC_REDO); + if(ptr->type==&RNA_ParticleSystem) { + ParticleSystem *psys = (ParticleSystem*)ptr->data; + Object *ob = psys_find_object(scene, psys); + + psys->recalc = PSYS_RECALC_RESET|PSYS_RECALC_TYPE; + + if(ob) { + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene); + } + } + else { + part = ptr->id.data; + psys_flush_particle_settings(scene, part, PSYS_RECALC_RESET|PSYS_RECALC_TYPE); + //WM_event_add_notifier(C, NC_SCENE|ND_CACHE_PHYSICS, scene); + } } static void rna_Particle_redo_child(bContext *C, PointerRNA *ptr) { + Scene *scene = CTX_data_scene(C); ParticleSettings *part; - if(ptr->type==&RNA_ParticleSystem) - part = ((ParticleSystem*)ptr->data)->part; - else + + if(ptr->type==&RNA_ParticleSystem) { + ParticleSystem *psys = (ParticleSystem*)ptr->data; + Object *ob = psys_find_object(scene, psys); + + psys->recalc = PSYS_RECALC_CHILD; + + if(ob) + DAG_object_flush_update(scene, ob, OB_RECALC_DATA); + } + else { part = ptr->id.data; - psys_flush_particle_settings(CTX_data_scene(C), part, PSYS_RECALC_CHILD); + psys_flush_particle_settings(scene, part, PSYS_RECALC_CHILD); + } } static void rna_PartSettings_start_set(struct PointerRNA *ptr, float value) { @@ -887,7 +933,7 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_int_sdna(prop, NULL, "disp"); RNA_def_property_range(prop, 0, 100); RNA_def_property_ui_text(prop, "Display", "Percentage of particles to display in 3d view"); - RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo"); + RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_reset"); prop= RNA_def_property(srna, "material", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "omat"); |