diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-06-06 23:47:41 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-06-09 02:15:17 +0300 |
commit | cc31d7bb49090194e13fc4ebe58bb8f7f63f4186 (patch) | |
tree | 14727b9362cca5c15300c1f76dc45240cd9030b4 /source/blender/makesrna/intern | |
parent | 346619159ae39dfb4063f563d498eec32bba13aa (diff) |
Probe: Add new object datablock
We went for a new datablock because blending probe functionality with empties was going to be messy.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/CMakeLists.txt | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/makesrna.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main.c | 7 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_main_api.c | 52 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_object.c | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_probe.c | 75 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 1 |
9 files changed, 141 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 899c9bf77a9..262c229c5e6 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -72,6 +72,7 @@ set(DEFSRC rna_palette.c rna_particle.c rna_pose.c + rna_probe.c rna_property.c rna_render.c rna_rigidbody.c diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index babca789361..46b0d6e82ad 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -3345,6 +3345,7 @@ static RNAProcessItem PROCESS_ITEMS[] = { {"rna_palette.c", NULL, RNA_def_palette}, {"rna_particle.c", NULL, RNA_def_particle}, {"rna_pose.c", "rna_pose_api.c", RNA_def_pose}, + {"rna_probe.c", NULL, RNA_def_probe}, {"rna_property.c", NULL, RNA_def_gameproperty}, {"rna_render.c", NULL, RNA_def_render}, {"rna_rigidbody.c", NULL, RNA_def_rigidbody}, diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index 57a98c1e825..a247184174b 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -74,6 +74,7 @@ EnumPropertyItem rna_enum_id_type_items[] = { {ID_PC, "PAINTCURVE", ICON_CURVE_BEZCURVE, "Paint Curve", ""}, {ID_PAL, "PALETTE", ICON_COLOR, "Palette", ""}, {ID_PA, "PARTICLE", ICON_PARTICLE_DATA, "Particle", ""}, + {ID_PRB, "PROBE", ICON_RADIO, "Probe", ""}, {ID_SCE, "SCENE", ICON_SCENE_DATA, "Scene", ""}, {ID_SCR, "SCREEN", ICON_SPLITSCREEN, "Screen", ""}, {ID_SO, "SOUND", ICON_PLAY_AUDIO, "Sound", ""}, diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 878ee722c2d..2ace1a10a9c 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -166,6 +166,7 @@ void RNA_def_packedfile(struct BlenderRNA *brna); void RNA_def_palette(struct BlenderRNA *brna); void RNA_def_particle(struct BlenderRNA *brna); void RNA_def_pose(struct BlenderRNA *brna); +void RNA_def_probe(struct BlenderRNA *brna); void RNA_def_render(struct BlenderRNA *brna); void RNA_def_rigidbody(struct BlenderRNA *brna); void RNA_def_rna(struct BlenderRNA *brna); @@ -337,6 +338,7 @@ void RNA_def_main_linestyles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_cachefiles(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_paintcurves(BlenderRNA *brna, PropertyRNA *cprop); void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop); +void RNA_def_main_probes(BlenderRNA *brna, PropertyRNA *cprop); /* ID Properties */ diff --git a/source/blender/makesrna/intern/rna_main.c b/source/blender/makesrna/intern/rna_main.c index 4f52ac97961..3509205e727 100644 --- a/source/blender/makesrna/intern/rna_main.c +++ b/source/blender/makesrna/intern/rna_main.c @@ -299,6 +299,12 @@ static void rna_Main_workspaces_begin(CollectionPropertyIterator *iter, PointerR rna_iterator_listbase_begin(iter, &bmain->workspaces, NULL); } +static void rna_Main_probes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +{ + Main *bmain = (Main *)ptr->data; + rna_iterator_listbase_begin(iter, &bmain->probe, NULL); +} + static void rna_Main_version_get(PointerRNA *ptr, int *value) { Main *bmain = (Main *)ptr->data; @@ -375,6 +381,7 @@ void RNA_def_main(BlenderRNA *brna) {"cache_files", "CacheFile", "rna_Main_cachefiles_begin", "Cache Files", "Cache Files data-blocks", RNA_def_main_cachefiles}, {"paint_curves", "PaintCurve", "rna_Main_paintcurves_begin", "Paint Curves", "Paint Curves data-blocks", RNA_def_main_paintcurves}, {"workspaces", "WorkSpace", "rna_Main_workspaces_begin", "Workspaces", "Workspace data-blocks", RNA_def_main_workspaces}, + {"probes", "Probe", "rna_Main_probes_begin", "Probes", "Probe data-blocks", RNA_def_main_probes}, {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 7d7cd9f90f0..536e65c6e2a 100644 --- a/source/blender/makesrna/intern/rna_main_api.c +++ b/source/blender/makesrna/intern/rna_main_api.c @@ -79,6 +79,7 @@ #include "BKE_font.h" #include "BKE_node.h" #include "BKE_speaker.h" +#include "BKE_probe.h" #include "BKE_movieclip.h" #include "BKE_mask.h" #include "BKE_gpencil.h" @@ -95,6 +96,7 @@ #include "DNA_mesh_types.h" #include "DNA_speaker_types.h" #include "DNA_sound_types.h" +#include "DNA_probe_types.h" #include "DNA_text_types.h" #include "DNA_texture_types.h" #include "DNA_group_types.h" @@ -573,6 +575,16 @@ static FreestyleLineStyle *rna_Main_linestyles_new(Main *bmain, const char *name return linestyle; } +static Probe *rna_Main_probe_new(Main *bmain, const char *name) +{ + char safe_name[MAX_ID_NAME - 2]; + rna_idname_validate(name, safe_name); + + Probe *probe = BKE_probe_add(bmain, safe_name); + id_us_min(&probe->id); + return probe; +} + /* tag and is_updated functions, all the same */ #define RNA_MAIN_ID_TAG_FUNCS_DEF(_func_name, _listbase_name, _id_type) \ static void rna_Main_##_func_name##_tag(Main *bmain, int value) { \ @@ -616,6 +628,7 @@ RNA_MAIN_ID_TAG_FUNCS_DEF(linestyle, linestyle, ID_LS) RNA_MAIN_ID_TAG_FUNCS_DEF(cachefiles, cachefiles, ID_CF) RNA_MAIN_ID_TAG_FUNCS_DEF(paintcurves, paintcurves, ID_PC) RNA_MAIN_ID_TAG_FUNCS_DEF(workspaces, workspaces, ID_WS) +RNA_MAIN_ID_TAG_FUNCS_DEF(probes, probe, ID_PRB) #undef RNA_MAIN_ID_TAG_FUNCS_DEF @@ -1846,4 +1859,43 @@ void RNA_def_main_workspaces(BlenderRNA *brna, PropertyRNA *cprop) RNA_def_property_boolean_funcs(prop, "rna_Main_workspaces_is_updated_get", NULL); } +void RNA_def_main_probes(BlenderRNA *brna, PropertyRNA *cprop) +{ + StructRNA *srna; + FunctionRNA *func; + PropertyRNA *parm; + PropertyRNA *prop; + + RNA_def_property_srna(cprop, "BlendDataProbes"); + srna = RNA_def_struct(brna, "BlendDataProbes", NULL); + RNA_def_struct_sdna(srna, "Main"); + RNA_def_struct_ui_text(srna, "Main Probes", "Collection of probes"); + + func = RNA_def_function(srna, "new", "rna_Main_probe_new"); + RNA_def_function_ui_description(func, "Add a new probe to the main database"); + parm = RNA_def_string(func, "name", "Probe", 0, "", "New name for the data-block"); + RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + /* return type */ + parm = RNA_def_pointer(func, "probe", "Probe", "", "New probe data-block"); + RNA_def_function_return(func, parm); + + func = RNA_def_function(srna, "remove", "rna_Main_ID_remove"); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + RNA_def_function_ui_description(func, "Remove a probe from the current blendfile"); + parm = RNA_def_pointer(func, "probe", "Probe", "", "Probe to remove"); + RNA_def_parameter_flags(parm, PROP_NEVER_NULL, PARM_REQUIRED | PARM_RNAPTR); + RNA_def_parameter_clear_flags(parm, PROP_THICK_WRAP, 0); + RNA_def_boolean(func, "do_unlink", true, "", + "Unlink all usages of this probe before deleting it " + "(WARNING: will also delete objects instancing that probe data)"); + + func = RNA_def_function(srna, "tag", "rna_Main_probes_tag"); + parm = RNA_def_boolean(func, "value", 0, "Value", ""); + RNA_def_parameter_flags(parm, 0, PARM_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_probes_is_updated_get", NULL); +} + #endif diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index f4712cbf0a6..f9786bc7366 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -148,6 +148,7 @@ EnumPropertyItem rna_enum_object_type_items[] = { {OB_CAMERA, "CAMERA", 0, "Camera", ""}, {OB_LAMP, "LAMP", 0, "Lamp", ""}, {OB_SPEAKER, "SPEAKER", 0, "Speaker", ""}, + {OB_PROBE, "PROBE", 0, "Probe", ""}, {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_probe.c b/source/blender/makesrna/intern/rna_probe.c new file mode 100644 index 00000000000..0f4b44d6b66 --- /dev/null +++ b/source/blender/makesrna/intern/rna_probe.c @@ -0,0 +1,75 @@ +/* + * ***** 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. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/makesrna/intern/rna_probe.c + * \ingroup RNA + */ + +#include <stdlib.h> + +#include "RNA_define.h" +#include "RNA_enum_types.h" + +#include "rna_internal.h" + +#include "DNA_probe_types.h" + +#ifdef RNA_RUNTIME + +#include "MEM_guardedalloc.h" + +#include "BKE_depsgraph.h" +#include "BKE_main.h" + +#include "WM_api.h" +#include "WM_types.h" + +#else + +static void rna_def_probe(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "Probe", "ID"); + RNA_def_struct_ui_text(srna, "Probe", "Probe data-block for lighting capture objects"); + RNA_def_struct_ui_icon(srna, ICON_RADIO); + + // prop = RNA_def_property(srna, "influence", PROP_FLOAT, PROP_NONE); + // RNA_def_property_clear_flag(prop, PROP_ANIMATABLE); + // RNA_def_property_range(prop, 0.0f, 1.0f); + // RNA_def_property_ui_text(prop, "Maximum Volume", "Maximum volume, no matter how near the object is"); + /* RNA_def_property_float_funcs(prop, NULL, "rna_Speaker_volume_max_set", NULL); */ + /* RNA_def_property_update(prop, 0, "rna_Speaker_update"); */ + + /* common */ + rna_def_animdata_common(srna); +} + + +void RNA_def_probe(BlenderRNA *brna) +{ + rna_def_probe(brna); +} + +#endif + diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index c3a6438286a..392361ac6d2 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -3906,6 +3906,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) "Particles Settings", "Show/hide Particle Settings data-blocks"}, {FILTER_ID_PAL, "PALETTE", ICON_COLOR, "Palettes", "Show/hide Palette data-blocks"}, {FILTER_ID_PC, "PAINT_CURVE", ICON_CURVE_BEZCURVE, "Paint Curves", "Show/hide Paint Curve data-blocks"}, + {FILTER_ID_PRB, "PROBE", ICON_RADIO, "Probes", "Show/hide Probe data-blocks"}, {FILTER_ID_SCE, "SCENE", ICON_SCENE_DATA, "Scenes", "Show/hide Scene data-blocks"}, {FILTER_ID_SPK, "SPEAKER", ICON_SPEAKER, "Speakers", "Show/hide Speaker data-blocks"}, {FILTER_ID_SO, "SOUND", ICON_SOUND, "Sounds", "Show/hide Sound data-blocks"}, |