feat: working parameter creation
This commit is contained in:
@@ -21,6 +21,7 @@ set(ENGINE_SOURCES
|
|||||||
src/Engine/Operator/OperatorTable.cpp
|
src/Engine/Operator/OperatorTable.cpp
|
||||||
src/Engine/Operator/Context.cpp
|
src/Engine/Operator/Context.cpp
|
||||||
src/Engine/Parameter/Template.cpp
|
src/Engine/Parameter/Template.cpp
|
||||||
|
src/Engine/Parameter/Parameter.cpp
|
||||||
src/Engine/Network/NetworkManager.cpp
|
src/Engine/Network/NetworkManager.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
#include "Engine/Network/NetworkManager.h"
|
#include "Engine/Network/NetworkManager.h"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "Engine/Operator/Context.h"
|
#include "Engine/Operator/Context.h"
|
||||||
|
#include "Engine/Parameter/Parameter.h"
|
||||||
|
#include "Engine/Parameter/Template.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using namespace enzo;
|
using namespace enzo;
|
||||||
@@ -23,12 +25,27 @@ void enzo::nt::connectOperators(enzo::nt::OpId inputOpId, unsigned int inputInde
|
|||||||
outputOp.addInputConnection(newConnection);
|
outputOp.addInputConnection(newConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo)
|
nt::GeometryOperator::GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo)
|
||||||
: opId_{opId}, opDef_(opinfo.ctorFunc(opId))
|
: opId_{opId}, opInfo_{opInfo}, opDef_(opInfo.ctorFunc(opId))
|
||||||
{
|
{
|
||||||
// TODO: drive by geometry definition
|
// TODO: drive by geometry definition
|
||||||
maxInputs_=4;
|
maxInputs_=4;
|
||||||
maxOutputs_=4;
|
maxOutputs_=4;
|
||||||
|
|
||||||
|
initParameters();
|
||||||
|
}
|
||||||
|
|
||||||
|
void nt::GeometryOperator::initParameters()
|
||||||
|
{
|
||||||
|
for(const prm::Template* t = opInfo_.templates; t->isValid(); ++t)
|
||||||
|
{
|
||||||
|
std::cout << "name: " << t->getName() << "\n";
|
||||||
|
// create parameter
|
||||||
|
parameters_.push_back(
|
||||||
|
std::make_shared<prm::Parameter>(*t)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "Engine/Operator/GeometryConnection.h"
|
#include "Engine/Operator/GeometryConnection.h"
|
||||||
#include "Engine/Operator/OpInfo.h"
|
#include "Engine/Operator/OpInfo.h"
|
||||||
#include "Engine/Operator/GeometryOpDef.h"
|
#include "Engine/Operator/GeometryOpDef.h"
|
||||||
|
#include "Engine/Parameter/Parameter.h"
|
||||||
#include "Engine/Types.h"
|
#include "Engine/Types.h"
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -12,7 +13,7 @@ void connectOperators(enzo::nt::OpId inputOpId, unsigned int inputIndex, enzo::n
|
|||||||
class GeometryOperator
|
class GeometryOperator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opinfo);
|
GeometryOperator(enzo::nt::OpId opId, op::OpInfo opInfo);
|
||||||
|
|
||||||
// disable copying
|
// disable copying
|
||||||
GeometryOperator(const GeometryOperator&) = delete;
|
GeometryOperator(const GeometryOperator&) = delete;
|
||||||
@@ -33,12 +34,16 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initParameters();
|
||||||
|
|
||||||
// TODO: avoid duplicate connections
|
// TODO: avoid duplicate connections
|
||||||
std::vector<std::shared_ptr<nt::GeometryConnection>> inputConnections_;
|
std::vector<std::shared_ptr<nt::GeometryConnection>> inputConnections_;
|
||||||
std::vector<std::shared_ptr<nt::GeometryConnection>> outputConnections_;
|
std::vector<std::shared_ptr<nt::GeometryConnection>> outputConnections_;
|
||||||
|
std::vector<std::shared_ptr<prm::Parameter>> parameters_;
|
||||||
unsigned int maxInputs_;
|
unsigned int maxInputs_;
|
||||||
unsigned int maxOutputs_;
|
unsigned int maxOutputs_;
|
||||||
std::unique_ptr<enzo::nt::GeometryOpDef> opDef_;
|
std::unique_ptr<enzo::nt::GeometryOpDef> opDef_;
|
||||||
enzo::nt::OpId opId_;
|
enzo::nt::OpId opId_;
|
||||||
|
enzo::op::OpInfo opInfo_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ struct OpInfo
|
|||||||
std::string displayName;
|
std::string displayName;
|
||||||
enzo::nt::opConstructor ctorFunc;
|
enzo::nt::opConstructor ctorFunc;
|
||||||
enzo::prm::Template* templates;
|
enzo::prm::Template* templates;
|
||||||
|
size_t templatesSize;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,15 +3,17 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates)
|
void enzo::op::OperatorTable::addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templates[])
|
||||||
{
|
{
|
||||||
std::cout << "OPERATOR TABLE ADDED\n";
|
std::cout << "OPERATOR TABLE ADDED\n";
|
||||||
std::cout << "adding operator: " << displayName << "\n";
|
std::cout << "adding operator: " << displayName << "\n";
|
||||||
|
std::cout << "tempalate size: " << sizeof(templates) << "\n";
|
||||||
enzo::op::OpInfo info {
|
enzo::op::OpInfo info {
|
||||||
internalName,
|
internalName,
|
||||||
displayName,
|
displayName,
|
||||||
ctorFunc,
|
ctorFunc,
|
||||||
templates
|
templates,
|
||||||
|
sizeof(*templates)
|
||||||
};
|
};
|
||||||
|
|
||||||
opInfoStore_.push_back(info);
|
opInfoStore_.push_back(info);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace enzo::op
|
|||||||
class BOOST_SYMBOL_EXPORT OperatorTable
|
class BOOST_SYMBOL_EXPORT OperatorTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templates);
|
static void addOperator(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templates[]);
|
||||||
static nt::opConstructor getOpConstructor(std::string name);
|
static nt::opConstructor getOpConstructor(std::string name);
|
||||||
static const std::optional<op::OpInfo> getOpInfo(std::string name);
|
static const std::optional<op::OpInfo> getOpInfo(std::string name);
|
||||||
static std::vector<OpInfo> getData();
|
static std::vector<OpInfo> getData();
|
||||||
@@ -22,6 +22,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
static std::vector<OpInfo> opInfoStore_;
|
static std::vector<OpInfo> opInfoStore_;
|
||||||
};
|
};
|
||||||
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template* templateList);
|
using addOperatorPtr = void (*)(const char* internalName, const char* displayName, nt::opConstructor ctorFunc, prm::Template templateList[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
#include "Engine/Parameter/FloatParm.h"
|
|
||||||
|
|
||||||
|
|
||||||
enzo::prm::FloatParm::FloatParm(Template prmTemplate)
|
|
||||||
: template_{prmTemplate}
|
|
||||||
{
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include "Engine/Parameter/Template.h"
|
|
||||||
#include "Engine/Types.h"
|
|
||||||
|
|
||||||
namespace enzo::prm
|
|
||||||
{
|
|
||||||
class FloatParm
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
FloatParm(Template prmTemplate);
|
|
||||||
inline bt::floatT getValue() const {return value_;}
|
|
||||||
inline void setValue(bt::floatT value) {value_ = value;}
|
|
||||||
private:
|
|
||||||
Template template_;
|
|
||||||
bt::floatT value_ = 0;
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
|
||||||
9
src/Engine/Parameter/Parameter.cpp
Normal file
9
src/Engine/Parameter/Parameter.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "Engine/Parameter/Parameter.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
|
enzo::prm::Parameter::Parameter(Template prmTemplate)
|
||||||
|
: template_{prmTemplate}
|
||||||
|
{
|
||||||
|
std::cout << "created new parameter: " << prmTemplate.getName() << "\n";
|
||||||
|
}
|
||||||
18
src/Engine/Parameter/Parameter.h
Normal file
18
src/Engine/Parameter/Parameter.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Engine/Parameter/Template.h"
|
||||||
|
#include "Engine/Types.h"
|
||||||
|
|
||||||
|
namespace enzo::prm
|
||||||
|
{
|
||||||
|
class Parameter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Parameter(Template prmTemplate);
|
||||||
|
inline bt::floatT evalFloat() const {return floatValue_;}
|
||||||
|
inline void setFloat(bt::floatT value) {floatValue_ = value;}
|
||||||
|
private:
|
||||||
|
Template template_;
|
||||||
|
bt::floatT floatValue_ = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -6,3 +6,20 @@ enzo::prm::Template::Template(enzo::prm::Type type, const char* name)
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enzo::prm::Template::Template()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool enzo::prm::Template::isValid() const
|
||||||
|
{
|
||||||
|
return name_!=nullptr;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* enzo::prm::Template::getName() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ class Template
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Template(enzo::prm::Type type, const char* name);
|
Template(enzo::prm::Type type, const char* name);
|
||||||
|
Template();
|
||||||
|
const char* getName() const;
|
||||||
|
bool isValid() const;
|
||||||
private:
|
private:
|
||||||
enzo::prm::Type type_;
|
enzo::prm::Type type_;
|
||||||
// TODO: make a class that holds token and name
|
// TODO: make a class that holds token and name
|
||||||
@@ -15,5 +18,7 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline enzo::prm::Template Terminator = enzo::prm::Template();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,4 +79,7 @@ void GOP_house::cookOp(enzo::op::Context context)
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
enzo::prm::Template GOP_house::parameterList[] = {};
|
enzo::prm::Template GOP_house::parameterList[] =
|
||||||
|
{
|
||||||
|
enzo::prm::Terminator
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "OpDefs/GopTransform.hpp"
|
#include "OpDefs/GopTransform.hpp"
|
||||||
#include "Engine/Operator/AttributeHandle.h"
|
#include "Engine/Operator/AttributeHandle.h"
|
||||||
|
#include "Engine/Parameter/Template.h"
|
||||||
|
|
||||||
GopTransform::GopTransform(enzo::nt::OpId opId)
|
GopTransform::GopTransform(enzo::nt::OpId opId)
|
||||||
: enzo::nt::GeometryOpDef(opId)
|
: enzo::nt::GeometryOpDef(opId)
|
||||||
@@ -40,6 +41,7 @@ void GopTransform::cookOp(enzo::op::Context context)
|
|||||||
|
|
||||||
enzo::prm::Template GopTransform::parameterList[] = {
|
enzo::prm::Template GopTransform::parameterList[] = {
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "Test"),
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "Test"),
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "Test2")
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "Test2"),
|
||||||
|
enzo::prm::Terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user