Cleanup: GPv3: Small tweaks to modifiers
- Fix modifier icon - Remove unused includes - Remove unused argument - Change function name - Use `eval_frame` for retrieving drawings - Avoid unnecessary cast - Remove unnecessary parentheses - Declare some variables const Pull Request: https://projects.blender.org/blender/blender/pulls/117281
This commit is contained in:
@@ -203,7 +203,7 @@ const EnumPropertyItem rna_enum_object_modifier_type_items[] = {
|
|||||||
"Convert faces into thickened edges"},
|
"Convert faces into thickened edges"},
|
||||||
{eModifierType_GreasePencilSubdiv,
|
{eModifierType_GreasePencilSubdiv,
|
||||||
"GREASEPENCIL_SUBDIV",
|
"GREASEPENCIL_SUBDIV",
|
||||||
ICON_GREASEPENCIL,
|
ICON_MOD_SUBSURF,
|
||||||
"Subdivide strokes",
|
"Subdivide strokes",
|
||||||
"Grease Pencil subdivide modifier"},
|
"Grease Pencil subdivide modifier"},
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
|
|
||||||
#include "BLO_read_write.hh"
|
#include "BLO_read_write.hh"
|
||||||
|
|
||||||
#include "DEG_depsgraph_query.hh"
|
|
||||||
|
|
||||||
#include "UI_interface.hh"
|
#include "UI_interface.hh"
|
||||||
#include "UI_resources.hh"
|
#include "UI_resources.hh"
|
||||||
|
|
||||||
@@ -143,11 +141,9 @@ static void modify_fill_color(const GreasePencilOpacityModifierData &omd,
|
|||||||
/* Fill color opacity per stroke. */
|
/* Fill color opacity per stroke. */
|
||||||
bke::SpanAttributeWriter<float> fill_opacities = attributes.lookup_or_add_for_write_span<float>(
|
bke::SpanAttributeWriter<float> fill_opacities = attributes.lookup_or_add_for_write_span<float>(
|
||||||
"fill_opacity", bke::AttrDomain::Curve);
|
"fill_opacity", bke::AttrDomain::Curve);
|
||||||
VArray<float> vgroup_weights = attributes
|
const StringRef vgroup_name = omd.influence.vertex_group_name;
|
||||||
.lookup_or_default<float>(omd.influence.vertex_group_name,
|
const VArray<float> vgroup_weights =
|
||||||
bke::AttrDomain::Point,
|
attributes.lookup_or_default<float>(vgroup_name, bke::AttrDomain::Point, 1.0f).varray;
|
||||||
1.0f)
|
|
||||||
.varray;
|
|
||||||
|
|
||||||
curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) {
|
curves_mask.foreach_index(GrainSize(512), [&](int64_t curve_i) {
|
||||||
if (use_vgroup_opacity) {
|
if (use_vgroup_opacity) {
|
||||||
@@ -188,10 +184,10 @@ static void modify_curves(ModifierData *md,
|
|||||||
const ModifierEvalContext *ctx,
|
const ModifierEvalContext *ctx,
|
||||||
bke::CurvesGeometry &curves)
|
bke::CurvesGeometry &curves)
|
||||||
{
|
{
|
||||||
auto *omd = reinterpret_cast<GreasePencilOpacityModifierData *>(md);
|
const auto *omd = reinterpret_cast<GreasePencilOpacityModifierData *>(md);
|
||||||
|
|
||||||
IndexMaskMemory mask_memory;
|
IndexMaskMemory mask_memory;
|
||||||
IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask(
|
const IndexMask curves_mask = modifier::greasepencil::get_filtered_stroke_mask(
|
||||||
ctx->object, curves, omd->influence, mask_memory);
|
ctx->object, curves, omd->influence, mask_memory);
|
||||||
|
|
||||||
switch (omd->color_mode) {
|
switch (omd->color_mode) {
|
||||||
@@ -215,9 +211,7 @@ static void modify_geometry_set(ModifierData *md,
|
|||||||
const ModifierEvalContext *ctx,
|
const ModifierEvalContext *ctx,
|
||||||
bke::GeometrySet *geometry_set)
|
bke::GeometrySet *geometry_set)
|
||||||
{
|
{
|
||||||
auto *omd = reinterpret_cast<GreasePencilOpacityModifierData *>(md);
|
const auto *omd = reinterpret_cast<GreasePencilOpacityModifierData *>(md);
|
||||||
const Scene *scene = DEG_get_evaluated_scene(ctx->depsgraph);
|
|
||||||
const int frame = scene->r.cfra;
|
|
||||||
|
|
||||||
GreasePencil *grease_pencil = geometry_set->get_grease_pencil_for_write();
|
GreasePencil *grease_pencil = geometry_set->get_grease_pencil_for_write();
|
||||||
if (grease_pencil == nullptr) {
|
if (grease_pencil == nullptr) {
|
||||||
@@ -225,9 +219,10 @@ static void modify_geometry_set(ModifierData *md,
|
|||||||
}
|
}
|
||||||
|
|
||||||
IndexMaskMemory mask_memory;
|
IndexMaskMemory mask_memory;
|
||||||
IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
|
const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
|
||||||
*grease_pencil, omd->influence, mask_memory);
|
*grease_pencil, omd->influence, mask_memory);
|
||||||
Vector<Drawing *> drawings = modifier::greasepencil::get_drawings_for_write(
|
const int frame = grease_pencil->runtime->eval_frame;
|
||||||
|
const Vector<Drawing *> drawings = modifier::greasepencil::get_drawings_for_write(
|
||||||
*grease_pencil, layer_mask, frame);
|
*grease_pencil, layer_mask, frame);
|
||||||
threading::parallel_for_each(
|
threading::parallel_for_each(
|
||||||
drawings, [&](Drawing *drawing) { modify_curves(md, ctx, drawing->strokes_for_write()); });
|
drawings, [&](Drawing *drawing) { modify_curves(md, ctx, drawing->strokes_for_write()); });
|
||||||
@@ -309,9 +304,8 @@ ModifierTypeInfo modifierType_GreasePencilOpacity = {
|
|||||||
/*srna*/ &RNA_GreasePencilOpacityModifier,
|
/*srna*/ &RNA_GreasePencilOpacityModifier,
|
||||||
/*type*/ ModifierTypeType::Nonconstructive,
|
/*type*/ ModifierTypeType::Nonconstructive,
|
||||||
/*flags*/
|
/*flags*/
|
||||||
static_cast<ModifierTypeFlag>(
|
eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode |
|
||||||
eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode |
|
eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping,
|
||||||
eModifierTypeFlag_EnableInEditmode | eModifierTypeFlag_SupportsMapping),
|
|
||||||
/*icon*/ ICON_MOD_OPACITY,
|
/*icon*/ ICON_MOD_OPACITY,
|
||||||
|
|
||||||
/*copy_data*/ blender::copy_data,
|
/*copy_data*/ blender::copy_data,
|
||||||
|
|||||||
@@ -6,11 +6,7 @@
|
|||||||
* \ingroup modifiers
|
* \ingroup modifiers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BLI_array.hh"
|
|
||||||
#include "BLI_index_mask.hh"
|
#include "BLI_index_mask.hh"
|
||||||
#include "BLI_math_vector_types.hh"
|
|
||||||
#include "BLI_task.h"
|
|
||||||
#include "BLI_utildefines.h"
|
|
||||||
|
|
||||||
#include "BLT_translation.h"
|
#include "BLT_translation.h"
|
||||||
|
|
||||||
@@ -18,33 +14,23 @@
|
|||||||
|
|
||||||
#include "DNA_defaults.h"
|
#include "DNA_defaults.h"
|
||||||
#include "DNA_modifier_types.h"
|
#include "DNA_modifier_types.h"
|
||||||
#include "DNA_scene_types.h"
|
|
||||||
#include "DNA_screen_types.h"
|
#include "DNA_screen_types.h"
|
||||||
|
|
||||||
#include "BKE_context.hh"
|
|
||||||
#include "BKE_curves.hh"
|
|
||||||
#include "BKE_geometry_set.hh"
|
#include "BKE_geometry_set.hh"
|
||||||
#include "BKE_grease_pencil.hh"
|
#include "BKE_grease_pencil.hh"
|
||||||
#include "BKE_lib_query.hh"
|
|
||||||
#include "BKE_modifier.hh"
|
#include "BKE_modifier.hh"
|
||||||
#include "BKE_screen.hh"
|
|
||||||
|
|
||||||
#include "GEO_subdivide_curves.hh"
|
#include "GEO_subdivide_curves.hh"
|
||||||
|
|
||||||
#include "UI_interface.hh"
|
#include "UI_interface.hh"
|
||||||
#include "UI_resources.hh"
|
#include "UI_resources.hh"
|
||||||
|
|
||||||
#include "ED_grease_pencil.hh"
|
|
||||||
|
|
||||||
#include "MOD_grease_pencil_util.hh"
|
#include "MOD_grease_pencil_util.hh"
|
||||||
#include "MOD_modifiertypes.hh"
|
#include "MOD_modifiertypes.hh"
|
||||||
#include "MOD_ui_common.hh"
|
#include "MOD_ui_common.hh"
|
||||||
|
|
||||||
#include "RNA_prototypes.h"
|
#include "RNA_prototypes.h"
|
||||||
|
|
||||||
#include "DEG_depsgraph.hh"
|
|
||||||
#include "DEG_depsgraph_query.hh"
|
|
||||||
|
|
||||||
namespace blender {
|
namespace blender {
|
||||||
|
|
||||||
static void init_data(ModifierData *md)
|
static void init_data(ModifierData *md)
|
||||||
@@ -91,10 +77,7 @@ static void blend_read(BlendDataReader *reader, ModifierData *md)
|
|||||||
modifier::greasepencil::read_influence_data(reader, &mmd->influence);
|
modifier::greasepencil::read_influence_data(reader, &mmd->influence);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deform_drawing(ModifierData &md,
|
static void subdivide_drawing(ModifierData &md, Object &ob, bke::greasepencil::Drawing &drawing)
|
||||||
Depsgraph * /*depsgraph*/,
|
|
||||||
Object &ob,
|
|
||||||
bke::greasepencil::Drawing &drawing)
|
|
||||||
{
|
{
|
||||||
GreasePencilSubdivModifierData &mmd = reinterpret_cast<GreasePencilSubdivModifierData &>(md);
|
GreasePencilSubdivModifierData &mmd = reinterpret_cast<GreasePencilSubdivModifierData &>(md);
|
||||||
|
|
||||||
@@ -102,7 +85,7 @@ static void deform_drawing(ModifierData &md,
|
|||||||
const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask(
|
const IndexMask strokes = modifier::greasepencil::get_filtered_stroke_mask(
|
||||||
&ob, drawing.strokes_for_write(), mmd.influence, memory);
|
&ob, drawing.strokes_for_write(), mmd.influence, memory);
|
||||||
|
|
||||||
VArray<int> cuts = VArray<int>::ForSingle(mmd.level, drawing.strokes().points_num());
|
const VArray<int> cuts = VArray<int>::ForSingle(mmd.level, drawing.strokes().points_num());
|
||||||
|
|
||||||
drawing.strokes_for_write() = geometry::subdivide_curves(
|
drawing.strokes_for_write() = geometry::subdivide_curves(
|
||||||
drawing.strokes(), strokes, std::move(cuts), {});
|
drawing.strokes(), strokes, std::move(cuts), {});
|
||||||
@@ -120,7 +103,7 @@ static void modify_geometry_set(ModifierData *md,
|
|||||||
}
|
}
|
||||||
|
|
||||||
GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write();
|
GreasePencil &grease_pencil = *geometry_set->get_grease_pencil_for_write();
|
||||||
const int current_frame = DEG_get_evaluated_scene(ctx->depsgraph)->r.cfra;
|
const int current_frame = grease_pencil.runtime->eval_frame;
|
||||||
|
|
||||||
IndexMaskMemory mask_memory;
|
IndexMaskMemory mask_memory;
|
||||||
const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
|
const IndexMask layer_mask = modifier::greasepencil::get_filtered_layer_mask(
|
||||||
@@ -129,7 +112,7 @@ static void modify_geometry_set(ModifierData *md,
|
|||||||
modifier::greasepencil::get_drawings_for_write(grease_pencil, layer_mask, current_frame);
|
modifier::greasepencil::get_drawings_for_write(grease_pencil, layer_mask, current_frame);
|
||||||
|
|
||||||
threading::parallel_for_each(drawings, [&](bke::greasepencil::Drawing *drawing) {
|
threading::parallel_for_each(drawings, [&](bke::greasepencil::Drawing *drawing) {
|
||||||
deform_drawing(*md, ctx->depsgraph, *ctx->object, *drawing);
|
subdivide_drawing(*md, *ctx->object, *drawing);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,8 +159,8 @@ ModifierTypeInfo modifierType_GreasePencilSubdiv = {
|
|||||||
/*srna*/ &RNA_GreasePencilSubdivModifier,
|
/*srna*/ &RNA_GreasePencilSubdivModifier,
|
||||||
/*type*/ ModifierTypeType::Constructive,
|
/*type*/ ModifierTypeType::Constructive,
|
||||||
/*flags*/
|
/*flags*/
|
||||||
(eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode |
|
eModifierTypeFlag_AcceptsGreasePencil | eModifierTypeFlag_SupportsEditmode |
|
||||||
eModifierTypeFlag_EnableInEditmode),
|
eModifierTypeFlag_EnableInEditmode,
|
||||||
/*icon*/ ICON_MOD_SUBSURF,
|
/*icon*/ ICON_MOD_SUBSURF,
|
||||||
|
|
||||||
/*copy_data*/ blender::copy_data,
|
/*copy_data*/ blender::copy_data,
|
||||||
|
|||||||
Reference in New Issue
Block a user