Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/subdiv_ccg.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| const int *BKE_subdiv_ccg_start_face_grid_index_get(const SubdivCCG *subdiv_ccg) | const int *BKE_subdiv_ccg_start_face_grid_index_get(const SubdivCCG *subdiv_ccg) | ||||
| { | { | ||||
| return subdiv_ccg->cache_.start_face_grid_index; | return subdiv_ccg->cache_.start_face_grid_index; | ||||
| } | } | ||||
| static void adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_ccg, | static void adjacet_vertices_index_from_adjacent_edge(const SubdivCCG *subdiv_ccg, | ||||
| const SubdivCCGCoord *coord, | const SubdivCCGCoord *coord, | ||||
| const MLoop *mloop, | const int *corner_verts, | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| int *r_v1, | int *r_v1, | ||||
| int *r_v2) | int *r_v2) | ||||
| { | { | ||||
| const int grid_size_1 = subdiv_ccg->grid_size - 1; | const int grid_size_1 = subdiv_ccg->grid_size - 1; | ||||
| const int poly_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, coord->grid_index); | const int poly_index = BKE_subdiv_ccg_grid_to_face_index(subdiv_ccg, coord->grid_index); | ||||
| const MPoly *p = &mpoly[poly_index]; | const MPoly *p = &mpoly[poly_index]; | ||||
| *r_v1 = mloop[coord->grid_index].v; | *r_v1 = corner_verts[coord->grid_index]; | ||||
| const int corner = poly_find_loop_from_vert(p, &mloop[p->loopstart], *r_v1); | const int corner = poly_find_loop_from_vert(p, &corner_verts[p->loopstart], *r_v1); | ||||
| if (coord->x == grid_size_1) { | if (coord->x == grid_size_1) { | ||||
| const MLoop *next = ME_POLY_LOOP_NEXT(mloop, p, corner); | const int next = ME_POLY_LOOP_NEXT(p, corner); | ||||
| *r_v2 = next->v; | *r_v2 = corner_verts[next]; | ||||
| } | } | ||||
| if (coord->y == grid_size_1) { | if (coord->y == grid_size_1) { | ||||
| const MLoop *prev = ME_POLY_LOOP_PREV(mloop, p, corner); | const int prev = ME_POLY_LOOP_PREV(p, corner); | ||||
| *r_v2 = prev->v; | *r_v2 = corner_verts[prev]; | ||||
| } | } | ||||
| } | } | ||||
| SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const SubdivCCG *subdiv_ccg, | SubdivCCGAdjacencyType BKE_subdiv_ccg_coarse_mesh_adjacency_info_get(const SubdivCCG *subdiv_ccg, | ||||
| const SubdivCCGCoord *coord, | const SubdivCCGCoord *coord, | ||||
| const MLoop *mloop, | const int *corner_verts, | ||||
| const MPoly *mpoly, | const MPoly *mpoly, | ||||
| int *r_v1, | int *r_v1, | ||||
| int *r_v2) | int *r_v2) | ||||
| { | { | ||||
| const int grid_size_1 = subdiv_ccg->grid_size - 1; | const int grid_size_1 = subdiv_ccg->grid_size - 1; | ||||
| if (is_corner_grid_coord(subdiv_ccg, coord)) { | if (is_corner_grid_coord(subdiv_ccg, coord)) { | ||||
| if (coord->x == 0 && coord->y == 0) { | if (coord->x == 0 && coord->y == 0) { | ||||
| /* Grid corner in the center of a poly. */ | /* Grid corner in the center of a poly. */ | ||||
| return SUBDIV_CCG_ADJACENT_NONE; | return SUBDIV_CCG_ADJACENT_NONE; | ||||
| } | } | ||||
| if (coord->x == grid_size_1 && coord->y == grid_size_1) { | if (coord->x == grid_size_1 && coord->y == grid_size_1) { | ||||
| /* Grid corner adjacent to a coarse mesh vertex. */ | /* Grid corner adjacent to a coarse mesh vertex. */ | ||||
| *r_v1 = *r_v2 = mloop[coord->grid_index].v; | *r_v1 = *r_v2 = corner_verts[coord->grid_index]; | ||||
| return SUBDIV_CCG_ADJACENT_VERTEX; | return SUBDIV_CCG_ADJACENT_VERTEX; | ||||
| } | } | ||||
| /* Grid corner adjacent to the middle of a coarse mesh edge. */ | /* Grid corner adjacent to the middle of a coarse mesh edge. */ | ||||
| adjacet_vertices_index_from_adjacent_edge(subdiv_ccg, coord, mloop, mpoly, r_v1, r_v2); | adjacet_vertices_index_from_adjacent_edge(subdiv_ccg, coord, corner_verts, mpoly, r_v1, r_v2); | ||||
| return SUBDIV_CCG_ADJACENT_EDGE; | return SUBDIV_CCG_ADJACENT_EDGE; | ||||
| } | } | ||||
| if (is_boundary_grid_coord(subdiv_ccg, coord)) { | if (is_boundary_grid_coord(subdiv_ccg, coord)) { | ||||
| if (!is_inner_edge_grid_coordinate(subdiv_ccg, coord)) { | if (!is_inner_edge_grid_coordinate(subdiv_ccg, coord)) { | ||||
| /* Grid boundary adjacent to a coarse mesh edge. */ | /* Grid boundary adjacent to a coarse mesh edge. */ | ||||
| adjacet_vertices_index_from_adjacent_edge(subdiv_ccg, coord, mloop, mpoly, r_v1, r_v2); | adjacet_vertices_index_from_adjacent_edge( | ||||
| subdiv_ccg, coord, corner_verts, mpoly, r_v1, r_v2); | |||||
| return SUBDIV_CCG_ADJACENT_EDGE; | return SUBDIV_CCG_ADJACENT_EDGE; | ||||
| } | } | ||||
| } | } | ||||
| return SUBDIV_CCG_ADJACENT_NONE; | return SUBDIV_CCG_ADJACENT_NONE; | ||||
| } | } | ||||
| void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index) | void BKE_subdiv_ccg_grid_hidden_ensure(SubdivCCG *subdiv_ccg, int grid_index) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines | |||||