Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/sculpt.c
| Show First 20 Lines • Show All 606 Lines • ▼ Show 20 Lines | for (int i = 0; i < ARRAY_SIZE(adj_v); i++) { | ||||
| const BMVert *v_other = adj_v[i]; | const BMVert *v_other = adj_v[i]; | ||||
| if (BM_elem_index_get(v_other) != (int)index) { | if (BM_elem_index_get(v_other) != (int)index) { | ||||
| sculpt_vertex_neighbor_add(iter, BM_elem_index_get(v_other)); | sculpt_vertex_neighbor_add(iter, BM_elem_index_get(v_other)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void sculpt_vertex_face_neighbors_get_faces(SculptSession *ss, | |||||
| int index, | |||||
| SculptVertexNeighborIter *iter) | |||||
| { | |||||
| MeshElemMap *vert_map = &ss->pmap[(int)index]; | |||||
| iter->size = 0; | |||||
| iter->num_duplicates = 0; | |||||
| iter->capacity = SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY; | |||||
| iter->neighbors = iter->neighbors_fixed; | |||||
| for (int i = 0; i < ss->pmap[index].count; i++) { | |||||
| const MPoly *p = &ss->mpoly[vert_map->indices[i]]; | |||||
| int j; | |||||
| MLoop *loopstart = &ss->mloop[p->loopstart]; | |||||
| for (j = 0; j < p->totloop; j++, loopstart++) { | |||||
| if (loopstart->v != (int)index) { | |||||
| sculpt_vertex_neighbor_add(iter, loopstart->v); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| static void sculpt_vertex_neighbors_get_faces(SculptSession *ss, | static void sculpt_vertex_neighbors_get_faces(SculptSession *ss, | ||||
| int index, | int index, | ||||
| SculptVertexNeighborIter *iter) | SculptVertexNeighborIter *iter) | ||||
| { | { | ||||
| MeshElemMap *vert_map = &ss->pmap[index]; | MeshElemMap *vert_map = &ss->pmap[index]; | ||||
| iter->size = 0; | iter->size = 0; | ||||
| iter->num_duplicates = 0; | iter->num_duplicates = 0; | ||||
| iter->capacity = SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY; | iter->capacity = SCULPT_VERTEX_NEIGHBOR_FIXED_CAPACITY; | ||||
| ▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | static void sculpt_vertex_neighbors_get_grids(SculptSession *ss, | ||||
| if (neighbors.coords != neighbors.coords_fixed) { | if (neighbors.coords != neighbors.coords_fixed) { | ||||
| MEM_freeN(neighbors.coords); | MEM_freeN(neighbors.coords); | ||||
| } | } | ||||
| } | } | ||||
| void SCULPT_vertex_neighbors_get(SculptSession *ss, | void SCULPT_vertex_neighbors_get(SculptSession *ss, | ||||
| const int index, | const int index, | ||||
| const bool include_duplicates, | const bool include_duplicates, | ||||
| const bool include_face_neighbors, | |||||
| SculptVertexNeighborIter *iter) | SculptVertexNeighborIter *iter) | ||||
| { | { | ||||
| switch (BKE_pbvh_type(ss->pbvh)) { | switch (BKE_pbvh_type(ss->pbvh)) { | ||||
| case PBVH_FACES: | case PBVH_FACES: | ||||
| if (include_face_neighbors) { | |||||
| sculpt_vertex_face_neighbors_get_faces(ss, index, iter); | |||||
| } | |||||
| else { | |||||
| sculpt_vertex_neighbors_get_faces(ss, index, iter); | sculpt_vertex_neighbors_get_faces(ss, index, iter); | ||||
| } | |||||
| return; | return; | ||||
| case PBVH_BMESH: | case PBVH_BMESH: | ||||
| sculpt_vertex_neighbors_get_bmesh(ss, index, iter); | sculpt_vertex_neighbors_get_bmesh(ss, index, iter); | ||||
| return; | return; | ||||
| case PBVH_GRIDS: | case PBVH_GRIDS: | ||||
| sculpt_vertex_neighbors_get_grids(ss, index, include_duplicates, iter); | sculpt_vertex_neighbors_get_grids(ss, index, include_duplicates, iter); | ||||
| return; | return; | ||||
| } | } | ||||
| Show All 34 Lines | switch (BKE_pbvh_type(ss->pbvh)) { | ||||
| case PBVH_GRIDS: | case PBVH_GRIDS: | ||||
| return true; | return true; | ||||
| } | } | ||||
| return true; | return true; | ||||
| } | } | ||||
| bool SCULPT_vertices_share_face(SculptSession *ss, const int v1, const int v2) | |||||
| { | |||||
| switch (BKE_pbvh_type(ss->pbvh)) { | |||||
| case PBVH_FACES: { | |||||
| const MeshElemMap *vert_map = &ss->pmap[v1]; | |||||
| for (int i = 0; i < vert_map->count; i++) { | |||||
| const MPoly *p = &ss->mpoly[vert_map->indices[i]]; | |||||
| MLoop *loopstart = &ss->mloop[p->loopstart]; | |||||
| for (int j = 0; j < p->totloop; j++, loopstart++) { | |||||
| if (loopstart->v == (unsigned int)v2) { | |||||
| return true; | |||||
| } | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| case PBVH_BMESH: { | |||||
| return false; | |||||
| } | |||||
| case PBVH_GRIDS: { | |||||
| return false; | |||||
| } | |||||
| } | |||||
| return false; | |||||
| } | |||||
| /* Utils */ | /* Utils */ | ||||
| bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm) | bool SCULPT_check_vertex_pivot_symmetry(const float vco[3], const float pco[3], const char symm) | ||||
| { | { | ||||
| bool is_in_symmetry_area = true; | bool is_in_symmetry_area = true; | ||||
| for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
| char symm_it = 1 << i; | char symm_it = 1 << i; | ||||
| if (symm & symm_it) { | if (symm & symm_it) { | ||||
| if (pco[i] == 0.0f) { | if (pco[i] == 0.0f) { | ||||
| ▲ Show 20 Lines • Show All 7,173 Lines • Show Last 20 Lines | |||||