|
|
|
|
@@ -656,7 +656,7 @@ static void pbvh_build(PBVH *pbvh,
|
|
|
|
|
build_sub(pbvh, material_indices, sharp_faces, 0, cb, prim_bbc, 0, totprim, nullptr, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
|
|
|
|
|
static void pbvh_draw_args_init(const Mesh &mesh, PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
|
|
|
|
|
{
|
|
|
|
|
memset((void *)args, 0, sizeof(*args));
|
|
|
|
|
|
|
|
|
|
@@ -681,6 +681,9 @@ static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
|
|
|
|
|
nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
args->active_color = mesh.active_color_attribute;
|
|
|
|
|
args->render_color = mesh.default_color_attribute;
|
|
|
|
|
|
|
|
|
|
switch (pbvh->header.type) {
|
|
|
|
|
case PBVH_FACES:
|
|
|
|
|
args->vert_data = pbvh->vert_data;
|
|
|
|
|
@@ -691,9 +694,6 @@ static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
|
|
|
|
|
args->vert_normals = pbvh->vert_normals;
|
|
|
|
|
args->face_normals = pbvh->face_normals;
|
|
|
|
|
|
|
|
|
|
args->active_color = pbvh->mesh->active_color_attribute;
|
|
|
|
|
args->render_color = pbvh->mesh->default_color_attribute;
|
|
|
|
|
|
|
|
|
|
args->prim_indices = node->prim_indices;
|
|
|
|
|
args->face_sets = pbvh->face_sets;
|
|
|
|
|
args->looptri_faces = pbvh->looptri_faces;
|
|
|
|
|
@@ -709,9 +709,6 @@ static void pbvh_draw_args_init(PBVH *pbvh, PBVH_GPU_Args *args, PBVHNode *node)
|
|
|
|
|
args->face_sets = pbvh->face_sets;
|
|
|
|
|
args->faces = pbvh->faces;
|
|
|
|
|
|
|
|
|
|
args->active_color = pbvh->mesh->active_color_attribute;
|
|
|
|
|
args->render_color = pbvh->mesh->default_color_attribute;
|
|
|
|
|
|
|
|
|
|
args->mesh_grids_num = pbvh->totgrid;
|
|
|
|
|
args->grids = pbvh->grids;
|
|
|
|
|
args->grid_flag_mats = pbvh->grid_flag_mats;
|
|
|
|
|
@@ -1423,14 +1420,14 @@ bool BKE_pbvh_get_color_layer(Mesh *me, CustomDataLayer **r_layer, eAttrDomain *
|
|
|
|
|
return *r_layer != nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void node_update_draw_buffers(PBVH &pbvh, PBVHNode &node)
|
|
|
|
|
static void node_update_draw_buffers(const Mesh &mesh, PBVH &pbvh, PBVHNode &node)
|
|
|
|
|
{
|
|
|
|
|
/* Create and update draw buffers. The functions called here must not
|
|
|
|
|
* 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) {
|
|
|
|
|
PBVH_GPU_Args args;
|
|
|
|
|
pbvh_draw_args_init(&pbvh, &args, &node);
|
|
|
|
|
pbvh_draw_args_init(mesh, &pbvh, &args, &node);
|
|
|
|
|
node.draw_batches = DRW_pbvh_node_create(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1439,7 +1436,7 @@ static void node_update_draw_buffers(PBVH &pbvh, PBVHNode &node)
|
|
|
|
|
|
|
|
|
|
if (node.draw_batches) {
|
|
|
|
|
PBVH_GPU_Args args;
|
|
|
|
|
pbvh_draw_args_init(&pbvh, &args, &node);
|
|
|
|
|
pbvh_draw_args_init(mesh, &pbvh, &args, &node);
|
|
|
|
|
DRW_pbvh_node_update(node.draw_batches, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1453,7 +1450,10 @@ void pbvh_free_draw_buffers(PBVH * /*pbvh*/, PBVHNode *node)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void pbvh_update_draw_buffers(PBVH *pbvh, Span<PBVHNode *> nodes, int update_flag)
|
|
|
|
|
static void pbvh_update_draw_buffers(const Mesh &mesh,
|
|
|
|
|
PBVH *pbvh,
|
|
|
|
|
Span<PBVHNode *> nodes,
|
|
|
|
|
int update_flag)
|
|
|
|
|
{
|
|
|
|
|
using namespace blender;
|
|
|
|
|
if (pbvh->header.type == PBVH_BMESH && !pbvh->header.bm) {
|
|
|
|
|
@@ -1470,7 +1470,7 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, Span<PBVHNode *> nodes, int upd
|
|
|
|
|
else if ((node->flag & PBVH_UpdateDrawBuffers) && node->draw_batches) {
|
|
|
|
|
PBVH_GPU_Args args;
|
|
|
|
|
|
|
|
|
|
pbvh_draw_args_init(pbvh, &args, node);
|
|
|
|
|
pbvh_draw_args_init(mesh, pbvh, &args, node);
|
|
|
|
|
DRW_pbvh_update_pre(node->draw_batches, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -1480,7 +1480,7 @@ static void pbvh_update_draw_buffers(PBVH *pbvh, Span<PBVHNode *> nodes, int upd
|
|
|
|
|
|
|
|
|
|
threading::parallel_for(nodes.index_range(), 1, [&](const IndexRange range) {
|
|
|
|
|
for (PBVHNode *node : nodes.slice(range)) {
|
|
|
|
|
node_update_draw_buffers(*pbvh, *node);
|
|
|
|
|
node_update_draw_buffers(mesh, *pbvh, *node);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -2864,7 +2864,8 @@ static bool pbvh_draw_search(PBVHNode *node, PBVHDrawSearchData *data)
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|
|
|
|
void BKE_pbvh_draw_cb(const Mesh &mesh,
|
|
|
|
|
PBVH *pbvh,
|
|
|
|
|
bool update_only_visible,
|
|
|
|
|
PBVHFrustumPlanes *update_frustum,
|
|
|
|
|
PBVHFrustumPlanes *draw_frustum,
|
|
|
|
|
@@ -2903,7 +2904,7 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|
|
|
|
|
|
|
|
|
/* Update draw buffers. */
|
|
|
|
|
if (!nodes.is_empty() && (update_flag & (PBVH_RebuildDrawBuffers | PBVH_UpdateDrawBuffers))) {
|
|
|
|
|
pbvh_update_draw_buffers(pbvh, nodes, update_flag);
|
|
|
|
|
pbvh_update_draw_buffers(mesh, pbvh, nodes, update_flag);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Draw visible nodes. */
|
|
|
|
|
@@ -2917,7 +2918,7 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
|
|
|
|
|
|
|
|
|
|
for (PBVHNode *node : nodes) {
|
|
|
|
|
if (!(node->flag & PBVH_FullyHidden)) {
|
|
|
|
|
pbvh_draw_args_init(pbvh, &args, node);
|
|
|
|
|
pbvh_draw_args_init(mesh, pbvh, &args, node);
|
|
|
|
|
draw_fn(user_data, node->draw_batches, args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|