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 13:38:52 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2020-05-27 13:07:16 +0300
commitece54172d001332ca9ea0f2046276b7d03547190 (patch)
treec38e9352b6f2828231caef60d3f15bfacccbdf78 /intern/opensubdiv/internal/topology/mesh_topology.h
parent16aef5dc4ae7d8dc0347fc6cd3787c17b71ed169 (diff)
OpenSubdiv: Use explicit storage for edge sharpness
Similar to previous change in vertex sharpness, explicitly store value provided by the converter. Allows to avoid rather fragile check for boundary edges. Also allows to avoid need in constructing edge map. This lowers memory footprint of the comparison process and avoids memory allocations during the comparison (which is an extra benefit from the performance point of view).
Diffstat (limited to 'intern/opensubdiv/internal/topology/mesh_topology.h')
-rw-r--r--intern/opensubdiv/internal/topology/mesh_topology.h41
1 files changed, 39 insertions, 2 deletions
diff --git a/intern/opensubdiv/internal/topology/mesh_topology.h b/intern/opensubdiv/internal/topology/mesh_topology.h
index 9893c70dac8..183f5eb45d4 100644
--- a/intern/opensubdiv/internal/topology/mesh_topology.h
+++ b/intern/opensubdiv/internal/topology/mesh_topology.h
@@ -27,7 +27,12 @@ struct OpenSubdiv_Converter;
namespace blender {
namespace opensubdiv {
-class VertexTopology {
+class VertexTopologyTag {
+ public:
+ float sharpness = 0.0f;
+};
+
+class EdgeTopologyTag {
public:
float sharpness = 0.0f;
};
@@ -45,12 +50,44 @@ class MeshTopology {
MeshTopology &operator=(const MeshTopology &other) = default;
MeshTopology &operator=(MeshTopology &&other) = default;
+ //////////////////////////////////////////////////////////////////////////////
+ // Vertices.
+
void setNumVertices(int num_vertices);
int getNumVertices() const;
void setVertexSharpness(int vertex_index, float sharpness);
+ float getVertexSharpness(int vertex_index) const;
+
+ //////////////////////////////////////////////////////////////////////////////
+ // Edges.
+
+ void setNumEdges(int num_edges);
+
+ // NOTE: Unless full topology was specified will return number of edges based
+ // on last edge index for which topology tag was specified.
+ int getNumEdges() const;
+
+ void setEdgeSharpness(int edge_index, float sharpness);
+ float getEdgeSharpness(int edge_index) const;
+
+ protected:
+ // Unless full topology was specified the number of edges is not know ahead
+ // of a time.
+ void ensureNumEdgesAtLeast(int num_edges);
+
+ // Geometry tags are stored sparsly.
+ //
+ // These functions ensures that the storage can be addressed by an index which
+ // corresponds to the given size.
+ void ensureVertexTagsSize(int num_vertices);
+ void ensureEdgeTagsSize(int num_edges);
+
+ int num_vertices_;
+ vector<VertexTopologyTag> vertex_tags_;
- vector<VertexTopology> vertices;
+ int num_edges_;
+ vector<EdgeTopologyTag> edge_tags_;
MEM_CXX_CLASS_ALLOC_FUNCS("MeshTopology");
};