feat: context can red parameters

This commit is contained in:
parker
2025-07-24 01:26:11 +01:00
parent f49c6bd5de
commit 8a380a0fee
7 changed files with 32 additions and 1 deletions

View File

@@ -1,6 +1,8 @@
#include "Engine/Operator/Context.h"
#include "Engine/Network/NetworkManager.h"
#include "Engine/Parameter/Parameter.h"
#include <iostream>
#include <memory>
enzo::op::Context::Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager)
@@ -23,3 +25,13 @@ enzo::geo::Geometry enzo::op::Context::cloneInputGeo(unsigned int inputIndex)
return networkManager_.getGeoOperator(inputConnection->getInputOpId()).getOutputGeo(inputConnection->getInputIndex());
}
enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName) const
{
enzo::nt::GeometryOperator& selfOp = networkManager_.getGeoOperator(opId_);
std::weak_ptr<prm::Parameter> parameter = selfOp.getParameter(parmName);
if(auto sharedParm = parameter.lock())
{
return sharedParm->evalFloat();
}
}

View File

@@ -15,6 +15,7 @@ class Context
public:
Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager);
enzo::geo::Geometry cloneInputGeo(unsigned int inputIndex);
bt::floatT evalFloatParm(const char* parmName) const;
private:
enzo::nt::OpId opId_;
enzo::nt::NetworkManager& networkManager_;

View File

@@ -20,6 +20,7 @@ private:
unsigned int minInputs_;
unsigned int maxInputs_;
unsigned int maxOutputs_;
protected:
enzo::nt::OpId opId_;
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex);

View File

@@ -74,6 +74,19 @@ void nt::GeometryOperator::addOutputConnection(std::shared_ptr<nt::GeometryConne
std::cout << "size: " << outputConnections_.size() << "\n";
}
std::weak_ptr<prm::Parameter> nt::GeometryOperator::getParameter(std::string parameterName)
{
for(auto parm : parameters_)
{
if(parm->getName()==parameterName)
{
return parm;
}
}
return std::weak_ptr<prm::Parameter>();
}
std::vector<std::shared_ptr<const nt::GeometryConnection>> nt::GeometryOperator::getInputConnections() const
{
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections;

View File

@@ -27,6 +27,7 @@ public:
std::vector<std::shared_ptr<const GeometryConnection>> getInputConnections() const;
std::vector<std::shared_ptr<const GeometryConnection>> getOutputConnections() const;
std::vector<std::weak_ptr<prm::Parameter>> getParameters();
std::weak_ptr<prm::Parameter> getParameter(std::string parameterName);
unsigned int getMaxInputs() const;