diff --git a/src/Engine/Operator/Geometry.cpp b/src/Engine/Operator/Geometry.cpp index 8f2a72d..a3e1cdc 100644 --- a/src/Engine/Operator/Geometry.cpp +++ b/src/Engine/Operator/Geometry.cpp @@ -30,7 +30,10 @@ geo::Geometry::Geometry(const Geometry& other): vertexCountHandlePrim_{enzo::ga::AttributeHandleInt(getAttribByName(ga::AttrOwner::PRIMITIVE, "vertexCount"))}, closedHandlePrim_{enzo::ga::AttributeHandleBool(getAttribByName(ga::AttrOwner::PRIMITIVE, "closed"))}, 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 pointOffsets, bool closed) for(ga::Offset pointOffset : pointOffsets) { pointOffsetHandleVert_.addValue(pointOffset); + soloPoints_.erase(pointOffset); } vertexCountHandlePrim_.addValue(pointOffsets.size()); closedHandlePrim_.addValue(closed); @@ -49,10 +53,29 @@ void geo::Geometry::addFace(std::vector pointOffsets, bool closed) void geo::Geometry::addPoint(const bt::Vector3& pos) { posHandlePoint_.addValue(pos); + soloPoints_.emplace(posHandlePoint_.getSize()-1); +} + +ga::Offset geo::Geometry::getNumSoloPoints() const +{ + return soloPoints_.size(); } + +std::set::const_iterator geo::Geometry::soloPointsBegin() +{ + return soloPoints_.begin(); +} + +std::set::const_iterator geo::Geometry::soloPointsEnd() +{ + return soloPoints_.end(); +} + + + bt::Vector3 geo::Geometry::getPosFromVert(ga::Offset vertexOffset) const { // get point offset diff --git a/src/Engine/Operator/Geometry.h b/src/Engine/Operator/Geometry.h index e865149..5d9516a 100644 --- a/src/Engine/Operator/Geometry.h +++ b/src/Engine/Operator/Geometry.h @@ -34,6 +34,9 @@ public: void addFace(std::vector pointOffsets, bool closed=true); void addPoint(const bt::Vector3& pos); + std::set::const_iterator soloPointsBegin(); + std::set::const_iterator soloPointsEnd(); + void setPointPos(const ga::Offset offset, const bt::Vector3& pos); 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 getNumVerts() const; ga::Offset getNumPoints() const; + ga::Offset getNumSoloPoints() const; bt::boolT isClosed(ga::Offset primOffset) const; @@ -58,6 +62,8 @@ private: attribVector primitiveAttributes_; attribVector globalAttributes_; + std::set soloPoints_; + std::vector primStarts_; // handles diff --git a/src/Gui/Viewport/GLPoints.cpp b/src/Gui/Viewport/GLPoints.cpp index c5d7fd1..89f9e97 100644 --- a/src/Gui/Viewport/GLPoints.cpp +++ b/src/Gui/Viewport/GLPoints.cpp @@ -10,9 +10,6 @@ #include "Gui/Viewport/GLCamera.h" #include "icecream.hpp" -#define GLM_ENABLE_EXPERIMENTAL -#include - GLPoints::GLPoints() { @@ -61,17 +58,23 @@ void GLPoints::initBuffers() 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 enzo::bt::Vector3 camPos(camPosGlm.x, camPosGlm.y, camPosGlm.z); points_ = std::vector(numPoints); - for(enzo::ga::Offset ptOffset=0; ptOffset soloPoints = {geometry.soloPointsBegin(), geometry.soloPointsEnd()}; + + tbb::parallel_for(tbb::blocked_range(0, numPoints), [&](tbb::blocked_range range) { - const enzo::bt::Vector3 pos = geometry.getPointPos(ptOffset); - points_[ptOffset] = {glm::vec3(pos.x(), pos.y(), pos.z()), static_cast((pos-camPos).norm())*0.005f}; - } + for(enzo::ga::Offset i=range.begin(); i((pos-camPos).norm())*0.005f}; + } + }); pointCount = points_.size(); glBindBuffer(GL_ARRAY_BUFFER, pointDataBuffer_);