diff options
Diffstat (limited to 'source/blender/makesrna/intern')
28 files changed, 3180 insertions, 29 deletions
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index e878e0877d2..a05c1834ed1 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -38,6 +38,7 @@ set(DEFSRC rna_armature.c rna_boid.c rna_brush.c + rna_cache_library.c rna_camera.c rna_cloth.c rna_color.c @@ -60,6 +61,7 @@ set(DEFSRC rna_mask.c rna_material.c rna_mesh.c + rna_mesh_sample.c rna_meta.c rna_modifier.c rna_movieclip.c @@ -84,6 +86,7 @@ set(DEFSRC rna_sound.c rna_space.c rna_speaker.c + rna_strands.c rna_test.c rna_text.c rna_texture.c @@ -300,6 +303,10 @@ if(WITH_FREESTYLE) add_definitions(-DWITH_FREESTYLE) endif() +if(WITH_OPENVDB_BLOSC) + add_definitions(-DWITH_OPENVDB_BLOSC) +endif() + # Build makesrna executable blender_include_dirs( . diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index dfd0f13ec1a..0c2082c9597 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3287,6 +3287,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_boid.c", NULL, RNA_def_boid}, {"rna_brush.c", NULL, RNA_def_brush}, {"rna_camera.c", "rna_camera_api.c", RNA_def_camera}, + {"rna_cache_library.c", NULL, RNA_def_cache_library}, {"rna_cloth.c", NULL, RNA_def_cloth}, {"rna_color.c", NULL, RNA_def_color}, {"rna_constraint.c", NULL, RNA_def_constraint}, @@ -3307,6 +3308,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_main.c", "rna_main_api.c", RNA_def_main}, {"rna_material.c", "rna_material_api.c", RNA_def_material}, {"rna_mesh.c", "rna_mesh_api.c", RNA_def_mesh}, + {"rna_mesh_sample.c", NULL, RNA_def_mesh_sample}, {"rna_meta.c", "rna_meta_api.c", RNA_def_meta}, {"rna_modifier.c", NULL, RNA_def_modifier}, {"rna_nla.c", NULL, RNA_def_nla}, @@ -3328,6 +3330,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_smoke.c", NULL, RNA_def_smoke}, {"rna_space.c", "rna_space_api.c", RNA_def_space}, {"rna_speaker.c", NULL, RNA_def_speaker}, + {"rna_strands.c", NULL, RNA_def_strands}, {"rna_test.c", NULL, RNA_def_test}, {"rna_text.c", "rna_text_api.c", RNA_def_text}, {"rna_timeline.c", NULL, RNA_def_timeline_marker}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index b87b455b36f..d29450aa320 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -52,6 +52,7 @@ EnumPropertyItem id_type_items[] = { {ID_AR, "ARMATURE", ICON_ARMATURE_DATA, "Armature", ""}, {ID_BR, "BRUSH", ICON_BRUSH_DATA, "Brush", ""}, {ID_CA, "CAMERA", ICON_CAMERA_DATA, "Camera", ""}, + {ID_CL, "CACHELIBRARY", ICON_PHYSICS, "Cache Library", ""}, {ID_CU, "CURVE", ICON_CURVE_DATA, "Curve", ""}, {ID_VF, "FONT", ICON_FONT_DATA, "Font", ""}, {ID_GD, "GREASEPENCIL", ICON_GREASEPENCIL, "Grease Pencil", ""}, @@ -132,6 +133,7 @@ short RNA_type_to_ID_code(StructRNA *type) if (RNA_struct_is_a(type, &RNA_Action)) return ID_AC; if (RNA_struct_is_a(type, &RNA_Armature)) return ID_AR; if (RNA_struct_is_a(type, &RNA_Brush)) return ID_BR; + if (RNA_struct_is_a(type, &RNA_CacheLibrary)) return ID_CL; if (RNA_struct_is_a(type, &RNA_Camera)) return ID_CA; if (RNA_struct_is_a(type, &RNA_Curve)) return ID_CU; if (RNA_struct_is_a(type, &RNA_GreasePencil)) return ID_GD; @@ -172,6 +174,7 @@ StructRNA *ID_code_to_RNA_type(short idcode) case ID_AR: return &RNA_Armature; case ID_BR: return &RNA_Brush; case ID_CA: return &RNA_Camera; + case ID_CL: return &RNA_CacheLibrary; case ID_CU: return &RNA_Curve; case ID_GD: return &RNA_GreasePencil; case ID_GR: return &RNA_Group; diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c index b03b099048f..4078d783ad1 100644 --- a/source/blender/makesrna/intern/rna_brush.c +++ b/source/blender/makesrna/intern/rna_brush.c @@ -107,6 +107,17 @@ EnumPropertyItem brush_image_tool_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem brush_hair_tool_items[] = { + {HAIR_TOOL_COMB, "COMB", ICON_BRUSH_HAIR_COMB, "Comb", "Align hairs to the stroke direction"}, + {HAIR_TOOL_CUT, "CUT", ICON_BRUSH_HAIR_CUT, "Cut", "Shorten and/or remove hairs"}, + {HAIR_TOOL_LENGTH, "LENGTH", ICON_BRUSH_HAIR_LENGTH, "Length", "Increase hair length"}, + {HAIR_TOOL_PUFF, "PUFF", ICON_BRUSH_HAIR_PUFF, "Puff", "Increase spacing between hairs"}, + {HAIR_TOOL_ADD, "ADD", ICON_BRUSH_HAIR_ADD, "Add", "Add more hairs on the object"}, + {HAIR_TOOL_SMOOTH, "SMOOTH", ICON_BRUSH_HAIR_SMOOTH, "Smooth", "Align hairs in the same direction"}, + {HAIR_TOOL_WEIGHT, "WEIGHT", ICON_BRUSH_HAIR_WEIGHT, "Weight", "Set hair vertex weights"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "MEM_guardedalloc.h" @@ -395,6 +406,13 @@ static void rna_Brush_imagepaint_tool_update(Main *bmain, Scene *scene, PointerR rna_Brush_update(bmain, scene, ptr); } +static void rna_Brush_hair_tool_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Brush *br = (Brush *)ptr->data; + rna_Brush_reset_icon(br, "hair"); + rna_Brush_update(bmain, scene, ptr); +} + static void rna_Brush_stroke_update(Main *bmain, Scene *scene, PointerRNA *ptr) { WM_main_add_notifier(NC_SCENE | ND_TOOLSETTINGS, scene); @@ -877,6 +895,12 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Image Paint Tool", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, "rna_Brush_imagepaint_tool_update"); + prop = RNA_def_property(srna, "hair_tool", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "hair_tool"); + RNA_def_property_enum_items(prop, brush_hair_tool_items); + RNA_def_property_ui_text(prop, "Hair Tool", ""); + RNA_def_property_update(prop, 0, "rna_Brush_hair_tool_update"); + prop = RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE); RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag"); RNA_def_property_enum_items(prop, prop_direction_items); @@ -1319,6 +1343,10 @@ static void rna_def_brush(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_TEXTURE_PAINT); RNA_def_property_ui_text(prop, "Use Texture", "Use this brush in texture paint mode"); + prop = RNA_def_property(srna, "use_hair_edit", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "ob_mode", OB_MODE_HAIR_EDIT); + RNA_def_property_ui_text(prop, "Use Hair", "Use this brush in hair edit mode"); + /* texture */ prop = RNA_def_property(srna, "texture_slot", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "BrushTextureSlot"); diff --git a/source/blender/makesrna/intern/rna_cache_library.c b/source/blender/makesrna/intern/rna_cache_library.c new file mode 100644 index 00000000000..4c8b8835491 --- /dev/null +++ b/source/blender/makesrna/intern/rna_cache_library.c @@ -0,0 +1,1049 @@ +/* + * ***** 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 (2015). + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_cache_library.c + * \ingroup RNA + */ + +#include <stdlib.h> +#include <assert.h> +#include <string.h> + +#include "DNA_cache_library_types.h" + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "WM_types.h" + +EnumPropertyItem cache_library_data_type_items[] = { + {CACHE_TYPE_OBJECT, "OBJECT", ICON_OBJECT_DATA, "Object", "Object base properties"}, + {CACHE_TYPE_DERIVED_MESH, "DERIVED_MESH", ICON_OUTLINER_OB_MESH, "Derived Mesh", "Mesh result from modifiers"}, + {CACHE_TYPE_HAIR, "HAIR", ICON_PARTICLE_POINT, "Hair", "Hair parent strands"}, + {CACHE_TYPE_HAIR_PATHS, "HAIR_PATHS", ICON_PARTICLE_PATH, "Hair Paths", "Full hair paths"}, + {CACHE_TYPE_PARTICLES, "PARTICLES", ICON_PARTICLES, "Particles", "Emitter particles"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem cache_library_read_result_items[] = { + {CACHE_READ_SAMPLE_INVALID, "INVALID", ICON_ERROR, "Invalid", "No valid sample found"}, + {CACHE_READ_SAMPLE_EXACT, "EXACT", ICON_SPACE3, "Exact", "Found sample for requested frame"}, + {CACHE_READ_SAMPLE_INTERPOLATED, "INTERPOLATED", ICON_TRIA_DOWN_BAR, "Interpolated", "Enclosing samples found for interpolation"}, + {CACHE_READ_SAMPLE_EARLY, "EARLY", ICON_TRIA_RIGHT_BAR, "Early", "Requested frame before the first sample"}, + {CACHE_READ_SAMPLE_LATE, "LATE", ICON_TRIA_LEFT_BAR, "Late", "Requested frame after the last sample"}, + {0, NULL, 0, NULL, NULL} +}; + +EnumPropertyItem cache_modifier_type_items[] = { + {eCacheModifierType_HairSimulation, "HAIR_SIMULATION", ICON_HAIR, "Hair Simulation", ""}, + {eCacheModifierType_ForceField, "FORCE_FIELD", ICON_FORCE_FORCE, "Force Field", ""}, + {eCacheModifierType_ShrinkWrap, "SHRINK_WRAP", ICON_MOD_SHRINKWRAP, "Shrink Wrap", ""}, + {eCacheModifierType_StrandsKey, "STRANDS_KEY", ICON_SHAPEKEY_DATA, "Strands Key", "Shape key for strands"}, + {eCacheModifierType_Haircut, "HAIRCUT", ICON_HAIR, "Hair Cut", "Cut strands where they intersect with an object"}, + {0, NULL, 0, NULL, NULL} +}; + +#ifdef RNA_RUNTIME + +#include "MEM_guardedalloc.h" + +#include "BLI_listbase.h" +#include "BLI_math.h" +#include "BLI_string.h" + +#include "DNA_key_types.h" +#include "DNA_object_types.h" +#include "DNA_particle_types.h" + +#include "BKE_animsys.h" +#include "BKE_cache_library.h" +#include "BKE_depsgraph.h" +#include "BKE_main.h" + +#include "RNA_access.h" + +#include "WM_api.h" + +/* ========================================================================= */ + +static void rna_CacheLibrary_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + CacheLibrary *cachelib = ptr->data; + DAG_id_tag_update(&cachelib->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_WINDOW, NULL); +} + +static void rna_CacheArchiveInfo_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ +// CacheLibrary *cachelib = ptr->id.data; +// WM_main_add_notifier(NC_OBJECT | ND_DRAW, NULL); +} + +/* ========================================================================= */ + +static void rna_CacheModifier_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr)) +{ +} + +#if 0 /* unused */ +static void rna_CacheModifier_dependency_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + rna_CacheModifier_update(bmain, scene, ptr); + DAG_relations_tag_update(bmain); +} +#endif + + +static StructRNA *rna_CacheModifier_refine(struct PointerRNA *ptr) +{ + CacheModifier *md = (CacheModifier *)ptr->data; + + switch ((eCacheModifier_Type)md->type) { + case eCacheModifierType_HairSimulation: + return &RNA_HairSimulationCacheModifier; + case eCacheModifierType_ForceField: + return &RNA_ForceFieldCacheModifier; + case eCacheModifierType_ShrinkWrap: + return &RNA_ShrinkWrapCacheModifier; + case eCacheModifierType_StrandsKey: + return &RNA_StrandsKeyCacheModifier; + case eCacheModifierType_Haircut: + return &RNA_HaircutCacheModifier; + + /* Default */ + case eCacheModifierType_None: + case NUM_CACHE_MODIFIER_TYPES: + return &RNA_CacheLibraryModifier; + } + + return &RNA_CacheLibraryModifier; +} + +static void rna_CacheLibraryModifier_name_set(PointerRNA *ptr, const char *value) +{ + CacheModifier *md = ptr->data; + char oldname[sizeof(md->name)]; + + /* make a copy of the old name first */ + BLI_strncpy(oldname, md->name, sizeof(md->name)); + + /* copy the new name into the name slot */ + BLI_strncpy_utf8(md->name, value, sizeof(md->name)); + + /* make sure the name is truly unique */ + if (ptr->id.data) { + CacheLibrary *cachelib = ptr->id.data; + BKE_cache_modifier_unique_name(&cachelib->modifiers, md); + } + + /* fix all the animation data which may link to this */ + BKE_animdata_fix_paths_rename_all(NULL, "modifiers", oldname, md->name); +} + +static char *rna_CacheLibraryModifier_path(PointerRNA *ptr) +{ + CacheModifier *md = ptr->data; + char name_esc[sizeof(md->name) * 2]; + + BLI_strescape(name_esc, md->name, sizeof(name_esc)); + return BLI_sprintfN("modifiers[\"%s\"]", name_esc); +} + +static CacheModifier *rna_CacheLibrary_modifier_new(CacheLibrary *cachelib, bContext *UNUSED(C), ReportList *UNUSED(reports), + const char *name, int type) +{ + return BKE_cache_modifier_add(cachelib, name, type); +} + +static void rna_CacheLibrary_modifier_remove(CacheLibrary *cachelib, bContext *UNUSED(C), ReportList *UNUSED(reports), PointerRNA *md_ptr) +{ + CacheModifier *md = md_ptr->data; + + BKE_cache_modifier_remove(cachelib, md); + + RNA_POINTER_INVALIDATE(md_ptr); +} + +static void rna_CacheLibrary_modifier_clear(CacheLibrary *cachelib, bContext *UNUSED(C)) +{ + BKE_cache_modifier_clear(cachelib); +} + +/* ------------------------------------------------------------------------- */ + +static int rna_CacheLibraryModifier_mesh_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) +{ + /*HairSimCacheModifier *hsmd = ptr->data;*/ + Object *ob = value.data; + + return ob->type == OB_MESH && ob->data != NULL; +} + +static int rna_CacheLibraryModifier_hair_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) +{ + /*HairSimCacheModifier *hsmd = ptr->data;*/ + Object *ob = value.data; + ParticleSystem *psys; + bool has_hair_system = false; + + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->part && psys->part->type == PART_HAIR) { + has_hair_system = true; + break; + } + } + return has_hair_system; +} + +static PointerRNA rna_HairSimulationCacheModifier_hair_system_get(PointerRNA *ptr) +{ + HairSimCacheModifier *hsmd = ptr->data; + ParticleSystem *psys = hsmd->object ? BLI_findlink(&hsmd->object->particlesystem, hsmd->hair_system) : NULL; + PointerRNA value; + + RNA_pointer_create(ptr->id.data, &RNA_ParticleSystem, psys, &value); + return value; +} + +static void rna_HairSimulationCacheModifier_hair_system_set(PointerRNA *ptr, PointerRNA value) +{ + HairSimCacheModifier *hsmd = ptr->data; + ParticleSystem *psys = value.data; + hsmd->hair_system = hsmd->object ? BLI_findindex(&hsmd->object->particlesystem, psys) : -1; +} + +static int rna_HairSimulationCacheModifier_hair_system_poll(PointerRNA *ptr, PointerRNA value) +{ + HairSimCacheModifier *hsmd = ptr->data; + ParticleSystem *psys = value.data; + + if (!hsmd->object) + return false; + if (BLI_findindex(&hsmd->object->particlesystem, psys) == -1) + return false; + if (!psys->part || psys->part->type != PART_HAIR) + return false; + return true; +} + +static PointerRNA rna_ShrinkWrapCacheModifier_hair_system_get(PointerRNA *ptr) +{ + ShrinkWrapCacheModifier *smd = ptr->data; + ParticleSystem *psys = smd->object ? BLI_findlink(&smd->object->particlesystem, smd->hair_system) : NULL; + PointerRNA value; + + RNA_pointer_create(ptr->id.data, &RNA_ParticleSystem, psys, &value); + return value; +} + +static void rna_ShrinkWrapCacheModifier_hair_system_set(PointerRNA *ptr, PointerRNA value) +{ + ShrinkWrapCacheModifier *smd = ptr->data; + ParticleSystem *psys = value.data; + smd->hair_system = smd->object ? BLI_findindex(&smd->object->particlesystem, psys) : -1; +} + +static int rna_ShrinkWrapCacheModifier_hair_system_poll(PointerRNA *ptr, PointerRNA value) +{ + ShrinkWrapCacheModifier *smd = ptr->data; + ParticleSystem *psys = value.data; + + if (!smd->object) + return false; + if (BLI_findindex(&smd->object->particlesystem, psys) == -1) + return false; + if (!psys->part || psys->part->type != PART_HAIR) + return false; + return true; +} + +static PointerRNA rna_StrandsKeyCacheModifier_hair_system_get(PointerRNA *ptr) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + ParticleSystem *psys = skmd->object ? BLI_findlink(&skmd->object->particlesystem, skmd->hair_system) : NULL; + PointerRNA value; + + RNA_pointer_create(ptr->id.data, &RNA_ParticleSystem, psys, &value); + return value; +} + +static void rna_StrandsKeyCacheModifier_hair_system_set(PointerRNA *ptr, PointerRNA value) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + ParticleSystem *psys = value.data; + skmd->hair_system = skmd->object ? BLI_findindex(&skmd->object->particlesystem, psys) : -1; +} + +static int rna_StrandsKeyCacheModifier_hair_system_poll(PointerRNA *ptr, PointerRNA value) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + ParticleSystem *psys = value.data; + + if (!skmd->object) + return false; + if (BLI_findindex(&skmd->object->particlesystem, psys) == -1) + return false; + if (!psys->part || psys->part->type != PART_HAIR) + return false; + return true; +} + +static void rna_StrandsKeyCacheModifier_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ +#if 0 // TODO + StrandsKeyCacheModifier *skmd = ptr->data; + + if (scene->obedit == ob) { + /* exit/enter editmode to get new shape */ + switch (ob->type) { + case OB_MESH: + EDBM_mesh_load(ob); + EDBM_mesh_make(scene->toolsettings, ob); + EDBM_mesh_normals_update(((Mesh *)ob->data)->edit_btmesh); + BKE_editmesh_tessface_calc(((Mesh *)ob->data)->edit_btmesh); + break; + case OB_CURVE: + case OB_SURF: + load_editNurb(ob); + make_editNurb(ob); + break; + case OB_LATTICE: + load_editLatt(ob); + make_editLatt(ob); + break; + } + } +#endif + + rna_CacheModifier_update(bmain, scene, ptr); +} + +static void rna_StrandsKeyCacheModifier_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, int *UNUSED(softmin), int *UNUSED(softmax)) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + Key *key = skmd->key; + + *min = 0; + if (key) { + *max = BLI_listbase_count(&key->block) - 1; + if (*max < 0) *max = 0; + } + else { + *max = 0; + } +} + +static int rna_StrandsKeyCacheModifier_active_shape_key_index_get(PointerRNA *ptr) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + + return max_ii(skmd->shapenr - 1, 0); +} + +static void rna_StrandsKeyCacheModifier_active_shape_key_index_set(PointerRNA *ptr, int value) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + + skmd->shapenr = value + 1; +} + +static PointerRNA rna_StrandsKeyCacheModifier_active_shape_key_get(PointerRNA *ptr) +{ + StrandsKeyCacheModifier *skmd = ptr->data; + Key *key = skmd->key; + KeyBlock *kb; + PointerRNA keyptr; + + if (key == NULL) + return PointerRNA_NULL; + + kb = BLI_findlink(&key->block, skmd->shapenr - 1); + RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr); + return keyptr; +} + +static PointerRNA rna_HaircutCacheModifier_hair_system_get(PointerRNA *ptr) +{ + HaircutCacheModifier *hmd = ptr->data; + ParticleSystem *psys = hmd->object ? BLI_findlink(&hmd->object->particlesystem, hmd->hair_system) : NULL; + PointerRNA value; + + RNA_pointer_create(ptr->id.data, &RNA_ParticleSystem, psys, &value); + return value; +} + +static void rna_HaircutCacheModifier_hair_system_set(PointerRNA *ptr, PointerRNA value) +{ + HaircutCacheModifier *hmd = ptr->data; + ParticleSystem *psys = value.data; + hmd->hair_system = hmd->object ? BLI_findindex(&hmd->object->particlesystem, psys) : -1; +} + +static int rna_HaircutCacheModifier_hair_system_poll(PointerRNA *ptr, PointerRNA value) +{ + HaircutCacheModifier *hmd = ptr->data; + ParticleSystem *psys = value.data; + + if (!hmd->object) + return false; + if (BLI_findindex(&hmd->object->particlesystem, psys) == -1) + return false; + if (!psys->part || psys->part->type != PART_HAIR) + return false; + return true; +} + +static void rna_CacheArchiveInfoNode_bytes_size_get(PointerRNA *ptr, char *value) +{ + CacheArchiveInfoNode *node = ptr->data; + BLI_snprintf(value, MAX_NAME, "%lld", (long long int)node->bytes_size); +} + +static int rna_CacheArchiveInfoNode_bytes_size_length(PointerRNA *ptr) +{ + char buf[MAX_NAME]; + /* theoretically could do a dummy BLI_snprintf here, but BLI does not allow NULL buffer ... */ + CacheArchiveInfoNode *node = ptr->data; + return BLI_snprintf(buf, sizeof(buf), "%lld", (long long int)node->bytes_size); +} + +#else + +static void rna_def_hair_sim_params(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "HairSimulationParameters", NULL); + RNA_def_struct_sdna(srna, "HairSimParams"); + RNA_def_struct_ui_text(srna, "Hair Simulation Parameters", "Simulation parameters for hair simulation"); + RNA_def_struct_ui_icon(srna, ICON_HAIR); + + prop = RNA_def_property(srna, "timescale", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1f, 3); + RNA_def_property_ui_text(prop, "Time Scale", "Simulation time scale relative to scene time"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "substeps", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 80); + RNA_def_property_ui_text(prop, "Substeps", "Simulation steps per frame"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "effector_weights", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "EffectorWeights"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Effector Weights", ""); + + prop = RNA_def_property(srna, "mass", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, 10.0f); + RNA_def_property_ui_text(prop, "Mass", "Mass of hair vertices"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "drag", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1f, 3); + RNA_def_property_ui_text(prop, "Drag", "Drag simulating friction with surrounding air"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "goal_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_ui_text(prop, "Goal Strength", "Goal spring, pulling vertices toward their rest position"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "goal_damping", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Goal Damping", "Damping factor of goal springs"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_goal_stiffness_curve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eHairSimParams_Flag_UseGoalStiffnessCurve); + RNA_def_property_ui_text(prop, "Use Goal Stiffness Curve", "Use a curve to define goal stiffness along the strand"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "goal_stiffness_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "goal_stiffness_mapping"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Goal Stiffness Curve", "Stiffness of goal springs along the strand curves"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_goal_deflect", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eHairSimParams_Flag_UseGoalDeflect); + RNA_def_property_ui_text(prop, "Use Goal Deflect", "Disable goal springs inside deflectors, to avoid unstable deformations"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_bend_stiffness_curve", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eHairSimParams_Flag_UseBendStiffnessCurve); + RNA_def_property_ui_text(prop, "Use Bend Stiffness Curve", "Use a curve to define bend resistance along the strand"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "bend_stiffness_curve", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "bend_stiffness_mapping"); + RNA_def_property_struct_type(prop, "CurveMapping"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Bend Stiffness Curve", "Resistance to bending along the strand curves"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "stretch_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10000.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 10000.0f); + RNA_def_property_ui_text(prop, "Stretch Stiffness", "Resistance to stretching"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "stretch_damping", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 0.1f); + RNA_def_property_ui_text(prop, "Stretch Damping", "Damping factor of stretch springs"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "bend_stiffness", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1000.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 100.0f); + RNA_def_property_ui_text(prop, "Bend Stiffness", "Resistance to bending of the rest shape"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "bend_damping", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 1.0f, 0.1f, 3); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_ui_text(prop, "Bend Damping", "Damping factor of bending springs"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); +} + +static void rna_def_cache_modifier_hair_simulation(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + rna_def_hair_sim_params(brna); + + srna = RNA_def_struct(brna, "HairSimulationCacheModifier", "CacheLibraryModifier"); + RNA_def_struct_sdna(srna, "HairSimCacheModifier"); + RNA_def_struct_ui_text(srna, "Hair Simulation Cache Modifier", "Apply hair dynamics simulation to the cache"); + RNA_def_struct_ui_icon(srna, ICON_HAIR); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_CacheLibraryModifier_hair_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object whose cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "hair_system"); + RNA_def_property_ui_text(prop, "Hair System Index", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, "rna_HairSimulationCacheModifier_hair_system_get", "rna_HairSimulationCacheModifier_hair_system_set", NULL, "rna_HairSimulationCacheModifier_hair_system_poll"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Hair System", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "parameters", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "sim_params"); + RNA_def_property_struct_type(prop, "HairSimulationParameters"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Simulation Parameters", "Parameters of the simulation"); +} + +static void rna_def_cache_modifier_force_field(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem force_type_items[] = { + {eForceFieldCacheModifier_Type_Deflect, "DEFLECT", ICON_FORCE_FORCE, "Deflect", "Push away from the surface"}, + {eForceFieldCacheModifier_Type_Drag, "DRAG", ICON_FORCE_DRAG, "Drag", "Adjust velocity to the surface"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "ForceFieldCacheModifier", "CacheLibraryModifier"); + RNA_def_struct_sdna(srna, "ForceFieldCacheModifier"); + RNA_def_struct_ui_text(srna, "Force Field Cache Modifier", "Use an object as a force field"); + RNA_def_struct_ui_icon(srna, ICON_FORCE_FORCE); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_CacheLibraryModifier_mesh_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object whose cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "force_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, force_type_items); + RNA_def_property_ui_text(prop, "Force Type", "Type of force field"); + + prop = RNA_def_property(srna, "strength", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, -10000.0f, 10000.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Strength", ""); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "falloff", PROP_FLOAT, PROP_NONE); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Falloff", ""); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "min_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, -100.0f, 100.0f, 0.1, 4); + RNA_def_property_ui_text(prop, "Minimum Distance", ""); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "max_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_range(prop, -FLT_MAX, FLT_MAX); + RNA_def_property_ui_range(prop, -100.0f, 100.0f, 0.1, 4); + RNA_def_property_ui_text(prop, "Maximum Distance", ""); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_double_sided", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eForceFieldCacheModifier_Flag_DoubleSided); + RNA_def_property_ui_text(prop, "Use Double Sided", ""); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); +} + +static void rna_def_cache_modifier_shrink_wrap(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "ShrinkWrapCacheModifier", "CacheLibraryModifier"); + RNA_def_struct_sdna(srna, "ShrinkWrapCacheModifier"); + RNA_def_struct_ui_text(srna, "Shrink Wrap Cache Modifier", ""); + RNA_def_struct_ui_icon(srna, ICON_HAIR); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_CacheLibraryModifier_hair_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object whose cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "hair_system"); + RNA_def_property_ui_text(prop, "Hair System Index", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, "rna_ShrinkWrapCacheModifier_hair_system_get", "rna_ShrinkWrapCacheModifier_hair_system_set", NULL, "rna_ShrinkWrapCacheModifier_hair_system_poll"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Hair System", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "target"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Target", "Mesh object to wrap onto"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_internal_target", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eShrinkWrapCacheModifier_Flag_InternalTarget); + RNA_def_property_ui_text(prop, "Use Internal Target", "Use a cached object from the group instead of an object in the scene"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); +} + +static void rna_def_cache_modifier_strands_key(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsKeyCacheModifier", "CacheLibraryModifier"); + RNA_def_struct_sdna(srna, "StrandsKeyCacheModifier"); + RNA_def_struct_ui_text(srna, "Strands Key Cache Modifier", ""); + RNA_def_struct_ui_icon(srna, ICON_SHAPEKEY_DATA); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_CacheLibraryModifier_hair_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object whose cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "hair_system"); + RNA_def_property_ui_text(prop, "Hair System Index", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, "rna_StrandsKeyCacheModifier_hair_system_get", "rna_StrandsKeyCacheModifier_hair_system_set", NULL, "rna_StrandsKeyCacheModifier_hair_system_poll"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Hair System", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + /* shape keys */ + prop = RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "key"); + RNA_def_property_ui_text(prop, "Shape Keys", ""); + + prop = RNA_def_property(srna, "use_motion_state", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eStrandsKeyCacheModifier_Flag_UseMotionState); + RNA_def_property_ui_text(prop, "Use Motion State", "Apply the shape key to the motion state instead of the base shape"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "show_only_shape_key", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eStrandsKeyCacheModifier_Flag_ShapeLock); + RNA_def_property_ui_text(prop, "Shape Key Lock", "Always show the current Shape for this Object"); + RNA_def_property_ui_icon(prop, ICON_UNPINNED, 1); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ShapeKey"); + RNA_def_property_pointer_funcs(prop, "rna_StrandsKeyCacheModifier_active_shape_key_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key"); + + prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "shapenr"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); /* XXX this is really unpredictable... */ + RNA_def_property_int_funcs(prop, "rna_StrandsKeyCacheModifier_active_shape_key_index_get", "rna_StrandsKeyCacheModifier_active_shape_key_index_set", + "rna_StrandsKeyCacheModifier_active_shape_key_index_range"); + RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index"); + RNA_def_property_update(prop, 0, "rna_StrandsKeyCacheModifier_active_shape_update"); +} + +static void rna_def_cache_modifier_haircut(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem cut_mode_items[] = { + {eHaircutCacheModifier_CutMode_Enter, "ENTER", 0, "Enter", "Cut strands when entering the target mesh"}, + {eHaircutCacheModifier_CutMode_Exit, "EXIT", 0, "Exit", "Cut strands when exiting the target mesh"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "HaircutCacheModifier", "CacheLibraryModifier"); + RNA_def_struct_sdna(srna, "HaircutCacheModifier"); + RNA_def_struct_ui_text(srna, "Hair Cut Cache Modifier", ""); + RNA_def_struct_ui_icon(srna, ICON_HAIR); + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "object"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_CacheLibraryModifier_hair_object_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object whose cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "hair_system"); + RNA_def_property_ui_text(prop, "Hair System Index", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "hair_system", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_funcs(prop, "rna_HaircutCacheModifier_hair_system_get", "rna_HaircutCacheModifier_hair_system_set", NULL, "rna_HaircutCacheModifier_hair_system_poll"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Hair System", "Hair system cache to simulate"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "target", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "target"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Target", "Mesh object to wrap onto"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "use_internal_target", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eHaircutCacheModifier_Flag_InternalTarget); + RNA_def_property_ui_text(prop, "Use Internal Target", "Use a cached object from the group instead of an object in the scene"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); + + prop = RNA_def_property(srna, "cut_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "cut_mode"); + RNA_def_property_enum_items(prop, cut_mode_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Cut Mode", "When to cut strands with the target"); + RNA_def_property_update(prop, 0, "rna_CacheModifier_update"); +} + +static void rna_def_cache_modifier(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CacheLibraryModifier", NULL); + RNA_def_struct_sdna(srna, "CacheModifier"); + RNA_def_struct_path_func(srna, "rna_CacheLibraryModifier_path"); + RNA_def_struct_refine_func(srna, "rna_CacheModifier_refine"); + RNA_def_struct_ui_text(srna, "Cache Modifier", "Cache Modifier"); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type"); + RNA_def_property_enum_items(prop, cache_modifier_type_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Type", "Type of the cache modifier"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_CacheLibraryModifier_name_set"); + RNA_def_property_ui_text(prop, "Name", "Modifier name"); + RNA_def_property_update(prop, NC_ID | NA_RENAME, NULL); + RNA_def_struct_name_property(srna, prop); + + rna_def_cache_modifier_hair_simulation(brna); + rna_def_cache_modifier_force_field(brna); + rna_def_cache_modifier_shrink_wrap(brna); + rna_def_cache_modifier_strands_key(brna); + rna_def_cache_modifier_haircut(brna); +} + +static void rna_def_cache_library_modifiers(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "CacheLibraryModifiers"); + srna = RNA_def_struct(brna, "CacheLibraryModifiers", NULL); + RNA_def_struct_sdna(srna, "CacheLibrary"); + RNA_def_struct_ui_text(srna, "Cache Modifiers", "Collection of cache modifiers"); + + /* add modifier */ + func = RNA_def_function(srna, "new", "rna_CacheLibrary_modifier_new"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Add a new modifier"); + parm = RNA_def_string(func, "name", "Name", 0, "", "New name for the modifier"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* modifier to add */ + parm = RNA_def_enum(func, "type", cache_modifier_type_items, 1, "", "Modifier type to add"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "modifier", "CacheLibraryModifier", "", "Newly created modifier"); + RNA_def_function_return(func, parm); + + /* remove modifier */ + func = RNA_def_function(srna, "remove", "rna_CacheLibrary_modifier_remove"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove an existing modifier"); + /* modifier to remove */ + parm = RNA_def_pointer(func, "modifier", "CacheLibraryModifier", "", "Modifier to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + + /* clear all modifiers */ + func = RNA_def_function(srna, "clear", "rna_CacheLibrary_modifier_clear"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_function_ui_description(func, "Remove all modifiers"); +} + +static void rna_def_cache_library(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem source_mode_items[] = { + {CACHE_LIBRARY_SOURCE_SCENE, "SCENE", 0, "Scene", "Use generated scene data as source"}, + {CACHE_LIBRARY_SOURCE_CACHE, "CACHE", 0, "Cache", "Use cache data as source"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem display_mode_items[] = { + {CACHE_LIBRARY_DISPLAY_SOURCE, "SOURCE", 0, "Source", "Display source data unmodified"}, + {CACHE_LIBRARY_DISPLAY_MODIFIERS, "MODIFIERS", 0, "Modifiers", "Display source data with modifiers applied"}, + {CACHE_LIBRARY_DISPLAY_RESULT, "RESULT", 0, "Result", "Display resulting data"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "CacheLibrary", "ID"); + RNA_def_struct_ui_text(srna, "Cache Library", "Cache Library datablock for constructing an archive of caches"); + RNA_def_struct_ui_icon(srna, ICON_PHYSICS); + + prop = RNA_def_property(srna, "input_filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "input_filepath"); + RNA_def_property_ui_text(prop, "Input File Path", "Path to a cache archive for reading input"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "output_filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_string_sdna(prop, NULL, "output_filepath"); + RNA_def_property_ui_text(prop, "Output File Path", "Path where cache output is written"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "source_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "source_mode"); + RNA_def_property_enum_items(prop, source_mode_items); + RNA_def_property_ui_text(prop, "Source Mode", "Source of the cache library data"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "display_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "display_mode"); + RNA_def_property_enum_items(prop, display_mode_items); + RNA_def_property_ui_text(prop, "Display Mode", "What data to display in the viewport"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "display_motion", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "display_flag", CACHE_LIBRARY_DISPLAY_MOTION); + RNA_def_property_ui_text(prop, "Display Motion", "Display motion state result from simulation, if available"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "display_children", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "display_flag", CACHE_LIBRARY_DISPLAY_CHILDREN); + RNA_def_property_ui_text(prop, "Display Children", "Display child strands, if available"); + RNA_def_property_update(prop, 0, "rna_CacheLibrary_update"); + + prop = RNA_def_property(srna, "data_types", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "data_types"); + RNA_def_property_enum_items(prop, cache_library_data_type_items); + RNA_def_property_flag(prop, PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Data Types", "Types of data to store in the cache"); + + prop = RNA_def_property(srna, "filter_group", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "filter_group"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Filter Group", "If set, only objects in this group will be cached"); + + prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Description", "Description of the output archive"); + + /* modifiers */ + prop = RNA_def_property(srna, "modifiers", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "CacheLibraryModifier"); + RNA_def_property_ui_text(prop, "Modifiers", "Modifiers applying to the cached data"); + rna_def_cache_library_modifiers(brna, prop); + + prop = RNA_def_property(srna, "archive_info", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "CacheArchiveInfo"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Archive Info", "Information about structure and contents of the archive"); +} + +static void rna_def_cache_archive_info_node(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem type_items[] = { + {eCacheArchiveInfoNode_Type_Object, "OBJECT", 0, "Object", "Structural object node forming the hierarchy"}, + {eCacheArchiveInfoNode_Type_ScalarProperty, "SCALAR_PROPERTY", 0, "Scalar Property", "Property with a single value per sample"}, + {eCacheArchiveInfoNode_Type_ArrayProperty, "ARRAY_PROPERTY", 0, "Array Property", "Array property with an arbitrary number of values per sample"}, + {eCacheArchiveInfoNode_Type_CompoundProperty, "COMPOUND_PROPERTY", 0, "Compound Property", "Compound property containing other properties"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "CacheArchiveInfoNode", NULL); + RNA_def_struct_ui_text(srna, "Cache Archive Info Node", "Node in the structure of a cache archive"); + + prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, type_items); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Type", "Type of archive node"); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Name", "Name of the archive node"); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "child_nodes", PROP_COLLECTION, PROP_NONE); + RNA_def_property_struct_type(prop, "CacheArchiveInfoNode"); + RNA_def_property_ui_text(prop, "Child Nodes", "Nested archive nodes"); + + prop = RNA_def_property(srna, "expand", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", eCacheArchiveInfoNode_Flag_Expand); + RNA_def_property_ui_text(prop, "Expand", "Show contents of the node"); + RNA_def_property_update(prop, 0, "rna_CacheArchiveInfo_update"); + + /* XXX this is a 64bit integer, not supported nicely by RNA, + * but string encoding is sufficient for feedback + */ + prop = RNA_def_property(srna, "bytes_size", PROP_STRING, PROP_NONE); + RNA_def_property_string_funcs(prop, "rna_CacheArchiveInfoNode_bytes_size_get", "rna_CacheArchiveInfoNode_bytes_size_length", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Bytes Size", "Overall size of the node data in bytes"); + + prop = RNA_def_property(srna, "datatype", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "datatype_name"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Datatype", "Type of values stored in the property"); + + prop = RNA_def_property(srna, "datatype_extent", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Datatype Extent", "Array extent of a single data element"); + + prop = RNA_def_property(srna, "samples", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "num_samples"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Samples", "Number of samples stored for the property"); + + prop = RNA_def_property(srna, "array_size", PROP_INT, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Array Size", "Maximum array size for any sample of the property"); +} + +static void rna_def_cache_archive_info(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CacheArchiveInfo", NULL); + RNA_def_struct_ui_text(srna, "Cache Archive Info", "Information about structure and contents of a cache file"); + + prop = RNA_def_property(srna, "filepath", PROP_STRING, PROP_FILEPATH); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "File Path", "Path to the cache archive"); + + prop = RNA_def_property(srna, "app_name", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Application", "Name of the application that created the archive"); + + prop = RNA_def_property(srna, "date_written", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Date", "Date and time when the archive was created"); + + prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Description", "Description of the archive"); + + prop = RNA_def_property(srna, "root_node", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "CacheArchiveInfoNode"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Root Node", "Root node of the archive"); +} + +void RNA_def_cache_library(BlenderRNA *brna) +{ + rna_def_cache_modifier(brna); + rna_def_cache_library(brna); + rna_def_cache_archive_info_node(brna); + rna_def_cache_archive_info(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_context.c b/source/blender/makesrna/intern/rna_context.c index d7a679e9702..a512f1d750f 100644 --- a/source/blender/makesrna/intern/rna_context.c +++ b/source/blender/makesrna/intern/rna_context.c @@ -148,6 +148,7 @@ void RNA_def_context(BlenderRNA *brna) {CTX_MODE_PAINT_VERTEX, "PAINT_VERTEX", 0, "Vertex Paint", ""}, {CTX_MODE_PAINT_TEXTURE, "PAINT_TEXTURE", 0, "Texture Paint", ""}, {CTX_MODE_PARTICLE, "PARTICLE", 0, "Particle", ""}, + {CTX_MODE_HAIR, "HAIR", 0, "Hair", ""}, {CTX_MODE_OBJECT, "OBJECT", 0, "Object", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index eab14be9085..62fe71fe8a5 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -133,6 +133,7 @@ void RNA_def_armature(struct BlenderRNA *brna); void RNA_def_actuator(struct BlenderRNA *brna); void RNA_def_boid(struct BlenderRNA *brna); void RNA_def_brush(struct BlenderRNA *brna); +void RNA_def_cache_library(struct BlenderRNA *brna); void RNA_def_camera(struct BlenderRNA *brna); void RNA_def_cloth(struct BlenderRNA *brna); void RNA_def_color(struct BlenderRNA *brna); @@ -155,6 +156,7 @@ void RNA_def_linestyle(struct BlenderRNA *brna); void RNA_def_main(struct BlenderRNA *brna); void RNA_def_material(struct BlenderRNA *brna); void RNA_def_mesh(struct BlenderRNA *brna); +void RNA_def_mesh_sample(struct BlenderRNA *brna); void RNA_def_meta(struct BlenderRNA *brna); void RNA_def_modifier(struct BlenderRNA *brna); void RNA_def_nla(struct BlenderRNA *brna); @@ -176,6 +178,7 @@ void RNA_def_sequencer(struct BlenderRNA *brna); void RNA_def_smoke(struct BlenderRNA *brna); void RNA_def_space(struct BlenderRNA *brna); void RNA_def_speaker(struct BlenderRNA *brna); +void RNA_def_strands(struct BlenderRNA *brna); void RNA_def_test(struct BlenderRNA *brna); void RNA_def_text(struct BlenderRNA *brna); void RNA_def_texture(struct BlenderRNA *brna); @@ -264,6 +267,7 @@ void RNA_api_image(struct StructRNA *srna); void RNA_api_lattice(struct StructRNA *srna); void RNA_api_operator(struct StructRNA *srna); void RNA_api_macro(struct StructRNA *srna); +void RNA_api_widgetgroup(struct StructRNA *srna); void RNA_api_keyconfig(struct StructRNA *srna); void RNA_api_keyconfigs(struct StructRNA *srna); void RNA_api_keyingset(struct StructRNA *srna); @@ -330,6 +334,7 @@ void RNA_def_main_gpencil(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_movieclips(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_masks(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_cache_libraries(BlenderRNA *brna, PropertyRNA *cprop); /* ID Properties */ diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index 04cba835ae2..641c9a596a8 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -32,6 +32,7 @@ #include "DNA_key_types.h" #include "DNA_lattice_types.h" #include "DNA_mesh_types.h" +#include "DNA_particle_types.h" #include "BLI_utildefines.h" @@ -47,9 +48,11 @@ #include <stddef.h> +#include "DNA_cache_library_types.h" #include "DNA_object_types.h" #include "BKE_animsys.h" +#include "BKE_cache_library.h" #include "BKE_depsgraph.h" #include "BKE_key.h" #include "BKE_main.h" @@ -302,7 +305,7 @@ static void rna_ShapeKey_data_begin(CollectionPropertyIterator *iter, PointerRNA Nurb *nu; int tot = kb->totelem, size = key->elemsize; - if (GS(key->from->name) == ID_CU) { + if (key->from && key->fromtype == KEY_OWNER_CURVE) { cu = (Curve *)key->from; nu = cu->nurb.first; @@ -323,7 +326,7 @@ static int rna_ShapeKey_data_length(PointerRNA *ptr) Nurb *nu; int tot = kb->totelem; - if (GS(key->from->name) == ID_CU) { + if (key->from && key->fromtype == KEY_OWNER_CURVE) { cu = (Curve *)key->from; nu = cu->nurb.first; @@ -341,7 +344,7 @@ static PointerRNA rna_ShapeKey_data_get(CollectionPropertyIterator *iter) Curve *cu; Nurb *nu; - if (GS(key->from->name) == ID_CU) { + if (key->from && key->fromtype == KEY_OWNER_CURVE) { cu = (Curve *)key->from; nu = cu->nurb.first; @@ -374,11 +377,37 @@ static void rna_Key_update_data(Main *bmain, Scene *UNUSED(scene), PointerRNA *p { Key *key = ptr->id.data; Object *ob; - - for (ob = bmain->object.first; ob; ob = ob->id.next) { - if (BKE_key_from_object(ob) == key) { - DAG_id_tag_update(&ob->id, OB_RECALC_DATA); - WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); + CacheLibrary *cachelib; + + switch (key->fromtype) { + case KEY_OWNER_MESH: + case KEY_OWNER_CURVE: + case KEY_OWNER_LATTICE: + for (ob = bmain->object.first; ob; ob = ob->id.next) { + if (BKE_key_from_object(ob) == key) { + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_MODIFIER, ob); + } + } + break; + case KEY_OWNER_PARTICLES: + for (ob = bmain->object.first; ob; ob = ob->id.next) { + ParticleSystem *psys; + for (psys = ob->particlesystem.first; psys; psys = psys->next) { + if (psys->key == key) { + psys->recalc |= PSYS_RECALC_REDO; + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_OBJECT | ND_PARTICLE | NA_EDITED, ob); + } + } + } + break; + } + + for (cachelib = bmain->cache_library.first; cachelib; cachelib = cachelib->id.next) { + if (BKE_cache_library_uses_key(cachelib, key)) { + DAG_id_tag_update(&cachelib->id, OB_RECALC_DATA); + WM_main_add_notifier(NC_WINDOW, NULL); } } } @@ -600,6 +629,11 @@ static void rna_def_keyblock(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Group", "Vertex weight group, to blend with basis shape"); RNA_def_property_update(prop, 0, "rna_Key_update_data"); + prop = RNA_def_property(srna, "face_map", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "facemap"); + RNA_def_property_ui_text(prop, "Face Map", "Face Map used to initiate interpolation for this shapekey"); + RNA_def_property_update(prop, 0, "rna_Key_update_data"); + prop = RNA_def_property(srna, "relative_key", PROP_POINTER, PROP_NONE); RNA_def_property_struct_type(prop, "ShapeKey"); RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL); diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 348fa3c8302..926c5db5ae6 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -287,6 +287,12 @@ static void rna_Main_linestyle_begin(CollectionPropertyIterator *iter, PointerRN rna_iterator_listbase_begin(iter, &bmain->linestyle, NULL); } +static void rna_Main_cachelibraries_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Main *bmain = (Main *)ptr->data; + rna_iterator_listbase_begin(iter, &bmain->cache_library, NULL); +} + static void rna_Main_version_get(PointerRNA *ptr, int *value) { Main *bmain = (Main *)ptr->data; @@ -361,6 +367,7 @@ void RNA_def_main(BlenderRNA *brna) {"movieclips", "MovieClip", "rna_Main_movieclips_begin", "Movie Clips", "Movie Clip datablocks", RNA_def_main_movieclips}, {"masks", "Mask", "rna_Main_masks_begin", "Masks", "Masks datablocks", RNA_def_main_masks}, {"linestyles", "FreestyleLineStyle", "rna_Main_linestyle_begin", "Line Styles", "Line Style datablocks", RNA_def_main_linestyles}, + {"cache_libraries", "CacheLibrary", "rna_Main_cachelibraries_begin", "Cache Libraries", "Cache Library datablocks", RNA_def_main_cache_libraries}, {NULL, NULL, NULL, NULL, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c index 8b5ed66e217..b9b3bb519ca 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -49,6 +49,8 @@ #ifdef RNA_RUNTIME #include "BKE_main.h" +#include "BKE_anim.h" +#include "BKE_cache_library.h" #include "BKE_camera.h" #include "BKE_curve.h" #include "BKE_DerivedMesh.h" @@ -83,6 +85,7 @@ #include "BKE_linestyle.h" #include "DNA_armature_types.h" +#include "DNA_cache_library_types.h" #include "DNA_camera_types.h" #include "DNA_curve_types.h" #include "DNA_lamp_types.h" @@ -312,6 +315,61 @@ Mesh *rna_Main_meshes_new_from_object( return BKE_mesh_new_from_object(bmain, sce, ob, apply_modifiers, settings, calc_tessface, calc_undeformed); } +/* copied from Mesh_getFromObject and adapted to RNA interface */ +/* settings: 1 - preview, 2 - render */ +Mesh *rna_Main_meshes_new_from_dupli( + Main *bmain, ReportList *reports, Scene *scene, Object *parent, DupliObject *dob, + int settings, int calc_tessface, int calc_undeformed) +{ + Mesh *mesh = NULL; + bool is_cached = parent->cache_library && (parent->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE || parent->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_RESULT); + + switch (dob->ob->type) { + case OB_FONT: + case OB_CURVE: + case OB_SURF: + case OB_MBALL: + case OB_MESH: + break; + default: + BKE_report(reports, RPT_ERROR, "Object does not have geometry data"); + return NULL; + } + + if (is_cached) { + float frame = (float)scene->r.cfra + scene->r.subframe; + bool use_render = (settings == 2); + + if (!ELEM(settings, 1, 2)) + return NULL; + + if (settings == 1 && parent->dup_cache) { + DupliObjectData *data; + + /* use dupli cache for realtime dupli data if possible */ + data = BKE_dupli_cache_find_data(parent->dup_cache, dob->ob); + if (data) + mesh = BKE_mesh_new_from_dupli_data(bmain, data, calc_tessface, calc_undeformed); + } + else { + DupliObjectData data; + + memset(&data, 0, sizeof(data)); + if (BKE_cache_read_dupli_object(parent->cache_library, &data, scene, dob->ob, frame, use_render, true)) + mesh = BKE_mesh_new_from_dupli_data(bmain, &data, calc_tessface, calc_undeformed); + + BKE_dupli_object_data_clear(&data); + } + } + + /* default, and fallback in case no mesh data was stored in the cache */ + if (!mesh) { + mesh = BKE_mesh_new_from_object(bmain, scene, dob->ob, true, settings, calc_tessface, calc_undeformed); + } + + return mesh; +} + static void rna_Main_meshes_remove(Main *bmain, ReportList *reports, PointerRNA *mesh_ptr) { Mesh *mesh = mesh_ptr->data; @@ -744,6 +802,22 @@ static void rna_Main_linestyles_remove(Main *bmain, ReportList *reports, Freesty /* XXX python now has invalid pointer? */ } +static CacheLibrary *rna_Main_cachelibraries_new(Main *bmain, const char *name) +{ + CacheLibrary *cachelib = BKE_cache_library_add(bmain, name); + id_us_min(&cachelib->id); + return cachelib; +} + +static void rna_Main_cachelibraries_remove(Main *bmain, ReportList *reports, CacheLibrary *cachelib) +{ + if (ID_REAL_USERS(cachelib) <= 0) + BKE_libblock_free(bmain, cachelib); + else + BKE_reportf(reports, RPT_ERROR, "Cache library '%s' must have zero users to be removed, found %d", + cachelib->id.name + 2, ID_REAL_USERS(cachelib)); +} + /* tag functions, all the same */ static void rna_Main_cameras_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->camera, value); } static void rna_Main_scenes_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->scene, value); } @@ -777,6 +851,7 @@ static void rna_Main_gpencil_tag(Main *bmain, int value) { BKE_main_id_tag_listb static void rna_Main_movieclips_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->movieclip, value); } static void rna_Main_masks_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->mask, value); } static void rna_Main_linestyle_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->linestyle, value); } +static void rna_Main_cachelibraries_tag(Main *bmain, int value) { BKE_main_id_tag_listbase(&bmain->cache_library, value); } static int rna_Main_cameras_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CA) != 0; } static int rna_Main_scenes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_SCE) != 0; } @@ -806,6 +881,7 @@ static int rna_Main_particles_is_updated_get(PointerRNA *ptr) { return DAG_id_ty static int rna_Main_palettes_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_PAL) != 0; } static int rna_Main_gpencil_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_GD) != 0; } static int rna_Main_linestyle_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_LS) != 0; } +static int rna_Main_cachelibraries_is_updated_get(PointerRNA *ptr) { return DAG_id_type_tagged(ptr->data, ID_CL) != 0; } #else @@ -1059,6 +1135,23 @@ void RNA_def_main_meshes(BlenderRNA *brna, PropertyRNA *cprop) "Mesh created from object, remove it if it is only used for export"); RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "new_from_dupli", "rna_Main_meshes_new_from_dupli"); + RNA_def_function_ui_description(func, "Add a new mesh created from dupli cache data"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "parent", "Object", "", "Duplicator parent of the object"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "dupli_object", "DupliObject", "", "Dupli Object to create mesh from"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_enum(func, "settings", mesh_type_items, 0, "", "Modifier settings to apply"); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_boolean(func, "calc_tessface", true, "Calculate Tessellation", "Calculate tessellation faces"); + RNA_def_boolean(func, "calc_undeformed", false, "Calculate Undeformed", "Calculate undeformed vertex coordinates"); + parm = RNA_def_pointer(func, "mesh", "Mesh", "", + "Mesh created from object, remove it if it is only used for export"); + RNA_def_function_return(func, parm); + func = RNA_def_function(srna, "remove", "rna_Main_meshes_remove"); RNA_def_function_flag(func, FUNC_USE_REPORTS); RNA_def_function_ui_description(func, "Remove a mesh from the current blendfile"); @@ -1906,4 +1999,39 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_boolean_funcs(prop, "rna_Main_linestyle_is_updated_get", NULL); } +void RNA_def_main_cache_libraries(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataCacheLibraries"); + srna = RNA_def_struct(brna, "BlendDataCacheLibraries", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Cache Libraries", "Collection of cache libraries"); + + func = RNA_def_function(srna, "tag", "rna_Main_cachelibraries_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + + func = RNA_def_function(srna, "new", "rna_Main_cachelibraries_new"); + RNA_def_function_ui_description(func, "Add a new cache library to the main database"); + parm = RNA_def_string(func, "name", "CacheLibrary", 0, "", "New name for the datablock"); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "cachelib", "CacheLibrary", "", "New cache library datablock"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_cachelibraries_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a cache library from the current blendfile"); + parm = RNA_def_pointer(func, "cachelib", "CacheLibrary", "", "Cache Library to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED); + + prop = RNA_def_property(srna, "is_updated", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_boolean_funcs(prop, "rna_Main_cachelibraries_is_updated_get", NULL); +} + #endif diff --git a/source/blender/makesrna/intern/rna_mesh_sample.c b/source/blender/makesrna/intern/rna_mesh_sample.c new file mode 100644 index 00000000000..81a3f4bf5e4 --- /dev/null +++ b/source/blender/makesrna/intern/rna_mesh_sample.c @@ -0,0 +1,73 @@ +/* + * ***** 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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_mesh_sample.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "MEM_guardedalloc.h" + +#include "DNA_meshdata_types.h" + +#include "BLI_utildefines.h" + +#include "BKE_mesh_sample.h" + +#include "RNA_access.h" +#include "RNA_define.h" +#include "RNA_types.h" + +#include "rna_internal.h" + +#include "WM_types.h" + + +#ifdef RNA_RUNTIME + +#include "WM_api.h" +#include "WM_types.h" + + + +#else + +static void rna_def_mesh_sample(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "MeshSample", NULL); + RNA_def_struct_sdna(srna, "MSurfaceSample"); + RNA_def_struct_ui_text(srna, "Mesh Sample", "Point on a mesh that follows deformation"); + + prop = RNA_def_property(srna, "vertex_indices", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_sdna(prop, NULL, "orig_verts"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Vertex Indices", "Index of the mesh vertices used for interpolation"); +} + +void RNA_def_mesh_sample(BlenderRNA *brna) +{ + rna_def_mesh_sample(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 087db2bedcd..394c3a3c519 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -258,6 +258,8 @@ EnumPropertyItem DT_layers_select_dst_items[] = { #ifdef RNA_RUNTIME +#include "BLI_listbase.h" + #include "DNA_particle_types.h" #include "DNA_curve_types.h" #include "DNA_smoke_types.h" @@ -1065,6 +1067,43 @@ static int rna_CorrectiveSmoothModifier_is_bind_get(PointerRNA *ptr) return (csmd->bind_coords != NULL); } +static int rna_ParticleInstanceModifier_particle_system_poll(PointerRNA *ptr, const PointerRNA value) +{ + ParticleInstanceModifierData *psmd = ptr->data; + ParticleSystem *psys = value.data; + + if (!psmd->ob) + return false; + + /* make sure psys is in the object */ + return BLI_findindex(&psmd->ob->particlesystem, psys) >= 0; +} + +static PointerRNA rna_ParticleInstanceModifier_particle_system_get(PointerRNA *ptr) +{ + ParticleInstanceModifierData *psmd = ptr->data; + ParticleSystem *psys; + PointerRNA rptr; + + if (!psmd->ob) + return PointerRNA_NULL; + + psys = BLI_findlink(&psmd->ob->particlesystem, psmd->psys - 1); + RNA_pointer_create((ID *)psmd->ob, &RNA_ParticleSystem, psys, &rptr); + return rptr; +} + +static void rna_ParticleInstanceModifier_particle_system_set(PointerRNA *ptr, const PointerRNA value) +{ + ParticleInstanceModifierData *psmd = ptr->data; + + if (!psmd->ob) + return; + + psmd->psys = BLI_findindex(&psmd->ob->particlesystem, value.data) + 1; + CLAMP_MIN(psmd->psys, 1); +} + #else static PropertyRNA *rna_def_property_subdivision_common(StructRNA *srna, const char type[]) @@ -1685,6 +1724,11 @@ static void rna_def_modifier_armature(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Bone Envelopes", "Bind Bone envelopes to armature modifier"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_face_maps", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_FACEMAPS); + RNA_def_property_ui_text(prop, "Use Face Maps", "Create facemap widgets with same name as bones in the armature"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_vertex_groups", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "deformflag", ARM_DEF_VGROUP); RNA_def_property_ui_text(prop, "Use Vertex Groups", "Bind vertex groups to armature modifier"); @@ -2467,6 +2511,12 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) {0, NULL, 0, NULL, NULL} }; + static EnumPropertyItem particleinstance_space[] = { + {eParticleInstanceSpace_Local, "LOCAL", 0, "Local", "Use offset from the particle object in the instance object"}, + {eParticleInstanceSpace_World, "WORLD", 0, "World", "Use world space offset in the instance object"}, + {0, NULL, 0, NULL, NULL} + }; + srna = RNA_def_struct(brna, "ParticleInstanceModifier", "Modifier"); RNA_def_struct_ui_text(srna, "ParticleInstance Modifier", "Particle system instancing modifier"); RNA_def_struct_sdna(srna, "ParticleInstanceModifierData"); @@ -2481,16 +2531,30 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) prop = RNA_def_property(srna, "particle_system_index", PROP_INT, PROP_NONE); RNA_def_property_int_sdna(prop, NULL, "psys"); - RNA_def_property_range(prop, 1, 10); + RNA_def_property_range(prop, 1, SHRT_MAX); RNA_def_property_ui_text(prop, "Particle System Number", ""); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_pointer_funcs(prop, "rna_ParticleInstanceModifier_particle_system_get", "rna_ParticleInstanceModifier_particle_system_set", + NULL, "rna_ParticleInstanceModifier_particle_system_poll"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Particle System", ""); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "axis", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "axis"); RNA_def_property_enum_items(prop, particleinstance_axis); RNA_def_property_ui_text(prop, "Axis", "Pole axis for rotation"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); - + + prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "space"); + RNA_def_property_enum_items(prop, particleinstance_space); + RNA_def_property_ui_text(prop, "Space", "Space to use for copying mesh data"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "use_normal", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", eParticleInstanceFlag_Parents); RNA_def_property_ui_text(prop, "Normal", "Create instances from normal particles"); @@ -2542,6 +2606,40 @@ static void rna_def_modifier_particleinstance(BlenderRNA *brna) RNA_def_property_range(prop, 0.0, 1.0); RNA_def_property_ui_text(prop, "Random Position", "Randomize position along path"); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "rotation"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Rotation", "Rotation around path"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "random_rotation", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_float_sdna(prop, NULL, "random_rotation"); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Random Rotation", "Randomize rotation around path"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "particle_amount", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Particle Amount", "Amount of particles to use for instancing"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "particle_offset", PROP_FLOAT, PROP_FACTOR); + RNA_def_property_range(prop, 0.0, 1.0); + RNA_def_property_ui_text(prop, "Particle Offset", "Relative offset of particles to use for instancing, to avoid overlap of multiple instances"); + RNA_def_property_float_default(prop, 0.0f); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "index_layer_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "index_layer_name"); + RNA_def_property_ui_text(prop, "Index Layer Name", "Custom data layer name for the index"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + + prop = RNA_def_property(srna, "value_layer_name", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "value_layer_name"); + RNA_def_property_ui_text(prop, "Value Layer Name", "Custom data layer name for the randomized value"); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); } static void rna_def_modifier_explode(BlenderRNA *brna) @@ -2620,7 +2718,7 @@ static void rna_def_modifier_cloth(BlenderRNA *brna) RNA_def_property_struct_type(prop, "ClothSolverResult"); RNA_def_property_pointer_sdna(prop, NULL, "solver_result"); RNA_def_property_ui_text(prop, "Solver Result", ""); - + prop = RNA_def_property(srna, "point_cache", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_ui_text(prop, "Point Cache", ""); diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 4df954b062b..cbdb0d2fcae 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -38,6 +38,8 @@ #include "DNA_mesh_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_particle_types.h" +#include "DNA_scene_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" @@ -61,6 +63,8 @@ #include "MEM_guardedalloc.h" +#include "RE_render_ext.h" + EnumPropertyItem node_socket_in_out_items[] = { { SOCK_IN, "IN", 0, "Input", "" }, { SOCK_OUT, "OUT", 0, "Output", "" }, @@ -2966,6 +2970,101 @@ static void rna_CompositorNodeScale_update(Main *bmain, Scene *scene, PointerRNA rna_Node_update(bmain, scene, ptr); } +static PointerRNA rna_ShaderNodePointDensity_psys_get(PointerRNA *ptr) +{ + bNode *node = ptr->data; + NodeShaderTexPointDensity *shader_point_density = node->storage; + Object *ob = (Object*)node->id; + ParticleSystem *psys = NULL; + PointerRNA value; + + if (ob && shader_point_density->particle_system) { + psys = BLI_findlink(&ob->particlesystem, shader_point_density->particle_system - 1); + } + + RNA_pointer_create(&ob->id, &RNA_ParticleSystem, psys, &value); + return value; +} + +static void rna_ShaderNodePointDensity_psys_set(PointerRNA *ptr, PointerRNA value) +{ + bNode *node = ptr->data; + NodeShaderTexPointDensity *shader_point_density = node->storage; + Object *ob = (Object*)node->id; + + if (ob && value.id.data == ob) { + shader_point_density->particle_system = BLI_findindex(&ob->particlesystem, value.data) + 1; + } + else { + shader_point_density->particle_system = 0; + } +} + +static int point_density_color_source_from_shader(NodeShaderTexPointDensity *shader_point_density) +{ + switch (shader_point_density->color_source) { + case SHD_POINTDENSITY_COLOR_CONSTANT: return TEX_PD_COLOR_CONSTANT; + case SHD_POINTDENSITY_COLOR_PARTAGE: return TEX_PD_COLOR_PARTAGE; + case SHD_POINTDENSITY_COLOR_PARTSPEED: return TEX_PD_COLOR_PARTSPEED; + case SHD_POINTDENSITY_COLOR_PARTVEL: return TEX_PD_COLOR_PARTVEL; + case SHD_POINTDENSITY_COLOR_PARTTEX: return TEX_PD_COLOR_PARTTEX; + default: BLI_assert(false); return TEX_PD_COLOR_CONSTANT; + } +} + +/* TODO(sergey): This functio nassumes allocated array was passed, + * works fine with Cycles via C++ RNA, but fails with call from python. + */ +void rna_ShaderNodePointDensity_density_calc(bNode *self, Scene *scene, int *length, float **values) +{ + NodeShaderTexPointDensity *shader_point_density = self->storage; + PointDensity pd; + + *length = 4 * shader_point_density->resolution * + shader_point_density->resolution * + shader_point_density->resolution; + + if (*values == NULL) { + *values = MEM_mallocN(sizeof(float) * (*length), "point density dynamic array"); + } + + /* Create PointDensity structure from node for sampling. */ + BKE_texture_pointdensity_init_data(&pd); + pd.object = (Object *)self->id; + pd.radius = shader_point_density->radius; + if (shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) { + pd.source = TEX_PD_PSYS; + pd.psys = shader_point_density->particle_system; + pd.psys_cache_space = TEX_PD_OBJECTSPACE; + } + else { + BLI_assert(shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_OBJECT); + pd.source = TEX_PD_OBJECT; + pd.ob_cache_space = TEX_PD_OBJECTSPACE; + } + pd.color_source = point_density_color_source_from_shader(shader_point_density); + + /* Single-threaded sampling of the voxel domain. */ + RE_sample_point_density(scene, &pd, + shader_point_density->resolution, + *values); + + /* We're done, time to clean up. */ + BKE_texture_pointdensity_free_data(&pd); +} + +static void rna_ShaderNodeOpenVDB_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + bNodeTree *ntree = (bNodeTree *)ptr->id.data; + bNode *node = (bNode *)ptr->data; + + ntreeUpdateOpenVDBNode(bmain, ntree, node); + ntreeUpdateTree(bmain, ntree); + WM_main_add_notifier(NC_NODE | NA_EDITED, ntree); + + UNUSED_VARS(scene); +} + #else static EnumPropertyItem prop_image_layer_items[] = { @@ -3792,6 +3891,105 @@ static void def_sh_tex_wireframe(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_sh_tex_pointdensity(StructRNA *srna) +{ + PropertyRNA *prop; + FunctionRNA *func; + + static EnumPropertyItem point_source_items[] = { + {SHD_POINTDENSITY_SOURCE_PSYS, "PARTICLE_SYSTEM", 0, "Particle System", + "Generate point density from a particle system"}, + {SHD_POINTDENSITY_SOURCE_OBJECT, "OBJECT", 0, "Object Vertices", + "Generate point density from an object's vertices"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem prop_interpolation_items[] = { + {SHD_INTERP_CLOSEST, "Closest", 0, "Closest", + "No interpolation (sample closest texel)"}, + {SHD_INTERP_LINEAR, "Linear", 0, "Linear", + "Linear interpolation"}, + {SHD_INTERP_CUBIC, "Cubic", 0, "Cubic", + "Cubic interpolation (CPU only)"}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem space_items[] = { + {SHD_POINTDENSITY_SPACE_OBJECT, "OBJECT", 0, "Object Space", ""}, + {SHD_POINTDENSITY_SPACE_WORLD, "WORLD", 0, "World Space", ""}, + {0, NULL, 0, NULL, NULL} + }; + + static EnumPropertyItem color_source_items[] = { + {SHD_POINTDENSITY_COLOR_CONSTANT, "CONSTANT", 0, "Constant", ""}, + {SHD_POINTDENSITY_COLOR_PARTAGE, "PARTICLE_AGE", 0, "Particle Age", + "Lifetime mapped as 0.0 - 1.0 intensity"}, + {SHD_POINTDENSITY_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", + "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"}, + {SHD_POINTDENSITY_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", + "XYZ velocity mapped to RGB colors"}, + {SHD_POINTDENSITY_COLOR_PARTTEX, "PARTICLE_TEXTURE", 0, "Particle Texture", "Texture color of particles"}, + {0, NULL, 0, NULL, NULL} + }; + + prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "id"); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Object", "Object to take point data from)"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "NodeShaderTexPointDensity", "storage"); + + prop = RNA_def_property(srna, "point_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, point_source_items); + RNA_def_property_ui_text(prop, "Point Source", "Point data to use as renderable point density"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "particle_system", PROP_POINTER, PROP_NONE); + RNA_def_property_ui_text(prop, "Particle System", "Particle System to render as points"); + RNA_def_property_struct_type(prop, "ParticleSystem"); + RNA_def_property_pointer_funcs(prop, "rna_ShaderNodePointDensity_psys_get", + "rna_ShaderNodePointDensity_psys_set", NULL, NULL); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "resolution", PROP_INT, PROP_NONE); + RNA_def_property_range(prop, 1, 32768); + RNA_def_property_ui_text(prop, "Resolution", "Resolution used by the texture holding the point density"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "radius"); + RNA_def_property_range(prop, 0.001, FLT_MAX); + RNA_def_property_ui_text(prop, "Radius", "Radius from the shaded sample to look for points within"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "space", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, space_items); + RNA_def_property_ui_text(prop, "Space", "Coordinate system to calculate voxels in"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "interpolation", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_interpolation_items); + RNA_def_property_ui_text(prop, "Interpolation", "Texture interpolation"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "color_source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "color_source"); + RNA_def_property_enum_items(prop, color_source_items); + RNA_def_property_ui_text(prop, "Color Source", "Data to derive color results from"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + func = RNA_def_function(srna, "calc_point_density", "rna_ShaderNodePointDensity_density_calc"); + RNA_def_function_ui_description(func, "Calculate point density"); + RNA_def_pointer(func, "scene", "Scene", "", ""); + /* TODO, See how array size of 0 works, this shouldnt be used. */ + prop = RNA_def_float_array(func, "rgba_values", 1, NULL, 0, 0, "", "RGBA Values", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC); + RNA_def_function_output(func, prop); +} + static void def_glossy(StructRNA *srna) { PropertyRNA *prop; @@ -3875,6 +4073,43 @@ static void def_sh_uvmap(StructRNA *srna) RNA_def_struct_sdna_from(srna, "bNode", NULL); } +static void def_sh_openvdb(StructRNA *srna) +{ + PropertyRNA *prop; + + static const EnumPropertyItem prop_openvdb_sampling[] = { + {NODE_VDB_SAMPLE_POINT, "POINT", 0, "Point", + "Nearest neighbor interpolation type"}, + {NODE_VDB_SAMPLE_BOX, "Box", 0, "Box", + "Trilinear interpolation type"}, + {0, NULL, 0, NULL, NULL} + }; + + static const EnumPropertyItem prop_openvdb_source[] = { + {NODE_VDB_SRC_FILE, "FILE", 0, "Single File", "Single vdb file"}, + {NODE_VDB_SRC_SEQ, "SEQUENCE", 0, "File Sequence", "Multiple vdb files, as a sequence"}, + {0, NULL, 0, NULL, NULL} + }; + + RNA_def_struct_sdna_from(srna, "NodeShaderOpenVDB", "storage"); + + prop = RNA_def_property(srna, "filename", PROP_STRING, PROP_FILEPATH); + RNA_def_property_ui_text(prop, "File Path", "Path to the file to use"); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNodeOpenVDB_update"); + + prop = RNA_def_property(srna, "sampling", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_openvdb_sampling); + RNA_def_property_ui_text(prop, "Sampling", "Grid interpolation"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + prop = RNA_def_property(srna, "source", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, prop_openvdb_source); + RNA_def_property_ui_text(prop, "Source", "File Source"); + RNA_def_property_update(prop, 0, "rna_Node_update"); + + RNA_def_struct_sdna_from(srna, "bNode", NULL); +} + static void def_sh_uvalongstroke(StructRNA *srna) { PropertyRNA *prop; diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f433c2c36a8..cc60d59ae95 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -42,6 +42,7 @@ #include "BLI_utildefines.h" #include "BLI_listbase.h" +#include "BKE_facemap.h" #include "BKE_camera.h" #include "BKE_paint.h" #include "BKE_editmesh.h" @@ -69,6 +70,7 @@ EnumPropertyItem object_mode_items[] = { {OB_MODE_WEIGHT_PAINT, "WEIGHT_PAINT", ICON_WPAINT_HLT, "Weight Paint", ""}, {OB_MODE_TEXTURE_PAINT, "TEXTURE_PAINT", ICON_TPAINT_HLT, "Texture Paint", ""}, {OB_MODE_PARTICLE_EDIT, "PARTICLE_EDIT", ICON_PARTICLEMODE, "Particle Edit", ""}, + {OB_MODE_HAIR_EDIT, "HAIR_EDIT", ICON_PARTICLEMODE, "Hair Edit", ""}, {0, NULL, 0, NULL, NULL} }; @@ -179,12 +181,15 @@ EnumPropertyItem object_axis_unsigned_items[] = { #include "BLI_math.h" #include "DNA_key_types.h" +#include "DNA_cache_library_types.h" #include "DNA_constraint_types.h" #include "DNA_lattice_types.h" #include "DNA_node_types.h" +#include "BKE_anim.h" #include "BKE_armature.h" #include "BKE_bullet.h" +#include "BKE_cache_library.h" #include "BKE_constraint.h" #include "BKE_context.h" #include "BKE_curve.h" @@ -197,6 +202,7 @@ EnumPropertyItem object_axis_unsigned_items[] = { #include "BKE_mesh.h" #include "BKE_particle.h" #include "BKE_scene.h" +#include "BKE_strands.h" #include "BKE_deform.h" #include "ED_object.h" @@ -622,6 +628,87 @@ void rna_object_vgroup_name_set(PointerRNA *ptr, const char *value, char *result result[0] = '\0'; } +static void rna_FaceMap_name_set(PointerRNA *ptr, const char *value) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap = (bFaceMap *)ptr->data; + BLI_strncpy_utf8(fmap->name, value, sizeof(fmap->name)); + fmap_unique_name(fmap, ob); +} + +static int rna_FaceMap_index_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + + return BLI_findindex(&ob->fmaps, ptr->data); +} + +static PointerRNA rna_Object_active_face_map_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + return rna_pointer_inherit_refine(ptr, &RNA_FaceMap, BLI_findlink(&ob->fmaps, ob->actfmap - 1)); +} + +static int rna_Object_active_face_map_index_get(PointerRNA *ptr) +{ + Object *ob = (Object *)ptr->id.data; + return ob->actfmap - 1; +} + +static void rna_Object_active_face_map_index_set(PointerRNA *ptr, int value) +{ + Object *ob = (Object *)ptr->id.data; + ob->actfmap = value + 1; +} + +static void rna_Object_active_face_map_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + Object *ob = (Object *)ptr->id.data; + + *min = 0; + *max = max_ii(0, BLI_listbase_count(&ob->fmaps) - 1); +} + +void rna_object_fmap_name_index_get(PointerRNA *ptr, char *value, int index) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap; + + fmap = BLI_findlink(&ob->fmaps, index - 1); + + if (fmap) BLI_strncpy(value, fmap->name, sizeof(fmap->name)); + else value[0] = '\0'; +} + +int rna_object_fmap_name_index_length(PointerRNA *ptr, int index) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap; + + fmap = BLI_findlink(&ob->fmaps, index - 1); + return (fmap) ? strlen(fmap->name) : 0; +} + +void rna_object_fmap_name_index_set(PointerRNA *ptr, const char *value, short *index) +{ + Object *ob = (Object *)ptr->id.data; + *index = fmap_name_index(ob, value) + 1; +} + +void rna_object_fmap_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) +{ + Object *ob = (Object *)ptr->id.data; + bFaceMap *fmap = fmap_find_name(ob, value); + if (fmap) { + BLI_strncpy(result, value, maxlen); /* no need for BLI_strncpy_utf8, since this matches an existing group */ + return; + } + + result[0] = '\0'; +} + + void rna_object_uvlayer_name_set(PointerRNA *ptr, const char *value, char *result, int maxlen) { Object *ob = (Object *)ptr->id.data; @@ -1457,6 +1544,69 @@ static float rna_VertexGroup_weight(ID *id, bDeformGroup *dg, ReportList *report return weight; } +static bFaceMap *rna_Object_fmap_new(Object *ob, const char *name) +{ + bFaceMap *fmap = BKE_object_facemap_add_name(ob, name); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); + + return fmap; +} + +static void rna_Object_fmap_remove(Object *ob, ReportList *reports, PointerRNA *fmap_ptr) +{ + bFaceMap *fmap = fmap_ptr->data; + if (BLI_findindex(&ob->fmaps, fmap) == -1) { + BKE_reportf(reports, RPT_ERROR, "FaceMap '%s' not in object '%s'", fmap->name, ob->id.name + 2); + return; + } + + BKE_object_facemap_remove(ob, fmap); + RNA_POINTER_INVALIDATE(fmap_ptr); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); +} + + +static void rna_Object_fmap_clear(Object *ob) +{ + BKE_object_fmap_remove_all(ob); + + WM_main_add_notifier(NC_OBJECT | ND_DRAW, ob); +} + + +static void rna_FaceMap_face_add(ID *id, bFaceMap *fmap, ReportList *reports, int index_len, + int *index) +{ + Object *ob = (Object *)id; + + if (BKE_object_is_in_editmode(ob)) { + BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode"); + return; + } + + while (index_len--) + ED_fmap_face_add(ob, fmap, *index++); + + WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data); +} + +static void rna_FaceMap_face_remove(ID *id, bFaceMap *fmap, ReportList *reports, int index_len, int *index) +{ + Object *ob = (Object *)id; + + if (BKE_object_is_in_editmode(ob)) { + BKE_report(reports, RPT_ERROR, "FaceMap.add(): cannot be called while object is in edit mode"); + return; + } + + while (index_len--) + ED_fmap_face_remove(ob, fmap, *index++); + + WM_main_add_notifier(NC_GEOM | ND_DATA, (ID *)ob->data); +} + /* generic poll functions */ int rna_Lattice_object_poll(PointerRNA *UNUSED(ptr), PointerRNA value) { @@ -1510,6 +1660,120 @@ static void rna_Object_lod_distance_update(Main *UNUSED(bmain), Scene *UNUSED(sc (void)ob; #endif } + +/* settings: 1 - preview, 2 - render */ +Strands *rna_DupliObject_strands_new(DupliObject *dob, ReportList *UNUSED(reports), Scene *scene, Object *parent, ParticleSystem *psys, int settings) +{ + Strands *strands = NULL; + bool is_cached = parent->cache_library && (parent->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE || parent->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_RESULT); + + if (is_cached) { + float frame = (float)scene->r.cfra + scene->r.subframe; + bool use_render = (settings == 2); + + if (!ELEM(settings, 1, 2)) + return NULL; + + if (!use_render && parent->dup_cache) { + DupliObjectData *data; + + /* use dupli cache for realtime dupli data if possible */ + data = BKE_dupli_cache_find_data(parent->dup_cache, dob->ob); + if (data) { + /* TODO(sergey): Consider sharing the data between viewport and + * render engine. + */ + BKE_dupli_object_data_find_strands(data, psys->name, &strands, NULL); + if (strands) { + strands = BKE_strands_copy(strands); + } + } + } + else { + DupliObjectData data; + + memset(&data, 0, sizeof(data)); + if (BKE_cache_read_dupli_object(parent->cache_library, &data, scene, dob->ob, frame, use_render, true)) { + BKE_dupli_object_data_find_strands(&data, psys->name, &strands, NULL); + if (strands) + BKE_dupli_object_data_acquire_strands(&data, strands); + } + + BKE_dupli_object_data_clear(&data); + } + } + + return strands; +} + +static void rna_DupliObject_strands_free(DupliObject *UNUSED(dob), ReportList *UNUSED(reports), PointerRNA *strands_ptr) +{ + Strands *strands = strands_ptr->data; + if (strands) + BKE_strands_free(strands); +} + +/* settings: 1 - preview, 2 - render */ +StrandsChildren *rna_DupliObject_strands_children_new(DupliObject *dob, ReportList *UNUSED(reports), Scene *scene, Object *parent, ParticleSystem *psys, int settings) +{ + StrandsChildren *strands = NULL; + bool is_cached = parent->cache_library && (parent->cache_library->source_mode == CACHE_LIBRARY_SOURCE_CACHE || parent->cache_library->display_mode == CACHE_LIBRARY_DISPLAY_RESULT); + + if (is_cached) { + float frame = (float)scene->r.cfra + scene->r.subframe; + bool use_render = (settings == 2); + + if (!ELEM(settings, 1, 2)) + return NULL; + + if (!use_render && parent->dup_cache) { + DupliObjectData *data; + + /* use dupli cache for realtime dupli data if possible */ + data = BKE_dupli_cache_find_data(parent->dup_cache, dob->ob); + if (data) { + /* TODO(sergey): Consider sharing the data between viewport and + * render engine. + */ + BKE_dupli_object_data_find_strands(data, psys->name, NULL, &strands); + if (strands) { + strands = BKE_strands_children_copy(strands); + } + } + } + else { + DupliObjectData data; + + memset(&data, 0, sizeof(data)); + if (BKE_cache_read_dupli_object(parent->cache_library, &data, scene, dob->ob, frame, use_render, true)) { + Strands *parents; + BKE_dupli_object_data_find_strands(&data, psys->name, &parents, &strands); + if (strands) { + BKE_dupli_object_data_acquire_strands_children(&data, strands); + + /* Deform child strands to follow parent motion. + * Note that this is an optional feature for viewport/render display, + * strand motion is not applied to raw child data in caches. + */ + if (parents) + BKE_strands_children_deform(strands, parents, true); + } + } + + BKE_dupli_object_data_clear(&data); + } + } + + return strands; +} + +static void rna_DupliObject_strands_children_free(DupliObject *UNUSED(dob), ReportList *UNUSED(reports), PointerRNA *strands_ptr) +{ + StrandsChildren *strands = strands_ptr->data; + if (strands) + BKE_strands_children_free(strands); +} + #else static void rna_def_vertex_group(BlenderRNA *brna) @@ -1575,6 +1839,44 @@ static void rna_def_vertex_group(BlenderRNA *brna) RNA_def_function_return(func, prop); } +static void rna_def_face_map(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + FunctionRNA *func; + + srna = RNA_def_struct(brna, "FaceMap", NULL); + RNA_def_struct_sdna(srna, "bFaceMap"); + RNA_def_struct_ui_text(srna, "Face Map", "Group of faces, each face can only be part of one map"); + RNA_def_struct_ui_icon(srna, ICON_MOD_TRIANGULATE); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_ui_text(prop, "Name", "Face map name"); + RNA_def_struct_name_property(srna, prop); + RNA_def_property_string_funcs(prop, NULL, NULL, "rna_FaceMap_name_set"); + /* update data because modifiers may use [#24761] */ + RNA_def_property_update(prop, NC_GEOM | ND_DATA | NA_RENAME, "rna_Object_internal_update_data"); + + prop = RNA_def_property(srna, "index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_int_funcs(prop, "rna_FaceMap_index_get", NULL, NULL); + RNA_def_property_ui_text(prop, "Index", "Index number of the face map"); + + func = RNA_def_function(srna, "add", "rna_FaceMap_face_add"); + RNA_def_function_ui_description(func, "Add vertices to the group"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED); + + func = RNA_def_function(srna, "remove", "rna_FaceMap_face_remove"); + RNA_def_function_ui_description(func, "Remove a vertex from the group"); + RNA_def_function_flag(func, FUNC_USE_REPORTS | FUNC_USE_SELF_ID); + /* TODO, see how array size of 0 works, this shouldnt be used */ + prop = RNA_def_int_array(func, "index", 1, NULL, 0, 0, "", "Index List", 0, 0); + RNA_def_property_flag(prop, PROP_DYNAMIC | PROP_REQUIRED); +} + static void rna_def_material_slot(BlenderRNA *brna) { StructRNA *srna; @@ -2090,6 +2392,54 @@ static void rna_def_object_vertex_groups(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_function_ui_description(func, "Delete all vertex groups from object"); } +/* object.vertex_groups */ +static void rna_def_object_face_maps(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + + PropertyRNA *prop; + + FunctionRNA *func; + PropertyRNA *parm; + + RNA_def_property_srna(cprop, "FaceMaps"); + srna = RNA_def_struct(brna, "FaceMaps", NULL); + RNA_def_struct_sdna(srna, "Object"); + RNA_def_struct_ui_text(srna, "Face Maps", "Collection of face maps"); + + prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "FaceMap"); + RNA_def_property_pointer_funcs(prop, "rna_Object_active_face_map_get", + "rna_Object_active_face_map_set", NULL, NULL); + RNA_def_property_ui_text(prop, "Active Face Map", "Face maps of the object"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + + prop = RNA_def_property(srna, "active_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_sdna(prop, NULL, "actfmap"); + RNA_def_property_int_funcs(prop, "rna_Object_active_face_map_index_get", + "rna_Object_active_face_map_index_set", + "rna_Object_active_face_map_index_range"); + RNA_def_property_ui_text(prop, "Active Face Map Index", "Active index in face map array"); + RNA_def_property_update(prop, NC_GEOM | ND_DATA, "rna_Object_internal_update_data"); + + /* face maps */ /* add_face_map */ + func = RNA_def_function(srna, "new", "rna_Object_fmap_new"); + RNA_def_function_ui_description(func, "Add face map to object"); + RNA_def_string(func, "name", "Map", 0, "", "face map name"); /* optional */ + parm = RNA_def_pointer(func, "fmap", "FaceMap", "", "New face map"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Object_fmap_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Delete vertex group from object"); + parm = RNA_def_pointer(func, "group", "FaceMap", "", "Face map to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + + func = RNA_def_function(srna, "clear", "rna_Object_fmap_clear"); + RNA_def_function_ui_description(func, "Delete all vertex groups from object"); +} static void rna_def_object_lodlevel(BlenderRNA *brna) { @@ -2510,6 +2860,14 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Vertex Groups", "Vertex groups of the object"); rna_def_object_vertex_groups(brna, prop); + + /* vertex groups */ + prop = RNA_def_property(srna, "face_maps", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "fmaps", NULL); + RNA_def_property_struct_type(prop, "FaceMap"); + RNA_def_property_ui_text(prop, "Face Maps", "Maps of faces of the object"); + rna_def_object_face_maps(brna, prop); + /* empty */ prop = RNA_def_property(srna, "empty_draw_type", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "empty_drawtype"); @@ -2670,6 +3028,12 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Dupli Group", "Instance an existing group"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); + prop = RNA_def_property(srna, "cache_library", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "cache_library"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Cache Library", "Cache Library to use"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_dependency_update"); + prop = RNA_def_property(srna, "dupli_frames_start", PROP_INT, PROP_NONE | PROP_UNIT_TIME); RNA_def_property_int_sdna(prop, NULL, "dupsta"); RNA_def_property_range(prop, MINAFRAME, MAXFRAME); @@ -2748,6 +3112,11 @@ static void rna_def_object(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Draw All Edges", "Display all edges for mesh objects"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "show_wire_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAW_WIRECOLOR); + RNA_def_property_ui_text(prop, "Draw Wire Color", "Use custom wire color"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); + prop = RNA_def_property(srna, "show_transparent", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "dtx", OB_DRAWTRANSP); RNA_def_property_ui_text(prop, "Draw Transparent", @@ -2826,6 +3195,14 @@ static void rna_def_dupli_object(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; + FunctionRNA *func; + PropertyRNA *parm; + + static EnumPropertyItem strand_settings_items[] = { + {1, "PREVIEW", 0, "Preview", "Apply preview settings"}, + {2, "RENDER", 0, "Render", "Apply render settings"}, + {0, NULL, 0, NULL, NULL} + }; srna = RNA_def_struct(brna, "DupliObject", NULL); RNA_def_struct_sdna(srna, "DupliObject"); @@ -2874,6 +3251,60 @@ static void rna_def_dupli_object(BlenderRNA *brna) RNA_def_property_enum_items(prop, dupli_items); RNA_def_property_clear_flag(prop, PROP_ANIMATABLE | PROP_EDITABLE); RNA_def_property_ui_text(prop, "Dupli Type", "Duplicator type that generated this dupli object"); + + func = RNA_def_function(srna, "strands_new", "rna_DupliObject_strands_new"); + RNA_def_function_ui_description(func, "Add new strands created from dupli cache data"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "parent", "Object", "", "Duplicator parent of the object"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "particle_system", "ParticleSystem", "", "Particle System"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_enum(func, "settings", strand_settings_items, 0, "", "Modifier settings to apply"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "strands", "Strands", "", + "Strands created from object, remove it if it is only used for export"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "strands_free", "rna_DupliObject_strands_free"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Free strands data"); + parm = RNA_def_pointer(func, "strands", "Strands", "", "Strands to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); + + func = RNA_def_function(srna, "strands_children_new", "rna_DupliObject_strands_children_new"); + RNA_def_function_ui_description(func, "Add new strands created from dupli cache data"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + parm = RNA_def_pointer(func, "scene", "Scene", "", "Scene within which to evaluate modifiers"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "parent", "Object", "", "Duplicator parent of the object"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "particle_system", "ParticleSystem", "", "Particle System"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_enum(func, "settings", strand_settings_items, 0, "", "Modifier settings to apply"); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_pointer(func, "strands", "StrandsChildren", "", + "Strands created from object, remove it if it is only used for export"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "strands_children_free", "rna_DupliObject_strands_children_free"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Free strands data"); + parm = RNA_def_pointer(func, "strands", "StrandsChildren", "", "Strands to remove"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL | PROP_RNAPTR); + RNA_def_property_clear_flag(parm, PROP_THICK_WRAP); +} + +static void rna_def_dupli_object_data(BlenderRNA *brna) +{ + StructRNA *srna; + /*PropertyRNA *prop;*/ + + srna = RNA_def_struct(brna, "DupliObjectData", NULL); + RNA_def_struct_sdna(srna, "DupliObjectData"); + RNA_def_struct_ui_text(srna, "Object Duplicate Data", "Override of object data for duplis"); } static void rna_def_object_base(BlenderRNA *brna) @@ -2920,8 +3351,10 @@ void RNA_def_object(BlenderRNA *brna) rna_def_object_game_settings(brna); rna_def_object_base(brna); rna_def_vertex_group(brna); + rna_def_face_map(brna); rna_def_material_slot(brna); rna_def_dupli_object(brna); + rna_def_dupli_object_data(brna); RNA_define_animate_sdna(true); rna_def_object_lodlevel(brna); } diff --git a/source/blender/makesrna/intern/rna_object_api.c b/source/blender/makesrna/intern/rna_object_api.c index 55f559c0222..541971ea748 100644 --- a/source/blender/makesrna/intern/rna_object_api.c +++ b/source/blender/makesrna/intern/rna_object_api.c @@ -224,6 +224,18 @@ static void rna_Object_free_duplilist(Object *ob) } } +static PointerRNA rna_Object_find_dupli_cache(Object *ob, Object *dupob) +{ + DupliObjectData *data = NULL; + PointerRNA ptr; + + if (ob->dup_cache) + data = BKE_dupli_cache_find_data(ob->dup_cache, dupob); + + RNA_pointer_create((ID *)ob, &RNA_DupliObjectData, data, &ptr); + return ptr; +} + static PointerRNA rna_Object_shape_key_add(Object *ob, bContext *C, ReportList *reports, const char *name, int from_mix) { @@ -466,6 +478,12 @@ static int rna_Object_update_from_editmode(Object *ob) } return false; } + +static void rna_Object_cache_release(Object *object, int free_smoke_sim) +{ + BKE_object_free_caches(object, free_smoke_sim != 0); +} + #else /* RNA_RUNTIME */ void RNA_api_object(StructRNA *srna) @@ -572,6 +590,14 @@ void RNA_api_object(StructRNA *srna) func = RNA_def_function(srna, "dupli_list_clear", "rna_Object_free_duplilist"); RNA_def_function_ui_description(func, "Free the list of dupli objects"); + func = RNA_def_function(srna, "find_dupli_cache", "rna_Object_find_dupli_cache"); + RNA_def_function_ui_description(func, "Find cached data for a dupli object"); + parm = RNA_def_pointer(func, "object", "Object", "", "Object data to look up"); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + parm = RNA_def_pointer(func, "data", "DupliObjectData", "", "Cached object data"); + RNA_def_property_flag(parm, PROP_RNAPTR); + RNA_def_function_return(func, parm); + /* Armature */ func = RNA_def_function(srna, "find_armature", "modifiers_isDeformedByArmature"); RNA_def_function_ui_description(func, "Find armature influencing this object as a parent or via a modifier"); @@ -688,7 +714,8 @@ void RNA_api_object(StructRNA *srna) parm = RNA_def_boolean(func, "result", 0, "", "Success"); RNA_def_function_return(func, parm); - func = RNA_def_function(srna, "cache_release", "BKE_object_free_caches"); + func = RNA_def_function(srna, "cache_release", "rna_Object_cache_release"); + RNA_def_boolean(func, "free_smoke_sim", 0, "", "Free baked smoke simulation data"); RNA_def_function_ui_description(func, "Release memory used by caches associated with this object. Intended to be used by render engines only"); } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 75becb341b9..21f53f86d90 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -1337,6 +1337,11 @@ static void rna_def_field(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Use Max", "Use a maximum distance for the field to work"); RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + prop = RNA_def_property(srna, "use_signed_distance", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USE_SIGNED_DISTANCE); + RNA_def_property_ui_text(prop, "Use Signed Distance", "Use negative distance on the interior of surface shapes"); + RNA_def_property_update(prop, 0, "rna_FieldSettings_update"); + prop = RNA_def_property(srna, "use_radial_min", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", PFIELD_USEMINR); RNA_def_property_ui_text(prop, "Use Min", "Use a minimum radial distance for the field's fall-off"); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index c0ce8f21870..a6bbbfcb8b4 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -35,6 +35,7 @@ #include "DNA_meshdata_types.h" #include "DNA_modifier_types.h" #include "DNA_cloth_types.h" +#include "DNA_key_types.h" #include "DNA_particle_types.h" #include "DNA_object_force.h" #include "DNA_object_types.h" @@ -97,9 +98,12 @@ static EnumPropertyItem part_draw_as_items[] = { #ifdef RNA_RUNTIME static EnumPropertyItem part_hair_draw_as_items[] = { - {PART_DRAW_NOT, "NONE", 0, "None", ""}, - {PART_DRAW_REND, "RENDER", 0, "Rendered", ""}, - {PART_DRAW_PATH, "PATH", 0, "Path", ""}, + {PART_DRAW_NOT, "NONE", 0, "None", "No hair drawing"}, + {PART_DRAW_REND, "RENDER", 0, "Rendered", "Approximate render result in the viewport"}, + {PART_DRAW_PATH, "PATH", 0, "Path", "Show path of hair particles"}, +#ifdef USE_PARTICLE_HULL_DRAWING + {PART_DRAW_HULL, "HULL", 0, "Hull", "Show convex hull of child particle paths"}, +#endif {0, NULL, 0, NULL, NULL} }; #endif @@ -127,6 +131,7 @@ static EnumPropertyItem part_hair_ren_as_items[] = { #ifdef RNA_RUNTIME +#include "BLI_listbase.h" #include "BLI_math.h" #include "BKE_context.h" @@ -137,12 +142,17 @@ static EnumPropertyItem part_hair_ren_as_items[] = { #include "BKE_DerivedMesh.h" #include "BKE_cdderivedmesh.h" #include "BKE_effect.h" +#include "BKE_key.h" #include "BKE_material.h" #include "BKE_modifier.h" #include "BKE_particle.h" #include "BKE_pointcache.h" #include "BKE_texture.h" +#include "RNA_access.h" + +#include "ED_particle.h" + /* use for object space hair get/set */ static void rna_ParticleHairKey_location_object_info(PointerRNA *ptr, ParticleSystemModifierData **psmd_pt, ParticleData **pa_pt) @@ -735,6 +745,7 @@ static void rna_Particle_hair_dynamics(Main *bmain, Scene *scene, PointerRNA *pt DAG_id_tag_update(&ob->id, OB_RECALC_DATA); } + static PointerRNA rna_particle_settings_get(PointerRNA *ptr) { ParticleSystem *psys = (ParticleSystem *)ptr->data; @@ -763,6 +774,64 @@ static void rna_particle_settings_set(PointerRNA *ptr, PointerRNA value) psys->recalc |= PSYS_RECALC_TYPE; } } + +static void rna_Particle_active_shape_update(Main *bmain, Scene *scene, PointerRNA *ptr) +{ + Object *ob = ptr->id.data; + ParticleSystem *psys = ptr->data; + + if (PE_shapekey_load(ob, psys)) { + WM_main_add_notifier(NC_SCENE | ND_PARTICLE | NS_MODE_PARTICLE, ptr->id.data); + } + + rna_Particle_redo(bmain, scene, ptr); +} + +static void rna_Particle_active_shape_key_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + ParticleSystem *psys = ptr->data; + Key *key = psys->key; + + *min = 0; + if (key) { + *max = BLI_listbase_count(&key->block) - 1; + if (*max < 0) *max = 0; + } + else { + *max = 0; + } +} + +static int rna_Particle_active_shape_key_index_get(PointerRNA *ptr) +{ + ParticleSystem *psys = ptr->data; + + return MAX2(psys->shapenr - 1, 0); +} + +static void rna_Particle_active_shape_key_index_set(PointerRNA *ptr, int value) +{ + ParticleSystem *psys = ptr->data; + + psys->shapenr = value + 1; +} + +static PointerRNA rna_Particle_active_shape_key_get(PointerRNA *ptr) +{ + ParticleSystem *psys = ptr->data; + Key *key = psys->key; + KeyBlock *kb; + PointerRNA keyptr; + + if (key == NULL) + return PointerRNA_NULL; + + kb = BLI_findlink(&key->block, psys->shapenr - 1); + RNA_pointer_create((ID *)key, &RNA_ShapeKey, kb, &keyptr); + return keyptr; +} + static void rna_Particle_abspathtime_update(Main *bmain, Scene *scene, PointerRNA *ptr) { ParticleSettings *settings = (ParticleSettings *)ptr->data; @@ -1834,6 +1903,16 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Length", "Affect the child hair length"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop = RNA_def_property(srna, "use_map_shapekey", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_SHAPEKEY); + RNA_def_property_ui_text(prop, "Shape Key", "Affect the blend factor of a hair shape key"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop = RNA_def_property(srna, "use_map_particle_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "mapto", PAMAP_COLOR); + RNA_def_property_ui_text(prop, "Color", "Affect the particle color"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + /* influence factors */ prop = RNA_def_property(srna, "time_factor", PROP_FLOAT, PROP_NONE); @@ -1915,6 +1994,23 @@ static void rna_def_particle_settings_mtex(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0, 1, 10, 3); RNA_def_property_ui_text(prop, "Rough Factor", "Amount texture affects child roughness"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + + prop = RNA_def_property(srna, "shapekey_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "shapefac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Shape Key Factor", "Amount texture affects shape key blend value"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop = RNA_def_property(srna, "shapekey", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "shapekey"); + RNA_def_property_ui_text(prop, "Shape Key", "Name of the shape key affected by the texture"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop = RNA_def_property(srna, "particle_color_factor", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "pacolfac"); + RNA_def_property_ui_range(prop, 0, 1, 10, 3); + RNA_def_property_ui_text(prop, "Particle Color Factor", "Amount texture affects particle color"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); } static void rna_def_particle_settings(BlenderRNA *brna) @@ -2033,6 +2129,10 @@ static void rna_def_particle_settings(BlenderRNA *brna) {PART_DRAW_COL_MAT, "MATERIAL", 0, "Material", ""}, {PART_DRAW_COL_VEL, "VELOCITY", 0, "Velocity", ""}, {PART_DRAW_COL_ACC, "ACCELERATION", 0, "Acceleration", ""}, +#ifdef USE_PARTICLE_HULL_DRAWING + {PART_DRAW_COL_PARENT, "PARENT", 0, "Parent", ""}, +#endif + {PART_DRAW_COL_TEX, "TEXTURE", 0, "Texture", ""}, {0, NULL, 0, NULL, NULL} }; @@ -2861,6 +2961,20 @@ static void rna_def_particle_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Clump Noise Size", "Size of clump noise"); RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + prop = RNA_def_property(srna, "clump_noise_random", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "clump_noise_random"); + RNA_def_property_range(prop, -100000.0f, 100000.0f); + RNA_def_property_ui_range(prop, 0.0f, 10.0f, 0.1f, 3); + RNA_def_property_ui_text(prop, "Clump Noise Random", "Random offset of clump noise"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + + prop = RNA_def_property(srna, "clump_noise_random_size", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "clump_noise_random_size"); + RNA_def_property_range(prop, 0.00001f, 100000.0f); + RNA_def_property_ui_range(prop, 0.01f, 10.0f, 0.1f, 3); + RNA_def_property_ui_text(prop, "Clump Noise Random Size", "Size of clump noise offset"); + RNA_def_property_update(prop, 0, "rna_Particle_redo_child"); + /* kink */ prop = RNA_def_property(srna, "kink_amplitude", PROP_FLOAT, PROP_NONE); RNA_def_property_float_sdna(prop, NULL, "kink_amp"); @@ -3253,6 +3367,30 @@ static void rna_def_particle_system(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Hair Dynamics", "Enable hair dynamics using cloth simulation"); RNA_def_property_update(prop, 0, "rna_Particle_hair_dynamics"); + prop = RNA_def_property(srna, "hair_preview_factor", PROP_FLOAT, PROP_PERCENTAGE); + RNA_def_property_float_sdna(prop, NULL, "hair_preview_factor"); + RNA_def_property_range(prop, 0.0f, 100.0f); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_ui_text(prop, "Preview Factor", "Part of hair particles to use for simulation preview"); + RNA_def_property_update(prop, 0, "rna_Particle_reset"); + + prop = RNA_def_property(srna, "shape_keys", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "key"); + RNA_def_property_ui_text(prop, "Shape Keys", ""); + + prop = RNA_def_property(srna, "active_shape_key", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "ShapeKey"); + RNA_def_property_pointer_funcs(prop, "rna_Particle_active_shape_key_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active Shape Key", "Current shape key"); + + prop = RNA_def_property(srna, "active_shape_key_index", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "shapenr"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_int_funcs(prop, "rna_Particle_active_shape_key_index_get", "rna_Particle_active_shape_key_index_set", + "rna_Particle_active_shape_key_index_range"); + RNA_def_property_ui_text(prop, "Active Shape Key Index", "Current shape key index"); + RNA_def_property_update(prop, 0, "rna_Particle_active_shape_update"); + prop = RNA_def_property(srna, "cloth", PROP_POINTER, PROP_NONE); RNA_def_property_pointer_sdna(prop, NULL, "clmd"); RNA_def_property_struct_type(prop, "ClothModifier"); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4688e691dae..a588040ad82 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2114,6 +2114,10 @@ static void rna_def_tool_settings(BlenderRNA *brna) RNA_def_property_pointer_sdna(prop, NULL, "particle"); RNA_def_property_ui_text(prop, "Particle Edit", ""); + prop = RNA_def_property(srna, "hair_edit", PROP_POINTER, PROP_NONE); + RNA_def_property_pointer_sdna(prop, NULL, "hair_edit"); + RNA_def_property_ui_text(prop, "Hair Edit", ""); + prop = RNA_def_property(srna, "use_uv_sculpt", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "use_uv_sculpt", 1); RNA_def_property_ui_text(prop, "UV Sculpt", "Enable brush for UV sculpting"); diff --git a/source/blender/makesrna/intern/rna_sculpt_paint.c b/source/blender/makesrna/intern/rna_sculpt_paint.c index 7b30aa84cfb..acde663a799 100644 --- a/source/blender/makesrna/intern/rna_sculpt_paint.c +++ b/source/blender/makesrna/intern/rna_sculpt_paint.c @@ -77,6 +77,8 @@ EnumPropertyItem symmetrize_direction_items[] = { #include "BKE_context.h" #include "BKE_DerivedMesh.h" +#include "BKE_editstrands.h" +#include "BKE_effect.h" #include "BKE_pointcache.h" #include "BKE_particle.h" #include "BKE_depsgraph.h" @@ -221,6 +223,8 @@ static int rna_Brush_mode_poll(PointerRNA *ptr, PointerRNA value) mode = OB_MODE_VERTEX_PAINT; else if (ptr->data == ts->wpaint) mode = OB_MODE_WEIGHT_PAINT; + else if (ptr->data == &ts->hair_edit) + mode = OB_MODE_HAIR_EDIT; return brush->ob_mode & mode; } @@ -359,6 +363,30 @@ static int rna_ImaPaint_detect_data(ImagePaintSettings *imapaint) { return imapaint->missing_data == 0; } + +/* ==== Hair Edit ==== */ + +static char *rna_HairEdit_path(PointerRNA *UNUSED(ptr)) +{ + return BLI_strdup("tool_settings.hair_edit"); +} + +static void rna_HairEdit_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr)) +{ + Object *ob = OBACT; + + if (ob) + DAG_id_tag_update(&ob->id, OB_RECALC_DATA); +} + +static void rna_HairEdit_brush_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) +{ + HairEditSettings *settings = ptr->data; + Brush *brush = settings->brush; + BKE_paint_invalidate_overlay_all(); + WM_main_add_notifier(NC_BRUSH | NA_EDITED, brush); +} + #else static void rna_def_paint_curve(BlenderRNA *brna) @@ -911,6 +939,10 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Puff Volume", "Apply puff to unselected end-points (helps maintain hair volume when puffing root)"); + prop = RNA_def_property(srna, "use_add_stroke", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", PE_BRUSH_DATA_ADD_SINGLE); + RNA_def_property_ui_text(prop, "Add Stroke", "Add multiple particles per brush stroke"); + prop = RNA_def_property(srna, "length_mode", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "invert"); RNA_def_property_enum_items(prop, length_mode); @@ -923,6 +955,41 @@ static void rna_def_particle_edit(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Curve", ""); } +static void rna_def_hair_edit(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem select_mode_items[] = { + {HAIR_SELECT_STRAND, "STRAND", ICON_PARTICLE_PATH, "Strand", "Strand edit mode"}, + {HAIR_SELECT_VERTEX, "VERTEX", ICON_PARTICLE_POINT, "Vertex", "Vertex select mode"}, + {HAIR_SELECT_TIP, "TIP", ICON_PARTICLE_TIP, "Tip", "Tip select mode"}, + {0, NULL, 0, NULL, NULL} + }; + + srna = RNA_def_struct(brna, "HairEdit", NULL); + RNA_def_struct_sdna(srna, "HairEditSettings"); + RNA_def_struct_path_func(srna, "rna_HairEdit_path"); + RNA_def_struct_ui_text(srna, "Hair Edit", "Settings for hair editing mode"); + + prop = RNA_def_property(srna, "brush", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Brush_mode_poll"); + RNA_def_property_ui_text(prop, "Brush", "Active Brush"); + RNA_def_property_update(prop, 0, "rna_HairEdit_brush_update"); + + prop = RNA_def_property(srna, "select_mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "select_mode"); + RNA_def_property_enum_items(prop, select_mode_items); + RNA_def_property_ui_text(prop, "Selection Mode", "Hair selection mode"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_HairEdit_update"); + + prop = RNA_def_property(srna, "shape_object", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Shape Object", "Outer shape to use for tools"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_HairEdit_update"); +} + void RNA_def_sculpt_paint(BlenderRNA *brna) { /* *** Non-Animated *** */ @@ -934,6 +1001,7 @@ void RNA_def_sculpt_paint(BlenderRNA *brna) rna_def_vertex_paint(brna); rna_def_image_paint(brna); rna_def_particle_edit(brna); + rna_def_hair_edit(brna); RNA_define_animate_sdna(true); } diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index d7311b93b2f..02360ebf85e 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1903,7 +1903,12 @@ static void rna_def_scene(BlenderRNA *brna) RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); RNA_def_property_ui_text(prop, "Camera Override", "Override the scenes active camera"); RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); - + + prop = RNA_def_property(srna, "use_sequence", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SEQ_SCENE_STRIPS); + RNA_def_property_ui_text(prop, "Use Sequence", "Use scenes sequence strips directly, instead of rendering"); + RNA_def_property_update(prop, NC_SCENE | ND_SEQUENCER, "rna_Sequence_update"); + prop = RNA_def_property(srna, "use_grease_pencil", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_SCENE_NO_GPENCIL); RNA_def_property_ui_text(prop, "Use Grease Pencil", "Show Grease Pencil strokes in OpenGL previews"); diff --git a/source/blender/makesrna/intern/rna_smoke.c b/source/blender/makesrna/intern/rna_smoke.c index 539f3c192be..d1786dab8ca 100644 --- a/source/blender/makesrna/intern/rna_smoke.c +++ b/source/blender/makesrna/intern/rna_smoke.c @@ -53,6 +53,8 @@ #include "BKE_depsgraph.h" #include "BKE_particle.h" +#include "BLI_math.h" + #include "smoke_API.h" @@ -316,8 +318,99 @@ static void rna_SmokeFlow_uvlayer_set(PointerRNA *ptr, const char *value) rna_object_uvlayer_name_set(ptr, value, flow->uvlayer_name, sizeof(flow->uvlayer_name)); } +static PointerRNA rna_SmokeModifier_active_openvdb_cache_get(PointerRNA *ptr) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = NULL; + + cache = BKE_openvdb_get_current_cache(sds); + return rna_pointer_inherit_refine(ptr, &RNA_OpenVDBCache, cache); +} + +static void rna_SmokeModifier_active_openvdb_cache_index_range(PointerRNA *ptr, int *min, int *max, + int *UNUSED(softmin), int *UNUSED(softmax)) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + *min = 0; + *max = max_ii(0, BLI_listbase_count(&sds->vdb_caches) - 1); +} + +static int rna_SmokeModifier_active_openvdb_cache_index_get(PointerRNA *ptr) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = (OpenVDBCache *)sds->vdb_caches.first; + int i = 0; + + for (; cache; cache = cache->next, i++) { + if (cache->flags & VDB_CACHE_CURRENT) + return i; + } + return 0; +} + +static void rna_SmokeModifier_active_openvdb_cache_index_set(struct PointerRNA *ptr, int value) +{ + SmokeDomainSettings *sds = (SmokeDomainSettings *)ptr->data; + OpenVDBCache *cache = (OpenVDBCache *)sds->vdb_caches.first; + int i = 0; + + for (; cache; cache = cache->next, i++) { + if (i == value) + cache->flags |= VDB_CACHE_CURRENT; + else + cache->flags &= ~VDB_CACHE_CURRENT; + } +} + + #else +static void rna_def_openvdb_cache(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + static EnumPropertyItem prop_compression_items[] = { + { VDB_COMPRESSION_ZIP, "ZIP", 0, "Zip", "Slow and effective compression" }, +#ifdef WITH_OPENVDB_BLOSC + { VDB_COMPRESSION_BLOSC, "BLOSC", 0, "Blosc", "Multithreaded compression, almost similar in size and quality as 'Zip'" }, +#endif + { VDB_COMPRESSION_NONE, "NONE", 0, "None", "Do not use any compression" }, + { 0, NULL, 0, NULL, NULL } + }; + + srna = RNA_def_struct(brna, "OpenVDBCache", NULL); + RNA_def_struct_ui_text(srna, "OpenVDB cache", "OpenVDB cache"); + + 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, "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"); + + 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_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "compression", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "compression"); + RNA_def_property_enum_items(prop, prop_compression_items); + RNA_def_property_ui_text(prop, "File Compression", + "Select what type of compression to use when writing the files"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); +} + static void rna_def_smoke_domain_settings(BlenderRNA *brna) { StructRNA *srna; @@ -463,6 +556,14 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_enum_items(prop, smoke_cache_comp_items); RNA_def_property_ui_text(prop, "Cache Compression", "Compression method to be used"); + prop = RNA_def_property(srna, "point_cache_offset", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "point_cache_offset"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_range(prop, -10000, 10000); + RNA_def_property_ui_range(prop, -10000, 10000, 1, -1); + RNA_def_property_ui_text(prop, "Point Cache Offset", "Offset to add to cached frames"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_update"); + prop = RNA_def_property(srna, "collision_extents", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "border_collisions"); RNA_def_property_enum_items(prop, smoke_domain_colli_items); @@ -601,6 +702,37 @@ static void rna_def_smoke_domain_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Threshold", "Maximum amount of fluid cell can contain before it is considered empty"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_resetCache"); + + /* display */ + prop = RNA_def_property(srna, "display_thickness", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "display_thickness"); + RNA_def_property_range(prop, 0.001f, 1000.0f); + RNA_def_property_ui_range(prop, 0.1f, 10.0f, 0.1, 3); + RNA_def_property_ui_text(prop, "Thickness", "Thickness of smoke drawing in the viewport"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "use_openvdb", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "use_openvdb", 1); + RNA_def_property_ui_text(prop, "Use OpenVDB", "Use OpenVDB to cache the simulation"); + RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, NULL); + + prop = RNA_def_property(srna, "cache", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "vdb_caches", NULL); + RNA_def_property_struct_type(prop, "OpenVDBCache"); + + prop = RNA_def_property(srna, "active_openvdb_cache", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "OpenVDBCache"); + RNA_def_property_pointer_funcs(prop, "rna_SmokeModifier_active_openvdb_cache_get", NULL, NULL, NULL); + RNA_def_property_ui_text(prop, "Active OpenVDB cache", ""); + + prop = RNA_def_property(srna, "active_openvdb_cache_index", PROP_INT, PROP_UNSIGNED); + RNA_def_property_int_funcs(prop, "rna_SmokeModifier_active_openvdb_cache_index_get", + "rna_SmokeModifier_active_openvdb_cache_index_set", + "rna_SmokeModifier_active_openvdb_cache_index_range"); + RNA_def_property_ui_text(prop, "Active OpenVDB cache Index", ""); + + rna_def_openvdb_cache(brna); } static void rna_def_smoke_flow_settings(BlenderRNA *brna) @@ -732,6 +864,11 @@ static void rna_def_smoke_flow_settings(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Set Size", "Set particle size in simulation cells or use nearest cell"); RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "use_particle_texture_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flags", MOD_SMOKE_FLOW_USE_PART_TEXCOLOR); + RNA_def_property_ui_text(prop, "Set Texture Color", "Set particle texture color in simulation cells"); + RNA_def_property_update(prop, NC_OBJECT | ND_MODIFIER, "rna_Smoke_reset"); + prop = RNA_def_property(srna, "subframes", PROP_INT, PROP_NONE); RNA_def_property_range(prop, 0, 50); RNA_def_property_ui_range(prop, 0, 10, 1, -1); diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 20a6bd67dea..76535955929 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -2484,6 +2484,11 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "World Background", "Display world colors in the background"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "show_motionpaths", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag3", V3D_HIDE_MOTIONPATHS); + RNA_def_property_ui_text(prop, "Motion Paths", "Display animation motion paths -even in only render mode"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_occlude_geometry", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", V3D_ZBUF_SELECT); RNA_def_property_ui_text(prop, "Occlude Geometry", "Limit selection to visible (clipped with depth buffer)"); @@ -2608,6 +2613,11 @@ static void rna_def_space_view3d(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show 3D Marker Names", "Show names for reconstructed tracks objects"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_wire_color", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag2", V3D_WIRE_COLOR_NOCUSTOM); + RNA_def_property_ui_text(prop, "Color Wire", "Draw wireframes using object color"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); + prop = RNA_def_property(srna, "use_matcap", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SOLID_MATCAP); RNA_def_property_ui_text(prop, "Matcap", "Active Objects draw images mapped on normals, enhancing Solid Draw Mode"); @@ -3077,6 +3087,11 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Metadata", "Show metadata of first visible strip"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + prop = RNA_def_property(srna, "show_info", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_NO_INFO); + RNA_def_property_ui_text(prop, "Show Strip Info", "Show source info on the strip"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + prop = RNA_def_property(srna, "show_seconds", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SEQ_DRAWFRAMES); RNA_def_property_ui_text(prop, "Show Seconds", "Show timing in seconds not frames"); @@ -3134,10 +3149,22 @@ static void rna_def_space_sequencer(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Overlay Type", "Overlay draw type"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); - prop = RNA_def_property(srna, "show_backdrop", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_BACKDROP); - RNA_def_property_ui_text(prop, "Use Backdrop", "Display result under strips"); + prop = RNA_def_property(srna, "show_overdrop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_OVERDROP); + RNA_def_property_ui_text(prop, "Use Overdrop", "Display result under strips"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_SEQUENCER, NULL); + + prop = RNA_def_property(srna, "overdrop_zoom", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.01f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); + RNA_def_property_ui_text(prop, "Overdrop Zoom", "Overdrop zoom factor"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); + + prop = RNA_def_property(srna, "overdrop_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Overdrop Offset", "Overdrop offset"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "show_strip_offset", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "draw_flag", SEQ_DRAW_OFFSET_EXT); @@ -3497,6 +3524,23 @@ static void rna_def_space_graph(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Auto Normalization", "Automatically recalculate curve normalization on every curve edit"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + + prop = RNA_def_property(srna, "show_backdrop", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", SIPO_DRAW_BACKDROP); + RNA_def_property_ui_text(prop, "Show Backdrop", "Draw a backdrop showing the content of the 3D View"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + + prop = RNA_def_property(srna, "backdrop_camera", PROP_POINTER, PROP_NONE); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_pointer_funcs(prop, NULL, NULL, NULL, "rna_Camera_object_poll"); + RNA_def_property_ui_text(prop, "Backdrop Camera", "The camera that is used to project the backdrop"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); + + prop = RNA_def_property(srna, "backdrop_opacity", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "backdrop_opacity"); + RNA_def_property_range(prop, 0.0f, 1.0f); + RNA_def_property_ui_text(prop, "Backdrop Opacity", "Opacity of the backdrop"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_GRAPH, NULL); } static void rna_def_space_nla(BlenderRNA *brna) @@ -3744,6 +3788,11 @@ static void rna_def_fileselect_params(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Show Hidden", "Show hidden dot files"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "collapse_seq", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", FILE_COLLAPSE_IMAGES); + RNA_def_property_ui_text(prop, "Collapse Image Sequences", "Collapse image sequences"); + RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "sort"); RNA_def_property_enum_items(prop, file_sort_items); @@ -4173,21 +4222,15 @@ static void rna_def_space_node(BlenderRNA *brna) RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "backdrop_zoom", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "zoom"); RNA_def_property_float_default(prop, 1.0f); RNA_def_property_range(prop, 0.01f, FLT_MAX); RNA_def_property_ui_range(prop, 0.01, 100, 1, 2); RNA_def_property_ui_text(prop, "Backdrop Zoom", "Backdrop zoom factor"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - prop = RNA_def_property(srna, "backdrop_x", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "xof"); - RNA_def_property_ui_text(prop, "Backdrop X", "Backdrop X offset"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); - - prop = RNA_def_property(srna, "backdrop_y", PROP_FLOAT, PROP_NONE); - RNA_def_property_float_sdna(prop, NULL, "yof"); - RNA_def_property_ui_text(prop, "Backdrop Y", "Backdrop Y offset"); + prop = RNA_def_property(srna, "backdrop_offset", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "Backdrop Offset", "Backdrop offset"); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL); prop = RNA_def_property(srna, "backdrop_channels", PROP_ENUM, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_strands.c b/source/blender/makesrna/intern/rna_strands.c new file mode 100644 index 00000000000..f6154fd1e01 --- /dev/null +++ b/source/blender/makesrna/intern/rna_strands.c @@ -0,0 +1,312 @@ +/* + * Copyright 2015, Blender Foundation. + * + * 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. + */ + +/** \file blender/makesrna/intern/rna_strands.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "BLI_utildefines.h" + +#include "RNA_define.h" +#include "RNA_access.h" + +#include "rna_internal.h" + +#include "WM_types.h" + +#ifdef RNA_RUNTIME + +#include "BLI_math.h" + +#include "BKE_strands.h" +#include "BKE_report.h" + +static int rna_Strands_has_motion_state_get(PointerRNA *ptr) +{ + Strands *strands = ptr->data; + return (bool)(strands->state != NULL); +} + +static int rna_StrandsChildCurve_render_size_get(PointerRNA *ptr) +{ + StrandsChildCurve *curve = ptr->data; + return curve->cutoff < 0.0f ? curve->numverts : min_ii(curve->numverts, (int)ceilf(curve->cutoff) + 1); +} + +static void rna_StrandsChildren_curve_uvs_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + StrandsChildren *strands = ptr->data; + rna_iterator_array_begin(iter, strands->curve_uvs, sizeof(StrandsChildCurveUV), strands->totcurves * strands->numuv, false, NULL); +} + +static int rna_StrandsChildren_curve_uvs_length(PointerRNA *ptr) +{ + StrandsChildren *strands = ptr->data; + return strands->totcurves * strands->numuv; +} + +static int rna_StrandsChildren_curve_uvs_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + StrandsChildren *strands = ptr->data; + if (index >= 0 && index < strands->totcurves * strands->numuv) { + RNA_pointer_create(ptr->id.data, &RNA_StrandsChildCurveUV, strands->curve_uvs + index, r_ptr); + return true; + } + else { + RNA_pointer_create(ptr->id.data, &RNA_StrandsChildCurveUV, NULL, r_ptr); + return false; + } +} + +static void rna_StrandsChildren_curve_vcols_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + StrandsChildren *strands = ptr->data; + rna_iterator_array_begin(iter, strands->curve_vcols, sizeof(StrandsChildCurveVCol), strands->totcurves * strands->numvcol, false, NULL); +} + +static int rna_StrandsChildren_curve_vcols_length(PointerRNA *ptr) +{ + StrandsChildren *strands = ptr->data; + return strands->totcurves * strands->numvcol; +} + +static int rna_StrandsChildren_curve_vcols_lookup_int(PointerRNA *ptr, int index, PointerRNA *r_ptr) +{ + StrandsChildren *strands = ptr->data; + if (index >= 0 && index < strands->totcurves * strands->numvcol) { + RNA_pointer_create(ptr->id.data, &RNA_StrandsChildCurveVCol, strands->curve_vcols + index, r_ptr); + return true; + } + else { + RNA_pointer_create(ptr->id.data, &RNA_StrandsChildCurveVCol, NULL, r_ptr); + return false; + } +} + +#else + +static void rna_def_strands_curve(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsCurve", NULL); + RNA_def_struct_sdna(srna, "StrandsCurve"); + RNA_def_struct_ui_text(srna, "Strand Curve", "Strand curve"); + + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "numverts"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Size", "Number of vertices of the curve"); + + /* same as "size", defined for consistency */ + prop = RNA_def_property(srna, "render_size", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "numverts"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Render Size", "Number of vertices of the curve for rendering based on cutoff length"); +} + +static void rna_def_strands_vertex(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsVertex", NULL); + RNA_def_struct_sdna(srna, "StrandsVertex"); + RNA_def_struct_ui_text(srna, "Strand Vertex", "Strand vertex"); + + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "co"); + RNA_def_property_array(prop, 3); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Location", ""); +} + +static void rna_def_strands_motion_state(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsMotionState", NULL); + RNA_def_struct_sdna(srna, "StrandsMotionState"); + RNA_def_struct_ui_text(srna, "Strand Vertex Motion State", "Physical motion state of a vertex"); + + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "co"); + RNA_def_property_array(prop, 3); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Location", ""); +} + +static void rna_def_strands(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Strands", NULL); + RNA_def_struct_sdna(srna, "Strands"); + RNA_def_struct_ui_text(srna, "Strands", "Strand geometry to represent hair and similar linear structures"); + + prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "curves", "totcurves"); + RNA_def_property_struct_type(prop, "StrandsCurve"); + RNA_def_property_ui_text(prop, "Strand Curves", ""); + + prop = RNA_def_property(srna, "vertices", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "verts", "totverts"); + RNA_def_property_struct_type(prop, "StrandsVertex"); + RNA_def_property_ui_text(prop, "Strand Vertex", ""); + + prop = RNA_def_property(srna, "has_motion_state", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_funcs(prop, "rna_Strands_has_motion_state_get", NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Has Motion State", "Strands have physical motion data associated with vertices"); + + prop = RNA_def_property(srna, "motion_state", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "state", "totverts"); + RNA_def_property_struct_type(prop, "StrandsMotionState"); + RNA_def_property_ui_text(prop, "Strand Motion State", ""); +} + +static void rna_def_strands_child_curve(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsChildCurve", NULL); + RNA_def_struct_sdna(srna, "StrandsChildCurve"); + RNA_def_struct_ui_text(srna, "Strand Child Curve", "Strand child curve"); + + prop = RNA_def_property(srna, "size", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "numverts"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Size", "Number of vertices of the curve"); + + prop = RNA_def_property(srna, "render_size", PROP_INT, PROP_NONE); + RNA_def_property_int_funcs(prop, "rna_StrandsChildCurve_render_size_get", NULL, NULL); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Render Size", "Number of vertices of the curve for rendering based on cutoff length"); + + prop = RNA_def_property(srna, "cutoff", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "cutoff"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Cutoff", "Curve parameter at which the curve is cut short for rendering"); +} + +static void rna_def_strands_child_curve_uv(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsChildCurveUV", NULL); + RNA_def_struct_sdna(srna, "StrandsChildCurveUV"); + RNA_def_struct_ui_text(srna, "Strand Child Curve UV", "UV data for child strand curves"); + + prop = RNA_def_property(srna, "uv", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 2); + RNA_def_property_ui_text(prop, "UV", ""); +} + +static void rna_def_strands_child_curve_vcol(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsChildCurveVCol", NULL); + RNA_def_struct_sdna(srna, "StrandsChildCurveVCol"); + RNA_def_struct_ui_text(srna, "Strand Child Curve Vertex Color", "Vertex color data for child strand curves"); + + prop = RNA_def_property(srna, "vcol", PROP_FLOAT, PROP_NONE); + RNA_def_property_array(prop, 3); + RNA_def_property_ui_text(prop, "Vertex Color", ""); +} + +static void rna_def_strands_child_vertex(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsChildVertex", NULL); + RNA_def_struct_sdna(srna, "StrandsChildVertex"); + RNA_def_struct_ui_text(srna, "Strand Child Vertex", "Strand child vertex"); + + prop = RNA_def_property(srna, "location", PROP_FLOAT, PROP_TRANSLATION); + RNA_def_property_float_sdna(prop, NULL, "co"); + RNA_def_property_array(prop, 3); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Location", ""); +} + +static void rna_def_strands_children(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "StrandsChildren", NULL); + RNA_def_struct_sdna(srna, "StrandsChildren"); + RNA_def_struct_ui_text(srna, "Child Strands", "Strand geometry to represent hair and similar linear structures"); + + prop = RNA_def_property(srna, "curves", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "curves", "totcurves"); + RNA_def_property_struct_type(prop, "StrandsChildCurve"); + RNA_def_property_ui_text(prop, "Strand Child Curves", ""); + + prop = RNA_def_property(srna, "curve_uvs", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_StrandsChildren_curve_uvs_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", + "rna_StrandsChildren_curve_uvs_length", "rna_StrandsChildren_curve_uvs_lookup_int", NULL, NULL); + RNA_def_property_struct_type(prop, "StrandsChildCurveUV"); + RNA_def_property_ui_text(prop, "Strand Child Curves UV", ""); + + prop = RNA_def_property(srna, "num_curve_uv_layers", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "numuv"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "UV Layers", "Number of UV layers"); + + prop = RNA_def_property(srna, "curve_vcols", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_funcs(prop, "rna_StrandsChildren_curve_vcols_begin", "rna_iterator_array_next", "rna_iterator_array_end", "rna_iterator_array_get", + "rna_StrandsChildren_curve_vcols_length", "rna_StrandsChildren_curve_vcols_lookup_int", NULL, NULL); + RNA_def_property_struct_type(prop, "StrandsChildCurveVCol"); + RNA_def_property_ui_text(prop, "Strand Child Curves Vertex Colors", ""); + + prop = RNA_def_property(srna, "num_curve_vcol_layers", PROP_INT, PROP_NONE); + RNA_def_property_int_sdna(prop, NULL, "numvcol"); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text(prop, "Vertex Color Layers", "Number of Vertex Color layers"); + + prop = RNA_def_property(srna, "vertices", PROP_COLLECTION, PROP_NONE); + RNA_def_property_collection_sdna(prop, NULL, "verts", "totverts"); + RNA_def_property_struct_type(prop, "StrandsChildVertex"); + RNA_def_property_ui_text(prop, "Strand Child Vertex", ""); +} + +void RNA_def_strands(BlenderRNA *brna) +{ + rna_def_strands_curve(brna); + rna_def_strands_vertex(brna); + rna_def_strands_motion_state(brna); + rna_def_strands(brna); + rna_def_strands_child_curve(brna); + rna_def_strands_child_curve_uv(brna); + rna_def_strands_child_curve_vcol(brna); + rna_def_strands_child_vertex(brna); + rna_def_strands_children(brna); +} + +#endif diff --git a/source/blender/makesrna/intern/rna_texture.c b/source/blender/makesrna/intern/rna_texture.c index 726744782ed..88f164193d4 100644 --- a/source/blender/makesrna/intern/rna_texture.c +++ b/source/blender/makesrna/intern/rna_texture.c @@ -1674,6 +1674,7 @@ static void rna_def_texture_pointdensity(BlenderRNA *brna) {TEX_PD_COLOR_PARTSPEED, "PARTICLE_SPEED", 0, "Particle Speed", "Particle speed (absolute magnitude of velocity) mapped as 0.0-1.0 intensity"}, {TEX_PD_COLOR_PARTVEL, "PARTICLE_VELOCITY", 0, "Particle Velocity", "XYZ velocity mapped to RGB colors"}, + {TEX_PD_COLOR_PARTTEX, "PARTICLE_TEXTURE", 0, "Particle Texture", "Texture color of particles"}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index d75966f6599..59bee5bce8c 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -911,6 +911,19 @@ void RNA_api_ui_layout(StructRNA *srna) RNA_def_function_ui_description(func, "Node Socket Icon"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); RNA_def_float_array(func, "color", 4, node_socket_color_default, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f); + + /* cache library item */ + func = RNA_def_function(srna, "template_cache_library_item", "uiTemplateCacheLibraryItem"); + RNA_def_function_ui_description(func, "Cache Library Item"); + RNA_def_function_flag(func, FUNC_USE_CONTEXT); + RNA_def_pointer(func, "cachelib", "CacheLibrary", "Cache Library", "Cache library containing the item"); + RNA_def_pointer(func, "object", "Object", "Object", "Object to cache"); + parm = RNA_def_enum(func, "datatype", cache_library_data_type_items, 0, "Data Type", "Type of cached data"); + RNA_def_property_flag(parm, PROP_REQUIRED); + RNA_def_int(func, "index", -1, -1, INT_MAX, "Index", "Index of cached data", -1, INT_MAX); + RNA_def_boolean(func, "enabled", true, "Enabled", "Enable the item"); + parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in"); + RNA_def_function_return(func, parm); } #endif diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index 9604f643149..988b726f43e 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -3473,6 +3473,16 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Manipulator", "Use 3D transform manipulator"); RNA_def_property_update(prop, 0, "rna_userdef_show_manipulator_update"); + prop = RNA_def_property(srna, "shaded_widgets", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", V3D_SHADED_WIDGETS); + RNA_def_property_ui_text(prop, "Shaded Widgets", "3D shading for widgets"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + + prop = RNA_def_property(srna, "widgets_3d", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "tw_flag", V3D_3D_WIDGETS); + RNA_def_property_ui_text(prop, "3D widgets", "Widgets size stays constant in world space"); + RNA_def_property_update(prop, 0, "rna_userdef_update"); + prop = RNA_def_property(srna, "manipulator_size", PROP_INT, PROP_PIXEL); RNA_def_property_int_sdna(prop, NULL, "tw_size"); RNA_def_property_range(prop, 10, 200); diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 4446f5d9a2b..c23b56582b6 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -30,6 +30,7 @@ #include "DNA_space_types.h" #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" +#include "DNA_widget_types.h" #include "BLI_utildefines.h" @@ -522,6 +523,26 @@ static PointerRNA rna_Operator_properties_get(PointerRNA *ptr) return rna_pointer_inherit_refine(ptr, op->type->srna, op->properties); } +static void rna_WidgetGroup_name_get(PointerRNA *ptr, char *value) +{ + wmWidgetGroup *wgroup = ptr->data; + strcpy(value, "Dummy_XXX" /*wgroup->type->name*/); + (void)wgroup; +} + +static int rna_WidgetGroup_name_length(PointerRNA *ptr) +{ + wmWidgetGroup *wgroup = ptr->data; + return strlen("Dummy_XXX" /*wgroup->type->name*/); + (void)wgroup; +} + +static int rna_WidgetGroup_has_reports_get(PointerRNA *ptr) +{ + wmWidgetGroup *wgroup = ptr->data; + return (wgroup->reports && wgroup->reports->list.first); +} + static PointerRNA rna_OperatorMacro_properties_get(PointerRNA *ptr) { wmOperatorTypeMacro *otmacro = (wmOperatorTypeMacro *)ptr->data; @@ -1387,6 +1408,180 @@ static void rna_Operator_bl_description_set(PointerRNA *ptr, const char *value) assert(!"setting the bl_description on a non-builtin operator"); } +#ifdef WITH_PYTHON +static void rna_WidgetGroup_unregister(struct Main *bmain, StructRNA *type) +{ + //const char *idname; + wmWidgetGroupType *wgrouptype = RNA_struct_blender_type_get(type); + //wmWindowManager *wm; + //wmWidgetMapType *wmap = NULL; + + if (!wgrouptype) + return; + + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + //RNA_struct_free_extension(type, &wgrouptype->ext); + + WM_widgetgrouptype_unregister(NULL, bmain, wgrouptype); + //WM_operatortype_remove_ptr(ot); + + /* not to be confused with the RNA_struct_free that WM_operatortype_remove calls, they are 2 different srna's */ + RNA_struct_free(&BLENDER_RNA, type); +} + +static int widgetgroup_poll(const bContext *C, wmWidgetGroupType *wgrouptype) +{ + + extern FunctionRNA rna_WidgetGroup_poll_func; + + PointerRNA ptr; + ParameterList list; + FunctionRNA *func; + void *ret; + int visible; + + RNA_pointer_create(NULL, wgrouptype->ext.srna, NULL, &ptr); /* dummy */ + func = &rna_WidgetGroup_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */ + + RNA_parameter_list_create(&list, &ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + wgrouptype->ext.call((bContext *)C, &ptr, func, &list); + + RNA_parameter_get_lookup(&list, "visible", &ret); + visible = *(int *)ret; + + RNA_parameter_list_free(&list); + + return visible; +} + +static void widgetgroup_draw(const bContext *C, wmWidgetGroup *wgroup) +{ + extern FunctionRNA rna_WidgetGroup_draw_func; + + PointerRNA wgroup_ptr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, wgroup->type->ext.srna, wgroup, &wgroup_ptr); + func = &rna_WidgetGroup_draw_func; /* RNA_struct_find_function(&wgroupr, "draw"); */ + + RNA_parameter_list_create(&list, &wgroup_ptr, func); + RNA_parameter_set_lookup(&list, "context", &C); + wgroup->type->ext.call((bContext *)C, &wgroup_ptr, func, &list); + + RNA_parameter_list_free(&list); +} +#if 0 + +/* same as exec(), but call cancel */ +static void operator_cancel(bContext *C, wmWidgetGroup *op) +{ + extern FunctionRNA rna_WidgetGroup_cancel_func; + + PointerRNA opr; + ParameterList list; + FunctionRNA *func; + + RNA_pointer_create(NULL, op->type->ext.srna, op, &opr); + func = &rna_WidgetGroup_cancel_func; /* RNA_struct_find_function(&opr, "cancel"); */ + + RNA_parameter_list_create(&list, &opr, func); + RNA_parameter_set_lookup(&list, "context", &C); + op->type->ext.call(C, &opr, func, &list); + + RNA_parameter_list_free(&list); +} +#endif + +void widgetgroup_wrapper(wmWidgetGroupType *ot, void *userdata); + +static char _widgetgroup_idname[OP_MAX_TYPENAME]; +//static char _widgetgroup_name[OP_MAX_TYPENAME]; +//static char _widgetgroup_descr[RNA_DYN_DESCR_MAX]; +//static char _widgetgroup_ctxt[RNA_DYN_DESCR_MAX]; +static StructRNA *rna_WidgetGroup_register(Main *bmain, ReportList *reports, void *data, const char *identifier, + StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free) +{ + + wmWidgetGroupType *wgrouptype, dummywgt = {NULL}; + wmWidgetGroup dummywg = {NULL}; + PointerRNA wgptr; + int have_function[2]; + + /* setup dummy widgetgroup & widgetgroup type to store static properties in */ + dummywg.type = &dummywgt; + RNA_pointer_create(NULL, &RNA_WidgetGroup, &dummywg, &wgptr); + + /* clear in case they are left unset */ + _widgetgroup_idname[0] = '\0'; + + /* validate the python class */ + if (validate(&wgptr, data, have_function) != 0) + return NULL; + + if (strlen(identifier) >= sizeof(dummywgt.idname)) { + BKE_reportf(reports, RPT_ERROR, "Registering widgetgroup class: '%s' is too long, maximum length is %d", + identifier, (int)sizeof(dummywgt.idname)); + return NULL; + } + + /* check if the area supports widgets */ + if (!WM_widgetmaptype_find(dummywgt.mapidname ,dummywgt.spaceid, dummywgt.regionid, dummywgt.is_3d, false)) { + BKE_reportf(reports, RPT_ERROR, "Area type does not support widgets"); + return NULL; + } + +#if 0 + /* check if we have registered this widgetgroup type before, and remove it */ + { + //wmWidgetGroupType *ot = WM_widgetgrouptype_find(dummywgt.idname, true); + if (ot && ot->ext.srna) + rna_WidgetGroup_unregister(bmain, ot->ext.srna); + } + +#endif + /* XXX, this doubles up with the widgetgroup name [#29666] + * for now just remove from dir(bpy.types) */ + + /* create a new widgetgroup type */ + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_WidgetGroup); + RNA_def_struct_flag(dummywgt.ext.srna, STRUCT_NO_IDPROPERTIES); /* widgetgroup properties are registered separately */ + dummywgt.ext.data = data; + dummywgt.ext.call = call; + dummywgt.ext.free = free; + + dummywgt.poll = (have_function[0]) ? widgetgroup_poll : NULL; + dummywgt.draw = (have_function[1]) ? widgetgroup_draw : NULL; + + wgrouptype = WM_widgetgrouptype_new(dummywgt.poll, dummywgt.draw, bmain, dummywgt.mapidname, dummywgt.spaceid, dummywgt.regionid, dummywgt.is_3d); + memcpy(wgrouptype, &dummywgt, sizeof(dummywgt)); + + /* update while blender is running */ + WM_main_add_notifier(NC_SCREEN | NA_EDITED, NULL); + + dummywgt.ext.srna = RNA_def_struct_ptr(&BLENDER_RNA, dummywgt.idname, &RNA_WidgetGroup); + + return dummywgt.ext.srna; +} + +//RNA_struct_blender_type_set(pt->ext.srna, pt); + +static void **rna_WidgetGroup_instance(PointerRNA *ptr) +{ + wmWidgetGroup *wgroup = ptr->data; + return &wgroup->py_instance; +} + +static StructRNA *rna_WidgetGroup_refine(PointerRNA *wgroup_ptr) +{ + wmWidgetGroup *wgroup = wgroup_ptr->data; + return (wgroup->type && wgroup->type->ext.srna) ? wgroup->type->ext.srna : &RNA_WidgetGroup; +} + +#endif + static void rna_KeyMapItem_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr) { wmKeyMapItem *kmi = ptr->data; @@ -1635,7 +1830,62 @@ static void rna_def_operator_filelist_element(BlenderRNA *brna) RNA_def_property_flag(prop, PROP_IDPROPERTY); RNA_def_property_ui_text(prop, "Name", "Name of a file or directory within a file list"); } - + +static void rna_def_widgetgroup(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "WidgetGroup", NULL); + RNA_def_struct_ui_text(srna, "WidgetGroup", "Storage of an operator being executed, or registered after execution"); + RNA_def_struct_sdna(srna, "wmWidgetGroup"); + RNA_def_struct_refine_func(srna, "rna_WidgetGroup_refine"); +#ifdef WITH_PYTHON + RNA_def_struct_register_funcs(srna, "rna_WidgetGroup_register", "rna_WidgetGroup_unregister", "rna_WidgetGroup_instance"); +#endif + RNA_def_struct_translation_context(srna, BLF_I18NCONTEXT_OPERATOR_DEFAULT); + + prop = RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); + RNA_def_property_string_funcs(prop, "rna_WidgetGroup_name_get", "rna_WidgetGroup_name_length", NULL); + RNA_def_property_ui_text(prop, "Name", ""); + + prop = RNA_def_property(srna, "has_reports", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* this is 'virtual' property */ + RNA_def_property_boolean_funcs(prop, "rna_WidgetGroup_has_reports_get", NULL); + RNA_def_property_ui_text(prop, "Has Reports", + "WidgetGroup has a set of reports (warnings and errors) from last execution"); + + /* Registration */ + prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE); + RNA_def_property_string_sdna(prop, NULL, "type->idname"); + /* RNA_def_property_clear_flag(prop, PROP_EDITABLE); */ + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_struct_name_property(srna, prop); + + prop = RNA_def_property(srna, "bl_space_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->spaceid"); + RNA_def_property_enum_items(prop, space_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Space type", "The space where the panel is going to be used in"); + + prop = RNA_def_property(srna, "bl_region_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->regionid"); + RNA_def_property_enum_items(prop, region_type_items); + RNA_def_property_flag(prop, PROP_REGISTER); + RNA_def_property_ui_text(prop, "Region Type", "The region where the panel is going to be used in"); + +#if 0 + prop = RNA_def_property(srna, "bl_options", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "type->flag"); + RNA_def_property_enum_items(prop, operator_flag_items); + RNA_def_property_flag(prop, PROP_REGISTER_OPTIONAL | PROP_ENUM_FLAG); + RNA_def_property_ui_text(prop, "Options", "Options for this operator type"); +#endif + + RNA_api_widgetgroup(srna); +} + static void rna_def_event(BlenderRNA *brna) { StructRNA *srna; @@ -2217,6 +2467,7 @@ void RNA_def_wm(BlenderRNA *brna) rna_def_operator_filelist_element(brna); rna_def_macro_operator(brna); rna_def_operator_type_macro(brna); + rna_def_widgetgroup(brna); rna_def_event(brna); rna_def_timer(brna); rna_def_popupmenu(brna); diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c index e819d331124..2e0bd8f491a 100644 --- a/source/blender/makesrna/intern/rna_wm_api.c +++ b/source/blender/makesrna/intern/rna_wm_api.c @@ -616,6 +616,39 @@ void RNA_api_macro(StructRNA *srna) RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); } +void RNA_api_widgetgroup(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + +#if 0 + /* utility, not for registering */ + func = RNA_def_function(srna, "report", "rna_Operator_report"); + parm = RNA_def_enum_flag(func, "type", wm_report_items, 0, "Type", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); + parm = RNA_def_string(func, "message", NULL, 0, "Report Message", ""); + RNA_def_property_flag(parm, PROP_REQUIRED); +#endif + + + /* Registration */ + + /* poll */ + func = RNA_def_function(srna, "poll", NULL); + RNA_def_function_ui_description(func, "Test if the operator can be called or not"); + RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_REGISTER_OPTIONAL); + RNA_def_function_return(func, RNA_def_boolean(func, "visible", 1, "", "")); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); + + /* draw */ + func = RNA_def_function(srna, "draw", NULL); + RNA_def_function_ui_description(func, "Draw function for the operator"); + RNA_def_function_flag(func, FUNC_REGISTER); + parm = RNA_def_pointer(func, "context", "Context", "", ""); + RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL); +} + void RNA_api_keyconfig(StructRNA *UNUSED(srna)) { /* FunctionRNA *func; */ |