Blender V5.0
extract_mesh_vbo_skin_roots.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
10
11#include "extract_mesh.hh"
12
13namespace blender::draw {
14
19
21{
22 /* Exclusively for edit mode. */
23 BLI_assert(mr.bm);
24
25 static const GPUVertFormat format = []() {
27 GPU_vertformat_attr_add(&format, "size", gpu::VertAttrType::SFLOAT_32);
28 GPU_vertformat_attr_add(&format, "local_pos", gpu::VertAttrType::SFLOAT_32_32_32);
29 return format;
30 }();
31
32 Vector<SkinRootData> skin_roots;
33 const int offset = CustomData_get_offset(&mr.bm->vdata, CD_MVERT_SKIN);
34 BMIter iter;
35 BMVert *vert;
36 BM_ITER_MESH (vert, &iter, mr.bm, BM_VERTS_OF_MESH) {
37 const MVertSkin *vs = (const MVertSkin *)BM_ELEM_CD_GET_VOID_P(vert, offset);
38 if (vs->flag & MVERT_SKIN_ROOT) {
39 skin_roots.append({(vs->radius[0] + vs->radius[1]) * 0.5f, bm_vert_co_get(mr, vert)});
40 }
41 }
42
44 GPU_vertbuf_data_alloc(*vbo, skin_roots.size());
45 vbo->data<SkinRootData>().copy_from(skin_roots);
46 return vbo;
47}
48
49} // namespace blender::draw
int CustomData_get_offset(const CustomData *data, eCustomDataType type)
#define BLI_assert(a)
Definition BLI_assert.h:46
@ CD_MVERT_SKIN
@ MVERT_SKIN_ROOT
static blender::gpu::VertBuf * GPU_vertbuf_create_with_format(const GPUVertFormat &format)
void GPU_vertbuf_data_alloc(blender::gpu::VertBuf &verts, uint v_len)
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
#define BM_ELEM_CD_GET_VOID_P(ele, offset)
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_VERTS_OF_MESH
int64_t size() const
void append(const T &value)
Extraction of Mesh data into VBO to feed to GPU.
format
gpu::VertBufPtr extract_skin_roots(const MeshRenderData &mr)
BLI_INLINE const float * bm_vert_co_get(const MeshRenderData &mr, const BMVert *eve)
std::unique_ptr< gpu::VertBuf, gpu::VertBufDeleter > VertBufPtr
VecBase< float, 3 > float3
CustomData vdata