diff --git a/include/Algo/Geometry/boundingbox.h b/include/Algo/Geometry/boundingbox.h index b8a7d844d913c12837f60f24581da08778361a22..c953e3409524c9a1a709b3bc464de074456e2025 100644 --- a/include/Algo/Geometry/boundingbox.h +++ b/include/Algo/Geometry/boundingbox.h @@ -27,8 +27,10 @@ #include "Geometry/basic.h" #include "Geometry/bounding_box.h" +#include "Topology/generic/attributeHandler.h" #include "Topology/generic/traversorCell.h" + namespace CGoGN { diff --git a/include/Utils/drawer.h b/include/Utils/drawer.h index 56f619687bb745466d3554ab829cf028b4228dc2..a11698700298f06cb6bb643e43caa90e8b9853ef 100644 --- a/include/Utils/drawer.h +++ b/include/Utils/drawer.h @@ -106,13 +106,15 @@ public: /** * use as glVertex + * @return index of position for update */ - void vertex(const Geom::Vec3f& v); + unsigned int vertex(const Geom::Vec3f& v); /** * use as glVertex + * @return index of position for update */ - void vertex3f(float x, float y, float z); + unsigned int vertex3f(float x, float y, float z); /** * use as glColor @@ -139,6 +141,22 @@ public: */ void pointSize(float ps); + /** + * update position of VBO of drawer + * @param first index of vertex to update + * @param nb number of vertex tp update + * @param P ptr to table of vertices + */ + void updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P); + + /** + * update position of VBO of drawer + * @param first index of vertex to update + * @param nb number of vertex tp update + * @param P ptr to table of vertices + */ + void updatePositions(unsigned int first, unsigned int nb, const float* P); + /** * rendering in svg struct */ diff --git a/include/Utils/gl_matrices.h b/include/Utils/gl_matrices.h index 021c11062fb33bf21961ee008bd3d8e1b8066223..3f01488089c5757ac79c5e37ff37a652ceda118a 100644 --- a/include/Utils/gl_matrices.h +++ b/include/Utils/gl_matrices.h @@ -52,12 +52,18 @@ public: void popTransfo() { - if (m_stack.empty()) return; + if (m_stack.empty()) + return; m_matrices[2] = m_stack.top(); m_stack.pop(); } - glm::mat4 getTransfo() const + const glm::mat4& getTransfo() const + { + return m_matrices[2]; + } + + glm::mat4& getTransfo() { return m_matrices[2]; } @@ -82,6 +88,12 @@ public: m_matrices[2] = glm::scale(m_matrices[2], glm::vec3(s,s,s)); } + void apply (const glm::mat4& m) + { + m_matrices[2] = m * m_matrices[2]; + + } + }; diff --git a/src/Utils/drawer.cpp b/src/Utils/drawer.cpp index cdd2be8d6b011cb54b2409192e22499e4e53c01b..c44f65434074933b5534b30e824f192c8509496b 100644 --- a/src/Utils/drawer.cpp +++ b/src/Utils/drawer.cpp @@ -103,7 +103,7 @@ void Drawer::color3f(float r, float g, float b) color(Geom::Vec3f(r,g,b)); } -void Drawer::vertex(const Geom::Vec3f& v) +unsigned int Drawer::vertex(const Geom::Vec3f& v) { if (m_dataPos.size() == m_dataCol.size()) { @@ -112,13 +112,13 @@ void Drawer::vertex(const Geom::Vec3f& v) else m_dataCol.push_back( m_dataCol.back()); } - m_dataPos.push_back(v); + return m_dataPos.size()-1; } -void Drawer::vertex3f(float r, float g, float b) +unsigned int Drawer::vertex3f(float r, float g, float b) { - vertex(Geom::Vec3f(r,g,b)); + return vertex(Geom::Vec3f(r,g,b)); } void Drawer::newList(GLenum comp) @@ -152,6 +152,20 @@ void Drawer::endList() callList(); } + +void Drawer::updatePositions(unsigned int first, unsigned int nb, const Geom::Vec3f* P) +{ + m_vboPos->bind(); + glBufferSubData(GL_ARRAY_BUFFER, first * sizeof(Geom::Vec3f), nb * sizeof(Geom::Vec3f), P); +} + +void Drawer::updatePositions(unsigned int first, unsigned int nb, const float* P) +{ + m_vboPos->bind(); + glBufferSubData(GL_ARRAY_BUFFER, first * 3 * sizeof(float), nb * 3 * sizeof(float), P); +} + + void Drawer::callList() { if (m_begins.empty())