Cleanup: Move draw_pbvh to a C++ namespace

This commit is contained in:
Hans Goudey
2023-11-30 19:02:36 -05:00
parent 00c22b75d2
commit ed7b914bd8
10 changed files with 149 additions and 143 deletions

View File

@@ -14,7 +14,6 @@
#include "BLI_utildefines.h"
struct PBVHNode;
struct PBVHBatches;
struct BMesh;
enum PBVHType {

View File

@@ -41,14 +41,16 @@ struct MLoopTri;
struct Mesh;
struct PBVH;
struct PBVHNode;
struct PBVHBatches;
struct PBVH_GPU_Args;
struct SculptSession;
struct SubdivCCGFace;
struct SubdivCCG;
struct TaskParallelSettings;
struct Image;
struct ImageUser;
namespace blender::draw::pbvh {
struct PBVHBatches;
struct PBVH_GPU_Args;
} // namespace blender::draw::pbvh
/*
* These structs represent logical verts/edges/faces.
@@ -310,8 +312,8 @@ void BKE_pbvh_draw_cb(const Mesh &mesh,
PBVHFrustumPlanes *update_frustum,
PBVHFrustumPlanes *draw_frustum,
void (*draw_fn)(void *user_data,
PBVHBatches *batches,
const PBVH_GPU_Args &args),
blender::draw::pbvh::PBVHBatches *batches,
const blender::draw::pbvh::PBVH_GPU_Args &args),
void *user_data,
bool full_render,
PBVHAttrReq *attrs,

View File

@@ -984,7 +984,7 @@ void BKE_pbvh_free(PBVH *pbvh)
for (PBVHNode &node : pbvh->nodes) {
if (node.flag & PBVH_Leaf) {
if (node.draw_batches) {
DRW_pbvh_node_free(node.draw_batches);
blender::draw::pbvh::node_free(node.draw_batches);
}
}
@@ -1407,9 +1407,11 @@ bool BKE_pbvh_get_color_layer(Mesh *me, CustomDataLayer **r_layer, eAttrDomain *
return *r_layer != nullptr;
}
static PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh, PBVH &pbvh, const PBVHNode &node)
static blender::draw::pbvh::PBVH_GPU_Args pbvh_draw_args_init(const Mesh &mesh,
PBVH &pbvh,
const PBVHNode &node)
{
PBVH_GPU_Args args{};
blender::draw::pbvh::PBVH_GPU_Args args{};
args.pbvh_type = pbvh.header.type;
@@ -1471,16 +1473,16 @@ static void node_update_draw_buffers(const Mesh &mesh, PBVH &pbvh, PBVHNode &nod
* do any OpenGL calls. Flags are not cleared immediately, that happens
* after GPU_pbvh_buffer_flush() which does the final OpenGL calls. */
if (node.flag & PBVH_RebuildDrawBuffers) {
const PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, node);
node.draw_batches = DRW_pbvh_node_create(args);
const blender::draw::pbvh::PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, node);
node.draw_batches = blender::draw::pbvh::node_create(args);
}
if (node.flag & PBVH_UpdateDrawBuffers) {
node.debug_draw_gen++;
if (node.draw_batches) {
const PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, node);
DRW_pbvh_node_update(node.draw_batches, args);
const blender::draw::pbvh::PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, node);
blender::draw::pbvh::node_update(node.draw_batches, args);
}
}
}
@@ -1488,7 +1490,7 @@ static void node_update_draw_buffers(const Mesh &mesh, PBVH &pbvh, PBVHNode &nod
void pbvh_free_draw_buffers(PBVH & /*pbvh*/, PBVHNode *node)
{
if (node->draw_batches) {
DRW_pbvh_node_free(node->draw_batches);
blender::draw::pbvh::node_free(node->draw_batches);
node->draw_batches = nullptr;
}
}
@@ -1511,8 +1513,8 @@ static void pbvh_update_draw_buffers(const Mesh &mesh,
pbvh_free_draw_buffers(pbvh, node);
}
else if ((node->flag & PBVH_UpdateDrawBuffers) && node->draw_batches) {
const PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, *node);
DRW_pbvh_update_pre(node->draw_batches, args);
const draw::pbvh::PBVH_GPU_Args args = pbvh_draw_args_init(mesh, pbvh, *node);
draw::pbvh::update_pre(node->draw_batches, args);
}
}
}
@@ -1530,7 +1532,7 @@ static void pbvh_update_draw_buffers(const Mesh &mesh,
if (node->flag & PBVH_UpdateDrawBuffers) {
if (node->draw_batches) {
DRW_pbvh_node_gpu_flush(node->draw_batches);
draw::pbvh::node_gpu_flush(node->draw_batches);
}
}
@@ -2894,13 +2896,15 @@ void BKE_pbvh_draw_cb(const Mesh &mesh,
PBVHFrustumPlanes *update_frustum,
PBVHFrustumPlanes *draw_frustum,
void (*draw_fn)(void *user_data,
PBVHBatches *batches,
const PBVH_GPU_Args &args),
blender::draw::pbvh::PBVHBatches *batches,
const blender::draw::pbvh::PBVH_GPU_Args &args),
void *user_data,
bool /*full_render*/,
PBVHAttrReq *attrs,
int attrs_num)
{
using namespace blender;
using namespace blender::bke::pbvh;
Vector<PBVHNode *> nodes;
int update_flag = 0;
@@ -2914,15 +2918,13 @@ void BKE_pbvh_draw_cb(const Mesh &mesh,
data.accum_update_flag = 0;
data.attrs = attrs;
data.attrs_num = attrs_num;
nodes = blender::bke::pbvh::search_gather(
pbvh, [&](PBVHNode &node) { return pbvh_draw_search(&node, &data); });
nodes = search_gather(pbvh, [&](PBVHNode &node) { return pbvh_draw_search(&node, &data); });
update_flag = data.accum_update_flag;
}
else {
/* Get all nodes with draw updates, also those outside the view. */
const int search_flag = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers;
nodes = blender::bke::pbvh::search_gather(
pbvh, [&](PBVHNode &node) { return update_search(&node, search_flag); });
nodes = search_gather(pbvh, [&](PBVHNode &node) { return update_search(&node, search_flag); });
update_flag = PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers;
}
@@ -2935,12 +2937,11 @@ void BKE_pbvh_draw_cb(const Mesh &mesh,
PBVHDrawSearchData draw_data{};
draw_data.frustum = draw_frustum;
draw_data.accum_update_flag = 0;
nodes = blender::bke::pbvh::search_gather(
pbvh, [&](PBVHNode &node) { return pbvh_draw_search(&node, &draw_data); });
nodes = search_gather(pbvh, [&](PBVHNode &node) { return pbvh_draw_search(&node, &draw_data); });
for (PBVHNode *node : nodes) {
if (!(node->flag & PBVH_FullyHidden)) {
const PBVH_GPU_Args args = pbvh_draw_args_init(mesh, *pbvh, *node);
const draw::pbvh::PBVH_GPU_Args args = pbvh_draw_args_init(mesh, *pbvh, *node);
draw_fn(user_data, node->draw_batches, args);
}
}

View File

@@ -342,7 +342,7 @@ static void pbvh_bmesh_node_split(PBVH *pbvh, const Span<BBC> bbc_array, int nod
n->layer_disp = nullptr;
if (n->draw_batches) {
DRW_pbvh_node_free(n->draw_batches);
blender::draw::pbvh::node_free(n->draw_batches);
}
n->flag &= ~PBVH_Leaf;

View File

@@ -16,6 +16,10 @@
* \ingroup bke
*/
namespace blender::draw::pbvh {
struct PBVHBatches;
}
struct PBVHGPUFormat;
struct MLoopTri;
struct BMVert;
@@ -35,7 +39,7 @@ struct BBC {
* union'd structs */
struct PBVHNode {
/* Opaque handle for drawing code */
PBVHBatches *draw_batches = nullptr;
blender::draw::pbvh::PBVHBatches *draw_batches = nullptr;
/* Voxel bounds */
BB vb = {};

View File

@@ -21,9 +21,6 @@
class PBVHAttrReq;
struct GPUBatch;
struct PBVHNode;
struct PBVHBatches;
struct PBVHGPUFormat;
struct GSet;
struct DMFlagMat;
struct Mesh;
struct MLoopTri;
@@ -32,59 +29,66 @@ struct SubdivCCG;
struct BMesh;
struct BMFace;
namespace blender::draw::pbvh {
struct PBVHBatches;
struct PBVH_GPU_Args {
int pbvh_type;
BMesh *bm;
const Mesh *me;
blender::MutableSpan<blender::float3> vert_positions;
blender::Span<int> corner_verts;
blender::Span<int> corner_edges;
MutableSpan<float3> vert_positions;
Span<int> corner_verts;
Span<int> corner_edges;
const CustomData *vert_data;
const CustomData *loop_data;
const CustomData *face_data;
blender::Span<blender::float3> vert_normals;
blender::Span<blender::float3> face_normals;
Span<float3> vert_normals;
Span<float3> face_normals;
const char *active_color;
const char *render_color;
int face_sets_color_seed, face_sets_color_default;
int face_sets_color_seed;
int face_sets_color_default;
SubdivCCG *subdiv_ccg;
blender::Span<DMFlagMat> grid_flag_mats;
blender::Span<int> grid_indices;
Span<DMFlagMat> grid_flag_mats;
Span<int> grid_indices;
CCGKey ccg_key;
blender::Span<CCGElem *> grids;
blender::Span<const BLI_bitmap *> grid_hidden;
Span<CCGElem *> grids;
Span<const BLI_bitmap *> grid_hidden;
blender::Span<int> prim_indices;
Span<int> prim_indices;
const bool *hide_poly;
blender::Span<MLoopTri> mlooptri;
blender::Span<int> looptri_faces;
Span<MLoopTri> mlooptri;
Span<int> looptri_faces;
/* BMesh. */
const blender::Set<BMFace *, 0> *bm_faces;
const Set<BMFace *, 0> *bm_faces;
int cd_mask_layer;
};
void DRW_pbvh_node_update(PBVHBatches *batches, const PBVH_GPU_Args &args);
void DRW_pbvh_update_pre(PBVHBatches *batches, const PBVH_GPU_Args &args);
void node_update(PBVHBatches *batches, const PBVH_GPU_Args &args);
void update_pre(PBVHBatches *batches, const PBVH_GPU_Args &args);
void DRW_pbvh_node_gpu_flush(PBVHBatches *batches);
PBVHBatches *DRW_pbvh_node_create(const PBVH_GPU_Args &args);
void DRW_pbvh_node_free(PBVHBatches *batches);
GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids);
GPUBatch *DRW_pbvh_lines_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids);
void node_gpu_flush(PBVHBatches *batches);
PBVHBatches *node_create(const PBVH_GPU_Args &args);
void node_free(PBVHBatches *batches);
GPUBatch *tris_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids);
GPUBatch *lines_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids);
} // namespace blender::draw::pbvh

View File

@@ -1222,9 +1222,10 @@ static float sculpt_debug_colors[9][4] = {
};
static void sculpt_draw_cb(DRWSculptCallbackData *scd,
PBVHBatches *batches,
const PBVH_GPU_Args &pbvh_draw_args)
blender::draw::pbvh::PBVHBatches *batches,
const blender::draw::pbvh::PBVH_GPU_Args &pbvh_draw_args)
{
using namespace blender::draw;
if (!batches) {
return;
}
@@ -1233,18 +1234,18 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd,
GPUBatch *geom;
if (!scd->use_wire) {
geom = DRW_pbvh_tris_get(
geom = pbvh::tris_get(
batches, scd->attrs, scd->attrs_num, pbvh_draw_args, &primcount, scd->fast_mode);
}
else {
geom = DRW_pbvh_lines_get(
geom = pbvh::lines_get(
batches, scd->attrs, scd->attrs_num, pbvh_draw_args, &primcount, scd->fast_mode);
}
short index = 0;
if (scd->use_mats) {
index = drw_pbvh_material_index_get(batches);
index = pbvh::material_index_get(batches);
index = clamp_i(index, 0, scd->num_shading_groups - 1);
}
@@ -1368,7 +1369,9 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
update_only_visible,
&update_frustum,
&draw_frustum,
(void (*)(void *, PBVHBatches *, const PBVH_GPU_Args &))sculpt_draw_cb,
(void (*)(void *,
blender::draw::pbvh::PBVHBatches *,
const blender::draw::pbvh::PBVH_GPU_Args &))sculpt_draw_cb,
scd,
scd->use_mats,
scd->attrs,
@@ -1405,15 +1408,19 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup,
int attrs_num = 0;
/* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT, eCustomDataType(CD_PBVH_CO_TYPE));
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT, eCustomDataType(CD_PBVH_NO_TYPE));
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT,
eCustomDataType(blender::draw::pbvh::CD_PBVH_CO_TYPE));
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT,
eCustomDataType(blender::draw::pbvh::CD_PBVH_NO_TYPE));
if (use_mask) {
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT, eCustomDataType(CD_PBVH_MASK_TYPE));
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_POINT,
eCustomDataType(blender::draw::pbvh::CD_PBVH_MASK_TYPE));
}
if (use_fset) {
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_FACE, eCustomDataType(CD_PBVH_FSET_TYPE));
attrs[attrs_num++] = PBVHAttrReq(ATTR_DOMAIN_FACE,
eCustomDataType(blender::draw::pbvh::CD_PBVH_FSET_TYPE));
}
Mesh *me = BKE_object_get_original_mesh(ob);
@@ -1477,8 +1484,8 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
int attrs_i = 0;
/* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
attrs[attrs_i++].type = (eCustomDataType)CD_PBVH_CO_TYPE;
attrs[attrs_i++].type = (eCustomDataType)CD_PBVH_NO_TYPE;
attrs[attrs_i++].type = (eCustomDataType)blender::draw::pbvh::CD_PBVH_CO_TYPE;
attrs[attrs_i++].type = (eCustomDataType)blender::draw::pbvh::CD_PBVH_NO_TYPE;
for (int i = 0; i < draw_attrs.num_requests; i++) {
DRW_AttributeRequest *req = draw_attrs.requests + i;

View File

@@ -58,23 +58,10 @@
#define MAX_PBVH_BATCH_KEY 512
#define MAX_PBVH_VBOS 16
using blender::float3;
using blender::FunctionRef;
using blender::IndexRange;
using blender::Map;
using blender::MutableSpan;
using blender::short3;
using blender::short4;
using blender::Span;
using blender::StringRef;
using blender::StringRefNull;
using blender::uchar3;
using blender::uchar4;
using blender::Vector;
namespace blender::draw::pbvh {
static bool pbvh_attr_supported(int type, const eAttrDomain domain)
{
using namespace blender;
if (!ELEM(domain, ATTR_DOMAIN_POINT, ATTR_DOMAIN_FACE, ATTR_DOMAIN_CORNER)) {
/* PBVH drawing does not support edge domain attributes. */
return false;
@@ -85,7 +72,7 @@ static bool pbvh_attr_supported(int type, const eAttrDomain domain)
bool type_supported = false;
bke::attribute_math::convert_to_static_type(eCustomDataType(type), [&](auto dummy) {
using T = decltype(dummy);
using Converter = draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
if constexpr (!std::is_void_v<VBOType>) {
type_supported = true;
@@ -131,7 +118,7 @@ inline short4 normal_float_to_short(const float3 &value)
template<typename T>
void extract_data_vert_faces(const PBVH_GPU_Args &args, const Span<T> attribute, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
const Span<int> corner_verts = args.corner_verts;
const Span<MLoopTri> looptris = args.mlooptri;
@@ -154,7 +141,7 @@ void extract_data_vert_faces(const PBVH_GPU_Args &args, const Span<T> attribute,
template<typename T>
void extract_data_face_faces(const PBVH_GPU_Args &args, const Span<T> attribute, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
const Span<int> looptri_faces = args.looptri_faces;
@@ -174,7 +161,7 @@ void extract_data_face_faces(const PBVH_GPU_Args &args, const Span<T> attribute,
template<typename T>
void extract_data_corner_faces(const PBVH_GPU_Args &args, const Span<T> attribute, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
const Span<MLoopTri> looptris = args.mlooptri;
@@ -212,7 +199,7 @@ template<typename T> const T &bmesh_cd_face_get(const BMFace &face, const int of
template<typename T>
void extract_data_vert_bmesh(const PBVH_GPU_Args &args, const int cd_offset, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
VBOType *data = static_cast<VBOType *>(GPU_vertbuf_get_data(&vbo));
@@ -233,7 +220,7 @@ void extract_data_vert_bmesh(const PBVH_GPU_Args &args, const int cd_offset, GPU
template<typename T>
void extract_data_face_bmesh(const PBVH_GPU_Args &args, const int cd_offset, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
VBOType *data = static_cast<VBOType *>(GPU_vertbuf_get_data(&vbo));
@@ -249,7 +236,7 @@ void extract_data_face_bmesh(const PBVH_GPU_Args &args, const int cd_offset, GPU
template<typename T>
void extract_data_corner_bmesh(const PBVH_GPU_Args &args, const int cd_offset, GPUVertBuf &vbo)
{
using Converter = blender::draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
VBOType *data = static_cast<VBOType *>(GPU_vertbuf_get_data(&vbo));
@@ -514,7 +501,6 @@ struct PBVHBatches {
FunctionRef<void(FunctionRef<void(int x, int y, int grid_index, CCGElem *elems[4], int i)>
func)> foreach_grids)
{
using namespace blender;
uint vert_per_grid = square_i(args.ccg_key.grid_size - 1) * 4;
uint vert_count = args.grid_indices.size() * vert_per_grid;
@@ -607,7 +593,7 @@ struct PBVHBatches {
else {
bke::attribute_math::convert_to_static_type(eCustomDataType(vbo.type), [&](auto dummy) {
using T = decltype(dummy);
using Converter = draw::AttributeConverter<T>;
using Converter = AttributeConverter<T>;
using VBOType = typename Converter::VBOType;
std::fill_n(static_cast<VBOType *>(GPU_vertbuf_get_data(vbo.vert_buf)),
GPU_vertbuf_get_vertex_len(vbo.vert_buf),
@@ -682,7 +668,6 @@ struct PBVHBatches {
void fill_vbo_faces(PBVHVbo &vbo, const PBVH_GPU_Args &args)
{
using namespace blender;
const int totvert = this->count_faces(args) * 3;
int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
@@ -805,7 +790,6 @@ struct PBVHBatches {
void fill_vbo_bmesh(PBVHVbo &vbo, const PBVH_GPU_Args &args)
{
using namespace blender;
faces_count = tris_count = count_faces(args);
int existing_num = GPU_vertbuf_get_vertex_len(vbo.vert_buf);
@@ -964,7 +948,6 @@ struct PBVHBatches {
const StringRefNull name,
const PBVH_GPU_Args &args)
{
using namespace blender;
PBVHVbo vbo(domain, type, name);
GPUVertFormat format;
@@ -1058,7 +1041,6 @@ struct PBVHBatches {
void create_index_faces(const PBVH_GPU_Args &args)
{
using namespace blender;
const int *mat_index = static_cast<const int *>(
CustomData_get_layer_named(args.face_data, CD_PROP_INT32, "material_index"));
@@ -1068,7 +1050,7 @@ struct PBVHBatches {
material_index = mat_index[face_i];
}
const blender::Span<blender::int2> edges = args.me->edges();
const Span<int2> edges = args.me->edges();
/* Calculate number of edges. */
int edge_count = 0;
@@ -1078,7 +1060,7 @@ struct PBVHBatches {
continue;
}
const blender::int3 real_edges = bke::mesh::looptri_get_real_edges(
const int3 real_edges = bke::mesh::looptri_get_real_edges(
edges, args.corner_verts, args.corner_edges, args.mlooptri[looptri_i]);
if (real_edges[0] != -1) {
@@ -1102,7 +1084,7 @@ struct PBVHBatches {
continue;
}
const blender::int3 real_edges = bke::mesh::looptri_get_real_edges(
const int3 real_edges = bke::mesh::looptri_get_real_edges(
edges, args.corner_verts, args.corner_edges, args.mlooptri[looptri_i]);
if (real_edges[0] != -1) {
@@ -1398,33 +1380,33 @@ struct PBVHBatches {
}
};
void DRW_pbvh_node_update(PBVHBatches *batches, const PBVH_GPU_Args &args)
void node_update(PBVHBatches *batches, const PBVH_GPU_Args &args)
{
batches->update(args);
}
void DRW_pbvh_node_gpu_flush(PBVHBatches *batches)
void node_gpu_flush(PBVHBatches *batches)
{
batches->gpu_flush();
}
PBVHBatches *DRW_pbvh_node_create(const PBVH_GPU_Args &args)
PBVHBatches *node_create(const PBVH_GPU_Args &args)
{
PBVHBatches *batches = new PBVHBatches(args);
return batches;
}
void DRW_pbvh_node_free(PBVHBatches *batches)
void node_free(PBVHBatches *batches)
{
delete batches;
}
GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids)
GPUBatch *tris_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids)
{
do_coarse_grids &= args.pbvh_type == PBVH_GRIDS;
@@ -1435,12 +1417,12 @@ GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches,
return batch.tris;
}
GPUBatch *DRW_pbvh_lines_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids)
GPUBatch *lines_get(PBVHBatches *batches,
PBVHAttrReq *attrs,
int attrs_num,
const PBVH_GPU_Args &args,
int *r_prim_count,
bool do_coarse_grids)
{
do_coarse_grids &= args.pbvh_type == PBVH_GRIDS;
@@ -1451,12 +1433,14 @@ GPUBatch *DRW_pbvh_lines_get(PBVHBatches *batches,
return batch.lines;
}
void DRW_pbvh_update_pre(PBVHBatches *batches, const PBVH_GPU_Args &args)
void update_pre(PBVHBatches *batches, const PBVH_GPU_Args &args)
{
batches->update_pre(args);
}
int drw_pbvh_material_index_get(PBVHBatches *batches)
int material_index_get(PBVHBatches *batches)
{
return batches->material_index;
}
} // namespace blender::draw::pbvh

View File

@@ -6,6 +6,8 @@
#include "DNA_customdata_types.h"
namespace blender::draw::pbvh {
struct PBVHBatches;
enum {
@@ -15,4 +17,6 @@ enum {
CD_PBVH_MASK_TYPE = CD_NUMTYPES + 3
};
int drw_pbvh_material_index_get(PBVHBatches *batches);
int material_index_get(PBVHBatches *batches);
} // namespace blender::draw::pbvh

View File

@@ -47,8 +47,8 @@ struct SculptCallbackData {
};
static void sculpt_draw_cb(SculptCallbackData *data,
PBVHBatches *batches,
const PBVH_GPU_Args &pbvh_draw_args)
pbvh::PBVHBatches *batches,
const pbvh::PBVH_GPU_Args &pbvh_draw_args)
{
if (!batches) {
return;
@@ -58,15 +58,15 @@ static void sculpt_draw_cb(SculptCallbackData *data,
int primcount;
if (data->use_wire) {
batch.batch = DRW_pbvh_lines_get(
batch.batch = pbvh::lines_get(
batches, data->attrs, data->attrs_len, pbvh_draw_args, &primcount, data->fast_mode);
}
else {
batch.batch = DRW_pbvh_tris_get(
batch.batch = pbvh::tris_get(
batches, data->attrs, data->attrs_len, pbvh_draw_args, &primcount, data->fast_mode);
}
batch.material_slot = drw_pbvh_material_index_get(batches);
batch.material_slot = pbvh::material_index_get(batches);
batch.debug_index = data->batches.size();
data->batches.append(batch);
@@ -139,16 +139,17 @@ static Vector<SculptBatch> sculpt_batches_get_ex(
data.attrs = attrs;
data.attrs_len = attrs_len;
BKE_pbvh_draw_cb(*mesh,
pbvh,
update_only_visible,
&update_frustum,
&draw_frustum,
(void (*)(void *, PBVHBatches *, const PBVH_GPU_Args &))sculpt_draw_cb,
&data,
use_materials,
attrs,
attrs_len);
BKE_pbvh_draw_cb(
*mesh,
pbvh,
update_only_visible,
&update_frustum,
&draw_frustum,
(void (*)(void *, pbvh::PBVHBatches *, const pbvh::PBVH_GPU_Args &))sculpt_draw_cb,
&data,
use_materials,
attrs,
attrs_len);
return data.batches;
}
@@ -159,15 +160,15 @@ Vector<SculptBatch> sculpt_batches_get(Object *ob, bool per_material, SculptBatc
int attrs_len = 0;
/* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_CO_TYPE);
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_NO_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_CO_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_NO_TYPE);
if (features & SCULPT_BATCH_MASK) {
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_MASK_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_MASK_TYPE);
}
if (features & SCULPT_BATCH_FACE_SET) {
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_FSET_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_FSET_TYPE);
}
Mesh *mesh = BKE_object_get_original_mesh(ob);
@@ -213,8 +214,8 @@ Vector<SculptBatch> sculpt_batches_per_material_get(Object *ob,
int attrs_len = 0;
/* NOTE: these are NOT #eCustomDataType, they are extended values, ASAN may warn about this. */
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_CO_TYPE);
attrs[attrs_len++].type = eCustomDataType(CD_PBVH_NO_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_CO_TYPE);
attrs[attrs_len++].type = eCustomDataType(pbvh::CD_PBVH_NO_TYPE);
for (int i = 0; i < draw_attrs.num_requests; i++) {
DRW_AttributeRequest *req = draw_attrs.requests + i;