feat: only render solo points
This commit is contained in:
@@ -30,7 +30,10 @@ geo::Geometry::Geometry(const Geometry& other):
|
|||||||
vertexCountHandlePrim_{enzo::ga::AttributeHandleInt(getAttribByName(ga::AttrOwner::PRIMITIVE, "vertexCount"))},
|
vertexCountHandlePrim_{enzo::ga::AttributeHandleInt(getAttribByName(ga::AttrOwner::PRIMITIVE, "vertexCount"))},
|
||||||
closedHandlePrim_{enzo::ga::AttributeHandleBool(getAttribByName(ga::AttrOwner::PRIMITIVE, "closed"))},
|
closedHandlePrim_{enzo::ga::AttributeHandleBool(getAttribByName(ga::AttrOwner::PRIMITIVE, "closed"))},
|
||||||
pointOffsetHandleVert_{enzo::ga::AttributeHandleInt(getAttribByName(ga::AttrOwner::VERTEX, "point"))},
|
pointOffsetHandleVert_{enzo::ga::AttributeHandleInt(getAttribByName(ga::AttrOwner::VERTEX, "point"))},
|
||||||
posHandlePoint_{enzo::ga::AttributeHandleVector3(getAttribByName(ga::AttrOwner::POINT, "P"))}
|
posHandlePoint_{enzo::ga::AttributeHandleVector3(getAttribByName(ga::AttrOwner::POINT, "P"))},
|
||||||
|
|
||||||
|
// other
|
||||||
|
soloPoints_{other.soloPoints_}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -40,6 +43,7 @@ void geo::Geometry::addFace(std::vector<ga::Offset> pointOffsets, bool closed)
|
|||||||
for(ga::Offset pointOffset : pointOffsets)
|
for(ga::Offset pointOffset : pointOffsets)
|
||||||
{
|
{
|
||||||
pointOffsetHandleVert_.addValue(pointOffset);
|
pointOffsetHandleVert_.addValue(pointOffset);
|
||||||
|
soloPoints_.erase(pointOffset);
|
||||||
}
|
}
|
||||||
vertexCountHandlePrim_.addValue(pointOffsets.size());
|
vertexCountHandlePrim_.addValue(pointOffsets.size());
|
||||||
closedHandlePrim_.addValue(closed);
|
closedHandlePrim_.addValue(closed);
|
||||||
@@ -49,10 +53,29 @@ void geo::Geometry::addFace(std::vector<ga::Offset> pointOffsets, bool closed)
|
|||||||
void geo::Geometry::addPoint(const bt::Vector3& pos)
|
void geo::Geometry::addPoint(const bt::Vector3& pos)
|
||||||
{
|
{
|
||||||
posHandlePoint_.addValue(pos);
|
posHandlePoint_.addValue(pos);
|
||||||
|
soloPoints_.emplace(posHandlePoint_.getSize()-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
ga::Offset geo::Geometry::getNumSoloPoints() const
|
||||||
|
{
|
||||||
|
return soloPoints_.size();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::set<ga::Offset>::const_iterator geo::Geometry::soloPointsBegin()
|
||||||
|
{
|
||||||
|
return soloPoints_.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::set<ga::Offset>::const_iterator geo::Geometry::soloPointsEnd()
|
||||||
|
{
|
||||||
|
return soloPoints_.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bt::Vector3 geo::Geometry::getPosFromVert(ga::Offset vertexOffset) const
|
bt::Vector3 geo::Geometry::getPosFromVert(ga::Offset vertexOffset) const
|
||||||
{
|
{
|
||||||
// get point offset
|
// get point offset
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ public:
|
|||||||
void addFace(std::vector<ga::Offset> pointOffsets, bool closed=true);
|
void addFace(std::vector<ga::Offset> pointOffsets, bool closed=true);
|
||||||
void addPoint(const bt::Vector3& pos);
|
void addPoint(const bt::Vector3& pos);
|
||||||
|
|
||||||
|
std::set<ga::Offset>::const_iterator soloPointsBegin();
|
||||||
|
std::set<ga::Offset>::const_iterator soloPointsEnd();
|
||||||
|
|
||||||
void setPointPos(const ga::Offset offset, const bt::Vector3& pos);
|
void setPointPos(const ga::Offset offset, const bt::Vector3& pos);
|
||||||
|
|
||||||
ga::Offset getPrimStartVertex(ga::Offset primOffset) const; // returns the first vertex of the primitive
|
ga::Offset getPrimStartVertex(ga::Offset primOffset) const; // returns the first vertex of the primitive
|
||||||
@@ -43,6 +46,7 @@ public:
|
|||||||
ga::Offset getNumPrims() const;
|
ga::Offset getNumPrims() const;
|
||||||
ga::Offset getNumVerts() const;
|
ga::Offset getNumVerts() const;
|
||||||
ga::Offset getNumPoints() const;
|
ga::Offset getNumPoints() const;
|
||||||
|
ga::Offset getNumSoloPoints() const;
|
||||||
|
|
||||||
bt::boolT isClosed(ga::Offset primOffset) const;
|
bt::boolT isClosed(ga::Offset primOffset) const;
|
||||||
|
|
||||||
@@ -58,6 +62,8 @@ private:
|
|||||||
attribVector primitiveAttributes_;
|
attribVector primitiveAttributes_;
|
||||||
attribVector globalAttributes_;
|
attribVector globalAttributes_;
|
||||||
|
|
||||||
|
std::set<ga::Offset> soloPoints_;
|
||||||
|
|
||||||
std::vector<ga::Offset> primStarts_;
|
std::vector<ga::Offset> primStarts_;
|
||||||
|
|
||||||
// handles
|
// handles
|
||||||
|
|||||||
@@ -10,9 +10,6 @@
|
|||||||
#include "Gui/Viewport/GLCamera.h"
|
#include "Gui/Viewport/GLCamera.h"
|
||||||
#include "icecream.hpp"
|
#include "icecream.hpp"
|
||||||
|
|
||||||
#define GLM_ENABLE_EXPERIMENTAL
|
|
||||||
#include <glm/gtx/norm.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
GLPoints::GLPoints()
|
GLPoints::GLPoints()
|
||||||
{
|
{
|
||||||
@@ -61,17 +58,23 @@ void GLPoints::initBuffers()
|
|||||||
|
|
||||||
void GLPoints::setPoints(enzo::geo::Geometry& geometry, GLCamera& camera)
|
void GLPoints::setPoints(enzo::geo::Geometry& geometry, GLCamera& camera)
|
||||||
{
|
{
|
||||||
const enzo::ga::Offset numPoints = geometry.getNumPoints();
|
const enzo::ga::Offset numPoints = geometry.getNumSoloPoints();
|
||||||
const glm::vec3 camPosGlm = camera.getPos();
|
const glm::vec3 camPosGlm = camera.getPos();
|
||||||
const enzo::bt::Vector3 camPos(camPosGlm.x, camPosGlm.y, camPosGlm.z);
|
const enzo::bt::Vector3 camPos(camPosGlm.x, camPosGlm.y, camPosGlm.z);
|
||||||
|
|
||||||
points_ = std::vector<Point>(numPoints);
|
points_ = std::vector<Point>(numPoints);
|
||||||
|
|
||||||
for(enzo::ga::Offset ptOffset=0; ptOffset<numPoints; ++ptOffset)
|
std::vector<enzo::ga::Offset> soloPoints = {geometry.soloPointsBegin(), geometry.soloPointsEnd()};
|
||||||
|
|
||||||
|
tbb::parallel_for(tbb::blocked_range<enzo::ga::Offset>(0, numPoints), [&](tbb::blocked_range<enzo::ga::Offset> range)
|
||||||
{
|
{
|
||||||
const enzo::bt::Vector3 pos = geometry.getPointPos(ptOffset);
|
for(enzo::ga::Offset i=range.begin(); i<range.end(); ++i)
|
||||||
points_[ptOffset] = {glm::vec3(pos.x(), pos.y(), pos.z()), static_cast<float>((pos-camPos).norm())*0.005f};
|
{
|
||||||
}
|
const enzo::ga::Offset ptOffset = soloPoints[i];
|
||||||
|
const enzo::bt::Vector3 pos = geometry.getPointPos(ptOffset);
|
||||||
|
points_[i] = {glm::vec3(pos.x(), pos.y(), pos.z()), static_cast<float>((pos-camPos).norm())*0.005f};
|
||||||
|
}
|
||||||
|
});
|
||||||
pointCount = points_.size();
|
pointCount = points_.size();
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, pointDataBuffer_);
|
glBindBuffer(GL_ARRAY_BUFFER, pointDataBuffer_);
|
||||||
|
|||||||
Reference in New Issue
Block a user