Cleanup: Use references in mesh draw cache

This commit is contained in:
Hans Goudey
2024-05-21 09:09:02 -04:00
parent cdd5fd4522
commit 5c44f9bddc
23 changed files with 355 additions and 363 deletions

View File

@@ -842,12 +842,12 @@ BLI_INLINE DRWCallBuffer *custom_bone_instance_shgroup(const ArmatureDrawContext
}
static void drw_shgroup_bone_custom_solid_mesh(const ArmatureDrawContext *ctx,
Mesh *mesh,
Mesh &mesh,
const float (*bone_mat)[4],
const float bone_color[4],
const float hint_color[4],
const float outline_color[4],
Object *custom)
Object &custom)
{
using namespace blender::draw;
/* TODO(fclem): arg... less than ideal but we never iter on this object
@@ -885,14 +885,14 @@ static void drw_shgroup_bone_custom_solid_mesh(const ArmatureDrawContext *ctx,
}
/* TODO(fclem): needs to be moved elsewhere. */
drw_batch_cache_generate_requested_delayed(custom);
drw_batch_cache_generate_requested_delayed(&custom);
}
static void drw_shgroup_bone_custom_mesh_wire(const ArmatureDrawContext *ctx,
Mesh *mesh,
Mesh &mesh,
const float (*bone_mat)[4],
const float color[4],
Object *custom)
Object &custom)
{
using namespace blender::draw;
/* TODO(fclem): arg... less than ideal but we never iter on this object
@@ -910,7 +910,7 @@ static void drw_shgroup_bone_custom_mesh_wire(const ArmatureDrawContext *ctx,
}
/* TODO(fclem): needs to be moved elsewhere. */
drw_batch_cache_generate_requested_delayed(custom);
drw_batch_cache_generate_requested_delayed(&custom);
}
static void drw_shgroup_custom_bone_curve(const ArmatureDrawContext *ctx,
@@ -962,7 +962,7 @@ static void drw_shgroup_bone_custom_solid(const ArmatureDrawContext *ctx,
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
if (mesh != nullptr) {
drw_shgroup_bone_custom_solid_mesh(
ctx, mesh, bone_mat, bone_color, hint_color, outline_color, custom);
ctx, *mesh, bone_mat, bone_color, hint_color, outline_color, *custom);
return;
}
@@ -980,7 +980,7 @@ static void drw_shgroup_bone_custom_wire(const ArmatureDrawContext *ctx,
/* See comments in #drw_shgroup_bone_custom_solid. */
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(custom);
if (mesh != nullptr) {
drw_shgroup_bone_custom_mesh_wire(ctx, mesh, bone_mat, color, custom);
drw_shgroup_bone_custom_mesh_wire(ctx, *mesh, bone_mat, color, *custom);
return;
}

View File

@@ -235,8 +235,8 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob
bool has_edit_mesh_cage = false;
bool has_skin_roots = false;
/* TODO: Should be its own function. */
Mesh *mesh = (Mesh *)ob->data;
if (BMEditMesh *em = mesh->runtime->edit_mesh.get()) {
Mesh &mesh = *(Mesh *)ob->data;
if (BMEditMesh *em = mesh.runtime->edit_mesh.get()) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob);
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob);
@@ -295,7 +295,7 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)
}
if (show_retopology) {
Mesh *mesh = (Mesh *)ob->data;
Mesh &mesh = *(Mesh *)ob->data;
geom = DRW_mesh_batch_cache_get_edit_triangles(mesh);
DRW_shgroup_call_no_cull(pd->edit_mesh_depth_grp[do_in_front], geom, ob);
}
@@ -306,7 +306,7 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)
if (vnormals_do || lnormals_do || fnormals_do) {
blender::gpu::Batch *normal_geom = DRW_cache_normal_arrow_get();
Mesh *mesh = static_cast<Mesh *>(ob->data);
Mesh &mesh = *static_cast<Mesh *>(ob->data);
if (vnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_vert_normals(mesh);
DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);

View File

@@ -40,7 +40,7 @@
using blender::Vector;
/* Forward declarations. */
static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob);
static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object &ob);
struct OVERLAY_StretchingAreaTotals {
void *next, *prev;
@@ -422,16 +422,16 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
draw_ctx->scene, draw_ctx->view_layer, nullptr, draw_ctx->object_mode);
for (Object *object : objects) {
Object *object_eval = DEG_get_evaluated_object(draw_ctx->depsgraph, object);
DRW_mesh_batch_cache_validate(object_eval, (Mesh *)object_eval->data);
overlay_edit_uv_cache_populate(vedata, object_eval);
DRW_mesh_batch_cache_validate(*object_eval, *(Mesh *)object_eval->data);
overlay_edit_uv_cache_populate(vedata, *object_eval);
}
}
}
static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob)
static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object &ob)
{
using namespace blender::draw;
if (!(DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) {
if (!(DRW_object_visibility_in_active_context(&ob) & OB_VISIBLE_SELF)) {
return;
}
@@ -440,15 +440,15 @@ static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob)
blender::gpu::Batch *geom;
const DRWContextState *draw_ctx = DRW_context_state_get();
const bool is_edit_object = DRW_object_is_in_edit_mode(ob);
Mesh *mesh = (Mesh *)ob->data;
const bool has_active_object_uvmap = CustomData_get_active_layer(&mesh->corner_data,
const bool is_edit_object = DRW_object_is_in_edit_mode(&ob);
Mesh &mesh = *(Mesh *)ob.data;
const bool has_active_object_uvmap = CustomData_get_active_layer(&mesh.corner_data,
CD_PROP_FLOAT2) != -1;
const bool has_active_edit_uvmap = is_edit_object && (CustomData_get_active_layer(
&mesh->runtime->edit_mesh->bm->ldata,
&mesh.runtime->edit_mesh->bm->ldata,
CD_PROP_FLOAT2) != -1);
const bool draw_shadows = (draw_ctx->object_mode != OB_MODE_OBJECT) &&
(ob->mode == draw_ctx->object_mode);
(ob.mode == draw_ctx->object_mode);
if (has_active_edit_uvmap) {
if (pd->edit_uv.do_uv_overlay) {

View File

@@ -58,7 +58,7 @@ void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
DRW_shgroup_call_sculpt(pd->sculpt_mask_grp, ob, false, true, true, false, false);
}
else {
sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(static_cast<Mesh *>(ob->data));
sculpt_overlays = DRW_mesh_batch_cache_get_sculpt_overlays(*static_cast<Mesh *>(ob->data));
if (sculpt_overlays) {
DRW_shgroup_call(pd->sculpt_mask_grp, sculpt_overlays, ob);
}

View File

@@ -78,8 +78,8 @@ static void draw_select_id_edit_mesh(SELECTID_StorageList *stl,
uint *r_face_offset)
{
using namespace blender::draw;
Mesh *mesh = static_cast<Mesh *>(ob->data);
BMEditMesh *em = mesh->runtime->edit_mesh.get();
Mesh &mesh = *static_cast<Mesh *>(ob->data);
BMEditMesh *em = mesh.runtime->edit_mesh.get();
BM_mesh_elem_table_ensure(em->bm, BM_VERT | BM_EDGE | BM_FACE);
@@ -144,14 +144,14 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
uint *r_face_offset)
{
using namespace blender::draw;
Mesh *mesh = static_cast<Mesh *>(ob->data);
Mesh &mesh = *static_cast<Mesh *>(ob->data);
blender::gpu::Batch *geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(mesh);
DRWShadingGroup *face_shgrp;
if (select_mode & SCE_SELECT_FACE) {
face_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_face_flat);
DRW_shgroup_uniform_int_copy(face_shgrp, "offset", *(int *)&initial_offset);
*r_face_offset = initial_offset + mesh->faces_num;
*r_face_offset = initial_offset + mesh.faces_num;
}
else {
/* Only draw faces to mask out verts, we don't want their selection ID's. */
@@ -165,7 +165,7 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
DRWShadingGroup *edge_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_edge);
DRW_shgroup_uniform_int_copy(edge_shgrp, "offset", *(int *)r_face_offset);
DRW_shgroup_call_no_cull(edge_shgrp, geom_edges, ob);
*r_edge_offset = *r_face_offset + mesh->edges_num;
*r_edge_offset = *r_face_offset + mesh.edges_num;
}
else {
*r_edge_offset = *r_face_offset;
@@ -176,7 +176,7 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
DRWShadingGroup *vert_shgrp = DRW_shgroup_create_sub(stl->g_data->shgrp_vert);
DRW_shgroup_uniform_int_copy(vert_shgrp, "offset", *r_edge_offset);
DRW_shgroup_call_no_cull(vert_shgrp, geom_verts, ob);
*r_vert_offset = *r_edge_offset + mesh->verts_num;
*r_vert_offset = *r_edge_offset + mesh.verts_num;
}
else {
*r_vert_offset = *r_edge_offset;

View File

@@ -217,7 +217,7 @@ static void select_cache_populate(void *vedata, Object *ob)
/* This object is not in the array. It is here to participate in the depth buffer. */
if (ob->dt >= OB_SOLID) {
blender::gpu::Batch *geom_faces = DRW_mesh_batch_cache_get_surface(
static_cast<Mesh *>(ob->data));
*static_cast<Mesh *>(ob->data));
DRW_shgroup_call_obmat(stl->g_data->shgrp_occlude, geom_faces, ob->object_to_world().ptr());
}
}

View File

@@ -85,7 +85,7 @@ void drw_attributes_add_request(DRW_Attributes *attrs,
attrs->num_requests += 1;
}
bool drw_custom_data_match_attribute(const CustomData *custom_data,
bool drw_custom_data_match_attribute(const CustomData &custom_data,
const char *name,
int *r_layer_index,
eCustomDataType *r_type)
@@ -105,7 +105,7 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data,
for (int i = 0; i < ARRAY_SIZE(possible_attribute_types); i++) {
const eCustomDataType attr_type = possible_attribute_types[i];
int layer_index = CustomData_get_named_layer(custom_data, attr_type, name);
int layer_index = CustomData_get_named_layer(&custom_data, attr_type, name);
if (layer_index == -1) {
continue;
}

View File

@@ -68,7 +68,7 @@ void drw_attributes_add_request(DRW_Attributes *attrs,
int layer_index,
blender::bke::AttrDomain domain);
bool drw_custom_data_match_attribute(const CustomData *custom_data,
bool drw_custom_data_match_attribute(const CustomData &custom_data,
const char *name,
int *r_layer_index,
eCustomDataType *r_type);

View File

@@ -937,7 +937,7 @@ blender::gpu::VertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob)
switch (type) {
case OB_MESH:
return DRW_mesh_batch_cache_pos_vertbuf_get(
static_cast<Mesh *>((mesh != nullptr) ? mesh : ob->data));
*static_cast<Mesh *>((mesh != nullptr) ? mesh : ob->data));
default:
return nullptr;
}
@@ -959,7 +959,7 @@ int DRW_cache_object_material_count_get(const Object *ob)
switch (type) {
case OB_MESH:
return DRW_mesh_material_count_get(
ob, static_cast<const Mesh *>((mesh != nullptr) ? mesh : ob->data));
*ob, *static_cast<const Mesh *>((mesh != nullptr) ? mesh : ob->data));
case OB_CURVES_LEGACY:
case OB_SURF:
case OB_FONT:
@@ -2886,42 +2886,42 @@ blender::gpu::Batch *DRW_cache_mesh_all_verts_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_all_verts(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_all_verts(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_all_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_all_edges(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_all_edges(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_loose_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_loose_edges(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_loose_edges(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_edge_detection(static_cast<Mesh *>(ob->data), r_is_manifold);
return DRW_mesh_batch_cache_get_edge_detection(*static_cast<Mesh *>(ob->data), r_is_manifold);
}
blender::gpu::Batch *DRW_cache_mesh_surface_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_edges(ob, static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_edges(*ob, *static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch **DRW_cache_mesh_surface_shaded_get(Object *ob,
@@ -2931,63 +2931,63 @@ blender::gpu::Batch **DRW_cache_mesh_surface_shaded_get(Object *ob,
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_shaded(
ob, static_cast<Mesh *>(ob->data), gpumat_array, gpumat_array_len);
*ob, *static_cast<Mesh *>(ob->data), gpumat_array, gpumat_array_len);
}
blender::gpu::Batch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_texpaint(ob, static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_texpaint(*ob, *static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_texpaint_single(ob, static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_texpaint_single(*ob, *static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_vertpaint_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_vertpaint(ob, static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_vertpaint(*ob, *static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_sculpt(ob, static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_sculpt(*ob, *static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_weights_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_weights(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_weights(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_face_wireframe_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_wireframes_face(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_wireframes_face(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_edit_mesh_analysis(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_edit_mesh_analysis(*static_cast<Mesh *>(ob->data));
}
blender::gpu::Batch *DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_viewer_attribute(static_cast<Mesh *>(ob->data));
return DRW_mesh_batch_cache_get_surface_viewer_attribute(*static_cast<Mesh *>(ob->data));
}
/** \} */
@@ -3358,7 +3358,7 @@ void drw_batch_cache_validate(Object *ob)
using namespace blender::draw;
switch (ob->type) {
case OB_MESH:
DRW_mesh_batch_cache_validate(ob, (Mesh *)ob->data);
DRW_mesh_batch_cache_validate(*ob, *(Mesh *)ob->data);
break;
case OB_CURVES_LEGACY:
case OB_FONT:
@@ -3402,7 +3402,7 @@ void drw_batch_cache_generate_requested(Object *ob)
switch (ob->type) {
case OB_MESH:
DRW_mesh_batch_cache_create_requested(
DST.task_graph, ob, (Mesh *)ob->data, scene, is_paint_mode, use_hide);
*DST.task_graph, *ob, *(Mesh *)ob->data, *scene, is_paint_mode, use_hide);
break;
case OB_CURVES_LEGACY:
case OB_FONT:
@@ -3445,7 +3445,7 @@ void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob)
*/
if (mesh != nullptr) {
DRW_mesh_batch_cache_create_requested(
DST.task_graph, ob, mesh, scene, is_paint_mode, use_hide);
*DST.task_graph, *ob, *mesh, *scene, is_paint_mode, use_hide);
}
else if (ELEM(ob->type, OB_CURVES_LEGACY, OB_FONT, OB_SURF)) {
DRW_curve_batch_cache_create_requested(ob, scene);

View File

@@ -70,7 +70,7 @@ enum eMRDataType {
};
ENUM_OPERATORS(eMRDataType, MR_DATA_POLYS_SORTED)
int mesh_render_mat_len_get(const Object *object, const Mesh *mesh);
int mesh_render_mat_len_get(const Object &object, const Mesh &mesh);
struct MeshBufferList {
/* Every VBO below contains at least enough data for every loop in the mesh
@@ -302,18 +302,18 @@ struct MeshBatchCache {
(MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | \
MBC_EDITUV_EDGES | MBC_EDITUV_VERTS | MBC_EDITUV_FACEDOTS | MBC_WIRE_LOOPS_UVS)
void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
void mesh_buffer_cache_create_requested(TaskGraph &task_graph,
MeshBatchCache &cache,
MeshBufferCache &mbc,
Object *object,
Mesh *mesh,
Object &object,
Mesh &mesh,
bool is_editmode,
bool is_paint_mode,
bool edit_mode_active,
const float4x4 &object_to_world,
bool do_final,
bool do_uvedit,
const Scene *scene,
const Scene &scene,
const ToolSettings *ts,
bool use_hide);

View File

@@ -40,15 +40,15 @@
namespace blender::draw {
int mesh_render_mat_len_get(const Object *object, const Mesh *mesh)
int mesh_render_mat_len_get(const Object &object, const Mesh &mesh)
{
if (mesh->runtime->edit_mesh != nullptr) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
if (mesh.runtime->edit_mesh != nullptr) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(&object);
if (editmesh_eval_final != nullptr) {
return std::max<int>(1, editmesh_eval_final->totcol);
}
}
return std::max<int>(1, mesh->totcol);
return std::max<int>(1, mesh.totcol);
}
/* ---------------------------------------------------------------------- */
@@ -555,19 +555,18 @@ static TaskNode *mesh_extract_render_data_node_create(TaskGraph *task_graph,
/** \name Extract Loop
* \{ */
void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
void mesh_buffer_cache_create_requested(TaskGraph &task_graph,
MeshBatchCache &cache,
MeshBufferCache &mbc,
Object *object,
Mesh *mesh,
Object &object,
Mesh &mesh,
const bool is_editmode,
const bool is_paint_mode,
const bool edit_mode_active,
const float4x4 &object_to_world,
const bool do_final,
const bool do_uvedit,
const Scene *scene,
const Scene &scene,
const ToolSettings *ts,
const bool use_hide)
{
@@ -601,7 +600,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
* +-----> | extract_task2_loop_3 |
* +----------------------+
*/
const bool do_hq_normals = (scene->r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
const bool do_hq_normals = (scene.r.perf_flag & SCE_PERF_HQ_NORMALS) != 0 ||
GPU_use_hq_normals_workaround();
/* Create an array containing all the extractors that needs to be executed. */
@@ -678,7 +677,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
ts);
mr->use_subsurf_fdots = mr->mesh && !mr->mesh->runtime->subsurf_face_dot_tags.is_empty();
mr->use_final_mesh = do_final;
mr->use_simplify_normals = (scene->r.mode & R_SIMPLIFY) && (scene->r.mode & R_SIMPLIFY_NORMALS);
mr->use_simplify_normals = (scene.r.mode & R_SIMPLIFY) && (scene.r.mode & R_SIMPLIFY_NORMALS);
#ifdef DEBUG_TIME
double rdata_end = BLI_time_now_seconds();
@@ -688,7 +687,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
eMRDataType data_flag = extractors.data_types();
TaskNode *task_node_mesh_render_data = mesh_extract_render_data_node_create(
task_graph, *mr, mbc, iter_type, data_flag);
&task_graph, *mr, mbc, iter_type, data_flag);
/* Simple heuristic. */
const bool use_thread = (mr->corners_num + mr->loose_indices_num) > MIN_RANGE_LEN;
@@ -700,7 +699,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
MeshBatchCache &cache;
};
TaskNode *task_node = BLI_task_graph_node_create(
task_graph,
&task_graph,
[](void *__restrict task_data) {
const TaskData &data = *static_cast<TaskData *>(task_data);
const SortedFaceData &face_sorted = mesh_render_data_faces_sorted_ensure(data.mr,
@@ -718,7 +717,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
MeshBatchCache &cache;
};
TaskNode *task_node = BLI_task_graph_node_create(
task_graph,
&task_graph,
[](void *__restrict task_data) {
const TaskData &data = *static_cast<TaskData *>(task_data);
extract_lines(data.mr,
@@ -739,7 +738,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
ExtractorRunDatas *single_threaded_extractors = new ExtractorRunDatas();
single_threaded_extractors->append(extractor);
TaskNode *task_node = extract_task_node_create(
task_graph, *mr, cache, single_threaded_extractors, &buffers, false);
&task_graph, *mr, cache, single_threaded_extractors, &buffers, false);
BLI_task_graph_edge_create(task_node_mesh_render_data, task_node);
}
@@ -750,7 +749,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
extractors.filter_threaded_extractors_into(*multi_threaded_extractors);
if (!multi_threaded_extractors->is_empty()) {
TaskNode *task_node = extract_task_node_create(
task_graph, *mr, cache, multi_threaded_extractors, &buffers, true);
&task_graph, *mr, cache, multi_threaded_extractors, &buffers, true);
BLI_task_graph_edge_create(task_node_mesh_render_data, task_node);
}
@@ -763,7 +762,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
/* Run all requests on the same thread. */
ExtractorRunDatas *extractors_copy = new ExtractorRunDatas(extractors);
TaskNode *task_node = extract_task_node_create(
task_graph, *mr, cache, extractors_copy, &buffers, false);
&task_graph, *mr, cache, extractors_copy, &buffers, false);
BLI_task_graph_edge_create(task_node_mesh_render_data, task_node);
}
@@ -867,7 +866,7 @@ void mesh_buffer_cache_create_requested_subdiv(MeshBatchCache &cache,
mesh_render_data_update_normals(mr, MR_DATA_TAN_LOOP_NOR);
mesh_render_data_update_loose_geom(
mr, mbc, MR_ITER_LOOSE_EDGE | MR_ITER_LOOSE_VERT, MR_DATA_LOOSE_GEOM);
DRW_subdivide_loose_geom(&subdiv_cache, &mbc);
DRW_subdivide_loose_geom(subdiv_cache, mbc);
if (DRW_ibo_requested(buffers.ibo.lines) || DRW_ibo_requested(buffers.ibo.lines_loose)) {
extract_lines_subdiv(

View File

@@ -369,79 +369,79 @@ const SortedFaceData &mesh_render_data_faces_sorted_ensure(const MeshRenderData
/** \name Mesh/BMesh Interface (indirect, partially cached access to complex data).
* \{ */
const Mesh *editmesh_final_or_this(const Object *object, const Mesh *mesh)
const Mesh &editmesh_final_or_this(const Object &object, const Mesh &mesh)
{
if (mesh->runtime->edit_mesh != nullptr) {
if (const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object)) {
return editmesh_eval_final;
if (mesh.runtime->edit_mesh != nullptr) {
if (const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(&object)) {
return *editmesh_eval_final;
}
}
return mesh;
}
const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh)
const CustomData &mesh_cd_ldata_get_from_mesh(const Mesh &mesh)
{
switch (mesh->runtime->wrapper_type) {
switch (mesh.runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->corner_data;
return mesh.corner_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->runtime->edit_mesh->bm->ldata;
return mesh.runtime->edit_mesh->bm->ldata;
break;
}
BLI_assert(0);
return &mesh->corner_data;
return mesh.corner_data;
}
const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh)
const CustomData &mesh_cd_pdata_get_from_mesh(const Mesh &mesh)
{
switch (mesh->runtime->wrapper_type) {
switch (mesh.runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->face_data;
return mesh.face_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->runtime->edit_mesh->bm->pdata;
return mesh.runtime->edit_mesh->bm->pdata;
break;
}
BLI_assert(0);
return &mesh->face_data;
return mesh.face_data;
}
const CustomData *mesh_cd_edata_get_from_mesh(const Mesh *mesh)
const CustomData &mesh_cd_edata_get_from_mesh(const Mesh &mesh)
{
switch (mesh->runtime->wrapper_type) {
switch (mesh.runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->edge_data;
return mesh.edge_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->runtime->edit_mesh->bm->edata;
return mesh.runtime->edit_mesh->bm->edata;
break;
}
BLI_assert(0);
return &mesh->edge_data;
return mesh.edge_data;
}
const CustomData *mesh_cd_vdata_get_from_mesh(const Mesh *mesh)
const CustomData &mesh_cd_vdata_get_from_mesh(const Mesh &mesh)
{
switch (mesh->runtime->wrapper_type) {
switch (mesh.runtime->wrapper_type) {
case ME_WRAPPER_TYPE_SUBD:
case ME_WRAPPER_TYPE_MDATA:
return &mesh->vert_data;
return mesh.vert_data;
break;
case ME_WRAPPER_TYPE_BMESH:
return &mesh->runtime->edit_mesh->bm->vdata;
return mesh.runtime->edit_mesh->bm->vdata;
break;
}
BLI_assert(0);
return &mesh->vert_data;
return mesh.vert_data;
}
static bool bm_edge_is_sharp(const BMEdge *const &edge)
@@ -538,13 +538,13 @@ static void retrieve_active_attribute_names(MeshRenderData &mr,
const Object &object,
const Mesh &mesh)
{
const Mesh *mesh_final = editmesh_final_or_this(&object, &mesh);
mr.active_color_name = mesh_final->active_color_attribute;
mr.default_color_name = mesh_final->default_color_attribute;
const Mesh &mesh_final = editmesh_final_or_this(object, mesh);
mr.active_color_name = mesh_final.active_color_attribute;
mr.default_color_name = mesh_final.default_color_attribute;
}
MeshRenderData *mesh_render_data_create(Object *object,
Mesh *mesh,
MeshRenderData *mesh_render_data_create(Object &object,
Mesh &mesh,
const bool is_editmode,
const bool is_paint_mode,
const bool edit_mode_active,
@@ -563,12 +563,12 @@ MeshRenderData *mesh_render_data_create(Object *object,
mr->use_hide = use_hide;
if (is_editmode) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(object);
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(object);
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(&object);
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(&object);
BLI_assert(editmesh_eval_cage && editmesh_eval_final);
mr->bm = mesh->runtime->edit_mesh->bm;
mr->edit_bmesh = mesh->runtime->edit_mesh.get();
mr->bm = mesh.runtime->edit_mesh->bm;
mr->edit_bmesh = mesh.runtime->edit_mesh.get();
mr->mesh = (do_final) ? editmesh_eval_final : editmesh_eval_cage;
mr->edit_data = edit_mode_active ? mr->mesh->runtime->edit_data.get() : nullptr;
@@ -633,7 +633,7 @@ MeshRenderData *mesh_render_data_create(Object *object,
}
}
else {
mr->mesh = mesh;
mr->mesh = &mesh;
mr->edit_bmesh = nullptr;
mr->extract_type = MR_EXTRACT_MESH;
mr->hide_unmapped_edges = false;
@@ -707,7 +707,7 @@ MeshRenderData *mesh_render_data_create(Object *object,
mr->normals_domain = bmesh_normals_domain(bm);
}
retrieve_active_attribute_names(*mr, *object, *mr->mesh);
retrieve_active_attribute_names(*mr, object, *mr->mesh);
return mr;
}

View File

@@ -41,7 +41,7 @@ void DRW_curve_batch_cache_validate(Curve *cu);
void DRW_curve_batch_cache_free(Curve *cu);
void DRW_mesh_batch_cache_dirty_tag(Mesh *mesh, eMeshBatchDirtyMode mode);
void DRW_mesh_batch_cache_validate(Object *object, Mesh *mesh);
void DRW_mesh_batch_cache_validate(Object &object, Mesh &mesh);
void DRW_mesh_batch_cache_free(void *batch_cache);
void DRW_lattice_batch_cache_dirty_tag(Lattice *lt, int mode);
@@ -183,31 +183,31 @@ blender::gpu::Batch *DRW_volume_batch_cache_get_selection_surface(Volume *volume
/**
* Can be called for any surface type. Mesh *mesh is the final mesh.
*/
void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
Object *ob,
Mesh *mesh,
const Scene *scene,
void DRW_mesh_batch_cache_create_requested(TaskGraph &task_graph,
Object &ob,
Mesh &mesh,
const Scene &scene,
bool is_paint_mode,
bool use_hide);
blender::gpu::Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_loose_edges(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *mesh, bool *r_is_manifold);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_edges(Object *object, Mesh *mesh);
blender::gpu::Batch **DRW_mesh_batch_cache_get_surface_shaded(Object *object,
Mesh *mesh,
blender::gpu::Batch *DRW_mesh_batch_cache_get_all_verts(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_all_edges(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_loose_edges(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh &mesh, bool *r_is_manifold);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_edges(Object &object, Mesh &mesh);
blender::gpu::Batch **DRW_mesh_batch_cache_get_surface_shaded(Object &object,
Mesh &mesh,
GPUMaterial **gpumat_array,
uint gpumat_array_len);
blender::gpu::Batch **DRW_mesh_batch_cache_get_surface_texpaint(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_vertpaint(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_sculpt(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_weights(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_sculpt_overlays(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh *mesh);
blender::gpu::Batch **DRW_mesh_batch_cache_get_surface_texpaint(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_vertpaint(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_sculpt(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_weights(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_sculpt_overlays(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh &mesh);
/** \} */
@@ -215,13 +215,13 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh *mes
/** \name Edit-Mesh Drawing
* \{ */
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_triangles(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_vertices(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_edges(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_vert_normals(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_loop_normals(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_facedots(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_triangles(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_vertices(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_edges(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_vert_normals(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_loop_normals(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_facedots(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh &mesh);
/** \} */
@@ -229,10 +229,10 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh *mesh);
/** \name Edit-mesh Selection
* \{ */
blender::gpu::Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh &mesh);
/** \} */
@@ -240,7 +240,7 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *mesh);
/** \name Object Mode Wireframe Overlays
* \{ */
blender::gpu::Batch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_wireframes_face(Mesh &mesh);
/** \} */
@@ -255,16 +255,16 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *mesh);
* The `cache->tot_area` and cache->tot_uv_area` update are calculation are
* only valid after calling `DRW_mesh_batch_cache_create_requested`.
*/
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object *object,
Mesh *mesh,
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object &object,
Mesh &mesh,
float **tot_area,
float **tot_uv_area);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object *object,
Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_edges(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_verts(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object &object,
Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_edges(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_verts(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object &object, Mesh &mesh);
/** \} */
@@ -272,8 +272,8 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object *object, Me
/** \name For Image UV Editor
* \{ */
blender::gpu::Batch *DRW_mesh_batch_cache_get_uv_edges(Object *object, Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh *mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_uv_edges(Object &object, Mesh &mesh);
blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh &mesh);
/** \} */
@@ -281,9 +281,9 @@ blender::gpu::Batch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh *mesh);
/** \name For Direct Data Access
* \{ */
gpu::VertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(Mesh *mesh);
gpu::VertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(Mesh &mesh);
int DRW_mesh_material_count_get(const Object *object, const Mesh *mesh);
int DRW_mesh_material_count_get(const Object &object, const Mesh &mesh);
/* Edit mesh bitflags (is this the right place?) */
enum {

View File

@@ -676,8 +676,8 @@ static bool ensure_attributes(const Curves &curves,
CurvesBatchCache &cache,
const GPUMaterial *gpu_material)
{
const CustomData *cd_curve = &curves.geometry.curve_data;
const CustomData *cd_point = &curves.geometry.point_data;
const CustomData &cd_curve = curves.geometry.curve_data;
const CustomData &cd_point = curves.geometry.point_data;
CurvesEvalFinalCache &final_cache = cache.eval_cache.final;
if (gpu_material) {
@@ -697,7 +697,7 @@ static bool ensure_attributes(const Curves &curves,
* We do it based on the specified name.
*/
if (name[0] != '\0') {
layer = CustomData_get_named_layer(cd_curve, CD_PROP_FLOAT2, name);
layer = CustomData_get_named_layer(&cd_curve, CD_PROP_FLOAT2, name);
type = CD_MTFACE;
domain = bke::AttrDomain::Curve;
@@ -738,16 +738,16 @@ static bool ensure_attributes(const Curves &curves,
case CD_MTFACE: {
if (layer == -1) {
layer = (name[0] != '\0') ?
CustomData_get_named_layer(cd_curve, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(cd_curve, CD_PROP_FLOAT2);
CustomData_get_named_layer(&cd_curve, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(&cd_curve, CD_PROP_FLOAT2);
if (layer != -1) {
domain = bke::AttrDomain::Curve;
}
}
if (layer == -1) {
layer = (name[0] != '\0') ?
CustomData_get_named_layer(cd_point, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(cd_point, CD_PROP_FLOAT2);
CustomData_get_named_layer(&cd_point, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(&cd_point, CD_PROP_FLOAT2);
if (layer != -1) {
domain = bke::AttrDomain::Point;
}
@@ -755,7 +755,7 @@ static bool ensure_attributes(const Curves &curves,
if (layer != -1 && name[0] == '\0' && domain.has_value()) {
name = CustomData_get_layer_name(
domain == bke::AttrDomain::Curve ? cd_curve : cd_point, CD_PROP_FLOAT2, layer);
domain == bke::AttrDomain::Curve ? &cd_curve : &cd_point, CD_PROP_FLOAT2, layer);
}
if (layer != -1 && domain.has_value()) {

View File

@@ -240,53 +240,53 @@ BLI_INLINE void mesh_cd_layers_type_clear(DRW_MeshCDMask *a)
*((uint32_t *)a) = 0;
}
static void mesh_cd_calc_edit_uv_layer(const Mesh * /*mesh*/, DRW_MeshCDMask *cd_used)
static void mesh_cd_calc_edit_uv_layer(const Mesh & /*mesh*/, DRW_MeshCDMask *cd_used)
{
cd_used->edit_uv = 1;
}
static void mesh_cd_calc_active_uv_layer(const Object *object,
const Mesh *mesh,
DRW_MeshCDMask *cd_used)
static void mesh_cd_calc_active_uv_layer(const Object &object,
const Mesh &mesh,
DRW_MeshCDMask &cd_used)
{
const Mesh *me_final = editmesh_final_or_this(object, mesh);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
int layer = CustomData_get_active_layer(cd_ldata, CD_PROP_FLOAT2);
const Mesh &me_final = editmesh_final_or_this(object, mesh);
const CustomData &cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
int layer = CustomData_get_active_layer(&cd_ldata, CD_PROP_FLOAT2);
if (layer != -1) {
cd_used->uv |= (1 << layer);
cd_used.uv |= (1 << layer);
}
}
static void mesh_cd_calc_active_mask_uv_layer(const Object *object,
const Mesh *mesh,
DRW_MeshCDMask *cd_used)
static void mesh_cd_calc_active_mask_uv_layer(const Object &object,
const Mesh &mesh,
DRW_MeshCDMask &cd_used)
{
const Mesh *me_final = editmesh_final_or_this(object, mesh);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
int layer = CustomData_get_stencil_layer(cd_ldata, CD_PROP_FLOAT2);
const Mesh &me_final = editmesh_final_or_this(object, mesh);
const CustomData &cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
int layer = CustomData_get_stencil_layer(&cd_ldata, CD_PROP_FLOAT2);
if (layer != -1) {
cd_used->uv |= (1 << layer);
cd_used.uv |= (1 << layer);
}
}
static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
const Mesh *mesh,
static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object &object,
const Mesh &mesh,
const GPUMaterial *const *gpumat_array,
int gpumat_array_len,
DRW_Attributes *attributes)
{
const Mesh *me_final = editmesh_final_or_this(object, mesh);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
const CustomData *cd_pdata = mesh_cd_pdata_get_from_mesh(me_final);
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_edata = mesh_cd_edata_get_from_mesh(me_final);
const Mesh &me_final = editmesh_final_or_this(object, mesh);
const CustomData &cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
const CustomData &cd_pdata = mesh_cd_pdata_get_from_mesh(me_final);
const CustomData &cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData &cd_edata = mesh_cd_edata_get_from_mesh(me_final);
/* See: DM_vertex_attributes_from_gpu for similar logic */
DRW_MeshCDMask cd_used;
mesh_cd_layers_type_clear(&cd_used);
const StringRefNull default_color_name = me_final->default_color_attribute ?
me_final->default_color_attribute :
const StringRefNull default_color_name = me_final.default_color_attribute ?
me_final.default_color_attribute :
"";
for (int i = 0; i < gpumat_array_len; i++) {
@@ -311,7 +311,7 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
* We do it based on the specified name.
*/
if (name[0] != '\0') {
layer = CustomData_get_named_layer(cd_ldata, CD_PROP_FLOAT2, name);
layer = CustomData_get_named_layer(&cd_ldata, CD_PROP_FLOAT2, name);
type = CD_MTFACE;
#if 0 /* Tangents are always from UVs - this will never happen. */
@@ -354,10 +354,10 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
case CD_MTFACE: {
if (layer == -1) {
layer = (name[0] != '\0') ?
CustomData_get_named_layer(cd_ldata, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2);
CustomData_get_named_layer(&cd_ldata, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(&cd_ldata, CD_PROP_FLOAT2);
}
if (layer != -1 && !CustomData_layer_is_anonymous(cd_ldata, CD_PROP_FLOAT2, layer)) {
if (layer != -1 && !CustomData_layer_is_anonymous(&cd_ldata, CD_PROP_FLOAT2, layer)) {
cd_used.uv |= (1 << layer);
}
break;
@@ -365,12 +365,12 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
case CD_TANGENT: {
if (layer == -1) {
layer = (name[0] != '\0') ?
CustomData_get_named_layer(cd_ldata, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2);
CustomData_get_named_layer(&cd_ldata, CD_PROP_FLOAT2, name) :
CustomData_get_render_layer(&cd_ldata, CD_PROP_FLOAT2);
/* Only fallback to orco (below) when we have no UV layers, see: #56545 */
if (layer == -1 && name[0] != '\0') {
layer = CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2);
layer = CustomData_get_render_layer(&cd_ldata, CD_PROP_FLOAT2);
}
}
if (layer != -1) {
@@ -470,28 +470,28 @@ static bool drw_mesh_weight_state_compare(const DRW_MeshWeightState *a,
}
static void drw_mesh_weight_state_extract(
Object *ob, Mesh *mesh, const ToolSettings *ts, bool paint_mode, DRW_MeshWeightState *wstate)
Object &ob, Mesh &mesh, const ToolSettings &ts, bool paint_mode, DRW_MeshWeightState *wstate)
{
/* Extract complete vertex weight group selection state and mode flags. */
memset(wstate, 0, sizeof(*wstate));
wstate->defgroup_active = mesh->vertex_group_active_index - 1;
wstate->defgroup_len = BLI_listbase_count(&mesh->vertex_group_names);
wstate->defgroup_active = mesh.vertex_group_active_index - 1;
wstate->defgroup_len = BLI_listbase_count(&mesh.vertex_group_names);
wstate->alert_mode = ts->weightuser;
wstate->alert_mode = ts.weightuser;
if (paint_mode && ts->multipaint) {
if (paint_mode && ts.multipaint) {
/* Multi-paint needs to know all selected bones, not just the active group.
* This is actually a relatively expensive operation, but caching would be difficult. */
wstate->defgroup_sel = BKE_object_defgroup_selected_get(
ob, wstate->defgroup_len, &wstate->defgroup_sel_count);
&ob, wstate->defgroup_len, &wstate->defgroup_sel_count);
if (wstate->defgroup_sel_count > 1) {
wstate->flags |= DRW_MESH_WEIGHT_STATE_MULTIPAINT |
(ts->auto_normalize ? DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE : 0);
(ts.auto_normalize ? DRW_MESH_WEIGHT_STATE_AUTO_NORMALIZE : 0);
if (ME_USING_MIRROR_X_VERTEX_GROUPS(mesh)) {
BKE_object_defgroup_mirror_selection(ob,
if (ME_USING_MIRROR_X_VERTEX_GROUPS(&mesh)) {
BKE_object_defgroup_mirror_selection(&ob,
wstate->defgroup_len,
wstate->defgroup_sel,
wstate->defgroup_sel,
@@ -505,10 +505,10 @@ static void drw_mesh_weight_state_extract(
}
}
if (paint_mode && ts->wpaint_lock_relative) {
if (paint_mode && ts.wpaint_lock_relative) {
/* Set of locked vertex groups for the lock relative mode. */
wstate->defgroup_locked = BKE_object_defgroup_lock_flags_get(ob, wstate->defgroup_len);
wstate->defgroup_unlocked = BKE_object_defgroup_validmap_get(ob, wstate->defgroup_len);
wstate->defgroup_locked = BKE_object_defgroup_lock_flags_get(&ob, wstate->defgroup_len);
wstate->defgroup_unlocked = BKE_object_defgroup_validmap_get(&ob, wstate->defgroup_len);
/* Check that a deform group is active, and none of selected groups are locked. */
if (BKE_object_defgroup_check_lock_relative(
@@ -547,9 +547,9 @@ BLI_INLINE void mesh_batch_cache_add_request(MeshBatchCache &cache, DRWBatchFlag
/* gpu::Batch cache management. */
static bool mesh_batch_cache_valid(Object *object, Mesh *mesh)
static bool mesh_batch_cache_valid(Object &object, Mesh &mesh)
{
MeshBatchCache *cache = static_cast<MeshBatchCache *>(mesh->runtime->batch_cache);
MeshBatchCache *cache = static_cast<MeshBatchCache *>(mesh.runtime->batch_cache);
if (cache == nullptr) {
return false;
@@ -557,7 +557,7 @@ static bool mesh_batch_cache_valid(Object *object, Mesh *mesh)
/* NOTE: PBVH draw data should not be checked here. */
if (cache->is_editmode != (mesh->runtime->edit_mesh != nullptr)) {
if (cache->is_editmode != (mesh.runtime->edit_mesh != nullptr)) {
return false;
}
@@ -572,20 +572,20 @@ static bool mesh_batch_cache_valid(Object *object, Mesh *mesh)
return true;
}
static void mesh_batch_cache_init(Object *object, Mesh *mesh)
static void mesh_batch_cache_init(Object &object, Mesh &mesh)
{
if (!mesh->runtime->batch_cache) {
mesh->runtime->batch_cache = MEM_new<MeshBatchCache>(__func__);
if (!mesh.runtime->batch_cache) {
mesh.runtime->batch_cache = MEM_new<MeshBatchCache>(__func__);
}
else {
*static_cast<MeshBatchCache *>(mesh->runtime->batch_cache) = {};
*static_cast<MeshBatchCache *>(mesh.runtime->batch_cache) = {};
}
MeshBatchCache *cache = static_cast<MeshBatchCache *>(mesh->runtime->batch_cache);
MeshBatchCache *cache = static_cast<MeshBatchCache *>(mesh.runtime->batch_cache);
cache->is_editmode = mesh->runtime->edit_mesh != nullptr;
cache->is_editmode = mesh.runtime->edit_mesh != nullptr;
if (object->sculpt && object->sculpt->pbvh) {
cache->pbvh_is_drawing = BKE_pbvh_is_drawing(*object->sculpt->pbvh);
if (object.sculpt && object.sculpt->pbvh) {
cache->pbvh_is_drawing = BKE_pbvh_is_drawing(*object.sculpt->pbvh);
}
if (cache->is_editmode == false) {
@@ -606,19 +606,19 @@ static void mesh_batch_cache_init(Object *object, Mesh *mesh)
drw_mesh_weight_state_clear(&cache->weight_state);
}
void DRW_mesh_batch_cache_validate(Object *object, Mesh *mesh)
void DRW_mesh_batch_cache_validate(Object &object, Mesh &mesh)
{
if (!mesh_batch_cache_valid(object, mesh)) {
if (mesh->runtime->batch_cache) {
mesh_batch_cache_clear(*static_cast<MeshBatchCache *>(mesh->runtime->batch_cache));
if (mesh.runtime->batch_cache) {
mesh_batch_cache_clear(*static_cast<MeshBatchCache *>(mesh.runtime->batch_cache));
}
mesh_batch_cache_init(object, mesh);
}
}
static MeshBatchCache *mesh_batch_cache_get(Mesh *mesh)
static MeshBatchCache *mesh_batch_cache_get(Mesh &mesh)
{
return static_cast<MeshBatchCache *>(mesh->runtime->batch_cache);
return static_cast<MeshBatchCache *>(mesh.runtime->batch_cache);
}
static void mesh_batch_cache_check_vertex_group(MeshBatchCache &cache,
@@ -846,16 +846,16 @@ void DRW_mesh_batch_cache_free(void *batch_cache)
/** \name Public API
* \{ */
static void texpaint_request_active_uv(MeshBatchCache &cache, Object *object, Mesh *mesh)
static void texpaint_request_active_uv(MeshBatchCache &cache, Object &object, Mesh &mesh)
{
DRW_MeshCDMask cd_needed;
mesh_cd_layers_type_clear(&cd_needed);
mesh_cd_calc_active_uv_layer(object, mesh, &cd_needed);
mesh_cd_calc_active_uv_layer(object, mesh, cd_needed);
BLI_assert(cd_needed.uv != 0 &&
"No uv layer available in texpaint, but batches requested anyway!");
mesh_cd_calc_active_mask_uv_layer(object, mesh, &cd_needed);
mesh_cd_calc_active_mask_uv_layer(object, mesh, cd_needed);
mesh_cd_layers_type_merge(&cache.cd_needed, cd_needed);
}
@@ -863,9 +863,9 @@ static void request_active_and_default_color_attributes(const Object &object,
const Mesh &mesh,
DRW_Attributes &attributes)
{
const Mesh *me_final = editmesh_final_or_this(&object, &mesh);
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
const Mesh &me_final = editmesh_final_or_this(object, mesh);
const CustomData &cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData &cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
auto request_color_attribute = [&](const char *name) {
if (name) {
@@ -880,25 +880,25 @@ static void request_active_and_default_color_attributes(const Object &object,
}
};
request_color_attribute(me_final->active_color_attribute);
request_color_attribute(me_final->default_color_attribute);
request_color_attribute(me_final.active_color_attribute);
request_color_attribute(me_final.default_color_attribute);
}
gpu::Batch *DRW_mesh_batch_cache_get_all_verts(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_all_verts(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_ALL_VERTS);
return DRW_batch_request(&cache.batch.all_verts);
}
gpu::Batch *DRW_mesh_batch_cache_get_all_edges(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_all_edges(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_ALL_EDGES);
return DRW_batch_request(&cache.batch.all_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_surface(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_request_surface_batches(cache);
@@ -906,7 +906,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_surface(Mesh *mesh)
return cache.batch.surface;
}
gpu::Batch *DRW_mesh_batch_cache_get_loose_edges(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_loose_edges(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_LOOSE_EDGES);
@@ -917,14 +917,14 @@ gpu::Batch *DRW_mesh_batch_cache_get_loose_edges(Mesh *mesh)
return DRW_batch_request(&cache.batch.loose_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_weights(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_weights(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_SURFACE_WEIGHTS);
return DRW_batch_request(&cache.batch.surface_weights);
}
gpu::Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *mesh, bool *r_is_manifold)
gpu::Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh &mesh, bool *r_is_manifold)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDGE_DETECTION);
@@ -936,22 +936,22 @@ gpu::Batch *DRW_mesh_batch_cache_get_edge_detection(Mesh *mesh, bool *r_is_manif
return DRW_batch_request(&cache.batch.edge_detection);
}
gpu::Batch *DRW_mesh_batch_cache_get_wireframes_face(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_wireframes_face(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_WIRE_EDGES);
return DRW_batch_request(&cache.batch.wire_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_mesh_analysis(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_MESH_ANALYSIS);
return DRW_batch_request(&cache.batch.edit_mesh_analysis);
}
void DRW_mesh_get_attributes(const Object *object,
const Mesh *mesh,
void DRW_mesh_get_attributes(const Object &object,
const Mesh &mesh,
const GPUMaterial *const *gpumat_array,
int gpumat_array_len,
DRW_Attributes *r_attrs,
@@ -971,8 +971,8 @@ void DRW_mesh_get_attributes(const Object *object,
}
}
gpu::Batch **DRW_mesh_batch_cache_get_surface_shaded(Object *object,
Mesh *mesh,
gpu::Batch **DRW_mesh_batch_cache_get_surface_shaded(Object &object,
Mesh &mesh,
GPUMaterial **gpumat_array,
uint gpumat_array_len)
{
@@ -985,12 +985,12 @@ gpu::Batch **DRW_mesh_batch_cache_get_surface_shaded(Object *object,
BLI_assert(gpumat_array_len == cache.mat_len);
mesh_cd_layers_type_merge(&cache.cd_needed, cd_needed);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh->runtime->render_mutex);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh.runtime->render_mutex);
mesh_batch_cache_request_surface_batches(cache);
return cache.surface_per_mat.data();
}
gpu::Batch **DRW_mesh_batch_cache_get_surface_texpaint(Object *object, Mesh *mesh)
gpu::Batch **DRW_mesh_batch_cache_get_surface_texpaint(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
texpaint_request_active_uv(cache, object, mesh);
@@ -998,7 +998,7 @@ gpu::Batch **DRW_mesh_batch_cache_get_surface_texpaint(Object *object, Mesh *mes
return cache.surface_per_mat.data();
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
texpaint_request_active_uv(cache, object, mesh);
@@ -1006,38 +1006,38 @@ gpu::Batch *DRW_mesh_batch_cache_get_surface_texpaint_single(Object *object, Mes
return cache.batch.surface;
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_vertpaint(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_vertpaint(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
DRW_Attributes attrs_needed{};
request_active_and_default_color_attributes(*object, *mesh, attrs_needed);
request_active_and_default_color_attributes(object, mesh, attrs_needed);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh->runtime->render_mutex);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh.runtime->render_mutex);
mesh_batch_cache_request_surface_batches(cache);
return cache.batch.surface;
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_sculpt(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_sculpt(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
DRW_Attributes attrs_needed{};
request_active_and_default_color_attributes(*object, *mesh, attrs_needed);
request_active_and_default_color_attributes(object, mesh, attrs_needed);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh->runtime->render_mutex);
drw_attributes_merge(&cache.attr_needed, &attrs_needed, mesh.runtime->render_mutex);
mesh_batch_cache_request_surface_batches(cache);
return cache.batch.surface;
}
int DRW_mesh_material_count_get(const Object *object, const Mesh *mesh)
int DRW_mesh_material_count_get(const Object &object, const Mesh &mesh)
{
return mesh_render_mat_len_get(object, mesh);
}
gpu::Batch *DRW_mesh_batch_cache_get_sculpt_overlays(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_sculpt_overlays(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
@@ -1048,7 +1048,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_sculpt_overlays(Mesh *mesh)
return cache.batch.sculpt_overlays;
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
@@ -1064,7 +1064,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_surface_viewer_attribute(Mesh *mesh)
/** \name Edit Mode API
* \{ */
gpu::VertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(Mesh *mesh)
gpu::VertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
/* Request surface to trigger the vbo filling. Otherwise it may do nothing. */
@@ -1080,49 +1080,49 @@ gpu::VertBuf *DRW_mesh_batch_cache_pos_vertbuf_get(Mesh *mesh)
/** \name Edit Mode API
* \{ */
gpu::Batch *DRW_mesh_batch_cache_get_edit_triangles(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_triangles(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_TRIANGLES);
return DRW_batch_request(&cache.batch.edit_triangles);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_edges(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_edges(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_EDGES);
return DRW_batch_request(&cache.batch.edit_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_vertices(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_vertices(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_VERTICES);
return DRW_batch_request(&cache.batch.edit_vertices);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_vert_normals(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_vert_normals(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_VNOR);
return DRW_batch_request(&cache.batch.edit_vnor);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_loop_normals(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_loop_normals(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_LNOR);
return DRW_batch_request(&cache.batch.edit_lnor);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_facedots(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_facedots(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_FACEDOTS);
return DRW_batch_request(&cache.batch.edit_fdots);
}
gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_SKIN_ROOTS);
@@ -1135,28 +1135,28 @@ gpu::Batch *DRW_mesh_batch_cache_get_edit_skin_roots(Mesh *mesh)
/** \name Edit Mode selection API
* \{ */
gpu::Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_triangles_with_select_id(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_SELECTION_FACES);
return DRW_batch_request(&cache.batch.edit_selection_faces);
}
gpu::Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_facedots_with_select_id(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_SELECTION_FACEDOTS);
return DRW_batch_request(&cache.batch.edit_selection_fdots);
}
gpu::Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edges_with_select_id(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_SELECTION_EDGES);
return DRW_batch_request(&cache.batch.edit_selection_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
mesh_batch_cache_add_request(cache, MBC_EDIT_SELECTION_VERTS);
@@ -1169,22 +1169,22 @@ gpu::Batch *DRW_mesh_batch_cache_get_verts_with_select_id(Mesh *mesh)
/** \name UV Image editor API
* \{ */
static void edituv_request_active_uv(MeshBatchCache &cache, Object *object, Mesh *mesh)
static void edituv_request_active_uv(MeshBatchCache &cache, Object &object, Mesh &mesh)
{
DRW_MeshCDMask cd_needed;
mesh_cd_layers_type_clear(&cd_needed);
mesh_cd_calc_active_uv_layer(object, mesh, &cd_needed);
mesh_cd_calc_active_uv_layer(object, mesh, cd_needed);
mesh_cd_calc_edit_uv_layer(mesh, &cd_needed);
BLI_assert(cd_needed.edit_uv != 0 &&
"No uv layer available in edituv, but batches requested anyway!");
mesh_cd_calc_active_mask_uv_layer(object, mesh, &cd_needed);
mesh_cd_calc_active_mask_uv_layer(object, mesh, cd_needed);
mesh_cd_layers_type_merge(&cache.cd_needed, cd_needed);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object *object,
Mesh *mesh,
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object &object,
Mesh &mesh,
float **tot_area,
float **tot_uv_area)
{
@@ -1201,7 +1201,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_area(Object *object,
return DRW_batch_request(&cache.batch.edituv_faces_stretch_area);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1209,7 +1209,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces_stretch_angle(Object *object,
return DRW_batch_request(&cache.batch.edituv_faces_stretch_angle);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1217,7 +1217,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_faces(Object *object, Mesh *mesh)
return DRW_batch_request(&cache.batch.edituv_faces);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_edges(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edituv_edges(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1225,7 +1225,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_edges(Object *object, Mesh *mesh)
return DRW_batch_request(&cache.batch.edituv_edges);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_verts(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edituv_verts(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1233,7 +1233,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_verts(Object *object, Mesh *mesh)
return DRW_batch_request(&cache.batch.edituv_verts);
}
gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1241,7 +1241,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_edituv_facedots(Object *object, Mesh *mesh)
return DRW_batch_request(&cache.batch.edituv_fdots);
}
gpu::Batch *DRW_mesh_batch_cache_get_uv_edges(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_uv_edges(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
edituv_request_active_uv(cache, object, mesh);
@@ -1249,7 +1249,7 @@ gpu::Batch *DRW_mesh_batch_cache_get_uv_edges(Object *object, Mesh *mesh)
return DRW_batch_request(&cache.batch.wire_loops_uvs);
}
gpu::Batch *DRW_mesh_batch_cache_get_surface_edges(Object *object, Mesh *mesh)
gpu::Batch *DRW_mesh_batch_cache_get_surface_edges(Object &object, Mesh &mesh)
{
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
texpaint_request_active_uv(cache, object, mesh);
@@ -1298,14 +1298,14 @@ static void drw_add_attributes_vbo(gpu::Batch *batch,
#ifndef NDEBUG
/* Sanity check function to test if all requested batches are available. */
static void drw_mesh_batch_cache_check_available(TaskGraph *task_graph, Mesh *mesh)
static void drw_mesh_batch_cache_check_available(TaskGraph &task_graph, Mesh &mesh)
{
MeshBatchCache *cache = mesh_batch_cache_get(mesh);
/* Make sure all requested batches have been setup. */
/* NOTE: The next line creates a different scheduling than during release builds what can lead to
* some issues (See #77867 where we needed to disable this function in order to debug what was
* happening in release builds). */
BLI_task_graph_work_and_wait(task_graph);
BLI_task_graph_work_and_wait(&task_graph);
for (int i = 0; i < MBC_BATCH_LEN; i++) {
BLI_assert(!DRW_batch_requested(((gpu::Batch **)&cache->batch)[i], (GPUPrimType)0));
}
@@ -1330,18 +1330,15 @@ static void drw_mesh_batch_cache_check_available(TaskGraph *task_graph, Mesh *me
}
#endif
void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
Object *ob,
Mesh *mesh,
const Scene *scene,
void DRW_mesh_batch_cache_create_requested(TaskGraph &task_graph,
Object &ob,
Mesh &mesh,
const Scene &scene,
const bool is_paint_mode,
const bool use_hide)
{
BLI_assert(task_graph);
const ToolSettings *ts = nullptr;
if (scene) {
ts = scene->toolsettings;
}
const ToolSettings *ts = scene.toolsettings;
MeshBatchCache &cache = *mesh_batch_cache_get(mesh);
bool cd_uv_update = false;
@@ -1372,16 +1369,16 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
#endif
/* Sanity check. */
if ((mesh->runtime->edit_mesh != nullptr) && (ob->mode & OB_MODE_EDIT)) {
BLI_assert(BKE_object_get_editmesh_eval_final(ob) != nullptr);
if ((mesh.runtime->edit_mesh != nullptr) && (ob.mode & OB_MODE_EDIT)) {
BLI_assert(BKE_object_get_editmesh_eval_final(&ob) != nullptr);
}
const bool is_editmode = (mesh->runtime->edit_mesh != nullptr) &&
(BKE_object_get_editmesh_eval_final(ob) != nullptr) &&
DRW_object_is_in_edit_mode(ob);
const bool is_editmode = (mesh.runtime->edit_mesh != nullptr) &&
(BKE_object_get_editmesh_eval_final(&ob) != nullptr) &&
DRW_object_is_in_edit_mode(&ob);
/* This could be set for paint mode too, currently it's only used for edit-mode. */
const bool edit_mode_active = is_editmode && DRW_object_is_in_edit_mode(ob);
const bool edit_mode_active = is_editmode && DRW_object_is_in_edit_mode(&ob);
DRWBatchFlag batch_requested = cache.batch_requested;
cache.batch_requested = (DRWBatchFlag)0;
@@ -1390,8 +1387,8 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
/* Check vertex weights. */
if ((cache.batch.surface_weights != nullptr) && (ts != nullptr)) {
DRW_MeshWeightState wstate;
BLI_assert(ob->type == OB_MESH);
drw_mesh_weight_state_extract(ob, mesh, ts, is_paint_mode, &wstate);
BLI_assert(ob.type == OB_MESH);
drw_mesh_weight_state_extract(ob, mesh, *ts, is_paint_mode, &wstate);
mesh_batch_cache_check_vertex_group(cache, &wstate);
drw_mesh_weight_state_copy(&cache.weight_state, &wstate);
drw_mesh_weight_state_clear(&wstate);
@@ -1405,8 +1402,8 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
/* Modifiers will only generate an orco layer if the mesh is deformed. */
if (cache.cd_needed.orco != 0) {
/* Orco is always extracted from final mesh. */
const Mesh *me_final = (mesh->runtime->edit_mesh) ? BKE_object_get_editmesh_eval_final(ob) :
mesh;
const Mesh *me_final = (mesh.runtime->edit_mesh) ? BKE_object_get_editmesh_eval_final(&ob) :
&mesh;
if (CustomData_get_layer(&me_final->vert_data, CD_ORCO) == nullptr) {
/* Skip orco calculation */
cache.cd_needed.orco = 0;
@@ -1451,13 +1448,13 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
cache.batch_ready &= ~(MBC_SURFACE);
mesh_cd_layers_type_merge(&cache.cd_used, cache.cd_needed);
drw_attributes_merge(&cache.attr_used, &cache.attr_needed, mesh->runtime->render_mutex);
drw_attributes_merge(&cache.attr_used, &cache.attr_needed, mesh.runtime->render_mutex);
}
mesh_cd_layers_type_merge(&cache.cd_used_over_time, cache.cd_needed);
mesh_cd_layers_type_clear(&cache.cd_needed);
drw_attributes_merge(
&cache.attr_used_over_time, &cache.attr_needed, mesh->runtime->render_mutex);
&cache.attr_used_over_time, &cache.attr_needed, mesh.runtime->render_mutex);
drw_attributes_clear(&cache.attr_needed);
}
@@ -1501,25 +1498,25 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
* Normal updates should be part of the brush loop and only run during the stroke when the
* brush needs to sample the surface. The drawing code should only update the normals
* per redraw when smooth shading is enabled. */
const bool do_update_sculpt_normals = ob->sculpt && ob->sculpt->pbvh;
const bool do_update_sculpt_normals = ob.sculpt && ob.sculpt->pbvh;
if (do_update_sculpt_normals) {
Mesh *mesh = static_cast<Mesh *>(ob->data);
bke::pbvh::update_normals(*ob->sculpt->pbvh, mesh->runtime->subdiv_ccg.get());
Mesh *mesh = static_cast<Mesh *>(ob.data);
bke::pbvh::update_normals(*ob.sculpt->pbvh, mesh->runtime->subdiv_ccg.get());
}
cache.batch_ready |= batch_requested;
bool do_cage = false, do_uvcage = false;
if (is_editmode && edit_mode_active) {
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(ob);
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(ob);
const Mesh *editmesh_eval_final = BKE_object_get_editmesh_eval_final(&ob);
const Mesh *editmesh_eval_cage = BKE_object_get_editmesh_eval_cage(&ob);
do_cage = editmesh_eval_final != editmesh_eval_cage;
do_uvcage = !(editmesh_eval_final->runtime->is_original_bmesh &&
editmesh_eval_final->runtime->wrapper_type == ME_WRAPPER_TYPE_BMESH);
}
const bool do_subdivision = BKE_subsurf_modifier_has_gpu_subdiv(mesh);
const bool do_subdivision = BKE_subsurf_modifier_has_gpu_subdiv(&mesh);
MeshBufferList *mbuflist = &cache.final.buff;
@@ -1869,7 +1866,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
is_editmode,
is_paint_mode,
edit_mode_active,
ob->object_to_world(),
ob.object_to_world(),
false,
true,
scene,
@@ -1886,7 +1883,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
is_editmode,
is_paint_mode,
edit_mode_active,
ob->object_to_world(),
ob.object_to_world(),
false,
false,
scene,
@@ -1898,11 +1895,11 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
DRW_create_subdivision(ob,
mesh,
cache,
&cache.final,
cache.final,
is_editmode,
is_paint_mode,
edit_mode_active,
ob->object_to_world(),
ob.object_to_world(),
true,
false,
do_cage,
@@ -1923,7 +1920,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
is_editmode,
is_paint_mode,
edit_mode_active,
ob->object_to_world(),
ob.object_to_world(),
true,
false,
scene,
@@ -1937,7 +1934,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
* An idea to improve this is to separate the Object mode from the edit mode draw caches. And
* based on the mode the correct one will be updated. Other option is to look into using
* drw_batch_cache_generate_requested_delayed. */
BLI_task_graph_work_and_wait(task_graph);
BLI_task_graph_work_and_wait(&task_graph);
#ifndef NDEBUG
drw_mesh_batch_cache_check_available(task_graph, mesh);
#endif

View File

@@ -349,7 +349,7 @@ gpu::Batch **pointcloud_surface_shaded_get(PointCloud *pointcloud,
int layer_index;
eCustomDataType type;
bke::AttrDomain domain = bke::AttrDomain::Point;
if (!drw_custom_data_match_attribute(&pointcloud->pdata, name, &layer_index, &type)) {
if (!drw_custom_data_match_attribute(pointcloud->pdata, name, &layer_index, &type)) {
continue;
}
@@ -402,7 +402,7 @@ gpu::VertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const
int layer_index;
eCustomDataType type;
bke::AttrDomain domain = bke::AttrDomain::Point;
if (drw_custom_data_match_attribute(&pointcloud->pdata, name, &layer_index, &type)) {
if (drw_custom_data_match_attribute(pointcloud->pdata, name, &layer_index, &type)) {
DRW_Attributes attributes{};
drw_attributes_add_request(&attributes, name, type, layer_index, domain);
drw_attributes_merge(&cache.eval_cache.attr_used, &attributes, cache.render_mutex);

View File

@@ -2101,8 +2101,8 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache &cache,
MEM_freeN(per_face_mat_offset);
}
static bool draw_subdiv_create_requested_buffers(Object *ob,
Mesh *mesh,
static bool draw_subdiv_create_requested_buffers(Object &ob,
Mesh &mesh,
MeshBatchCache &batch_cache,
MeshBufferCache &mbc,
const bool is_editmode,
@@ -2116,18 +2116,18 @@ static bool draw_subdiv_create_requested_buffers(Object *ob,
const bool use_hide,
OpenSubdiv_EvaluatorCache *evaluator_cache)
{
SubsurfRuntimeData *runtime_data = mesh->runtime->subsurf_runtime_data;
SubsurfRuntimeData *runtime_data = mesh.runtime->subsurf_runtime_data;
BLI_assert(runtime_data && runtime_data->has_gpu_subdiv);
if (runtime_data->settings.level == 0) {
return false;
}
const Mesh *mesh_eval = mesh;
const Mesh *mesh_eval = &mesh;
BMesh *bm = nullptr;
if (mesh->runtime->edit_mesh) {
mesh_eval = BKE_object_get_editmesh_eval_final(ob);
bm = mesh->runtime->edit_mesh->bm;
if (mesh.runtime->edit_mesh) {
mesh_eval = BKE_object_get_editmesh_eval_final(&ob);
bm = mesh.runtime->edit_mesh->bm;
}
draw_subdiv_invalidate_evaluator_for_orco(runtime_data->subdiv_gpu, mesh_eval);
@@ -2207,24 +2207,24 @@ static bool draw_subdiv_create_requested_buffers(Object *ob,
return true;
}
void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cache)
void DRW_subdivide_loose_geom(DRWSubdivCache &subdiv_cache, const MeshBufferCache &cache)
{
const int coarse_loose_vert_len = cache->loose_geom.verts.size();
const int coarse_loose_edge_len = cache->loose_geom.edges.size();
const int coarse_loose_vert_len = cache.loose_geom.verts.size();
const int coarse_loose_edge_len = cache.loose_geom.edges.size();
if (coarse_loose_vert_len == 0 && coarse_loose_edge_len == 0) {
/* Nothing to do. */
return;
}
if (subdiv_cache->loose_geom.edges || subdiv_cache->loose_geom.verts) {
if (subdiv_cache.loose_geom.edges || subdiv_cache.loose_geom.verts) {
/* Already processed. */
return;
}
const Mesh *coarse_mesh = subdiv_cache->mesh;
const bool is_simple = subdiv_cache->subdiv->settings.is_simple;
const int resolution = subdiv_cache->resolution;
const Mesh *coarse_mesh = subdiv_cache.mesh;
const bool is_simple = subdiv_cache.subdiv->settings.is_simple;
const int resolution = subdiv_cache.resolution;
const int resolution_1 = resolution - 1;
const float inv_resolution_1 = 1.0f / float(resolution_1);
const int num_subdiv_vertices_per_coarse_edge = resolution - 2;
@@ -2257,8 +2257,8 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac
coarse_edges, coarse_mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
for (int i = 0; i < coarse_loose_edge_len; i++) {
const int coarse_edge_index = cache->loose_geom.edges[i];
const int2 &coarse_edge = coarse_edges[cache->loose_geom.edges[i]];
const int coarse_edge_index = cache.loose_geom.edges[i];
const int2 &coarse_edge = coarse_edges[cache.loose_geom.edges[i]];
/* Perform interpolation of each vertex. */
for (int i = 0; i < resolution - 1; i++, subd_edge_offset++) {
@@ -2287,18 +2287,18 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac
/* Copy the remaining loose_verts. */
for (int i = 0; i < coarse_loose_vert_len; i++) {
const int coarse_vertex_index = cache->loose_geom.verts[i];
const int coarse_vertex_index = cache.loose_geom.verts[i];
DRWSubdivLooseVertex &subd_v = loose_subd_verts[subd_vert_offset++];
subd_v.coarse_vertex_index = cache->loose_geom.verts[i];
subd_v.coarse_vertex_index = cache.loose_geom.verts[i];
copy_v3_v3(subd_v.co, coarse_positions[coarse_vertex_index]);
}
subdiv_cache->loose_geom.edges = loose_subd_edges;
subdiv_cache->loose_geom.verts = loose_subd_verts;
subdiv_cache->loose_geom.edge_len = num_subdivided_edge;
subdiv_cache->loose_geom.vert_len = coarse_loose_vert_len;
subdiv_cache->loose_geom.loop_len = num_subdivided_edge * 2 + coarse_loose_vert_len;
subdiv_cache.loose_geom.edges = loose_subd_edges;
subdiv_cache.loose_geom.verts = loose_subd_verts;
subdiv_cache.loose_geom.edge_len = num_subdivided_edge;
subdiv_cache.loose_geom.vert_len = coarse_loose_vert_len;
subdiv_cache.loose_geom.loop_len = num_subdivided_edge * 2 + coarse_loose_vert_len;
}
Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache &cache)
@@ -2314,10 +2314,10 @@ Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCach
static OpenSubdiv_EvaluatorCache *g_evaluator_cache = nullptr;
void DRW_create_subdivision(Object *ob,
Mesh *mesh,
void DRW_create_subdivision(Object &ob,
Mesh &mesh,
MeshBatchCache &batch_cache,
MeshBufferCache *mbc,
MeshBufferCache &mbc,
const bool is_editmode,
const bool is_paint_mode,
const bool edit_mode_active,
@@ -2341,7 +2341,7 @@ void DRW_create_subdivision(Object *ob,
if (!draw_subdiv_create_requested_buffers(ob,
mesh,
batch_cache,
*mbc,
mbc,
is_editmode,
is_paint_mode,
edit_mode_active,

View File

@@ -2880,7 +2880,7 @@ void DRW_draw_depth_object(
case OB_MESH: {
blender::gpu::Batch *batch;
Mesh *mesh = static_cast<Mesh *>(object->data);
Mesh &mesh = *static_cast<Mesh *>(object->data);
if (object->mode & OB_MODE_EDIT) {
batch = DRW_mesh_batch_cache_get_edit_triangles(mesh);
@@ -2889,7 +2889,7 @@ void DRW_draw_depth_object(
batch = DRW_mesh_batch_cache_get_surface(mesh);
}
TaskGraph *task_graph = BLI_task_graph_create();
DRW_mesh_batch_cache_create_requested(task_graph, object, mesh, scene, false, true);
DRW_mesh_batch_cache_create_requested(*task_graph, *object, mesh, *scene, false, true);
BLI_task_graph_work_and_wait(task_graph);
BLI_task_graph_free(task_graph);

View File

@@ -743,8 +743,8 @@ void drw_engine_data_free(GPUViewport *viewport);
namespace blender::draw {
void DRW_mesh_get_attributes(const Object *object,
const Mesh *mesh,
void DRW_mesh_get_attributes(const Object &object,
const Mesh &mesh,
const GPUMaterial *const *gpumat_array,
int gpumat_array_len,
DRW_Attributes *r_attrs,

View File

@@ -1471,7 +1471,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups,
const Mesh *mesh = static_cast<const Mesh *>(ob->data);
if (gpumats) {
DRW_mesh_get_attributes(ob, mesh, gpumats, num_shgroups, &draw_attrs, &cd_needed);
DRW_mesh_get_attributes(*ob, *mesh, gpumats, num_shgroups, &draw_attrs, &cd_needed);
}
else {
memset(&draw_attrs, 0, sizeof(draw_attrs));

View File

@@ -163,7 +163,7 @@ Vector<SculptBatch> sculpt_batches_per_material_get(const Object *ob,
DRW_Attributes draw_attrs;
DRW_MeshCDMask cd_needed;
DRW_mesh_get_attributes(ob, mesh, materials.data(), materials.size(), &draw_attrs, &cd_needed);
DRW_mesh_get_attributes(*ob, *mesh, materials.data(), materials.size(), &draw_attrs, &cd_needed);
Vector<pbvh::AttributeRequest, 16> attrs;

View File

@@ -170,10 +170,6 @@ struct DRWSubdivCache {
/* Contains the start loop index and the smooth flag for each coarse face. */
gpu::VertBuf *extra_coarse_face_data;
/* Computed for `ibo.points`, one value per subdivided vertex,
* mapping coarse vertices -> subdivided loop. */
int *point_indices;
/* Material offsets. */
int *mat_start;
int *mat_end;
@@ -197,10 +193,10 @@ void draw_subdiv_cache_free(DRWSubdivCache &cache);
/** \} */
void DRW_create_subdivision(Object *ob,
Mesh *mesh,
void DRW_create_subdivision(Object &ob,
Mesh &mesh,
MeshBatchCache &batch_cache,
MeshBufferCache *mbc,
MeshBufferCache &mbc,
bool is_editmode,
bool is_paint_mode,
bool edit_mode_active,
@@ -211,7 +207,7 @@ void DRW_create_subdivision(Object *ob,
const ToolSettings *ts,
bool use_hide);
void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cache);
void DRW_subdivide_loose_geom(DRWSubdivCache &subdiv_cache, const MeshBufferCache &cache);
void DRW_subdiv_cache_free(bke::subdiv::Subdiv *subdiv);

View File

@@ -124,11 +124,11 @@ struct MeshRenderData {
const char *default_color_name;
};
const Mesh *editmesh_final_or_this(const Object *object, const Mesh *mesh);
const CustomData *mesh_cd_vdata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_edata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_pdata_get_from_mesh(const Mesh *mesh);
const CustomData *mesh_cd_ldata_get_from_mesh(const Mesh *mesh);
const Mesh &editmesh_final_or_this(const Object &object, const Mesh &mesh);
const CustomData &mesh_cd_vdata_get_from_mesh(const Mesh &mesh);
const CustomData &mesh_cd_edata_get_from_mesh(const Mesh &mesh);
const CustomData &mesh_cd_pdata_get_from_mesh(const Mesh &mesh);
const CustomData &mesh_cd_ldata_get_from_mesh(const Mesh &mesh);
BLI_INLINE BMFace *bm_original_face_get(const MeshRenderData &mr, int idx)
{
@@ -279,8 +279,8 @@ struct MeshExtract {
* \param edit_mode_active: When true, use the modifiers from the edit-data,
* otherwise don't use modifiers as they are not from this object.
*/
MeshRenderData *mesh_render_data_create(Object *object,
Mesh *mesh,
MeshRenderData *mesh_render_data_create(Object &object,
Mesh &mesh,
bool is_editmode,
bool is_paint_mode,
bool edit_mode_active,