diff --git a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp index dcc46f1ce..ea887b056 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.Base.cpp +++ b/Source/Engine/Animations/Graph/AnimGraph.Base.cpp @@ -163,10 +163,12 @@ bool AnimGraphBase::onNodeLoaded(Node* n) // Animation case 2: ADD_BUCKET(AnimationBucketInit); + n->Assets.Resize(1); n->Assets[0] = (Asset*)Content::LoadAsync((Guid)n->Values[0]); break; // Blend with Mask case 11: + n->Assets.Resize(1); n->Assets[0] = (Asset*)Content::LoadAsync((Guid)n->Values[1]); break; // Multi Blend 1D @@ -174,6 +176,7 @@ bool AnimGraphBase::onNodeLoaded(Node* n) { ADD_BUCKET(MultiBlendBucketInit); n->Data.MultiBlend1D.Length = -1; + n->Assets.Resize(ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS); for (int32 i = 0; i < ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS; i++) { n->Assets[i] = Content::LoadAsync((Guid)n->Values[i * 2 + 5]); @@ -191,6 +194,7 @@ bool AnimGraphBase::onNodeLoaded(Node* n) // Get blend points locations Array> vertices; byte vertexIndexToAnimIndex[ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS]; + n->Assets.Resize(ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS); for (int32 i = 0; i < ANIM_GRAPH_MULTI_BLEND_MAX_ANIMS; i++) { n->Assets[i] = (Asset*)Content::LoadAsync((Guid)n->Values[i * 2 + 5]); @@ -305,6 +309,7 @@ bool AnimGraphBase::onNodeLoaded(Node* n) data.Graph = nullptr; break; } + n->Assets.Resize(1); n->Assets[0] = function; // Load the graph diff --git a/Source/Engine/Animations/Graph/AnimGraph.h b/Source/Engine/Animations/Graph/AnimGraph.h index ebee7e901..ef72c2d72 100644 --- a/Source/Engine/Animations/Graph/AnimGraph.h +++ b/Source/Engine/Animations/Graph/AnimGraph.h @@ -427,23 +427,7 @@ struct AnimGraphTransitionData float Length; }; -class AnimGraphBox : public VisjectGraphBox -{ -public: - AnimGraphBox() - { - } - - AnimGraphBox(AnimGraphNode* parent, byte id, const VariantType::Types type) - : VisjectGraphBox(parent, id, type) - { - } - - AnimGraphBox(AnimGraphNode* parent, byte id, const VariantType& type) - : VisjectGraphBox(parent, id, type) - { - } -}; +typedef VisjectGraphBox AnimGraphBox; class AnimGraphNode : public VisjectGraphNode { @@ -603,7 +587,7 @@ public: /// Gets the per-node node transformations cache (cached). /// /// The Graph execution context. - /// The modes data. + /// Nodes data. AnimGraphImpulse* GetNodes(AnimGraphExecutor* executor); }; diff --git a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp index ae1b7369f..fbb61c4a2 100644 --- a/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp +++ b/Source/Engine/Animations/Graph/AnimGroup.Animation.cpp @@ -673,19 +673,20 @@ void ComputeMultiBlendLength(float& length, AnimGraphNode* node) // TODO: lock graph or graph asset here? make it thread safe length = 0.0f; - for (int32 i = 0; i < ARRAY_COUNT(node->Assets); i++) + for (int32 i = 0; i < node->Assets.Count(); i++) { - if (node->Assets[i]) + auto& asset = node->Assets[i]; + if (asset) { // TODO: maybe don't update if not all anims are loaded? just skip the node with the bind pose? - if (node->Assets[i]->WaitForLoaded()) + if (asset->WaitForLoaded()) { - node->Assets[i] = nullptr; + asset = nullptr; LOG(Warning, "Failed to load one of the animations."); } else { - const auto anim = node->Assets[i].As(); + const auto anim = asset.As(); const auto aData = node->Values[4 + i * 2].AsFloat4(); length = Math::Max(length, anim->GetLength() * Math::Abs(aData.W)); } diff --git a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h index 7874e4d82..25d9c853f 100644 --- a/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h +++ b/Source/Engine/Particles/Graph/GPU/ParticleEmitterGraph.GPU.h @@ -26,7 +26,7 @@ public: /// /// The asset references. Linked resources such as Animation assets are referenced in graph data as ID. We need to keep valid refs to them at runtime to keep data in memory. /// - AssetReference Assets[14]; + Array> Assets; }; /// diff --git a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h index 77dd81d0f..07630a4b4 100644 --- a/Source/Engine/Particles/Graph/ParticleEmitterGraph.h +++ b/Source/Engine/Particles/Graph/ParticleEmitterGraph.h @@ -177,6 +177,7 @@ public: // Get Gameplay Global case GRAPH_NODE_MAKE_TYPE(7, 16): { + node->Assets.Resize(1); node->Assets[0] = Content::LoadAsync((Guid)node->Values[0]); break; } @@ -296,6 +297,7 @@ public: break; // Particle Emitter Function case GRAPH_NODE_MAKE_TYPE(14, 300): + node->Assets.Resize(1); InitParticleEmitterFunctionCall((Guid)node->Values[0], node->Assets[0], node->UsesParticleData, Layout); break; // Particle Index @@ -447,6 +449,7 @@ public: // Sprite Rendering case GRAPH_NODE_MAKE_TYPE(15, 400): { + node->Assets.Resize(1); node->Assets[0] = Content::LoadAsync((Guid)node->Values[2]); USE_ATTRIBUTE(Position, Float3, 0); USE_ATTRIBUTE(Rotation, Float3, 1); @@ -484,6 +487,7 @@ public: // Model Rendering case GRAPH_NODE_MAKE_TYPE(15, 403): { + node->Assets.Resize(2); node->Assets[0] = Content::LoadAsync((Guid)node->Values[2]); node->Assets[1] = Content::LoadAsync((Guid)node->Values[3]); USE_ATTRIBUTE(Position, Float3, 0); @@ -494,6 +498,7 @@ public: // Ribbon Rendering case GRAPH_NODE_MAKE_TYPE(15, 404): { + node->Assets.Resize(1); node->Assets[0] = Content::LoadAsync((Guid)node->Values[2]); USE_ATTRIBUTE(Position, Float3, 0); // TODO: add support for custom sorting key - not only by age @@ -503,6 +508,7 @@ public: // Volumetric Fog Rendering case GRAPH_NODE_MAKE_TYPE(15, 405): { + node->Assets.Resize(1); node->Assets[0] = Content::LoadAsync((Guid)node->Values[2]); USE_ATTRIBUTE(Position, Float3, 0); USE_ATTRIBUTE(Radius, Float, 1); diff --git a/Source/Engine/Visject/GraphNode.h b/Source/Engine/Visject/GraphNode.h index 628bc6d57..f4eb9cc29 100644 --- a/Source/Engine/Visject/GraphNode.h +++ b/Source/Engine/Visject/GraphNode.h @@ -11,8 +11,6 @@ class GraphNode; #define GRAPH_NODE_MAKE_TYPE(groupID, typeID) (uint32)((groupID) << 16 | (typeID)) -#define GRAPH_NODE_MAX_VALUES 32 - /// /// Represents single box of the graph node /// @@ -114,14 +112,13 @@ public: uint16 TypeID; uint16 GroupID; }; - uint32 Type; }; /// /// List of all node values. Array size and value types are constant over time. Only value data can change. /// - Array> Values; + Array> Values; /// /// Node boxes cache. Array index matches the box ID (for fast O(1) lookups). diff --git a/Source/Engine/Visject/VisjectGraph.h b/Source/Engine/Visject/VisjectGraph.h index 90ba44ed5..3a2e6439d 100644 --- a/Source/Engine/Visject/VisjectGraph.h +++ b/Source/Engine/Visject/VisjectGraph.h @@ -6,13 +6,12 @@ #include "Engine/Core/Math/Vector2.h" #include "Engine/Core/Math/Vector3.h" #include "Engine/Core/Math/Vector4.h" +#include "Engine/Core/Collections/Array.h" #include "Engine/Content/Asset.h" #include "Engine/Content/AssetReference.h" #include "Engine/Content/AssetsContainer.h" #include "Engine/Animations/Curve.h" -#define VISJECT_GRAPH_NODE_MAX_ASSETS 14 - template class VisjectGraphNode; @@ -94,7 +93,7 @@ public: /// /// The asset references. Linked resources such as Animation assets are referenced in graph data as ID. We need to keep valid refs to them at runtime to keep data in memory. /// - AssetReference Assets[VISJECT_GRAPH_NODE_MAX_ASSETS]; + Array> Assets; }; /// @@ -188,11 +187,10 @@ public: #undef SETUP_CURVE // Get Gameplay Global case 16: - { + n->Assets.Resize(1); n->Assets[0] = ::LoadAsset((Guid)n->Values[0], Asset::TypeInitializer); break; } - } } // Base