fix: general optimization, lazy cooking, transform caching, fix geometry copying

This commit is contained in:
parker
2025-08-02 23:02:14 +01:00
parent 92bfc8ff26
commit 48ad8909cc
12 changed files with 104 additions and 62 deletions

View File

@@ -20,6 +20,7 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
if(outputRequested(0))
{
std::string filePath = "/home/parker/Downloads/Rat_Placeholder_Polycount_12.obj";
std::cout << "COOKING IMPORT NODE\n";
geo::Geometry geo;
@@ -59,31 +60,26 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
}
const bt::Vector3 pointPos = {std::stod(result[1]), std::stod(result[2]), std::stod(result[3])};
PAttrHandle.addValue(pointPos);
std::cout << "adding vector: " << pointPos.x() << " " << pointPos.y() << " " << pointPos.z() << "\n";
}
else if(firstChar=='f')
{
std::vector<std::string> result;
boost::split(result, line, isspace);
// if(result.size()<3)
// {
// continue;
if(result.size()<3)
{
continue;
// }
}
// set vertex attributes
std::cout << "connecting:";
for(int i=1; i<result.size(); ++i)
{
const int primNum = std::stoi(result[i]);
pointAttrHandle.addValue(primNum-1);
std::cout << " " << primNum;
}
std::cout << "\n";
// set face attribute
std::cout << "face size: " << result.size()-1 << "\n";
vertexCountHandle.addValue(result.size()-1);
}
@@ -98,15 +94,6 @@ void GopGeometryImport::cookOp(enzo::op::Context context)
enzo::bt::Vector3 pointPos = PAttrHandle.getValue(i);
pointPos*=scale;
PAttrHandle.setValue(i, pointPos);
std::cout << "adding point: " << pointPos.x() << " " << pointPos.y() << " " << pointPos.z() << "\n";
}
for(auto value : pointAttrHandle.getAllValues())
{
std::cout << "adding vector: " << value << "\n";
}
for(auto value : vertexCountHandle.getAllValues())
{
std::cout << "adding face: " << value << "\n";
}
// ----

View File

@@ -1,8 +1,10 @@
#include "OpDefs/GopTransform.hpp"
#include "Engine/Operator/AttributeHandle.h"
#include "Engine/Parameter/Template.h"
#include "Engine/Types.h"
#include <Eigen/src/Core/Matrix.h>
#include <Eigen/src/Geometry/AngleAxis.h>
#include <Eigen/src/Geometry/Transform.h>
GopTransform::GopTransform(enzo::nt::NetworkManager* network, enzo::op::OpInfo opInfo)
: GeometryOpDef(network, opInfo)
@@ -25,20 +27,18 @@ void GopTransform::cookOp(enzo::op::Context context)
auto PAttr = geo.getAttribByName(ga::AttrOwner::POINT, "P");
ga::AttributeHandleVector3 PAttrHandle(PAttr);
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
{
enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
Eigen::AngleAxisd rotationX(context.evalFloatParm("rotateX"), Eigen::Vector3d(1,0,0));
Eigen::AngleAxisd rotationY(context.evalFloatParm("rotateY"), Eigen::Vector3d(0,1,0));
Eigen::AngleAxisd rotationZ(context.evalFloatParm("rotateZ"), Eigen::Vector3d(0,0,1));
vector = (rotationX*rotationY*rotationZ)*vector;
vector.x()+=context.evalFloatParm("translateX");
vector.y()+=context.evalFloatParm("translateY");
vector.z()+=context.evalFloatParm("translateZ");
PAttrHandle.setValue(i, vector);
}
// ----
Eigen::Affine3d transform = Eigen::Affine3d::Identity();
transform.rotate(Eigen::AngleAxisd(context.evalFloatParm("rotateX"), Eigen::Vector3d(1,0,0)));
transform.rotate(Eigen::AngleAxisd(context.evalFloatParm("rotateY"), Eigen::Vector3d(0,1,0)));
transform.rotate(Eigen::AngleAxisd(context.evalFloatParm("rotateZ"), Eigen::Vector3d(0,0,1)));
transform.translate(bt::Vector3(context.evalFloatParm("translateX"), context.evalFloatParm("translateY"), context.evalFloatParm("translateZ")));
for(int i=0; i<PAttrHandle.getSize(); ++i)
{
enzo::bt::Vector3 pointPos = PAttrHandle.getValue(i);
pointPos = transform*pointPos;
PAttrHandle.setValue(i, pointPos);
}
// set output geometry