diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-26 11:54:46 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-05-27 13:07:16 +0300 |
commit | 42cb1e3a2c4c708df4506b735d29b5841c07d960 (patch) | |
tree | 0aa8e9d2a9c0f7e9574b8c7ca5097edb3f5531e1 /intern/opensubdiv/internal/topology/mesh_topology_test.cc | |
parent | c971731b8f18a094aff0c2d8641681ffc9490806 (diff) |
OpenSubdiv: Optimize faces storage in mesh topology
Avoid per-face pointer and allocation: store everything as continuous
arrays.
Memory footprint for 1.5M faces:
- Theoretical worst case (all vertices and edges have crease) memory
goes down from 114 MiB to 96 MiB (15% improvement).
This case is not currently achievable since Blender does not expose
vertex crease yet.
- Current real life worst case (all edges have crease) memory goes
down from 108 MiB to 90 MiB (17% improvement).
- Best case (no creases at all) memory goes down from 96 MiB to 78 MiB
(19% improvement).
Diffstat (limited to 'intern/opensubdiv/internal/topology/mesh_topology_test.cc')
-rw-r--r-- | intern/opensubdiv/internal/topology/mesh_topology_test.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/intern/opensubdiv/internal/topology/mesh_topology_test.cc b/intern/opensubdiv/internal/topology/mesh_topology_test.cc index e80dab38fa3..5fb58c37add 100644 --- a/intern/opensubdiv/internal/topology/mesh_topology_test.cc +++ b/intern/opensubdiv/internal/topology/mesh_topology_test.cc @@ -27,6 +27,7 @@ TEST(MeshTopology, TrivialVertexSharpness) MeshTopology mesh_topology; mesh_topology.setNumVertices(3); + mesh_topology.finishResizeTopology(); mesh_topology.setVertexSharpness(0, 0.1f); mesh_topology.setVertexSharpness(1, 0.2f); @@ -42,6 +43,7 @@ TEST(MeshTopology, TrivialEdgeSharpness) mesh_topology.setNumVertices(8); mesh_topology.setNumEdges(3); + mesh_topology.finishResizeTopology(); mesh_topology.setEdgeVertexIndices(0, 0, 1); mesh_topology.setEdgeVertexIndices(1, 1, 2); @@ -60,29 +62,30 @@ TEST(MeshTopology, TrivialFaceTopology) MeshTopology mesh_topology; mesh_topology.setNumFaces(3); + mesh_topology.setNumFaceVertices(0, 4); + mesh_topology.setNumFaceVertices(1, 3); + mesh_topology.setNumFaceVertices(2, 5); + mesh_topology.finishResizeTopology(); + + EXPECT_EQ(mesh_topology.getNumFaceVertices(0), 4); + EXPECT_EQ(mesh_topology.getNumFaceVertices(1), 3); + EXPECT_EQ(mesh_topology.getNumFaceVertices(2), 5); { - mesh_topology.setNumFaceVertices(0, 4); int vertex_indices[] = {0, 1, 2, 3}; - mesh_topology.setFaceVertexIndices(0, vertex_indices); + mesh_topology.setFaceVertexIndices(0, 4, vertex_indices); } { - mesh_topology.setNumFaceVertices(1, 3); int vertex_indices[] = {4, 5, 6}; - mesh_topology.setFaceVertexIndices(1, vertex_indices); + mesh_topology.setFaceVertexIndices(1, 3, vertex_indices); } { - mesh_topology.setNumFaceVertices(2, 5); int vertex_indices[] = {7, 8, 9, 10, 11}; - mesh_topology.setFaceVertexIndices(2, vertex_indices); + mesh_topology.setFaceVertexIndices(2, 5, vertex_indices); } - EXPECT_EQ(mesh_topology.getNumFaceVertices(0), 4); - EXPECT_EQ(mesh_topology.getNumFaceVertices(1), 3); - EXPECT_EQ(mesh_topology.getNumFaceVertices(2), 5); - EXPECT_TRUE(mesh_topology.isFaceVertexIndicesEqual(0, {{0, 1, 2, 3}})); EXPECT_FALSE(mesh_topology.isFaceVertexIndicesEqual(0, {{10, 1, 2, 3}})); EXPECT_FALSE(mesh_topology.isFaceVertexIndicesEqual(0, {{0, 1, 2}})); |