Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_lines.cc
| Show First 20 Lines • Show All 152 Lines • ▼ Show 20 Lines | static void extract_lines_finish(const MeshRenderData *UNUSED(mr), | ||||
| void *data) | void *data) | ||||
| { | { | ||||
| GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | ||||
| GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buf); | GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buf); | ||||
| GPU_indexbuf_build_in_place(elb, ibo); | GPU_indexbuf_build_in_place(elb, ibo); | ||||
| } | } | ||||
| static void extract_lines_init_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_lines_init_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *mr, | const MeshRenderData *UNUSED(mr), | ||||
| struct MeshBatchCache *UNUSED(cache), | struct MeshBatchCache *UNUSED(cache), | ||||
| void *buffer, | void *buffer, | ||||
| void *UNUSED(data)) | void *UNUSED(data)) | ||||
| { | { | ||||
| const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; | |||||
| GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); | GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); | ||||
| GPU_indexbuf_init_build_on_device(ibo, | GPU_indexbuf_init_build_on_device(ibo, | ||||
| subdiv_cache->num_subdiv_loops * 2 + mr->edge_loose_len * 2); | subdiv_cache->num_subdiv_loops * 2 + loose_geom.edge_len * 2); | ||||
| if (subdiv_cache->num_subdiv_loops == 0) { | |||||
| return; | |||||
| } | |||||
| draw_subdiv_build_lines_buffer(subdiv_cache, ibo); | draw_subdiv_build_lines_buffer(subdiv_cache, ibo); | ||||
| } | } | ||||
| static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | static void extract_lines_loose_geom_subdiv(const DRWSubdivCache *subdiv_cache, | ||||
| const MeshRenderData *UNUSED(mr), | const MeshRenderData *UNUSED(mr), | ||||
| const MeshExtractLooseGeom *loose_geom, | |||||
| void *buffer, | void *buffer, | ||||
| void *UNUSED(data)) | void *UNUSED(data)) | ||||
| { | { | ||||
| if (loose_geom->edge_len == 0) { | const DRWSubdivLooseGeom &loose_geom = subdiv_cache->loose_geom; | ||||
| if (loose_geom.edge_len == 0) { | |||||
| return; | return; | ||||
| } | } | ||||
| GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); | GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buffer); | ||||
| draw_subdiv_build_lines_loose_buffer(subdiv_cache, ibo, static_cast<uint>(loose_geom->edge_len)); | draw_subdiv_build_lines_loose_buffer(subdiv_cache, ibo, static_cast<uint>(loose_geom.edge_len)); | ||||
| } | } | ||||
| constexpr MeshExtract create_extractor_lines() | constexpr MeshExtract create_extractor_lines() | ||||
| { | { | ||||
| MeshExtract extractor = {nullptr}; | MeshExtract extractor = {nullptr}; | ||||
| extractor.init = extract_lines_init; | extractor.init = extract_lines_init; | ||||
| extractor.iter_poly_bm = extract_lines_iter_poly_bm; | extractor.iter_poly_bm = extract_lines_iter_poly_bm; | ||||
| extractor.iter_poly_mesh = extract_lines_iter_poly_mesh; | extractor.iter_poly_mesh = extract_lines_iter_poly_mesh; | ||||
| Show All 33 Lines | static void extract_lines_with_lines_loose_finish(const MeshRenderData *mr, | ||||
| void *data) | void *data) | ||||
| { | { | ||||
| GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | GPUIndexBufBuilder *elb = static_cast<GPUIndexBufBuilder *>(data); | ||||
| GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buf); | GPUIndexBuf *ibo = static_cast<GPUIndexBuf *>(buf); | ||||
| GPU_indexbuf_build_in_place(elb, ibo); | GPU_indexbuf_build_in_place(elb, ibo); | ||||
| extract_lines_loose_subbuffer(mr, cache); | extract_lines_loose_subbuffer(mr, cache); | ||||
| } | } | ||||
| static void extract_lines_with_lines_loose_finish_subdiv(const struct DRWSubdivCache *subdiv_cache, | |||||
| const MeshRenderData *UNUSED(mr), | |||||
| struct MeshBatchCache *cache, | |||||
| void *UNUSED(buf), | |||||
| void *UNUSED(_data)) | |||||
| { | |||||
| /* Multiply by 2 because these are edges indices. */ | |||||
| const int start = subdiv_cache->num_subdiv_loops * 2; | |||||
| const int len = subdiv_cache->loose_geom.edge_len * 2; | |||||
| GPU_indexbuf_create_subrange_in_place( | |||||
| cache->final.buff.ibo.lines_loose, cache->final.buff.ibo.lines, start, len); | |||||
| cache->no_loose_wire = (len == 0); | |||||
| } | |||||
| constexpr MeshExtract create_extractor_lines_with_lines_loose() | constexpr MeshExtract create_extractor_lines_with_lines_loose() | ||||
| { | { | ||||
| MeshExtract extractor = {nullptr}; | MeshExtract extractor = {nullptr}; | ||||
| extractor.init = extract_lines_init; | extractor.init = extract_lines_init; | ||||
| extractor.iter_poly_bm = extract_lines_iter_poly_bm; | extractor.iter_poly_bm = extract_lines_iter_poly_bm; | ||||
| extractor.iter_poly_mesh = extract_lines_iter_poly_mesh; | extractor.iter_poly_mesh = extract_lines_iter_poly_mesh; | ||||
| extractor.iter_ledge_bm = extract_lines_iter_ledge_bm; | extractor.iter_ledge_bm = extract_lines_iter_ledge_bm; | ||||
| extractor.iter_ledge_mesh = extract_lines_iter_ledge_mesh; | extractor.iter_ledge_mesh = extract_lines_iter_ledge_mesh; | ||||
| extractor.task_reduce = extract_lines_task_reduce; | extractor.task_reduce = extract_lines_task_reduce; | ||||
| extractor.finish = extract_lines_with_lines_loose_finish; | extractor.finish = extract_lines_with_lines_loose_finish; | ||||
| extractor.init_subdiv = extract_lines_init_subdiv; | |||||
| extractor.iter_loose_geom_subdiv = extract_lines_loose_geom_subdiv; | |||||
| extractor.finish_subdiv = extract_lines_with_lines_loose_finish_subdiv; | |||||
| extractor.data_type = MR_DATA_NONE; | extractor.data_type = MR_DATA_NONE; | ||||
| extractor.data_size = sizeof(GPUIndexBufBuilder); | extractor.data_size = sizeof(GPUIndexBufBuilder); | ||||
| extractor.use_threading = true; | extractor.use_threading = true; | ||||
| extractor.mesh_buffer_offset = offsetof(MeshBufferList, ibo.lines); | extractor.mesh_buffer_offset = offsetof(MeshBufferList, ibo.lines); | ||||
| return extractor; | return extractor; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| /** \name Extract Loose Edges Sub Buffer | /** \name Extract Loose Edges Sub Buffer | ||||
| * \{ */ | * \{ */ | ||||
| static void extract_lines_loose_only_init(const MeshRenderData *mr, | static void extract_lines_loose_only_init(const MeshRenderData *mr, | ||||
| struct MeshBatchCache *cache, | struct MeshBatchCache *cache, | ||||
| void *buf, | void *buf, | ||||
| void *UNUSED(tls_data)) | void *UNUSED(tls_data)) | ||||
| { | { | ||||
| BLI_assert(buf == cache->final.buff.ibo.lines_loose); | BLI_assert(buf == cache->final.buff.ibo.lines_loose); | ||||
| UNUSED_VARS_NDEBUG(buf); | UNUSED_VARS_NDEBUG(buf); | ||||
| extract_lines_loose_subbuffer(mr, cache); | extract_lines_loose_subbuffer(mr, cache); | ||||
| } | } | ||||
| static void extract_lines_loose_only_init_subdiv(const DRWSubdivCache *UNUSED(subdiv_cache), | |||||
| const MeshRenderData *mr, | |||||
| struct MeshBatchCache *cache, | |||||
| void *buffer, | |||||
| void *UNUSED(data)) | |||||
| { | |||||
| BLI_assert(buffer == cache->final.buff.ibo.lines_loose); | |||||
| UNUSED_VARS_NDEBUG(buffer); | |||||
| extract_lines_loose_subbuffer(mr, cache); | |||||
| } | |||||
| constexpr MeshExtract create_extractor_lines_loose_only() | constexpr MeshExtract create_extractor_lines_loose_only() | ||||
| { | { | ||||
| MeshExtract extractor = {nullptr}; | MeshExtract extractor = {nullptr}; | ||||
| extractor.init = extract_lines_loose_only_init; | extractor.init = extract_lines_loose_only_init; | ||||
| extractor.init_subdiv = extract_lines_loose_only_init_subdiv; | |||||
| extractor.data_type = MR_DATA_LOOSE_GEOM; | extractor.data_type = MR_DATA_LOOSE_GEOM; | ||||
| extractor.data_size = 0; | extractor.data_size = 0; | ||||
| extractor.use_threading = false; | extractor.use_threading = false; | ||||
| extractor.mesh_buffer_offset = offsetof(MeshBufferList, ibo.lines_loose); | extractor.mesh_buffer_offset = offsetof(MeshBufferList, ibo.lines_loose); | ||||
| return extractor; | return extractor; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Show All 9 Lines | |||||