Differential D16893 Diff 59975 source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_edge_fac.cc
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr, | static void extract_edge_fac_iter_poly_mesh(const MeshRenderData *mr, | ||||
| const MPoly *mp, | const MPoly *mp, | ||||
| const int mp_index, | const int mp_index, | ||||
| void *_data) | void *_data) | ||||
| { | { | ||||
| MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data); | MeshExtract_EdgeFac_Data *data = static_cast<MeshExtract_EdgeFac_Data *>(_data); | ||||
| const MLoop *mloop = mr->mloop; | |||||
| const int ml_index_end = mp->loopstart + mp->totloop; | const int ml_index_end = mp->loopstart + mp->totloop; | ||||
| for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) { | for (int ml_index = mp->loopstart; ml_index < ml_index_end; ml_index += 1) { | ||||
| const MLoop *ml = &mloop[ml_index]; | const int vert = mr->corner_verts[ml_index]; | ||||
| const int edge = mr->corner_edges[ml_index]; | |||||
| if (data->use_edge_render) { | if (data->use_edge_render) { | ||||
| const MEdge *med = &mr->medge[ml->e]; | const MEdge *med = &mr->medge[edge]; | ||||
| data->vbo_data[ml_index] = (med->flag & ME_EDGEDRAW) ? 255 : 0; | data->vbo_data[ml_index] = (med->flag & ME_EDGEDRAW) ? 255 : 0; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Count loop per edge to detect non-manifold. */ | /* Count loop per edge to detect non-manifold. */ | ||||
| if (data->edge_loop_count[ml->e] < 3) { | if (data->edge_loop_count[edge] < 3) { | ||||
| data->edge_loop_count[ml->e]++; | data->edge_loop_count[edge]++; | ||||
| } | } | ||||
| if (data->edge_loop_count[ml->e] == 2) { | if (data->edge_loop_count[edge] == 2) { | ||||
| /* Manifold */ | /* Manifold */ | ||||
| const int ml_index_last = mp->totloop + mp->loopstart - 1; | const int ml_index_last = mp->totloop + mp->loopstart - 1; | ||||
| const int ml_index_other = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1); | const int ml_index_other = (ml_index == ml_index_last) ? mp->loopstart : (ml_index + 1); | ||||
| const MLoop *ml_next = &mr->mloop[ml_index_other]; | const int vert_next = mr->corner_verts[ml_index_other]; | ||||
| float ratio = loop_edge_factor_get(mr->poly_normals[mp_index], | float ratio = loop_edge_factor_get(mr->poly_normals[mp_index], | ||||
| mr->vert_positions[ml->v], | mr->vert_positions[vert], | ||||
| mr->vert_normals[ml->v], | mr->vert_normals[vert], | ||||
| mr->vert_positions[ml_next->v]); | mr->vert_positions[vert_next]); | ||||
| data->vbo_data[ml_index] = ratio * 253 + 1; | data->vbo_data[ml_index] = ratio * 253 + 1; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Non-manifold */ | /* Non-manifold */ | ||||
| data->vbo_data[ml_index] = 255; | data->vbo_data[ml_index] = 255; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||