fix: general optimization, lazy cooking, transform caching, fix geometry copying
This commit is contained in:
@@ -29,6 +29,32 @@ ga::Attribute::Attribute(std::string name, ga::AttributeType type)
|
||||
|
||||
}
|
||||
|
||||
ga::Attribute::Attribute(const Attribute& other)
|
||||
{
|
||||
type_ = other.type_;
|
||||
private_= other.private_;
|
||||
hidden_ = other.hidden_;
|
||||
readOnly_ = other.readOnly_;
|
||||
name_ = other.name_;
|
||||
|
||||
switch(type_)
|
||||
{
|
||||
case(AttrType::intT):
|
||||
intStore_=std::make_shared<std::vector<int>>(*other.intStore_);
|
||||
break;
|
||||
case(AttrType::floatT):
|
||||
floatStore_=std::make_shared<std::vector<float>>(*other.floatStore_);
|
||||
break;
|
||||
case(AttrType::vectorT):
|
||||
vector3Store_=std::make_shared<std::vector<enzo::bt::Vector3>>(*other.vector3Store_);
|
||||
break;
|
||||
default:
|
||||
throw std::runtime_error("Type " + std::to_string(static_cast<int>(type_)) + " was not properly accounted for");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ga::AttributeType ga::Attribute::getType()
|
||||
{
|
||||
return type_;
|
||||
|
||||
@@ -20,6 +20,7 @@ namespace enzo{
|
||||
{
|
||||
public:
|
||||
Attribute(std::string name, ga::AttributeType type);
|
||||
Attribute(const Attribute& other);
|
||||
AttributeType getType();
|
||||
std::string getName();
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace enzo{
|
||||
|
||||
std::string name_;
|
||||
|
||||
void* data_;
|
||||
// void* data_;
|
||||
|
||||
// data stores
|
||||
std::shared_ptr<StoreContainer<int>> intStore_;
|
||||
|
||||
@@ -25,7 +25,8 @@ enzo::geo::Geometry enzo::op::Context::cloneInputGeo(unsigned int inputIndex)
|
||||
auto inputConnection = inputConnections.at(inputIndex);
|
||||
if(auto inputConnectionSP = inputConnection.lock())
|
||||
{
|
||||
return networkManager_.getGeoOperator(inputConnectionSP->getInputOpId()).getOutputGeo(inputConnectionSP->getInputIndex());
|
||||
const nt::GeometryOperator& geoOp = networkManager_.getGeoOperator(inputConnectionSP->getInputOpId());
|
||||
return geoOp.getOutputGeo(inputConnectionSP->getInputIndex());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -33,6 +34,7 @@ enzo::geo::Geometry enzo::op::Context::cloneInputGeo(unsigned int inputIndex)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: cache value
|
||||
enzo::bt::floatT enzo::op::Context::evalFloatParm(const char* parmName) const
|
||||
{
|
||||
enzo::nt::GeometryOperator& selfOp = networkManager_.getGeoOperator(opId_);
|
||||
|
||||
@@ -17,6 +17,39 @@ geo::Geometry::Geometry()
|
||||
addIntAttribute(ga::AttrOwner::PRIMITIVE, "vertexCount");
|
||||
}
|
||||
|
||||
geo::Geometry::Geometry(const Geometry& other)
|
||||
{
|
||||
pointAttributes_ = deepCopyAttributes(other.pointAttributes_);
|
||||
vertexAttributes_ = deepCopyAttributes(other.vertexAttributes_);
|
||||
primitiveAttributes_ = deepCopyAttributes(other.primitiveAttributes_);
|
||||
globalAttributes_ = deepCopyAttributes(other.globalAttributes_);
|
||||
|
||||
}
|
||||
|
||||
geo::Geometry::attribVector geo::Geometry::deepCopyAttributes(attribVector originalVector)
|
||||
{
|
||||
geo::Geometry::attribVector copied;
|
||||
const size_t sourceSize = originalVector.size();
|
||||
|
||||
copied.reserve(sourceSize);
|
||||
|
||||
for(const std::shared_ptr<ga::Attribute> sourceAttrib : originalVector)
|
||||
{
|
||||
if(sourceAttrib)
|
||||
{
|
||||
copied.push_back(std::make_shared<ga::Attribute>(*sourceAttrib));
|
||||
}
|
||||
else
|
||||
{
|
||||
copied.push_back(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
return copied;
|
||||
|
||||
}
|
||||
|
||||
|
||||
enzo::geo::HeMesh geo::Geometry::computeHalfEdgeMesh()
|
||||
{
|
||||
HeMesh heMesh;
|
||||
|
||||
@@ -22,14 +22,19 @@ class Geometry
|
||||
{
|
||||
public:
|
||||
Geometry();
|
||||
Geometry(const Geometry& other);
|
||||
ga::AttributeHandle<int> addIntAttribute(ga::AttributeOwner owner, std::string name);
|
||||
ga::AttributeHandle<bt::Vector3> addVector3Attribute(ga::AttributeOwner owner, std::string name);
|
||||
// TODO: return weak ptr
|
||||
std::shared_ptr<ga::Attribute> getAttribByName(ga::AttributeOwner owner, std::string name);
|
||||
std::vector<bt::Vector3> derivePointNormals();
|
||||
HeMesh computeHalfEdgeMesh();
|
||||
private:
|
||||
using attribVector = std::vector<std::shared_ptr<ga::Attribute>>;
|
||||
attribVector& getAttributeStore(ga::AttributeOwner& owner);
|
||||
|
||||
attribVector deepCopyAttributes(attribVector source);
|
||||
|
||||
attribVector pointAttributes_;
|
||||
attribVector vertexAttributes_;
|
||||
attribVector primitiveAttributes_;
|
||||
|
||||
@@ -53,13 +53,19 @@ void enzo::nt::GeometryOperator::dirtyNode(bool dirtyDescendents)
|
||||
nodeDirtied(opId_, dirtyDescendents);
|
||||
}
|
||||
|
||||
bool enzo::nt::GeometryOperator::isDirty()
|
||||
{
|
||||
return dirty_;
|
||||
}
|
||||
|
||||
|
||||
void enzo::nt::GeometryOperator::cookOp(op::Context context)
|
||||
{
|
||||
opDef_->cookOp(context);
|
||||
dirty_=false;
|
||||
}
|
||||
|
||||
geo::Geometry& enzo::nt::GeometryOperator::getOutputGeo(unsigned outputIndex)
|
||||
geo::Geometry& enzo::nt::GeometryOperator::getOutputGeo(unsigned outputIndex) const
|
||||
{
|
||||
return opDef_->getOutputGeo(outputIndex);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
GeometryOperator& operator=(const GeometryOperator&) = delete;
|
||||
|
||||
void cookOp(op::Context context);
|
||||
geo::Geometry& getOutputGeo(unsigned outputIndex);
|
||||
geo::Geometry& getOutputGeo(unsigned outputIndex) const;
|
||||
|
||||
void addInputConnection(std::shared_ptr<nt::GeometryConnection> connection);
|
||||
void addOutputConnection(std::shared_ptr<nt::GeometryConnection> connection);
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
std::string getTypeName();
|
||||
|
||||
void dirtyNode(bool dirtyDescendents=true);
|
||||
bool isDirty();
|
||||
|
||||
|
||||
unsigned int getMinInputs() const;
|
||||
|
||||
Reference in New Issue
Block a user