Commit 6fbdc2c2 by Alisa Jung

Performance Boost for getPatchIndexBuffer? TODO Kai mess das mal

Conflicts: QTProject/subdivision.cpp
parent 02506fd3
...@@ -83,6 +83,7 @@ private: ...@@ -83,6 +83,7 @@ private:
/** /**
* @brief matchAndCompleteTriangle if vertices at indices tx ty matches vertices at indices sxsy, sysz or szsy, * @brief matchAndCompleteTriangle if vertices at indices tx ty matches vertices at indices sxsy, sysz or szsy,
* fill tz with third source vertex index. * fill tz with third source vertex index.
* both s(xyz) and t(xyz) are in SAME DIRECTION: matches sx with tx, sy with ty (..)
* @param sx source triangle: first vertex index * @param sx source triangle: first vertex index
* @param sy source triangle: second vertex index * @param sy source triangle: second vertex index
* @param sz source triangle: third vertex index * @param sz source triangle: third vertex index
...@@ -93,6 +94,7 @@ private: ...@@ -93,6 +94,7 @@ private:
* @return true if triangles could be matched and tz was filled. * @return true if triangles could be matched and tz was filled.
*/ */
bool matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz, QVector<Vertex> vb); bool matchAndCompleteTriangle(unsigned int sx, unsigned int sy, unsigned int sz, unsigned int tx, unsigned int ty, unsigned int &tz, QVector<Vertex> vb);
}; };
#endif #endif
...@@ -64,6 +64,11 @@ bool Triangle::get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const ...@@ -64,6 +64,11 @@ bool Triangle::get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const
return false; return false;
} }
bool Triangle::hasSharedEdge(Triangle other){
Edge a,b;
return get_shared_edge(other,a,b);
}
bool Triangle::get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_b) const { bool Triangle::get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_b) const {
if (u().samePos(other.u())) { if (u().samePos(other.u())) {
if (v().samePos(other.w())) { if (v().samePos(other.w())) {
...@@ -108,6 +113,21 @@ bool Triangle::get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_ ...@@ -108,6 +113,21 @@ bool Triangle::get_shared_edge_(const Triangle &other, Edge &edge_a, Edge &edge_
return false; return false;
} }
//e.g. first.name = uv, next.name = vw
bool Triangle::next_ctrclockwise(Edge first, Edge next) const{
return (first.name == Triangle::Edge::Name::uv &&
next.name == Triangle::Edge::Name::vw)
||(first.name == Triangle::Edge::Name::vw &&
next.name == Triangle::Edge::Name::wu)
||(first.name == Triangle::Edge::Name::wu &&
next.name == Triangle::Edge::Name::uv);
}
//e.g. first.name = vw, next.name = uv
bool Triangle::next_clockwise(Edge first, Edge next) const{
return next_ctrclockwise(next,first);
}
Triangle &Triangle::operator=(const Triangle &other) { Triangle &Triangle::operator=(const Triangle &other) {
this->vertex_buffer_ = other.vertex_buffer_; this->vertex_buffer_ = other.vertex_buffer_;
this->u_ = other.u_; this->u_ = other.u_;
......
...@@ -35,6 +35,8 @@ class Triangle { ...@@ -35,6 +35,8 @@ class Triangle {
bool get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const; bool get_shared_edge(Triangle other, Edge &edge_a, Edge &edge_b) const;
bool hasSharedEdge(Triangle other);
Triangle &operator=(const Triangle &other); Triangle &operator=(const Triangle &other);
// == and < both ignore the vertex buffer, they only compare indices. // == and < both ignore the vertex buffer, they only compare indices.
...@@ -42,6 +44,9 @@ class Triangle { ...@@ -42,6 +44,9 @@ class Triangle {
bool operator==(const Triangle &other) const; bool operator==(const Triangle &other) const;
bool operator<(const Triangle &other) const; bool operator<(const Triangle &other) const;
bool next_ctrclockwise(Edge first, Edge next) const;
bool next_clockwise(Edge first, Edge next) const;
private: private:
QVector<Vertex> vertex_buffer_; QVector<Vertex> vertex_buffer_;
unsigned int u_; unsigned int u_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment