diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-20 12:45:22 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2018-09-20 16:39:41 +0300 |
commit | 8196b9d7bcab5557f71a87c4bf334cc8ae099cd6 (patch) | |
tree | 1fc29f24e22d83708a706e4ab50289b8ad87ca39 | |
parent | 069fa8279d7057ba937d87093364cfc943040c5c (diff) |
OpenSubdiv: Add extra base level queries to topology refiner
-rw-r--r-- | intern/opensubdiv/internal/opensubdiv_topology_refiner.cc | 50 | ||||
-rw-r--r-- | intern/opensubdiv/opensubdiv_topology_refiner_capi.h | 15 |
2 files changed, 65 insertions, 0 deletions
diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc index e334a4b0871..6ac8a67e3e6 100644 --- a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc +++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc @@ -64,6 +64,14 @@ int getNumFaces(const OpenSubdiv_TopologyRefiner* topology_refiner) { //////////////////////////////////////////////////////////////////////////////// // PTex face geometry queries. +static void convertArrayToRaw( + const OpenSubdiv::Far::ConstIndexArray& array, + int* raw_array) { + for (int i = 0; i < array.size(); ++i) { + raw_array[i] = array[i]; + } +} + int getNumFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, const int face_index) { const OpenSubdiv::Far::TopologyLevel* base_level = @@ -71,6 +79,44 @@ int getNumFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, return base_level->GetFaceVertices(face_index).size(); } +void getFaceVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + int* face_vertices_indices) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + OpenSubdiv::Far::ConstIndexArray array = + base_level->GetFaceVertices(face_index); + convertArrayToRaw(array, face_vertices_indices); +} + +int getNumFaceEdges(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + return base_level->GetFaceEdges(face_index).size(); +} + +void getFaceEdges(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + int* face_edges_indices) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + OpenSubdiv::Far::ConstIndexArray array = base_level->GetFaceEdges(face_index); + convertArrayToRaw(array, face_edges_indices); +} + +void getEdgeVertices(const OpenSubdiv_TopologyRefiner* topology_refiner, + const int edge_index, + int edge_vertices_indices[2]) { + const OpenSubdiv::Far::TopologyLevel* base_level = + getOSDTopologyBaseLevel(topology_refiner); + OpenSubdiv::Far::ConstIndexArray array = + base_level->GetEdgeVertices(edge_index); + assert(array.size() == 2); + edge_vertices_indices[0] = array[0]; + edge_vertices_indices[1] = array[1]; +} + int getNumFacePtexFaces(const OpenSubdiv_TopologyRefiner* topology_refiner, const int face_index) { const int num_face_vertices = @@ -147,6 +193,10 @@ void assignFunctionPointers(OpenSubdiv_TopologyRefiner* topology_refiner) { topology_refiner->getNumEdges = getNumEdges; topology_refiner->getNumFaces = getNumFaces; topology_refiner->getNumFaceVertices = getNumFaceVertices; + topology_refiner->getFaceVertices = getFaceVertices; + topology_refiner->getNumFaceEdges = getNumFaceEdges; + topology_refiner->getFaceEdges = getFaceEdges; + topology_refiner->getEdgeVertices = getEdgeVertices; // PTex face geometry. topology_refiner->getNumFacePtexFaces = getNumFacePtexFaces; topology_refiner->getNumPtexFaces = getNumPtexFaces; diff --git a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h index fe4db0ca67c..771eb8d62a8 100644 --- a/intern/opensubdiv/opensubdiv_topology_refiner_capi.h +++ b/intern/opensubdiv/opensubdiv_topology_refiner_capi.h @@ -66,6 +66,21 @@ typedef struct OpenSubdiv_TopologyRefiner { int (*getNumFaceVertices)( const struct OpenSubdiv_TopologyRefiner* topology_refiner, const int face_index); + void (*getFaceVertices)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + int* face_vertices_indices); + int (*getNumFaceEdges)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index); + void (*getFaceEdges)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int face_index, + int* face_edges_indices); + void (*getEdgeVertices)( + const struct OpenSubdiv_TopologyRefiner* topology_refiner, + const int edge_index, + int edge_vertices_indices[2]); ////////////////////////////////////////////////////////////////////////////// // PTex face geometry queries. |