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/blenkernel | |
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/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_library.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_main.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_probe.h | 45 | ||||
-rw-r--r-- | source/blender/blenkernel/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/idcode.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library.c | 17 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/library_remap.c | 5 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/object.c | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/probe.c | 80 |
10 files changed, 159 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_library.h b/source/blender/blenkernel/BKE_library.h index dcc15c66c3e..863920c9c38 100644 --- a/source/blender/blenkernel/BKE_library.h +++ b/source/blender/blenkernel/BKE_library.h @@ -95,7 +95,7 @@ void id_clear_lib_data_ex(struct Main *bmain, struct ID *id, const bool id_in_ma struct ListBase *which_libbase(struct Main *mainlib, short type); -#define MAX_LIBARRAY 36 +#define MAX_LIBARRAY 37 int set_listbasepointers(struct Main *main, struct ListBase *lb[MAX_LIBARRAY]); /* Main API */ diff --git a/source/blender/blenkernel/BKE_main.h b/source/blender/blenkernel/BKE_main.h index a616429fa95..2f38eeb25df 100644 --- a/source/blender/blenkernel/BKE_main.h +++ b/source/blender/blenkernel/BKE_main.h @@ -108,6 +108,7 @@ typedef struct Main { ListBase vfont; ListBase text; ListBase speaker; + ListBase probe; ListBase sound; ListBase group; ListBase armature; diff --git a/source/blender/blenkernel/BKE_probe.h b/source/blender/blenkernel/BKE_probe.h new file mode 100644 index 00000000000..29e42e06113 --- /dev/null +++ b/source/blender/blenkernel/BKE_probe.h @@ -0,0 +1,45 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BKE_PROBE_H__ +#define __BKE_PROBE_H__ + +/** \file BKE_probe.h + * \ingroup bke + * \brief General operations for probes. + */ + +struct Main; +struct Probe; + +void BKE_probe_init(struct Probe *probe); +void *BKE_probe_add(struct Main *bmain, const char *name); +struct Probe *BKE_probe_copy(struct Main *bmain, struct Probe *probe); +void BKE_probe_make_local(struct Main *bmain, struct Probe *probe, const bool lib_local); +void BKE_probe_free(struct Probe *probe); + +#endif /* __BKE_PROBE_H__ */ diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt index 44dcb0a51ae..c1f80a1a976 100644 --- a/source/blender/blenkernel/CMakeLists.txt +++ b/source/blender/blenkernel/CMakeLists.txt @@ -159,6 +159,7 @@ set(SRC intern/pbvh.c intern/pbvh_bmesh.c intern/pointcache.c + intern/probe.c intern/property.c intern/layer.c intern/report.c @@ -280,6 +281,7 @@ set(SRC BKE_particle.h BKE_pbvh.h BKE_pointcache.h + BKE_probe.h BKE_property.h BKE_layer.h BKE_report.h diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index b9937957236..585e5183608 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -94,6 +94,7 @@ bool id_type_can_have_animdata(const short id_type) case ID_MA: case ID_TE: case ID_NT: case ID_LA: case ID_CA: case ID_WO: case ID_LS: + case ID_PRB: case ID_SPK: case ID_SCE: case ID_MC: diff --git a/source/blender/blenkernel/intern/idcode.c b/source/blender/blenkernel/intern/idcode.c index e905eaeed76..315fc32502a 100644 --- a/source/blender/blenkernel/intern/idcode.c +++ b/source/blender/blenkernel/intern/idcode.c @@ -81,6 +81,7 @@ static IDType idtypes[] = { { ID_PA, "ParticleSettings", "particles", BLT_I18NCONTEXT_ID_PARTICLESETTINGS, IDTYPE_FLAGS_ISLINKABLE }, { ID_PAL, "Palettes", "palettes", BLT_I18NCONTEXT_ID_PALETTE, IDTYPE_FLAGS_ISLINKABLE }, { ID_PC, "PaintCurve", "paint_curves", BLT_I18NCONTEXT_ID_PAINTCURVE, IDTYPE_FLAGS_ISLINKABLE }, + { ID_PRB, "Probe", "probes", BLT_I18NCONTEXT_ID_PROBE, IDTYPE_FLAGS_ISLINKABLE }, { ID_SCE, "Scene", "scenes", BLT_I18NCONTEXT_ID_SCENE, IDTYPE_FLAGS_ISLINKABLE }, { ID_SCR, "Screen", "screens", BLT_I18NCONTEXT_ID_SCREEN, IDTYPE_FLAGS_ISLINKABLE }, { ID_SEQ, "Sequence", "sequences", BLT_I18NCONTEXT_ID_SEQUENCE, 0 }, /* not actually ID data */ @@ -204,6 +205,7 @@ int BKE_idcode_to_idfilter(const short idcode) CASE_IDFILTER(PA); CASE_IDFILTER(PAL); CASE_IDFILTER(PC); + CASE_IDFILTER(PRB); CASE_IDFILTER(SCE); CASE_IDFILTER(SPK); CASE_IDFILTER(SO); @@ -249,6 +251,7 @@ short BKE_idcode_from_idfilter(const int idfilter) CASE_IDFILTER(PA); CASE_IDFILTER(PAL); CASE_IDFILTER(PC); + CASE_IDFILTER(PRB); CASE_IDFILTER(SCE); CASE_IDFILTER(SPK); CASE_IDFILTER(SO); @@ -296,6 +299,7 @@ int BKE_idcode_to_index(const short idcode) CASE_IDINDEX(PA); CASE_IDINDEX(PAL); CASE_IDINDEX(PC); + CASE_IDINDEX(PRB); CASE_IDINDEX(SCE); CASE_IDINDEX(SCR); CASE_IDINDEX(SPK); diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index b81465a1b1d..7f7985ff990 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -62,6 +62,7 @@ #include "DNA_mask_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_probe_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_speaker_types.h" @@ -117,6 +118,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_packedFile.h" +#include "BKE_probe.h" #include "BKE_sound.h" #include "BKE_speaker.h" #include "BKE_scene.h" @@ -419,6 +421,9 @@ bool id_make_local(Main *bmain, ID *id, const bool test, const bool lib_local) case ID_SPK: if (!test) BKE_speaker_make_local(bmain, (Speaker *)id, lib_local); return true; + case ID_PRB: + if (!test) BKE_probe_make_local(bmain, (Probe *)id, lib_local); + return true; case ID_WO: if (!test) BKE_world_make_local(bmain, (World *)id, lib_local); return true; @@ -532,6 +537,9 @@ bool id_copy(Main *bmain, ID *id, ID **newid, bool test) case ID_SPK: if (!test) *newid = (ID *)BKE_speaker_copy(bmain, (Speaker *)id); return true; + case ID_PRB: + if (!test) *newid = (ID *)BKE_probe_copy(bmain, (Probe *)id); + return true; case ID_CA: if (!test) *newid = (ID *)BKE_camera_copy(bmain, (Camera *)id); return true; @@ -669,6 +677,8 @@ ListBase *which_libbase(Main *mainlib, short type) return &(mainlib->text); case ID_SPK: return &(mainlib->speaker); + case ID_PRB: + return &(mainlib->probe); case ID_SO: return &(mainlib->sound); case ID_GR: @@ -839,6 +849,7 @@ int set_listbasepointers(Main *main, ListBase **lb) lb[INDEX_ID_BR] = &(main->brush); lb[INDEX_ID_PA] = &(main->particle); lb[INDEX_ID_SPK] = &(main->speaker); + lb[INDEX_ID_PRB] = &(main->probe); lb[INDEX_ID_WO] = &(main->world); lb[INDEX_ID_MC] = &(main->movieclip); @@ -931,6 +942,9 @@ void *BKE_libblock_alloc_notest(short type) case ID_SPK: id = MEM_callocN(sizeof(Speaker), "speaker"); break; + case ID_PRB: + id = MEM_callocN(sizeof(Probe), "probe"); + break; case ID_SO: id = MEM_callocN(sizeof(bSound), "sound"); break; @@ -1057,6 +1071,9 @@ void BKE_libblock_init_empty(ID *id) case ID_SPK: BKE_speaker_init((Speaker *)id); break; + case ID_PRB: + BKE_probe_init((Probe *)id); + break; case ID_CA: BKE_camera_init((Camera *)id); break; diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 235b10dd1da..23a2eaf4970 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -53,6 +53,7 @@ #include "DNA_mask_types.h" #include "DNA_node_types.h" #include "DNA_object_types.h" +#include "DNA_probe_types.h" #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_speaker_types.h" @@ -99,6 +100,7 @@ #include "BKE_object.h" #include "BKE_paint.h" #include "BKE_particle.h" +#include "BKE_probe.h" #include "BKE_sca.h" #include "BKE_speaker.h" #include "BKE_sound.h" @@ -838,6 +840,9 @@ void BKE_libblock_free_ex(Main *bmain, void *idv, const bool do_id_user, const b case ID_SPK: BKE_speaker_free((Speaker *)id); break; + case ID_PRB: + BKE_probe_free((Probe *)id); + break; case ID_SO: BKE_sound_free((bSound *)id); break; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index 9a2251b0f93..db580e3ea2b 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -58,6 +58,7 @@ #include "DNA_view3d_types.h" #include "DNA_world_types.h" #include "DNA_object_types.h" +#include "DNA_probe_types.h" #include "DNA_property_types.h" #include "DNA_rigidbody_types.h" @@ -107,6 +108,7 @@ #include "BKE_paint.h" #include "BKE_particle.h" #include "BKE_pointcache.h" +#include "BKE_probe.h" #include "BKE_property.h" #include "BKE_rigidbody.h" #include "BKE_sca.h" @@ -602,6 +604,7 @@ void *BKE_object_obdata_add_from_type(Main *bmain, int type, const char *name) case OB_LATTICE: return BKE_lattice_add(bmain, name); case OB_ARMATURE: return BKE_armature_add(bmain, name); case OB_SPEAKER: return BKE_speaker_add(bmain, name); + case OB_PROBE: return BKE_probe_add(bmain, name); case OB_EMPTY: return NULL; default: printf("%s: Internal error, bad type: %d\n", __func__, type); diff --git a/source/blender/blenkernel/intern/probe.c b/source/blender/blenkernel/intern/probe.c new file mode 100644 index 00000000000..48f6c12dc87 --- /dev/null +++ b/source/blender/blenkernel/intern/probe.c @@ -0,0 +1,80 @@ +/* + * ***** 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. + * + * The Original Code is Copyright (C) Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): none yet. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +/** \file blender/blenkernel/intern/probe.c + * \ingroup bke + */ + +#include "DNA_object_types.h" +#include "DNA_probe_types.h" + +#include "BLI_math.h" +#include "BLI_utildefines.h" + +#include "BKE_animsys.h" +#include "BKE_global.h" +#include "BKE_main.h" +#include "BKE_probe.h" + +void BKE_probe_init(Probe *probe) +{ + BLI_assert(MEMCMP_STRUCT_OFS_IS_ZERO(probe, id)); + + probe->influence = 0.5f; +} + +void *BKE_probe_add(Main *bmain, const char *name) +{ + Probe *probe; + + probe = BKE_libblock_alloc(bmain, ID_PRB, name); + + BKE_probe_init(probe); + + return probe; +} + +Probe *BKE_probe_copy(Main *bmain, Probe *probe) +{ + Probe *probe_new; + + probe_new = BKE_libblock_copy(bmain, &probe->id); + + BKE_id_copy_ensure_local(bmain, &probe->id, &probe_new->id); + + return probe_new; +} + +void BKE_probe_make_local(Main *bmain, Probe *probe, const bool lib_local) +{ + BKE_id_make_local_generic(bmain, &probe->id, true, lib_local); +} + +void BKE_probe_free(Probe *probe) +{ + BKE_animdata_free((ID *)probe, false); +} |