Differential D14171 Diff 48840 source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc
Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_points.cc
| Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | |||||
| static void extract_points_init_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_points_init_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *mr, | const MeshRenderData *mr, | ||||
| struct MeshBatchCache *UNUSED(cache), | struct MeshBatchCache *UNUSED(cache), | ||||
| void *UNUSED(buffer), | void *UNUSED(buffer), | ||||
| void *data) | void *data) | ||||
| { | { | ||||
| GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | ||||
| GPU_indexbuf_init( | GPU_indexbuf_init(elb, | ||||
| elb, GPU_PRIM_POINTS, mr->vert_len, subdiv_cache->num_subdiv_loops + mr->loop_loose_len); | GPU_PRIM_POINTS, | ||||
| mr->vert_len, | |||||
| subdiv_cache->num_subdiv_loops + subdiv_cache->loose_geom.loop_len); | |||||
| } | } | ||||
| static void extract_points_iter_subdiv_common(GPUIndexBufBuilder *elb, | static void extract_points_iter_subdiv_common(GPUIndexBufBuilder *elb, | ||||
| const MeshRenderData *mr, | const MeshRenderData *mr, | ||||
| const DRWSubdivCache *subdiv_cache, | const DRWSubdivCache *subdiv_cache, | ||||
| uint subdiv_quad_index) | uint subdiv_quad_index) | ||||
| { | { | ||||
| int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index); | int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index); | ||||
| Show All 31 Lines | static void extract_points_iter_subdiv_mesh(const DRWSubdivCache *subdiv_cache, | ||||
| const MPoly *UNUSED(coarse_quad)) | const MPoly *UNUSED(coarse_quad)) | ||||
| { | { | ||||
| GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_data); | GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(_data); | ||||
| extract_points_iter_subdiv_common(elb, mr, subdiv_cache, subdiv_quad_index); | extract_points_iter_subdiv_common(elb, mr, subdiv_cache, subdiv_quad_index); | ||||
| } | } | ||||
| static void extract_points_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_points_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *mr, | const MeshRenderData *mr, | ||||
| const MeshExtractLooseGeom *loose_geom, | |||||
| void *UNUSED(buffer), | void *UNUSED(buffer), | ||||
| void *data) | void *data) | ||||
| { | { | ||||
| const int loop_loose_len = loose_geom->edge_len + loose_geom->vert_len; | const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; | ||||
| const int loop_loose_len = loose_geom.loop_len; | |||||
| if (loop_loose_len == 0) { | if (loop_loose_len == 0) { | ||||
| return; | return; | ||||
| } | } | ||||
| GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | ||||
| uint offset = subdiv_cache->num_subdiv_loops; | uint offset = subdiv_cache->num_subdiv_loops; | ||||
| if (mr->extract_type == MR_EXTRACT_MESH) { | if (mr->extract_type != MR_EXTRACT_BMESH) { | ||||
| const Mesh *coarse_mesh = subdiv_cache->mesh; | blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges( | ||||
| const MEdge *coarse_edges = coarse_mesh->medge; | subdiv_cache); | ||||
| for (int i = 0; i < loose_geom->edge_len; i++) { | for (const DRWSubdivLooseEdge &loose_edge : loose_edges) { | ||||
| const MEdge *loose_edge = &coarse_edges[loose_geom->edges[i]]; | const DRWSubdivLooseVertex &v1 = loose_geom.verts[loose_edge.loose_subdiv_v1_index]; | ||||
| vert_set_mesh(elb, mr, loose_edge->v1, offset); | const DRWSubdivLooseVertex &v2 = loose_geom.verts[loose_edge.loose_subdiv_v2_index]; | ||||
| vert_set_mesh(elb, mr, loose_edge->v2, offset + 1); | if (v1.coarse_vertex_index != -1u) { | ||||
| vert_set_mesh(elb, mr, v1.coarse_vertex_index, offset); | |||||
| } | |||||
| if (v2.coarse_vertex_index != -1u) { | |||||
| vert_set_mesh(elb, mr, v2.coarse_vertex_index, offset + 1); | |||||
| } | |||||
| offset += 2; | offset += 2; | ||||
| } | } | ||||
| blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts( | |||||
| subdiv_cache); | |||||
| for (int i = 0; i < loose_geom->vert_len; i++) { | for (const DRWSubdivLooseVertex &loose_vert : loose_verts) { | ||||
| vert_set_mesh(elb, mr, loose_geom->verts[i], offset); | vert_set_mesh(elb, mr, loose_vert.coarse_vertex_index, offset); | ||||
| offset += 1; | offset += 1; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| BMesh *bm = mr->bm; | blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges( | ||||
| for (int i = 0; i < loose_geom->edge_len; i++) { | subdiv_cache); | ||||
| const BMEdge *loose_edge = BM_edge_at_index(bm, loose_geom->edges[i]); | |||||
| vert_set_bm(elb, loose_edge->v1, offset); | for (const DRWSubdivLooseEdge &loose_edge : loose_edges) { | ||||
| vert_set_bm(elb, loose_edge->v2, offset + 1); | const DRWSubdivLooseVertex &v1 = loose_geom.verts[loose_edge.loose_subdiv_v1_index]; | ||||
| const DRWSubdivLooseVertex &v2 = loose_geom.verts[loose_edge.loose_subdiv_v2_index]; | |||||
| if (v1.coarse_vertex_index != -1u) { | |||||
| BMVert *eve = mr->v_origindex ? bm_original_vert_get(mr, v1.coarse_vertex_index) : | |||||
| BM_vert_at_index(mr->bm, v1.coarse_vertex_index); | |||||
| vert_set_bm(elb, eve, offset); | |||||
| } | |||||
| if (v2.coarse_vertex_index != -1u) { | |||||
| BMVert *eve = mr->v_origindex ? bm_original_vert_get(mr, v2.coarse_vertex_index) : | |||||
| BM_vert_at_index(mr->bm, v2.coarse_vertex_index); | |||||
| vert_set_bm(elb, eve, offset + 1); | |||||
| } | |||||
| offset += 2; | offset += 2; | ||||
| } | } | ||||
| blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts( | |||||
| subdiv_cache); | |||||
| for (int i = 0; i < loose_geom->vert_len; i++) { | for (const DRWSubdivLooseVertex &loose_vert : loose_verts) { | ||||
| const BMVert *loose_vert = BM_vert_at_index(bm, loose_geom->verts[i]); | BMVert *eve = mr->v_origindex ? bm_original_vert_get(mr, loose_vert.coarse_vertex_index) : | ||||
| vert_set_bm(elb, loose_vert, offset); | BM_vert_at_index(mr->bm, loose_vert.coarse_vertex_index); | ||||
| vert_set_bm(elb, eve, offset); | |||||
| offset += 1; | offset += 1; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void extract_points_finish_subdiv(const DRWSubdivCache *UNUSED(subdiv_cache), | static void extract_points_finish_subdiv(const DRWSubdivCache *UNUSED(subdiv_cache), | ||||
| const MeshRenderData *UNUSED(mr), | const MeshRenderData *UNUSED(mr), | ||||
| struct MeshBatchCache *UNUSED(cache), | struct MeshBatchCache *UNUSED(cache), | ||||
| Show All 39 Lines | |||||