From fba76712051331ab15272bcf1fe4e654775e4bdc Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 19 Oct 2023 15:03:32 +0200 Subject: [PATCH] Cleanup: Const correctness, unused variable warning in GP draw code --- source/blender/blenkernel/intern/grease_pencil.cc | 1 + .../blender/draw/engines/gpencil/gpencil_object.hh | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/source/blender/blenkernel/intern/grease_pencil.cc b/source/blender/blenkernel/intern/grease_pencil.cc index d61bd7800d1..6863b40eeb9 100644 --- a/source/blender/blenkernel/intern/grease_pencil.cc +++ b/source/blender/blenkernel/intern/grease_pencil.cc @@ -1398,6 +1398,7 @@ void BKE_grease_pencil_material_remap(GreasePencil *grease_pencil, const uint *r } for (const int i : material_indices.span.index_range()) { BLI_assert(blender::IndexRange(totcol).contains(remap[material_indices.span[i]])); + UNUSED_VARS_NDEBUG(totcol); material_indices.span[i] = remap[material_indices.span[i]]; } material_indices.finish(); diff --git a/source/blender/draw/engines/gpencil/gpencil_object.hh b/source/blender/draw/engines/gpencil/gpencil_object.hh index 746905b8eaf..328d77df395 100644 --- a/source/blender/draw/engines/gpencil/gpencil_object.hh +++ b/source/blender/draw/engines/gpencil/gpencil_object.hh @@ -116,7 +116,7 @@ class ObjectModule { using namespace blender::bke::greasepencil; Object *object = object_ref.object; - GreasePencil &grease_pencil = *static_cast(object->data); + const GreasePencil &grease_pencil = *static_cast(object->data); if (grease_pencil.drawings().is_empty()) { return; @@ -196,7 +196,7 @@ class ObjectModule { object_subpass.draw(geom, handle); } - float4x4 plane_mat = get_object_plane_mat(object); + float4x4 plane_mat = get_object_plane_mat(*object); ResourceHandle handle_plane_mat = manager.resource_handle(plane_mat); object_subpass.framebuffer_set(&DRW_viewport_framebuffer_list_get()->depth_only_fb); object_subpass.state_set(DRW_STATE_DEPTH_LESS | DRW_STATE_WRITE_DEPTH); @@ -266,7 +266,7 @@ class ObjectModule { return objects_buf_.size() > 0; } - float4x4 get_object_plane_mat(Object *object) + float4x4 get_object_plane_mat(const Object &object) { using namespace math; /* Find the normal most likely to represent the gpObject. */ @@ -274,8 +274,8 @@ class ObjectModule { * strokes not aligned with the object axes. Maybe we could try to * compute the minimum axis of all strokes. But this would be more * computationally heavy and should go into the GPData evaluation. */ - BLI_assert(object->type == OB_GREASE_PENCIL); - const GreasePencil &grease_pencil = *static_cast(object->data); + BLI_assert(object.type == OB_GREASE_PENCIL); + const GreasePencil &grease_pencil = *static_cast(object.data); const std::optional> bounds = grease_pencil.bounds_min_max(); if (!bounds) { return float4x4::identity(); @@ -286,7 +286,7 @@ class ObjectModule { const float3 center = midpoint(bounds->min, bounds->max); /* BBox space to World. */ - const float4x4 object_to_world = float4x4(object->object_to_world); + const float4x4 object_to_world = float4x4(object.object_to_world); float4x4 bbox_mat = object_to_world * from_loc_rot_scale(center, Quaternion::identity(), size); float3 plane_normal;