Depsgraph: Make sound ID part of the graph
Currently those IDs are not covered by copy-on-write mechanism since that ruins the current design of BKE_sound, But this change allows to move towards system where sound handlers are only valid for an evaluated ID datablocks.
This commit is contained in:
@@ -58,6 +58,7 @@ extern "C" {
|
||||
#include "DNA_lightprobe_types.h"
|
||||
#include "DNA_rigidbody_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sound_types.h"
|
||||
#include "DNA_speaker_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
@@ -443,6 +444,9 @@ void DepsgraphNodeBuilder::build_id(ID *id)
|
||||
case ID_SPK:
|
||||
build_speaker((Speaker *)id);
|
||||
break;
|
||||
case ID_SO:
|
||||
build_sound((bSound *)id);
|
||||
break;
|
||||
case ID_TXT:
|
||||
/* Not a part of dependency graph. */
|
||||
break;
|
||||
@@ -708,7 +712,7 @@ void DepsgraphNodeBuilder::build_object_data_speaker(Object *object)
|
||||
{
|
||||
Speaker *speaker = (Speaker *)object->data;
|
||||
build_speaker(speaker);
|
||||
add_operation_node(&object->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
|
||||
add_operation_node(&object->id, NodeType::AUDIO, OperationCode::SPEAKER_EVAL);
|
||||
}
|
||||
|
||||
void DepsgraphNodeBuilder::build_object_transform(Object *object)
|
||||
@@ -1543,9 +1547,23 @@ void DepsgraphNodeBuilder::build_speaker(Speaker *speaker)
|
||||
return;
|
||||
}
|
||||
/* Placeholder so we can add relations and tag ID node for update. */
|
||||
add_operation_node(&speaker->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
|
||||
add_operation_node(&speaker->id, NodeType::AUDIO, OperationCode::SPEAKER_EVAL);
|
||||
build_animdata(&speaker->id);
|
||||
build_parameters(&speaker->id);
|
||||
if (speaker->sound != NULL) {
|
||||
build_sound(speaker->sound);
|
||||
}
|
||||
}
|
||||
|
||||
void DepsgraphNodeBuilder::build_sound(bSound *sound)
|
||||
{
|
||||
if (built_map_.checkIsBuiltAndTag(sound)) {
|
||||
return;
|
||||
}
|
||||
/* Placeholder so we can add relations and tag ID node for update. */
|
||||
add_operation_node(&sound->id, NodeType::AUDIO, OperationCode::SOUND_EVAL);
|
||||
build_animdata(&sound->id);
|
||||
build_parameters(&sound->id);
|
||||
}
|
||||
|
||||
/* **** ID traversal callbacks functions **** */
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
struct Base;
|
||||
struct bSound;
|
||||
struct CacheFile;
|
||||
struct Camera;
|
||||
struct Collection;
|
||||
@@ -206,6 +207,7 @@ class DepsgraphNodeBuilder : public DepsgraphBuilder {
|
||||
void build_movieclip(MovieClip *clip);
|
||||
void build_lightprobe(LightProbe *probe);
|
||||
void build_speaker(Speaker *speaker);
|
||||
void build_sound(bSound *sound);
|
||||
|
||||
/* Per-ID information about what was already in the dependency graph.
|
||||
* Allows to re-use certain values, to speed up following evaluation. */
|
||||
|
@@ -58,6 +58,7 @@ extern "C" {
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_rigidbody_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "DNA_sound_types.h"
|
||||
#include "DNA_speaker_types.h"
|
||||
#include "DNA_texture_types.h"
|
||||
#include "DNA_world_types.h"
|
||||
@@ -487,6 +488,9 @@ void DepsgraphRelationBuilder::build_id(ID *id)
|
||||
case ID_SPK:
|
||||
build_speaker((Speaker *)id);
|
||||
break;
|
||||
case ID_SO:
|
||||
build_sound((bSound *)id);
|
||||
break;
|
||||
case ID_TXT:
|
||||
/* Not a part of dependency graph. */
|
||||
break;
|
||||
@@ -766,9 +770,9 @@ void DepsgraphRelationBuilder::build_object_data_speaker(Object *object)
|
||||
{
|
||||
Speaker *speaker = (Speaker *)object->data;
|
||||
build_speaker(speaker);
|
||||
OperationKey probe_key(&speaker->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
|
||||
OperationKey object_key(&object->id, NodeType::PARAMETERS, OperationCode::SPEAKER_EVAL);
|
||||
add_relation(probe_key, object_key, "Speaker Update");
|
||||
ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
|
||||
ComponentKey object_key(&object->id, NodeType::AUDIO);
|
||||
add_relation(speaker_key, object_key, "Speaker Update");
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::build_object_parent(Object *object)
|
||||
@@ -2276,6 +2280,21 @@ void DepsgraphRelationBuilder::build_speaker(Speaker *speaker)
|
||||
}
|
||||
build_animdata(&speaker->id);
|
||||
build_parameters(&speaker->id);
|
||||
if (speaker->sound != NULL) {
|
||||
build_sound(speaker->sound);
|
||||
ComponentKey speaker_key(&speaker->id, NodeType::AUDIO);
|
||||
ComponentKey sound_key(&speaker->sound->id, NodeType::AUDIO);
|
||||
add_relation(sound_key, speaker_key, "Sound -> Speaker");
|
||||
}
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::build_sound(bSound *sound)
|
||||
{
|
||||
if (built_map_.checkIsBuiltAndTag(sound)) {
|
||||
return;
|
||||
}
|
||||
build_animdata(&sound->id);
|
||||
build_parameters(&sound->id);
|
||||
}
|
||||
|
||||
void DepsgraphRelationBuilder::build_copy_on_write_relations()
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include "intern/node/deg_node_operation.h"
|
||||
|
||||
struct Base;
|
||||
struct bSound;
|
||||
struct CacheFile;
|
||||
struct Camera;
|
||||
struct Collection;
|
||||
@@ -264,6 +265,7 @@ class DepsgraphRelationBuilder : public DepsgraphBuilder {
|
||||
void build_movieclip(MovieClip *clip);
|
||||
void build_lightprobe(LightProbe *probe);
|
||||
void build_speaker(Speaker *speaker);
|
||||
void build_sound(bSound *sound);
|
||||
|
||||
void build_nested_datablock(ID *owner, ID *id);
|
||||
void build_nested_nodetree(ID *owner, bNodeTree *ntree);
|
||||
|
@@ -434,6 +434,7 @@ static void deg_debug_graphviz_node(const DebugContext &ctx, const Node *node)
|
||||
case NodeType::BATCH_CACHE:
|
||||
case NodeType::DUPLI:
|
||||
case NodeType::SYNCHRONIZATION:
|
||||
case NodeType::AUDIO:
|
||||
case NodeType::GENERIC_DATABLOCK: {
|
||||
ComponentNode *comp_node = (ComponentNode *)node;
|
||||
if (!comp_node->operations.empty()) {
|
||||
|
@@ -1278,7 +1278,9 @@ bool deg_copy_on_write_is_expanded(const ID *id_cow)
|
||||
bool deg_copy_on_write_is_needed(const ID *id_orig)
|
||||
{
|
||||
const ID_Type id_type = GS(id_orig->name);
|
||||
return !ELEM(id_type, ID_IM);
|
||||
/* TODO(sergey): Make Sound copyable. It is here only because the code for dependency graph is
|
||||
* being work in progress. */
|
||||
return !ELEM(id_type, ID_IM, ID_SO);
|
||||
}
|
||||
|
||||
} // namespace DEG
|
||||
|
@@ -101,13 +101,12 @@ const char *nodeTypeAsString(NodeType type)
|
||||
return "POINT_CACHE";
|
||||
case NodeType::BATCH_CACHE:
|
||||
return "BATCH_CACHE";
|
||||
/* Duplication. */
|
||||
case NodeType::DUPLI:
|
||||
return "DUPLI";
|
||||
/* Synchronization. */
|
||||
case NodeType::SYNCHRONIZATION:
|
||||
return "SYNCHRONIZATION";
|
||||
/* Generic datablock. */
|
||||
case NodeType::AUDIO:
|
||||
return "AUDIO";
|
||||
case NodeType::GENERIC_DATABLOCK:
|
||||
return "GENERIC_DATABLOCK";
|
||||
|
||||
|
@@ -92,6 +92,8 @@ enum class NodeType {
|
||||
/* Used by all operations which are updating object when something is
|
||||
* changed in view layer. */
|
||||
OBJECT_FROM_LAYER,
|
||||
/* Audio-related evaluation. */
|
||||
AUDIO,
|
||||
/* Un-interestying datablock, which is a part of dependency graph, but does
|
||||
* not have very distinctive update procedure. */
|
||||
GENERIC_DATABLOCK,
|
||||
|
@@ -364,6 +364,7 @@ DEG_COMPONENT_NODE_DEFINE(Transform, TRANSFORM, ID_RECALC_TRANSFORM);
|
||||
DEG_COMPONENT_NODE_DEFINE(ObjectFromLayer, OBJECT_FROM_LAYER, 0);
|
||||
DEG_COMPONENT_NODE_DEFINE(Dupli, DUPLI, 0);
|
||||
DEG_COMPONENT_NODE_DEFINE(Synchronization, SYNCHRONIZATION, 0);
|
||||
DEG_COMPONENT_NODE_DEFINE(Audio, AUDIO, 0);
|
||||
DEG_COMPONENT_NODE_DEFINE(GenericDatablock, GENERIC_DATABLOCK, 0);
|
||||
|
||||
/* Node Types Register =================================== */
|
||||
@@ -390,6 +391,7 @@ void deg_register_component_depsnodes()
|
||||
register_node_typeinfo(&DNTI_OBJECT_FROM_LAYER);
|
||||
register_node_typeinfo(&DNTI_DUPLI);
|
||||
register_node_typeinfo(&DNTI_SYNCHRONIZATION);
|
||||
register_node_typeinfo(&DNTI_AUDIO);
|
||||
register_node_typeinfo(&DNTI_GENERIC_DATABLOCK);
|
||||
}
|
||||
|
||||
|
@@ -186,6 +186,7 @@ DEG_COMPONENT_NODE_DECLARE_GENERIC(Transform);
|
||||
DEG_COMPONENT_NODE_DECLARE_NO_COW_TAG_ON_UPDATE(ObjectFromLayer);
|
||||
DEG_COMPONENT_NODE_DECLARE_GENERIC(Dupli);
|
||||
DEG_COMPONENT_NODE_DECLARE_GENERIC(Synchronization);
|
||||
DEG_COMPONENT_NODE_DECLARE_GENERIC(Audio);
|
||||
DEG_COMPONENT_NODE_DECLARE_GENERIC(GenericDatablock);
|
||||
|
||||
/* Bone Component */
|
||||
|
@@ -100,6 +100,8 @@ const char *operationCodeAsString(OperationCode opcode)
|
||||
return "LIGHT_PROBE_EVAL";
|
||||
case OperationCode::SPEAKER_EVAL:
|
||||
return "SPEAKER_EVAL";
|
||||
case OperationCode::SOUND_EVAL:
|
||||
return "SOUND_EVAL";
|
||||
case OperationCode::ARMATURE_EVAL:
|
||||
return "ARMATURE_EVAL";
|
||||
/* Pose. */
|
||||
|
@@ -106,6 +106,7 @@ enum class OperationCode {
|
||||
/* Object data. --------------------------------------------------------- */
|
||||
LIGHT_PROBE_EVAL,
|
||||
SPEAKER_EVAL,
|
||||
SOUND_EVAL,
|
||||
ARMATURE_EVAL,
|
||||
|
||||
/* Pose. ---------------------------------------------------------------- */
|
||||
|
@@ -448,7 +448,9 @@ typedef enum ID_Type {
|
||||
|
||||
/* No copy-on-write for these types.
|
||||
* Keep in sync with check_datablocks_copy_on_writable and deg_copy_on_write_is_needed */
|
||||
#define ID_TYPE_IS_COW(_id_type) (!ELEM(_id_type, ID_BR, ID_LS, ID_PAL, ID_IM))
|
||||
/* TODO(sergey): Make Sound copyable. It is here only because the code for dependency graph is
|
||||
* being work in progress. */
|
||||
#define ID_TYPE_IS_COW(_id_type) (!ELEM(_id_type, ID_BR, ID_LS, ID_PAL, ID_IM, ID_SO))
|
||||
|
||||
#ifdef GS
|
||||
# undef GS
|
||||
|
Reference in New Issue
Block a user