Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/intern/draw_cache_impl_metaball.c
| Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | void DRW_mball_batch_cache_free(MetaBall *mb) | ||||
| MEM_SAFE_FREE(mb->batch_cache); | MEM_SAFE_FREE(mb->batch_cache); | ||||
| } | } | ||||
| static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBatchCache *cache) | static GPUVertBuf *mball_batch_cache_get_pos_and_normals(Object *ob, MetaBallBatchCache *cache) | ||||
| { | { | ||||
| if (cache->pos_nor_in_order == NULL) { | if (cache->pos_nor_in_order == NULL) { | ||||
| ListBase *lb = &ob->runtime.curve_cache->disp; | ListBase *lb = &ob->runtime.curve_cache->disp; | ||||
| cache->pos_nor_in_order = MEM_callocN(sizeof(GPUVertBuf), __func__); | cache->pos_nor_in_order = MEM_callocN(sizeof(GPUVertBuf), __func__); | ||||
| DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(lb, cache->pos_nor_in_order); | DRW_displist_vertbuf_create_pos_and_nor(lb, cache->pos_nor_in_order); | ||||
| } | } | ||||
| return cache->pos_nor_in_order; | return cache->pos_nor_in_order; | ||||
| } | } | ||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Public Object/MetaBall API | /** \name Public Object/MetaBall API | ||||
| * \{ */ | * \{ */ | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | GPUBatch *DRW_metaball_batch_cache_get_wireframes_face(Object *ob) | ||||
| } | } | ||||
| MetaBall *mb = ob->data; | MetaBall *mb = ob->data; | ||||
| MetaBallBatchCache *cache = metaball_batch_cache_get(mb); | MetaBallBatchCache *cache = metaball_batch_cache_get(mb); | ||||
| if (cache->face_wire.batch == NULL) { | if (cache->face_wire.batch == NULL) { | ||||
| ListBase *lb = &ob->runtime.curve_cache->disp; | ListBase *lb = &ob->runtime.curve_cache->disp; | ||||
| GPUVertBuf *vbo_pos_nor = MEM_callocN(sizeof(GPUVertBuf), __func__); | GPUVertBuf *vbo_wiredata = MEM_callocN(sizeof(GPUVertBuf), __func__); | ||||
| DRW_displist_vertbuf_create_pos_and_nor_and_wiredata(lb, vbo_pos_nor); | DRW_displist_vertbuf_create_wiredata(lb, vbo_wiredata); | ||||
| GPUIndexBuf *ibo = MEM_callocN(sizeof(GPUIndexBuf), __func__); | GPUIndexBuf *ibo = MEM_callocN(sizeof(GPUIndexBuf), __func__); | ||||
| DRW_displist_indexbuf_create_lines_in_order(lb, ibo); | DRW_displist_indexbuf_create_lines_in_order(lb, ibo); | ||||
| cache->face_wire.batch = GPU_batch_create_ex(GPU_PRIM_LINES, | cache->face_wire.batch = GPU_batch_create_ex( | ||||
| vbo_pos_nor, | GPU_PRIM_LINES, | ||||
| mball_batch_cache_get_pos_and_normals(ob, cache), | |||||
| ibo, | ibo, | ||||
| GPU_BATCH_OWNS_VBO | GPU_BATCH_OWNS_INDEX); | GPU_BATCH_OWNS_INDEX); | ||||
| GPU_batch_vertbuf_add_ex(cache->face_wire.batch, vbo_wiredata, true); | |||||
| } | } | ||||
| return cache->face_wire.batch; | return cache->face_wire.batch; | ||||
| } | } | ||||