Initial Grease Pencil 3.0 stage #106848

Merged
Falk David merged 224 commits from filedescriptor/blender:grease-pencil-v3 into main 2023-05-30 11:14:22 +02:00
9 changed files with 22 additions and 26 deletions
Showing only changes of commit 520c95f261 - Show all commits

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
* Copyright 2023 Blender Foundation. */
filedescriptor marked this conversation as resolved Outdated

2023

2023
/** \file
* \ingroup draw

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
* Copyright 2023 Blender Foundation. */
filedescriptor marked this conversation as resolved Outdated

2023

2023
/** \file
* \ingroup draw

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
* Copyright 2023 Blender Foundation. */

Check everywhere else :)

2023. Check everywhere else :)
/** \file
* \ingroup draw
@ -8,7 +8,6 @@
#pragma once
#include "BKE_grease_pencil.hh"
#include "BKE_image.h"
#include "DRW_gpu_wrapper.hh"
filedescriptor marked this conversation as resolved
Review

I am not sure all of those are needed here.
I.e. I do not see any BKE_image API used in this header. Might be missing something.

I am not sure all of those are needed here. I.e. I do not see any `BKE_image` API used in this header. Might be missing something.
#include "DRW_render.h"
@ -30,9 +29,10 @@ class LayerModule {
layers_buf_.clear();
}
void sync(const Object *object, const bke::greasepencil::Layer &layer, bool &do_layer_blending)
void sync(const Object * /*object*/,
const bke::greasepencil::Layer & /*layer*/,
bool &do_layer_blending)
{

In C++ use void sync(const Object * /*object*/, const bke::greasepencil::Layer & /*layer*/, bool &do_layer_blending)

In C++ use `void sync(const Object * /*object*/, const bke::greasepencil::Layer & /*layer*/, bool &do_layer_blending)`
UNUSED_VARS(object, layer);
/* TODO(fclem): All of this is placeholder. */
gpLayer gp_layer;
gp_layer.vertex_color_opacity = 0.0f;

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
* Copyright 2023 Blender Foundation. */
/** \file
* \ingroup draw

View File

@ -1,5 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. */
* Copyright 2023 Blender Foundation. */
/** \file
* \ingroup draw

View File

@ -1,4 +1,5 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2023 Blender Foundation. */
#ifndef GPU_SHADER
# pragma once

View File

@ -685,11 +685,8 @@ static bool ED_object_editmode_load_free_ex(Main *bmain,
ED_mball_editmball_free(obedit);
}
}
else if (obedit->type == OB_CURVES) {
/* Curves don't have specific edit mode data, so pass. */
}
else if (obedit->type == OB_GREASE_PENCIL) {
/* Grease Pencil does not have specific edit mode data, so pass. */
else if (ELEM(obedit->type, OB_CURVES, OB_GREASE_PENCIL)) {
/* Object doesn't have specific edit mode data, so pass. */
}
else {

This could be added to the existing OB_CURVES check with ELEM

This could be added to the existing `OB_CURVES` check with `ELEM`
return false;

View File

@ -46,8 +46,6 @@ static bool start_brush_operation(bContext &C,
/* FIXME: Somehow store the unique_ptr in the PaintStroke. */
operation = greasepencil::new_paint_operation().release();
break;
default:
BLI_assert_unreachable();
}
Review

I am not really sure what the goal is here. If the goal is to somehow ensure all cases are handled it is much better to not use default and let compiler tell you where cases are missing at the compile time.

I am not really sure what the goal is here. If the goal is to somehow ensure all cases are handled it is much better to not use `default` and let compiler tell you where cases are missing at the compile time.
if (operation) {
@ -122,16 +120,16 @@ static int grease_pencil_stroke_invoke(bContext *C, wmOperator *op, const wmEven
return OPERATOR_CANCELLED;
}
op->customdata = static_cast<void *>(paint_stroke_new(C,
op,
stroke_get_location,
stroke_test_start,
stroke_update_step,
stroke_redraw,
stroke_done,
event->type));
op->customdata = paint_stroke_new(C,
op,
stroke_get_location,
filedescriptor marked this conversation as resolved Outdated

Is the explicit cast to void* needed?

Is the explicit cast to `void*` needed?
stroke_test_start,
stroke_update_step,
stroke_redraw,
stroke_done,
event->type);
int return_value = op->type->modal(C, op, event);
const int return_value = op->type->modal(C, op, event);
if (return_value == OPERATOR_FINISHED) {
return OPERATOR_FINISHED;
filedescriptor marked this conversation as resolved
Review

const int

`const int`
}

View File

@ -109,7 +109,7 @@ void PaintOperation::on_stroke_done(const bContext &C)
curves.offsets_for_write()[num_old_curves] = num_old_points;
curves.offsets_for_write()[num_old_curves + 1] = num_old_points + stroke_points.size();
const offset_indices::OffsetIndices<int> points_by_curve = curves.points_by_curve();
const OffsetIndices<int> points_by_curve = curves.points_by_curve();
filedescriptor marked this conversation as resolved Outdated

offset_indices::OffsetIndices -> OffsetIndices

`offset_indices::OffsetIndices` -> `OffsetIndices`
const IndexRange new_points_range = points_by_curve[curves.curves_num() - 1];
const IndexRange new_curves_range = IndexRange(num_old_curves, 1);