diff options
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 6 | ||||
-rw-r--r-- | source/blender/makesrna/intern/SConscript | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fluidsim.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 21 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object_force.c | 350 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_particle.c | 11 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pointcache.c | 294 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_smoke.c | 5 |
10 files changed, 328 insertions, 364 deletions
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index e64743c5536..c6c5b54f989 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -70,6 +70,7 @@ set(DEFSRC rna_object_force.c rna_packedfile.c rna_particle.c + rna_pointcache.c rna_pose.c rna_property.c rna_render.c @@ -280,6 +281,10 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_ALEMBIC) + add_definitions(-DWITH_ALEMBIC) +endif() + # Build makesrna executable blender_include_dirs( . @@ -293,6 +298,7 @@ blender_include_dirs( ../../ikplugin ../../makesdna ../../nodes/ + ../../pointcache/ ../../windowmanager ../../editors/include ../../render/extern/include diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index 28151fe5db1..7ff671a0e9b 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -72,6 +72,7 @@ incs = [ '../../imbuf', '../../makesdna', '../../makesrna', + '../../pointcache', '../../render/extern/include', '../../windowmanager', ] diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index 9b33e1f5c28..40d752a3ed2 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3303,6 +3303,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_object_force.c", NULL, RNA_def_object_force}, {"rna_packedfile.c", NULL, RNA_def_packedfile}, {"rna_particle.c", NULL, RNA_def_particle}, + {"rna_pointcache.c", NULL, RNA_def_pointcache}, {"rna_pose.c", "rna_pose_api.c", RNA_def_pose}, {"rna_property.c", NULL, RNA_def_gameproperty}, {"rna_render.c", NULL, RNA_def_render}, diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 01feb3cb748..5e2bee12c00 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -141,7 +141,7 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA part->type = PART_FLUID; psys->part = part; - psys->pointcache = BKE_ptcache_add(&psys->ptcaches); + psys->pointcache = BKE_ptcache_new(); BLI_strncpy(psys->name, "FluidParticles", sizeof(psys->name)); BLI_addtail(&ob->particlesystem, psys); diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 051e7277425..2b1df7a713e 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -165,6 +165,7 @@ void RNA_def_object(struct BlenderRNA *brna); void RNA_def_object_force(struct BlenderRNA *brna); void RNA_def_packedfile(struct BlenderRNA *brna); void RNA_def_particle(struct BlenderRNA *brna); +void RNA_def_pointcache(struct BlenderRNA *brna); void RNA_def_pose(struct BlenderRNA *brna); void RNA_def_render(struct BlenderRNA *brna); void RNA_def_rigidbody(struct BlenderRNA *brna); diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 4911c106f53..5c63b95eaaf 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -58,6 +58,7 @@ EnumPropertyItem modifier_type_items[] = { {0, "", 0, N_("Modify"), ""}, {eModifierType_MeshCache, "MESH_CACHE", ICON_MOD_MESHDEFORM, "Mesh Cache", ""}, + {eModifierType_PointCache, "POINT_CACHE", ICON_MOD_MESHDEFORM, "Point Cache", ""}, {eModifierType_UVProject, "UV_PROJECT", ICON_MOD_UVPROJECT, "UV Project", ""}, {eModifierType_UVWarp, "UV_WARP", ICON_MOD_UVPROJECT, "UV Warp", ""}, {eModifierType_WeightVGEdit, "VERTEX_WEIGHT_EDIT", ICON_MOD_VERTEX_WEIGHT, "Vertex Weight Edit", ""}, @@ -244,6 +245,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr) return &RNA_LaplacianDeformModifier; case eModifierType_Wireframe: return &RNA_WireframeModifier; + case eModifierType_PointCache: + return &RNA_PointCacheModifier; /* Default */ case eModifierType_None: case eModifierType_ShapeKey: @@ -3664,6 +3667,23 @@ static void rna_def_modifier_wireframe(BlenderRNA *brna) RNA_def_property_update(prop, 0, "rna_Modifier_update"); } +static void rna_def_modifier_pointcache(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "PointCacheModifier", "Modifier"); + RNA_def_struct_ui_text(srna, "Point Cache Modifier", "Write and Read mesh results to/from point cache"); + RNA_def_struct_sdna(srna, "PointCacheModifierData"); + RNA_def_struct_ui_icon(srna, ICON_MOD_MESHDEFORM); /* XXX, needs own icon */ + + prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, 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", ""); +} + void RNA_def_modifier(BlenderRNA *brna) { StructRNA *srna; @@ -3777,6 +3797,7 @@ void RNA_def_modifier(BlenderRNA *brna) rna_def_modifier_meshcache(brna); rna_def_modifier_laplaciandeform(brna); rna_def_modifier_wireframe(brna); + rna_def_modifier_pointcache(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index cd28c608667..6170d33cced 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -100,221 +100,6 @@ static EnumPropertyItem empty_vortex_shape_items[] = { #include "ED_object.h" -static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL; - ListBase pidlist; - - if (!ob) - return; - - cache->flag |= PTCACHE_OUTDATED; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } - - if (pid) { - /* Just make sure this wasn't changed. */ - if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) - cache->step = 1; - BKE_ptcache_update_info(pid); - } - - BLI_freelistN(&pidlist); -} - -static void rna_Cache_toggle_disk_cache(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL; - ListBase pidlist; - - if (!ob) - return; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } - - /* smoke can only use disk cache */ - if (pid && pid->type != PTCACHE_TYPE_SMOKE_DOMAIN) - BKE_ptcache_toggle_disk_cache(pid); - else - cache->flag ^= PTCACHE_DISK_CACHE; - - BLI_freelistN(&pidlist); -} - -static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) -{ - Object *ob = (Object *)ptr->id.data; - PointCache *cache = (PointCache *)ptr->data; - PTCacheID *pid = NULL, *pid2 = NULL; - ListBase pidlist; - int new_name = 1; - - if (!ob) - return; - - /* TODO: check for proper characters */ - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - if (cache->flag & PTCACHE_EXTERNAL) { - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - break; - } - - if (!pid) - return; - - BKE_ptcache_load_external(pid); - - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, ob); - } - else { - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) - pid2 = pid; - else if (cache->name[0] != '\0' && strcmp(cache->name, pid->cache->name) == 0) { - /*TODO: report "name exists" to user */ - BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name)); - new_name = 0; - } - } - - if (new_name) { - if (pid2 && cache->flag & PTCACHE_DISK_CACHE) { - char old_name[80]; - char new_name[80]; - - BLI_strncpy(old_name, cache->prev_name, sizeof(old_name)); - BLI_strncpy(new_name, cache->name, sizeof(new_name)); - - BKE_ptcache_disk_cache_rename(pid2, old_name, new_name); - } - - BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name)); - } - } - - BLI_freelistN(&pidlist); -} - -static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) -{ - PointCache *cache = ptr->data; - ListBase lb; - - while (cache->prev) - cache = cache->prev; - - lb.first = cache; - lb.last = NULL; /* not used by listbase_begin */ - - rna_iterator_listbase_begin(iter, &lb, NULL); -} -static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max, - int *UNUSED(softmin), int *UNUSED(softmax)) -{ - Object *ob = ptr->id.data; - PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - *min = 0; - *max = 0; - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *max = max_ii(0, BLI_listbase_count(pid->ptcaches) - 1); - break; - } - } - - BLI_freelistN(&pidlist); -} - -static int rna_Cache_active_point_cache_index_get(PointerRNA *ptr) -{ - Object *ob = ptr->id.data; - PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - int num = 0; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - num = BLI_findindex(pid->ptcaches, cache); - break; - } - } - - BLI_freelistN(&pidlist); - - return num; -} - -static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int value) -{ - Object *ob = ptr->id.data; - PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *(pid->cache_ptr) = BLI_findlink(pid->ptcaches, value); - break; - } - } - - BLI_freelistN(&pidlist); -} - -static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, - int *UNUSED(softmin), int *UNUSED(softmax)) -{ - Object *ob = ptr->id.data; - PointCache *cache = ptr->data; - PTCacheID *pid; - ListBase pidlist; - - *min = 1; - *max = 20; - - BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); - - for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->cache == cache) { - *max = pid->max_step; - break; - } - } - - BLI_freelistN(&pidlist); -} - static char *rna_CollisionSettings_path(PointerRNA *UNUSED(ptr)) { /* both methods work ok, but return the shorter path */ @@ -760,140 +545,6 @@ static EnumPropertyItem *rna_Effector_shape_itemf(bContext *UNUSED(C), PointerRN #else -/* ptcache.point_caches */ -static void rna_def_ptcache_point_caches(BlenderRNA *brna, PropertyRNA *cprop) -{ - StructRNA *srna; - PropertyRNA *prop; - - /* FunctionRNA *func; */ - /* PropertyRNA *parm; */ - - RNA_def_property_srna(cprop, "PointCaches"); - srna = RNA_def_struct(brna, "PointCaches", NULL); - RNA_def_struct_sdna(srna, "PointCache"); - RNA_def_struct_ui_text(srna, "Point Caches", "Collection of point caches"); - - prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); - RNA_def_property_int_funcs(prop, "rna_Cache_active_point_cache_index_get", - "rna_Cache_active_point_cache_index_set", - "rna_Cache_active_point_cache_index_range"); - RNA_def_property_ui_text(prop, "Active Point Cache Index", ""); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); -} - -static void rna_def_pointcache(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - static EnumPropertyItem point_cache_compress_items[] = { - {PTCACHE_COMPRESS_NO, "NO", 0, "No", "No compression"}, - {PTCACHE_COMPRESS_LZO, "LIGHT", 0, "Light", "Fast but not so effective compression"}, - {PTCACHE_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"}, - {0, NULL, 0, NULL, NULL} - }; - - srna = RNA_def_struct(brna, "PointCache", NULL); - RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations"); - RNA_def_struct_ui_icon(srna, ICON_PHYSICS); - - prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); - RNA_def_property_int_sdna(prop, NULL, "startframe"); - RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); - RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1); - RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts"); - - prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); - RNA_def_property_int_sdna(prop, NULL, "endframe"); - RNA_def_property_range(prop, 1, MAXFRAME); - RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops"); - - prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "step"); - RNA_def_property_range(prop, 1, 20); - RNA_def_property_int_funcs(prop, NULL, NULL, "rna_PointCache_frame_step_range"); - RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); - - prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "index"); - RNA_def_property_range(prop, -1, 100); - RNA_def_property_ui_text(prop, "Cache Index", "Index number of cache files"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); - - prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE); - RNA_def_property_enum_items(prop, point_cache_compress_items); - RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); - - /* flags */ - prop = RNA_def_property(srna, "is_baked", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "is_baking", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_BAKING); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - prop = RNA_def_property(srna, "use_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 (.blend file must be saved first)"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_toggle_disk_cache"); - - prop = RNA_def_property(srna, "is_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, "frames_skipped", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_FRAMES_SKIPPED); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - - 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"); - RNA_def_struct_name_property(srna, prop); - - prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); - RNA_def_property_string_sdna(prop, NULL, "path"); - RNA_def_property_ui_text(prop, "File Path", "Cache file path"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); - - /* removed, see PTCACHE_QUICK_CACHE */ -#if 0 - prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE); - RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); -#endif - - 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"); - - prop = RNA_def_property(srna, "use_external", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_EXTERNAL); - RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); - - prop = RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTCACHE_IGNORE_LIBPATH); - RNA_def_property_ui_text(prop, "Library Path", - "Use this file's path for the disk cache when library linked into another file " - "(for local bakes per scene file, disable this option)"); - RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); - - prop = RNA_def_property(srna, "point_caches", PROP_COLLECTION, PROP_NONE); - RNA_def_property_collection_funcs(prop, "rna_Cache_list_begin", "rna_iterator_listbase_next", - "rna_iterator_listbase_end", "rna_iterator_listbase_get", - NULL, NULL, NULL, NULL); - RNA_def_property_struct_type(prop, "PointCache"); - RNA_def_property_ui_text(prop, "Point Cache List", "Point cache list"); - rna_def_ptcache_point_caches(brna, prop); -} - static void rna_def_collision(BlenderRNA *brna) { StructRNA *srna; @@ -1865,7 +1516,6 @@ static void rna_def_softbody(BlenderRNA *brna) void RNA_def_object_force(BlenderRNA *brna) { - rna_def_pointcache(brna); rna_def_collision(brna); rna_def_effector_weight(brna); rna_def_field(brna); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index dd32bb189e2..5c5f0c1ec36 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -978,12 +978,6 @@ static char *rna_SPHFluidSettings_path(PointerRNA *ptr) return NULL; } -static int rna_ParticleSystem_multiple_caches_get(PointerRNA *ptr) -{ - ParticleSystem *psys = (ParticleSystem *)ptr->data; - - return (psys->ptcaches.first != psys->ptcaches.last); -} static int rna_ParticleSystem_editable_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; @@ -3349,11 +3343,6 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_property_struct_type(prop, "PointCache"); RNA_def_property_ui_text(prop, "Point Cache", ""); - prop = RNA_def_property(srna, "has_multiple_caches", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_funcs(prop, "rna_ParticleSystem_multiple_caches_get", NULL); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text(prop, "Multiple Caches", "Particle system has multiple point caches"); - /* offset ob */ prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "parent"); diff --git a/source/blender/makesrna/intern/rna_pointcache.c b/source/blender/makesrna/intern/rna_pointcache.c new file mode 100644 index 00000000000..6422013f469 --- /dev/null +++ b/source/blender/makesrna/intern/rna_pointcache.c @@ -0,0 +1,294 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Blender Foundation, + * Sergey Sharybin + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_pointcache.c + * \ingroup RNA + */ + +/* XXX hack, remove later */ +#define POINTCACHE_OLD + +#include "DNA_object_force.h" +#include "DNA_pointcache_types.h" +#include "DNA_scene_types.h" + +#include "RNA_define.h" +#include "RNA_types.h" + +#include "rna_internal.h" + +#include "PTC_api.h" + +#include "WM_api.h" +#include "WM_types.h" + +#ifdef RNA_RUNTIME + +#ifdef POINTCACHE_OLD +#include "BLI_math_base.h" + +#include "DNA_object_types.h" + +#include "BKE_depsgraph.h" +#include "BKE_pointcache.h" + +static void rna_Cache_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + PointCache *cache = (PointCache *)ptr->data; + PTCacheID *pid = NULL; + ListBase pidlist; + + if (!ob) + return; + + cache->state.flag |= PTC_STATE_OUTDATED; + + BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + + for (pid = pidlist.first; pid; pid = pid->next) { + if (pid->cache == cache) + break; + } + + if (pid) { + /* Just make sure this wasn't changed. */ + if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN) + cache->step = 1; + BKE_ptcache_update_info(pid); + } + + BLI_freelistN(&pidlist); +} + +static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + PointCache *cache = (PointCache *)ptr->data; + PTCacheID *pid = NULL, *pid2 = NULL; + ListBase pidlist; + int new_name = 1; + + if (!ob) + return; + + /* TODO: check for proper characters */ + + BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + + if (cache->flag & PTC_EXTERNAL) { + for (pid = pidlist.first; pid; pid = pid->next) { + if (pid->cache == cache) + break; + } + + if (!pid) + return; + + BKE_ptcache_load_external(pid); + + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_POINTCACHE, ob); + } + else { + for (pid = pidlist.first; pid; pid = pid->next) { + if (pid->cache == cache) + pid2 = pid; + else if (cache->name[0] != '\0' && strcmp(cache->name, pid->cache->name) == 0) { + /*TODO: report "name exists" to user */ + BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name)); + new_name = 0; + } + } + + if (new_name) { + if (pid2) { + char old_name[80]; + char new_name[80]; + + BLI_strncpy(old_name, cache->prev_name, sizeof(old_name)); + BLI_strncpy(new_name, cache->name, sizeof(new_name)); + + BKE_ptcache_disk_cache_rename(pid2, old_name, new_name); + } + + BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name)); + } + } + + BLI_freelistN(&pidlist); +} + +static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + Object *ob = ptr->id.data; + PointCache *cache = ptr->data; + PTCacheID *pid; + ListBase pidlist; + + *min = 1; + *max = 20; + + BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0); + + for (pid = pidlist.first; pid; pid = pid->next) { + if (pid->cache == cache) { + *max = pid->max_step; + break; + } + } + + BLI_freelistN(&pidlist); +} +#endif /*POINTCACHE_OLD*/ + +#else + +static void rna_def_pointcache_state(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "PointCacheState", NULL); + RNA_def_struct_ui_text(srna, "Point Cache State", "State information about point cache data"); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); + + prop = RNA_def_property(srna, "is_baking", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTC_STATE_BAKING); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + prop = RNA_def_property(srna, "is_outdated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTC_STATE_OUTDATED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Cache is outdated", ""); + + prop = RNA_def_property(srna, "frames_skipped", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTC_STATE_FRAMES_SKIPPED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + + 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_pointcache(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + +#ifdef POINTCACHE_OLD + static EnumPropertyItem point_cache_compress_items[] = { + {PTC_COMPRESS_NO, "NO", 0, "No", "No compression"}, + {PTC_COMPRESS_LZO, "LIGHT", 0, "Light", "Fast but not so effective compression"}, + {PTC_COMPRESS_LZMA, "HEAVY", 0, "Heavy", "Effective but slow compression"}, + {0, NULL, 0, NULL, NULL} + }; +#endif /*POINTCACHE_OLD*/ + + srna = RNA_def_struct(brna, "PointCache", NULL); + RNA_def_struct_ui_text(srna, "Point Cache", "Point cache for physics simulations"); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); + +#ifdef POINTCACHE_OLD + prop = RNA_def_property(srna, "frame_start", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "startframe"); + RNA_def_property_range(prop, -MAXFRAME, MAXFRAME); + RNA_def_property_ui_range(prop, 1, MAXFRAME, 1, 1); + RNA_def_property_ui_text(prop, "Start", "Frame on which the simulation starts"); + + prop = RNA_def_property(srna, "frame_end", PROP_INT, PROP_TIME); + RNA_def_property_int_sdna(prop, NULL, "endframe"); + RNA_def_property_range(prop, 1, MAXFRAME); + RNA_def_property_ui_text(prop, "End", "Frame on which the simulation stops"); + + prop = RNA_def_property(srna, "frame_step", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "step"); + RNA_def_property_range(prop, 1, 20); + RNA_def_property_int_funcs(prop, NULL, NULL, "rna_PointCache_frame_step_range"); + RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "index"); + RNA_def_property_range(prop, -1, 100); + RNA_def_property_ui_text(prop, "Cache Index", "Index number of cache files"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, point_cache_compress_items); + RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); + + /* flags */ + 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"); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_DIRPATH); + RNA_def_property_string_sdna(prop, NULL, "path"); + RNA_def_property_ui_text(prop, "File Path", "Cache file path"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + /* removed, see PTCACHE_QUICK_CACHE */ +#if 0 + prop = RNA_def_property(srna, "use_quick_cache", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTCACHE_QUICK_CACHE); + RNA_def_property_ui_text(prop, "Quick Cache", "Update simulation with cache steps"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change"); +#endif + + prop = RNA_def_property(srna, "use_external", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTC_EXTERNAL); + RNA_def_property_ui_text(prop, "External", "Read cache from an external location"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); + + prop = RNA_def_property(srna, "use_library_path", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PTC_IGNORE_LIBPATH); + RNA_def_property_ui_text(prop, "Library Path", + "Use this file's path for the disk cache when library linked into another file " + "(for local bakes per scene file, disable this option)"); + RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_idname_change"); +#endif /*POINTCACHE_OLD*/ + + prop = RNA_def_property(srna, "lock_settings", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PTC_LOCK_SETTINGS); + RNA_def_property_ui_text(prop, "Lock", "Lock simulation settings to prevent overwriting the cache"); + + prop = RNA_def_property(srna, "state", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "PointCacheState"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "State", "State information about the point cache data"); +} + +void RNA_def_pointcache(BlenderRNA *brna) +{ + rna_def_pointcache_state(brna); + rna_def_pointcache(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 55262a98b2e..7189fa260b4 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -41,6 +41,7 @@ #include "DNA_modifier_types.h" #include "DNA_object_force.h" #include "DNA_object_types.h" +#include "DNA_pointcache_types.h" #include "DNA_scene_types.h" #include "DNA_smoke_types.h" @@ -71,7 +72,7 @@ static void rna_Smoke_resetCache(Main *UNUSED(bmain), Scene *UNUSED(scene), Poin { SmokeDomainSettings *settings = (SmokeDomainSettings *)ptr->data; if (settings->smd && settings->smd->domain) - settings->point_cache[0]->flag |= PTCACHE_OUTDATED; + settings->point_cache[0]->state.flag |= PTC_STATE_OUTDATED; DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); } @@ -92,7 +93,7 @@ static void rna_Smoke_reset_dependency(Main *bmain, Scene *scene, PointerRNA *pt smokeModifier_reset(settings->smd); if (settings->smd && settings->smd->domain) - settings->smd->domain->point_cache[0]->flag |= PTCACHE_OUTDATED; + settings->smd->domain->point_cache[0]->state.flag |= PTC_STATE_OUTDATED; rna_Smoke_dependency_update(bmain, scene, ptr); } |