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/Operator/Context.h"
#include "Engine/Network/NetworkManager.h" #include "Engine/Network/NetworkManager.h"
#include "Engine/Parameter/Parameter.h"
#include <iostream> #include <iostream>
#include <memory>
enzo::op::Context::Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager) 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()); 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: public:
Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager); Context(enzo::nt::OpId opId, enzo::nt::NetworkManager& networkManager);
enzo::geo::Geometry cloneInputGeo(unsigned int inputIndex); enzo::geo::Geometry cloneInputGeo(unsigned int inputIndex);
bt::floatT evalFloatParm(const char* parmName) const;
private: private:
enzo::nt::OpId opId_; enzo::nt::OpId opId_;
enzo::nt::NetworkManager& networkManager_; enzo::nt::NetworkManager& networkManager_;

View File

@@ -20,6 +20,7 @@ private:
unsigned int minInputs_; unsigned int minInputs_;
unsigned int maxInputs_; unsigned int maxInputs_;
unsigned int maxOutputs_; unsigned int maxOutputs_;
protected: protected:
enzo::nt::OpId opId_; enzo::nt::OpId opId_;
const enzo::geo::Geometry& getInputGeoView(unsigned int inputIndex); 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::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>> nt::GeometryOperator::getInputConnections() const
{ {
std::vector<std::shared_ptr<const nt::GeometryConnection>> inputConnections; 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>> getInputConnections() const;
std::vector<std::shared_ptr<const GeometryConnection>> getOutputConnections() const; std::vector<std::shared_ptr<const GeometryConnection>> getOutputConnections() const;
std::vector<std::weak_ptr<prm::Parameter>> getParameters(); std::vector<std::weak_ptr<prm::Parameter>> getParameters();
std::weak_ptr<prm::Parameter> getParameter(std::string parameterName);
unsigned int getMaxInputs() const; unsigned int getMaxInputs() const;

View File

@@ -18,6 +18,7 @@ add_library(${libName} SHARED
../Engine/Operator/Attribute.cpp ../Engine/Operator/Attribute.cpp
../Engine/Network/NetworkManager.cpp ../Engine/Network/NetworkManager.cpp
../Engine/Parameter/Template.cpp ../Engine/Parameter/Template.cpp
../Engine/Parameter/Parameter.cpp
GopTransform.cpp GopTransform.cpp
GopHouse.cpp GopHouse.cpp
) )

View File

@@ -26,7 +26,9 @@ void GopTransform::cookOp(enzo::op::Context context)
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i) for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
{ {
enzo::bt::Vector3 vector = PAttrHandle.getValue(i); enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
vector.y()+=2.5; vector.x()+=context.evalFloatParm("translateX");
vector.y()+=context.evalFloatParm("translateY");
vector.z()+=context.evalFloatParm("translateZ");
PAttrHandle.setValue(i, vector); PAttrHandle.setValue(i, vector);
} }
// ---- // ----