Ground work for node editor

Added ability to shader features and shaderGen to create multiple instances of the same feature with the option of calling a static creation function that can take arguments in the form of a struct.

FEATUREMGR now has createFeature to take advantage of this.

The node editor requires this ability as the same node could be used multiple times with different arguments so in its update function we will be calling

```FEATUREMGR->registerFeature(feature_type, (optional default constructor), createFunction);```

then adding it to the feature set with the required arguments to build the shader feature.
```FeatureSet->add(feature_type, index, ParameterStruct);```
This commit is contained in:
marauder2k7 2024-12-05 14:40:26 +00:00
parent f1cf4147a8
commit 8c7ddb7cf1
6 changed files with 102 additions and 16 deletions

View file

@ -27,16 +27,28 @@
#endif
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
#endif
#ifndef _UTIL_DELEGATE_H_
#include "core/util/delegate.h"
#endif
class FeatureType;
class ShaderFeature;
typedef Delegate<ShaderFeature* (void*)> CreateShaderFeatureDelegate;
/// <summary>
/// Used by the feature manager.
/// </summary>
/// <param name="type">The shader feature type.</param>
/// <param name="feature">The shader feature class.</param>
/// <param name="createFunc">The static create function for this feature.</param>
struct FeatureInfo
{
const FeatureType *type;
ShaderFeature *feature;
CreateShaderFeatureDelegate createFunc;
};
@ -67,10 +79,26 @@ public:
///
ShaderFeature* getByType( const FeatureType &type );
// Allows other systems to add features. index is
// the enum in GFXMaterialFeatureData.
void registerFeature( const FeatureType &type,
ShaderFeature *feature );
/// <summary>
/// Creates a shader feature of this type with the arguments provided.
/// </summary>
/// <param name="type">The shader feature type.</param>
/// <param name="argStruct">The arguments for setting up this isntance of the shaderFeature.</param>
/// <returns>An instance of the shader feature using its static createFunction taking in the
/// argument struct.
/// </returns>
ShaderFeature* createFeature(const FeatureType& type, void* argStruct);
/// <summary>
/// Allows other systems to add features. index is
/// the enum in GFXMaterialFeatureData.
/// </summary>
/// <param name="type">The shader feature type.</param>
/// <param name="feature">The shader feature (can be null if featureDelegate defined)</param>
/// <param name="featureDelegate">The feature delegate create function.</param>
void registerFeature(const FeatureType& type,
ShaderFeature* feature = nullptr,
CreateShaderFeatureDelegate featureDelegate = nullptr);
// Unregister a feature.
void unregisterFeature( const FeatureType &type );
@ -86,4 +114,4 @@ public:
// Helper for accessing the feature manager singleton.
#define FEATUREMGR ManagedSingleton<FeatureMgr>::instance()
#endif // FEATUREMGR
#endif // FEATUREMGR