Add support for multi-threaded CPU particles simulation

This commit is contained in:
Wojtek Figat
2021-06-15 23:48:00 +02:00
parent 2a73d18d14
commit d2d8a83461
11 changed files with 245 additions and 313 deletions

View File

@@ -52,36 +52,18 @@ public:
/// <summary>
/// The Particle Emitter Graph used to simulate particles.
/// </summary>
template<class Base, class NodeType, class ValueType>
class ParticleEmitterGraph : public Base
template<class BaseType, class NodeType, class ValueType>
class ParticleEmitterGraph : public BaseType
{
public:
typedef ValueType Value;
/// <summary>
/// The particle emitter module types.
/// </summary>
enum class ModuleType
{
/// <summary>
/// The spawn module.
/// </summary>
Spawn,
/// <summary>
/// The init module.
/// </summary>
Initialize,
/// <summary>
/// The update module.
/// </summary>
Update,
/// <summary>
/// The render module.
/// </summary>
Render,
};
@@ -172,8 +154,6 @@ public:
bool UsesVolumetricFogRendering = false;
protected:
virtual void InitializeNode(NodeType* node)
{
// Skip if already initialized
@@ -314,10 +294,8 @@ protected:
}
// Particle Emitter Function
case GRAPH_NODE_MAKE_TYPE(14, 300):
{
node->Assets[0] = Content::LoadAsync<Asset>((Guid)node->Values[0]);
break;
}
// Particle Index
case GRAPH_NODE_MAKE_TYPE(14, 301):
node->UsesParticleData = true;
@@ -566,7 +544,7 @@ public:
UsesVolumetricFogRendering = false;
// Base
Base::Clear();
BaseType::Clear();
}
bool Load(ReadStream* stream, bool loadMeta) override
@@ -575,7 +553,7 @@ public:
Version++;
// Base
if (Base::Load(stream, loadMeta))
if (BaseType::Load(stream, loadMeta))
return true;
// Compute particle data layout and initialize used nodes (for only used nodes, start depth searching rom the modules)
@@ -678,6 +656,6 @@ public:
}
}
return Base::onNodeLoaded(n);
return BaseType::onNodeLoaded(n);
}
};