2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2011-08-04 07:12:03 +00:00
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bke
|
2011-08-04 07:12:03 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-03-19 09:33:03 +01:00
|
|
|
#include "DNA_defaults.h"
|
2011-08-04 07:12:03 +00:00
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_sound_types.h"
|
|
|
|
|
#include "DNA_speaker_types.h"
|
|
|
|
|
|
2011-10-27 05:34:39 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2011-08-04 07:12:03 +00:00
|
|
|
|
2020-03-08 20:10:07 +01:00
|
|
|
#include "BLT_translation.h"
|
|
|
|
|
|
2020-09-10 17:31:18 +02:00
|
|
|
#include "BKE_anim_data.h"
|
2020-03-08 20:10:07 +01:00
|
|
|
#include "BKE_idtype.h"
|
2020-02-10 12:58:59 +01:00
|
|
|
#include "BKE_lib_id.h"
|
2020-05-13 19:30:04 +02:00
|
|
|
#include "BKE_lib_query.h"
|
2011-08-04 07:12:03 +00:00
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_speaker.h"
|
|
|
|
|
|
2023-08-28 15:01:05 +02:00
|
|
|
#include "BLO_read_write.hh"
|
2020-09-10 17:31:18 +02:00
|
|
|
|
2023-08-19 23:44:21 +10:00
|
|
|
#include <cstring>
|
Cleanup: reduce amount of math-related includes
Using ClangBuildAnalyzer on the whole Blender build, it was pointing
out that BLI_math.h is the heaviest "header hub" (i.e. non tiny file
that is included a lot).
However, there's very little (actually zero) source files in Blender
that need "all the math" (base, colors, vectors, matrices,
quaternions, intersection, interpolation, statistics, solvers and
time). A common use case is source files needing just vectors, or
just vectors & matrices, or just colors etc. Actually, 181 files
were including the whole math thing without needing it at all.
This change removes BLI_math.h completely, and instead in all the
places that need it, includes BLI_math_vector.h or BLI_math_color.h
and so on.
Change from that:
- BLI_math_color.h was included 1399 times -> now 408 (took 114.0sec
to parse -> now 36.3sec)
- BLI_simd.h 1403 -> 418 (109.7sec -> 34.9sec).
Full rebuild of Blender (Apple M1, Xcode, RelWithDebInfo) is not
affected much (342sec -> 334sec). Most of benefit would be when
someone's changing BLI_simd.h or BLI_math_color.h or similar files,
that now there's 3x fewer files result in a recompile.
Pull Request #110944
2023-08-09 11:39:20 +03:00
|
|
|
|
2020-03-08 20:10:07 +01:00
|
|
|
static void speaker_init_data(ID *id)
|
2011-08-04 07:12:03 +00:00
|
|
|
{
|
2020-03-08 20:10:07 +01:00
|
|
|
Speaker *speaker = (Speaker *)id;
|
|
|
|
|
|
|
|
|
|
BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(speaker, id));
|
2011-08-04 07:12:03 +00:00
|
|
|
|
2020-03-08 20:10:07 +01:00
|
|
|
MEMCPY_STRUCT_AFTER(speaker, DNA_struct_default_get(Speaker), id);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-13 19:30:04 +02:00
|
|
|
static void speaker_foreach_id(ID *id, LibraryForeachIDData *data)
|
|
|
|
|
{
|
|
|
|
|
Speaker *speaker = (Speaker *)id;
|
|
|
|
|
|
2021-10-26 10:40:36 +02:00
|
|
|
BKE_LIB_FOREACHID_PROCESS_IDSUPER(data, speaker->sound, IDWALK_CB_USER);
|
2020-05-13 19:30:04 +02:00
|
|
|
}
|
|
|
|
|
|
2020-09-10 17:31:18 +02:00
|
|
|
static void speaker_blend_write(BlendWriter *writer, ID *id, const void *id_address)
|
|
|
|
|
{
|
|
|
|
|
Speaker *spk = (Speaker *)id;
|
2021-08-19 11:13:55 +02:00
|
|
|
|
|
|
|
|
/* write LibData */
|
|
|
|
|
BLO_write_id_struct(writer, Speaker, id_address, &spk->id);
|
|
|
|
|
BKE_id_blend_write(writer, &spk->id);
|
2020-09-10 17:31:18 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-08 20:10:07 +01:00
|
|
|
IDTypeInfo IDType_ID_SPK = {
|
2023-07-17 10:46:26 +02:00
|
|
|
/*id_code*/ ID_SPK,
|
|
|
|
|
/*id_filter*/ FILTER_ID_SPK,
|
|
|
|
|
/*main_listbase_index*/ INDEX_ID_SPK,
|
|
|
|
|
/*struct_size*/ sizeof(Speaker),
|
|
|
|
|
/*name*/ "Speaker",
|
2023-10-04 02:53:31 +02:00
|
|
|
/*name_plural*/ N_("speakers"),
|
2023-07-17 10:46:26 +02:00
|
|
|
/*translation_context*/ BLT_I18NCONTEXT_ID_SPEAKER,
|
|
|
|
|
/*flags*/ IDTYPE_FLAGS_APPEND_IS_REUSABLE,
|
|
|
|
|
/*asset_type_info*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*init_data*/ speaker_init_data,
|
|
|
|
|
/*copy_data*/ nullptr,
|
|
|
|
|
/*free_data*/ nullptr,
|
|
|
|
|
/*make_local*/ nullptr,
|
|
|
|
|
/*foreach_id*/ speaker_foreach_id,
|
|
|
|
|
/*foreach_cache*/ nullptr,
|
|
|
|
|
/*foreach_path*/ nullptr,
|
|
|
|
|
/*owner_pointer_get*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*blend_write*/ speaker_blend_write,
|
2023-08-14 16:26:11 +02:00
|
|
|
/*blend_read_data*/ nullptr,
|
2023-03-11 18:07:59 +01:00
|
|
|
/*blend_read_after_liblink*/ nullptr,
|
2023-07-17 10:46:26 +02:00
|
|
|
|
|
|
|
|
/*blend_read_undo_preserve*/ nullptr,
|
|
|
|
|
|
|
|
|
|
/*lib_override_apply_post*/ nullptr,
|
2020-03-08 20:10:07 +01:00
|
|
|
};
|
|
|
|
|
|
First step to handle missing libs/datablocks when reading a file.
Idea is, instead of ignoring completely missing linked datablocks, to
create void placeholders for them.
That way, you can work on your file, save it, and find again your missing data once
lib becomes available again. Or you can edit missing lib's path (in Outliner),
save and reload the file, and you are done.
Also, Outliner now shows broken libraries (and placeholders) with a 'broken lib' icon.
Future plans are also to be able to relocate missing libs and reload them at runtime.
Code notes:
- Placeholder ID is just a regular datablock of same type as expected linked one,
with 'default' data, and a LIB_MISSING bitflag set.
- To allow creation of such datablocks, creation of datablocks in BKE was split in two step:
+ Allocation of memory itself.
+ Setting of all internal data to default values.
See also the design task (T43351).
Reviewed by @campbellbarton, thanks a bunch!
Differential Revision: https://developer.blender.org/D1394
2015-10-20 14:44:57 +02:00
|
|
|
void *BKE_speaker_add(Main *bmain, const char *name)
|
|
|
|
|
{
|
|
|
|
|
Speaker *spk;
|
|
|
|
|
|
2023-07-17 10:46:26 +02:00
|
|
|
spk = static_cast<Speaker *>(BKE_id_new(bmain, ID_SPK, name));
|
2011-08-04 07:12:03 +00:00
|
|
|
|
|
|
|
|
return spk;
|
|
|
|
|
}
|