Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2020-05-19 17:19:40 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-05-27 13:07:16 +0300
commita44440090060efe7e412e9ffcaec428dee84397f (patch)
tree69838de4172a6ee97153a805bf3819075a6dfe0f /intern/opensubdiv/internal/topology/mesh_topology.h
parent1e0de7c2ea74d0e390c8d306d70b46da1510d107 (diff)
OpenSubdiv: Keep explicit storage of base mesh faces
Allows to perform comparison by doing linear comparison of indices. Before cyclic match was used to deal with possibly changed winding from OpenSubdiv side. Speeds up comparison (and hence improves FPS), makes code more reliable nut uses more memory.
Diffstat (limited to 'intern/opensubdiv/internal/topology/mesh_topology.h')
-rw-r--r--intern/opensubdiv/internal/topology/mesh_topology.h49
1 files changed, 49 insertions, 0 deletions
diff --git a/intern/opensubdiv/internal/topology/mesh_topology.h b/intern/opensubdiv/internal/topology/mesh_topology.h
index 6edbc59b230..196d79c87df 100644
--- a/intern/opensubdiv/internal/topology/mesh_topology.h
+++ b/intern/opensubdiv/internal/topology/mesh_topology.h
@@ -19,6 +19,8 @@
#ifndef OPENSUBDIV_MESH_TOPOLOGY_H_
#define OPENSUBDIV_MESH_TOPOLOGY_H_
+#include <cstring>
+
#include "internal/base/memory.h"
#include "internal/base/type.h"
@@ -43,6 +45,37 @@ class EdgeTopology {
int v2 = -1;
};
+class FaceTopology {
+ public:
+ void setNumVertices(int num_vertices)
+ {
+ vertex_indices.resize(num_vertices, -1);
+ }
+
+ void setVertexIndices(int *face_vertex_indices)
+ {
+ memcpy(vertex_indices.data(), face_vertex_indices, sizeof(int) * vertex_indices.size());
+ }
+
+ bool isValid() const
+ {
+ for (int vertex_index : vertex_indices) {
+ if (vertex_index < 0) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ int getNumVertices() const
+ {
+ return vertex_indices.size();
+ }
+
+ vector<int> vertex_indices;
+};
+
class EdgeTopologyTag {
public:
float sharpness = 0.0f;
@@ -88,6 +121,19 @@ class MeshTopology {
float getEdgeSharpness(int edge_index) const;
//////////////////////////////////////////////////////////////////////////////
+ // Faces.
+
+ void setNumFaces(int num_faces);
+
+ int getNumFaces() const;
+
+ FaceTopology &getFace(int face_index);
+ const FaceTopology &getFace(int face_index) const;
+
+ void setNumFaceVertices(int face_index, int num_face_vertices);
+ void setFaceVertexIndices(int face_index, int *face_vertex_indices);
+
+ //////////////////////////////////////////////////////////////////////////////
// Comparison.
// Check whether this topology refiner defines same topology as the given
@@ -113,6 +159,9 @@ class MeshTopology {
vector<EdgeTopology> edges_;
vector<EdgeTopologyTag> edge_tags_;
+ int num_faces_;
+ vector<FaceTopology> faces_;
+
MEM_CXX_CLASS_ALLOC_FUNCS("MeshTopology");
};