feat: connect geometry position to GLMesh
This commit is contained in:
@@ -53,13 +53,19 @@ public:
|
||||
// TODO:make this private (primitive friend classes only)
|
||||
data_->push_back(value);
|
||||
}
|
||||
T getValue(uint pos)
|
||||
|
||||
std::vector<T> getData() const
|
||||
{
|
||||
return *data_;
|
||||
}
|
||||
|
||||
T getValue(uint pos) const
|
||||
{
|
||||
// TODO:protect against invalid positions
|
||||
// TODO: cast types
|
||||
return data_->at(pos);
|
||||
}
|
||||
std::string getName()
|
||||
std::string getName() const
|
||||
{
|
||||
return name_;
|
||||
}
|
||||
|
||||
@@ -8,17 +8,24 @@
|
||||
using namespace enzo;
|
||||
geo::Geometry::Geometry()
|
||||
{
|
||||
|
||||
addVector3Attribute(ga::AttrOwner::POINT, "P");
|
||||
}
|
||||
|
||||
ga::AttributeHandle<int> geo::Geometry::addIntAttribute(ga::AttributeOwner owner, std::string name)
|
||||
{
|
||||
auto newAttribute = std::make_shared<ga::Attribute>(name, ga::AttrType::intT);
|
||||
getOwnerVector(owner).push_back(newAttribute);
|
||||
getAttributeStore(owner).push_back(newAttribute);
|
||||
return ga::AttributeHandle<int>(newAttribute);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ga::Attribute>>& geo::Geometry::getOwnerVector(ga::AttributeOwner& owner)
|
||||
ga::AttributeHandle<bt::Vector3> geo::Geometry::addVector3Attribute(ga::AttributeOwner owner, std::string name)
|
||||
{
|
||||
auto newAttribute = std::make_shared<ga::Attribute>(name, ga::AttrType::vectorT);
|
||||
getAttributeStore(owner).push_back(newAttribute);
|
||||
return ga::AttributeHandle<bt::Vector3>(newAttribute);
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<ga::Attribute>>& geo::Geometry::getAttributeStore(ga::AttributeOwner& owner)
|
||||
{
|
||||
switch(owner)
|
||||
{
|
||||
@@ -42,7 +49,7 @@ std::vector<std::shared_ptr<ga::Attribute>>& geo::Geometry::getOwnerVector(ga::A
|
||||
|
||||
std::shared_ptr<ga::Attribute> geo::Geometry::getAttribByName(ga::AttributeOwner owner, std::string name)
|
||||
{
|
||||
auto& vector = getOwnerVector(owner);
|
||||
auto& vector = getAttributeStore(owner);
|
||||
for(auto it=vector.begin(); it!=vector.end(); ++it)
|
||||
{
|
||||
if((*it)->getName()==name)
|
||||
|
||||
@@ -10,10 +10,11 @@ class Geometry
|
||||
public:
|
||||
Geometry();
|
||||
ga::AttributeHandle<int> addIntAttribute(ga::AttributeOwner owner, std::string name);
|
||||
ga::AttributeHandle<bt::Vector3> addVector3Attribute(ga::AttributeOwner owner, std::string name);
|
||||
std::shared_ptr<ga::Attribute> getAttribByName(ga::AttributeOwner owner, std::string name);
|
||||
private:
|
||||
using attribVector = std::vector<std::shared_ptr<ga::Attribute>>;
|
||||
attribVector& getOwnerVector(ga::AttributeOwner& owner);
|
||||
attribVector& getAttributeStore(ga::AttributeOwner& owner);
|
||||
attribVector pointAttributes_;
|
||||
attribVector vertexAttributes_;
|
||||
attribVector primitiveAttributes_;
|
||||
|
||||
Reference in New Issue
Block a user