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

@ -96,16 +96,41 @@ ShaderFeature* FeatureMgr::getByType( const FeatureType &type )
return NULL;
}
void FeatureMgr::registerFeature( const FeatureType &type,
ShaderFeature *feature )
ShaderFeature* FeatureMgr::createFeature(const FeatureType& type, void* argStruct)
{
// Remove any existing feature first.
FeatureInfoVector::iterator iter = mFeatures.begin();
for (; iter != mFeatures.end(); iter++)
{
if (*iter->type == type)
{
if (iter->createFunc != NULL)
{
return iter->createFunc(argStruct);
}
}
}
return nullptr;
}
void FeatureMgr::registerFeature( const FeatureType &type,
ShaderFeature *feature,
CreateShaderFeatureDelegate featureDelegate)
{
if (feature == nullptr && featureDelegate == nullptr)
{
AssertFatal(false, "FeatureMgr::registerFeature - no feature or featureDelegate defined, cannot create this feature.");
}
// Remove any existing feature.
unregisterFeature( type );
// Now add the new feature.
mFeatures.increment();
mFeatures.last().type = &type;
mFeatures.last().feature = feature;
mFeatures.last().createFunc = featureDelegate;
// Make sure we resort the features.
mNeedsSort = true;