diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-10-04 19:49:39 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-10-04 20:00:57 +0300 |
commit | 8f1f756b839942531c69a7608c25ea85de1beb8a (patch) | |
tree | 9c9cb3d03598521ae1f8ef753b3cd1dcb0b4dadd /source/blender/blenkernel/BKE_subdiv_ccg.h | |
parent | bebdb6c8249939623f80cc72433aa7d7418444bf (diff) |
Subdiv CCG: add utility functions for accessing multires vertex neighbors
This is to be used by the new sculpting tools.
Diffstat (limited to 'source/blender/blenkernel/BKE_subdiv_ccg.h')
-rw-r--r-- | source/blender/blenkernel/BKE_subdiv_ccg.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_subdiv_ccg.h b/source/blender/blenkernel/BKE_subdiv_ccg.h index 9b7c613aa94..6e2733eb1ac 100644 --- a/source/blender/blenkernel/BKE_subdiv_ccg.h +++ b/source/blender/blenkernel/BKE_subdiv_ccg.h @@ -131,6 +131,9 @@ typedef struct SubdivCCG { /* Resolution of grid. All grids have matching resolution, and resolution * is same as ptex created for non-quad polygons. */ int grid_size; + /* Size of a single element of a grid (including coordinate and all the other layers). + * Measured in bytes. */ + int grid_element_size; /* Grids represent limit surface, with displacement applied. Grids are * corresponding to face-corners of coarse mesh, each grid has * grid_size^2 elements. @@ -251,4 +254,43 @@ void BKE_subdiv_ccg_topology_counters(const SubdivCCG *subdiv_ccg, int *r_num_faces, int *r_num_loops); +typedef struct SubdivCCGCoord { + /* Index of the grid within SubdivCCG::grids array. */ + int grid_index; + + /* Coordinate within the grid. */ + int x, y; +} SubdivCCGCoord; + +typedef struct SubdivCCGNeighbors { + SubdivCCGCoord *coords; + int size; + + SubdivCCGCoord coords_fixed[256]; +} SubdivCCGNeighbors; + +void BKE_subdiv_ccg_print_coord(const char *message, const SubdivCCGCoord *coord); +bool BKE_subdiv_ccg_check_coord_valid(const SubdivCCG *subdiv_ccg, const SubdivCCGCoord *coord); + +/* CCG element neighbors. + * + * Neighbors are considered: + * + * - For an inner elements of a grid other elements which are sharing same row or column (4 + * neighbor elements in total). + * + * - For the corner element a single neighboring element on every adjacent edge, single from + * every gird. + * + * - For the boundary element two neighbor elements on the boundary (from same grid) and one + * element inside of every neighboring grid. */ + +/* Get actual neighbors of the given coordinate. + * + * SubdivCCGNeighbors.neighbors must be freed if it is not equal to + * SubdivCCGNeighbors.fixed_neighbors. */ +void BKE_subdiv_ccg_neighbor_coords_get(const SubdivCCG *subdiv_ccg, + const SubdivCCGCoord *coord, + SubdivCCGNeighbors *r_neighbors); + #endif /* __BKE_SUBDIV_CCG_H__ */ |