67 return (cache && cache->
is_dirty ==
false);
78 memset(cache, 0,
sizeof(*cache));
101 if (cache ==
nullptr) {
121 MEM_SAFE_DELETE(grid.
name);
124 cache->
grids.free_no_destruct();
142 void *userdata,
const float (*verts)[3],
const int (*edges)[2],
int totvert,
int totedge)
154 uint pos_hq_id, nor_hq_id;
167 &format,
"pos", gpu::VertAttrType::SFLOAT_32_32_32);
169 &format,
"nor", gpu::VertAttrType::SNORM_16_16_16_16);
173 uint pos_id = do_hq_normals ? attr_id.pos_hq_id : attr_id.pos_id;
174 uint nor_id = do_hq_normals ? attr_id.nor_hq_id : attr_id.nor_id;
176 cache->
face_wire.pos_nor_in_order = GPU_vertbuf_create_with_format(do_hq_normals ? format_hq :
180 const float3 normal(1.0f, 0.0f, 0.0f);
203 for (
int i = 0; i < totedge; i++) {
242 void *userdata,
float (*verts)[3],
int (*tris)[3],
int totvert,
int tottris)
255 gpu::VertBuf *vbo_surface = GPU_vertbuf_create_with_format(format);
262 for (
int i = 0; i < tottris; i++) {
286 const bke::VolumeGridData *grid,
293 if (cache_grid.
name == name) {
309 if (!
ELEM(channels, 1, 3)) {
320 gpu::TextureFormat::SFLOAT_16;
329 if (cache_grid->
texture !=
nullptr) {
335 MEM_delete(dense_grid.
voxels);
336 printf(
"Error: Could not allocate 3D texture for volume.\n");
348 return (grid->
texture !=
nullptr) ? grid :
nullptr;
Volume data-block rendering and viewport drawing utilities.
#define GPU_batch_create(primitive_type, vertex_buf, index_buf)
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_TEXTURE_FREE_SAFE(texture)
#define GPU_VERTBUF_DISCARD_SAFE(verts)
Read Blender memory allocation and freeing.
std::string get_name(const VolumeGridData &grid)
int get_channels_num(VolumeGridType type)
VolumeGridType get_type(const VolumeGridData &grid)
void DRW_vertbuf_create_wiredata(gpu::VertBuf *vbo, const int vert_len)
gpu::Batch * DRW_volume_batch_cache_get_selection_surface(Volume *volume)
static void volume_batch_cache_clear(Volume *volume)
static void volume_batch_cache_init(Volume *volume)
void DRW_volume_batch_cache_free(Volume *volume)
void DRW_volume_batch_cache_validate(Volume *volume)
void DRW_volume_batch_cache_dirty_tag(Volume *volume, int mode)
gpu::Batch * DRW_volume_batch_cache_get_wireframes_face(Volume *volume)
static bool volume_batch_cache_valid(Volume *volume)
static DRWVolumeGrid * volume_grid_cache_get(const Volume *volume, const bke::VolumeGridData *grid, VolumeBatchCache *cache)
static VolumeBatchCache * volume_batch_cache_get(Volume *volume)
static void drw_volume_selection_surface_cb(void *userdata, float(*verts)[3], int(*tris)[3], int totvert, int tottris)
DRWVolumeGrid * DRW_volume_batch_cache_get_grid(Volume *volume, const bke::VolumeGridData *volume_grid)
static void drw_volume_wireframe_cb(void *userdata, const float(*verts)[3], const int(*edges)[2], int totvert, int totedge)
GPUType convert_normal(const float3 &src)
CartesianBasis invert(const CartesianBasis &basis)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
void GPU_indexbuf_init(GPUIndexBufBuilder *, GPUPrimType, uint prim_len, uint vertex_len)
void GPU_indexbuf_add_line_verts(GPUIndexBufBuilder *, uint v1, uint v2)
NormalizedIntVecBase< int32_t, 4, 10, 10, 10, 2 > int1010102_norm
@ GPU_SAMPLER_EXTEND_MODE_CLAMP_TO_BORDER
MatBase< float, 4, 4 > float4x4
bool BKE_volume_grid_dense_floats(const Volume *volume, const bke::VolumeGridData *volume_grid, DenseFloatVolumeGrid *r_dense_grid)
void GPU_vertbuf_attr_fill_stride(gpu::VertBuf *, uint a_idx, uint stride, const void *data)
bool GPU_use_hq_normals_workaround()
VecBase< int16_t, 4 > short4
gpu::IndexBuf * GPU_indexbuf_build(GPUIndexBufBuilder *)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
@ GPU_TEXTURE_USAGE_SHADER_READ
BMesh const char void * data
gpu::VertBuf * GPU_vertbuf_calloc()
void GPU_texture_swizzle_set(gpu::Texture *texture, const char swizzle[4])
gpu::Texture * GPU_texture_create_3d(const char *name, int width, int height, int depth, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const void *data)
bool BKE_volume_load(const Volume *volume, const Main *bmain)
void GPU_indexbuf_add_tri_verts(GPUIndexBufBuilder *, uint v1, uint v2, uint v3)
const DRWContext * DRW_context_get()
const bke::VolumeGridData * BKE_volume_grid_active_get_for_read(const Volume *volume)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_texture_extend_mode(gpu::Texture *texture, GPUSamplerExtendMode extend_mode)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
void GPU_vertbuf_attr_fill(gpu::VertBuf *, uint a_idx, const void *data)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
@ VOLUME_WIREFRAME_POINTS
void BKE_volume_grid_wireframe(const Volume *volume, const bke::VolumeGridData *volume_grid, BKE_volume_wireframe_cb cb, void *cb_userdata)
@ BKE_VOLUME_BATCH_DIRTY_ALL
VecBase< float, 3 > float3
void BKE_volume_dense_float_grid_clear(DenseFloatVolumeGrid *dense_grid)
void BKE_volume_grid_selection_surface(const Volume *volume, const bke::VolumeGridData *volume_grid, BKE_volume_selection_surface_cb cb, void *cb_userdata)
int GPU_batch_vertbuf_add(gpu::Batch *batch, gpu::VertBuf *vertex_buf, bool own_vbo)
float texture_to_object[4][4]
VolumeWireframeType wireframe_type
draw::VolumeBatchCache * batch_cache
float4x4 texture_to_object
float4x4 object_to_texture
gpu::VertBuf * pos_nor_in_order
ListBaseT< DRWVolumeGrid > grids
struct blender::draw::VolumeBatchCache::@144227213303224240240141160375002164052122071271 face_wire
gpu::Batch * selection_surface