LineArt: Use "Radius" instead of "Thickness" for generating strokes

Previously line art uses the same thickness value as found in grease
pencil before blender v4.3 for generating strokes, now everything is
migrated to using "radius", so it makes more sense to change that it to
using "radius" so it's consistent with everywhere else.

Pull Request: https://projects.blender.org/blender/blender/pulls/144121
This commit is contained in:
YimingWu
2025-08-07 15:40:17 +02:00
committed by YimingWu
parent 4333e070b4
commit 6f57268e9a
8 changed files with 33 additions and 12 deletions

View File

@@ -3197,7 +3197,7 @@ void lineart_wrap_v3(const LineartGpencilModifierData *lmd_legacy,
lmd->shadow_camera_near = lmd_legacy->shadow_camera_near;
lmd->shadow_camera_far = lmd_legacy->shadow_camera_far;
lmd->opacity = lmd_legacy->opacity;
lmd->thickness = lmd_legacy->thickness;
lmd->radius = float(lmd_legacy->thickness) * LEGACY_RADIUS_CONVERSION_FACTOR;
lmd->mask_switches = lmd_legacy->mask_switches;
lmd->material_mask_bits = lmd_legacy->material_mask_bits;
lmd->intersection_mask = lmd_legacy->intersection_mask;
@@ -3240,7 +3240,7 @@ void lineart_unwrap_v3(LineartGpencilModifierData *lmd_legacy,
lmd_legacy->shadow_camera_near = lmd->shadow_camera_near;
lmd_legacy->shadow_camera_far = lmd->shadow_camera_far;
lmd_legacy->opacity = lmd->opacity;
lmd_legacy->thickness = lmd->thickness;
lmd_legacy->thickness = lmd->radius / LEGACY_RADIUS_CONVERSION_FACTOR;
lmd_legacy->mask_switches = lmd->mask_switches;
lmd_legacy->material_mask_bits = lmd->material_mask_bits;
lmd_legacy->intersection_mask = lmd->intersection_mask;

View File

@@ -17,6 +17,7 @@
#include "DNA_curves_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_mesh_types.h"
#include "DNA_modifier_types.h"
#include "DNA_node_types.h"
#include "DNA_rigidbody_types.h"
#include "DNA_screen_types.h"
@@ -37,6 +38,7 @@
#include "BKE_attribute_legacy_convert.hh"
#include "BKE_colortools.hh"
#include "BKE_curves.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_idprop.hh"
#include "BKE_image_format.hh"
#include "BKE_lib_id.hh"
@@ -2161,6 +2163,21 @@ void blo_do_versions_500(FileData * /*fd*/, Library * /*lib*/, Main *bmain)
}
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 500, 54)) {
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
LISTBASE_FOREACH (ModifierData *, modifier, &object->modifiers) {
if (modifier->type != eModifierType_GreasePencilLineart) {
continue;
}
GreasePencilLineartModifierData *lmd = reinterpret_cast<GreasePencilLineartModifierData *>(
modifier);
if (lmd->radius != 0.0f) {
continue;
}
lmd->radius = float(lmd->thickness_legacy) *
bke::greasepencil::LEGACY_RADIUS_CONVERSION_FACTOR;
}
}
FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
if (node_tree->type != NTREE_COMPOSIT) {
continue;

View File

@@ -217,7 +217,7 @@ static bool bake_strokes(Object *ob,
lmd->mask_switches,
lmd->material_mask_bits,
lmd->intersection_mask,
float(lmd->thickness) / 1000.0f,
lmd->radius,
lmd->opacity,
lmd->shadow_selection,
lmd->silhouette_selection,

View File

@@ -969,8 +969,9 @@
#define _DNA_DEFAULT_GreasePencilLineartModifierData \
{ \
.edge_types = MOD_LINEART_EDGE_FLAG_INIT_TYPE, \
.thickness = 25, \
.radius = 0.0025, \
.opacity = 1.0f, \
.thickness_legacy = 25, \
.crease_threshold = DEG2RAD(140.0f), \
.calculation_flags = MOD_LINEART_ALLOW_DUPLI_OBJECTS | MOD_LINEART_ALLOW_CLIPPING_BOUNDARIES | \
MOD_LINEART_USE_CREASE_ON_SHARP_EDGES | MOD_LINEART_FILTER_FACE_MARK_KEEP_CONTOUR | \

View File

@@ -3193,7 +3193,9 @@ typedef struct GreasePencilLineartModifierData {
float shadow_camera_far;
float opacity;
short thickness;
float radius;
short thickness_legacy; /* Deprecated, use `radius`. */
unsigned char mask_switches; /* #eGreasePencilLineartMaskSwitches */
unsigned char material_mask_bits;
@@ -3201,7 +3203,7 @@ typedef struct GreasePencilLineartModifierData {
unsigned char shadow_selection;
unsigned char silhouette_selection;
char _pad[1];
char _pad[5];
/** `0..1` range for cosine angle */
float crease_threshold;

View File

@@ -112,6 +112,7 @@ DNA_STRUCT_RENAME_MEMBER(GreasePencil, drawing_array_size, drawing_array_num)
DNA_STRUCT_RENAME_MEMBER(GreasePencil, layers_data, layers_data_legacy)
DNA_STRUCT_RENAME_MEMBER(GreasePencil, material_array_size, material_array_num)
DNA_STRUCT_RENAME_MEMBER(GreasePencilLayerFramesMapStorage, size, num)
DNA_STRUCT_RENAME_MEMBER(GreasePencilLineartModifierData, thickness, thickness_legacy)
DNA_STRUCT_RENAME_MEMBER(HookModifierData, totindex, indexar_num)
DNA_STRUCT_RENAME_MEMBER(Image, name, filepath)
DNA_STRUCT_RENAME_MEMBER(LaplacianDeformModifierData, total_verts, verts_num)

View File

@@ -9047,10 +9047,10 @@ static void rna_def_modifier_grease_pencil_lineart(BlenderRNA *brna)
RNA_def_property_range(prop, 0.0f, 0.5f);
RNA_def_property_update(prop, NC_SCENE, "rna_Modifier_update");
prop = RNA_def_property(srna, "thickness", PROP_INT, PROP_NONE);
RNA_def_property_ui_text(prop, "Thickness", "The thickness for the generated strokes");
RNA_def_property_ui_range(prop, 1, 100, 1, 1);
RNA_def_property_range(prop, 1, 200);
prop = RNA_def_property(srna, "radius", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_ui_text(prop, "Radius", "The radius for the generated strokes");
RNA_def_property_ui_range(prop, 0.0f, 0.25f, 0.01f, 2);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "opacity", PROP_FLOAT, PROP_FACTOR);

View File

@@ -255,7 +255,7 @@ static void panel_draw(const bContext * /*C*/, Panel *panel)
ptr, "target_material", &obj_data_ptr, "materials", std::nullopt, ICON_MATERIAL);
col = &layout->column(false);
col->prop(ptr, "thickness", UI_ITEM_R_SLIDER, IFACE_("Line Thickness"), ICON_NONE);
col->prop(ptr, "radius", UI_ITEM_R_SLIDER, IFACE_("Line Radius"), ICON_NONE);
col->prop(ptr, "opacity", UI_ITEM_R_SLIDER, std::nullopt, ICON_NONE);
modifier_error_message_draw(layout, ptr);
@@ -802,7 +802,7 @@ static void generate_strokes(ModifierData &md,
lmd.mask_switches,
lmd.material_mask_bits,
lmd.intersection_mask,
float(lmd.thickness) / 1000.0f,
lmd.radius,
lmd.opacity,
lmd.shadow_selection,
lmd.silhouette_selection,