[Bf-blender-cvs] [2897d16a7fc] temp-lineart-contained: LineArt: Stroke Offset fixes
YimingWu
noreply at git.blender.org
Wed Aug 25 04:41:00 CEST 2021
Commit: 2897d16a7fcf4b67361fdafdcf758512b3d26285
Author: YimingWu
Date: Wed Aug 25 10:39:03 2021 +0800
Branches: temp-lineart-contained
https://developer.blender.org/rB2897d16a7fcf4b67361fdafdcf758512b3d26285
LineArt: Stroke Offset fixes
===================================================================
M source/blender/editors/object/object_add.c
M source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
M source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
M source/blender/makesdna/DNA_gpencil_modifier_defaults.h
M source/blender/makesrna/intern/rna_gpencil_modifier.c
===================================================================
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c
index 99154a98fc7..608f6bba07a 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -1530,7 +1530,7 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot)
RNA_def_boolean(ot->srna,
"use_in_front",
false,
- "In Front",
+ "Show In Front",
"Show line art grease pencil in front of everything");
RNA_def_boolean(
ot->srna, "use_lights", false, "Use Lights", "Use lights for this grease pencil object");
@@ -1540,7 +1540,7 @@ void OBJECT_OT_gpencil_add(wmOperatorType *ot)
rna_enum_gpencil_add_stroke_depth_order_items,
GP_DRAWMODE_3D,
"Stroke Depth Order",
- "Defines how the strokes are ordered in 3D space for objects not displayed 'In Front'");
+ "Defines how the strokes are ordered in 3D space for objects not displayed 'In Front')");
}
/** \} */
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 4f4a7fd07eb..e798477d70b 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -1132,19 +1132,35 @@ void MOD_lineart_chain_offset_towards_camera(LineartRenderBuffer *rb,
{
float dir[3];
float cam[3];
-
+ float view[3];
+ float view_clamp[3];
if (use_custom_camera) {
copy_v3fl_v3db(cam, rb->camera_pos);
}
else {
copy_v3fl_v3db(cam, rb->active_camera_pos);
}
-
- LISTBASE_FOREACH (LineartEdgeChain *, ec, &rb->chains) {
- LISTBASE_FOREACH (LineartEdgeChainItem *, eci, &ec->chain) {
- sub_v3_v3v3(dir, cam, eci->gpos);
- normalize_v3_length(dir, dist);
- add_v3_v3(eci->gpos, dir);
+ copy_v3fl_v3db(view, rb->view_vector);
+ if (rb->cam_is_persp) {
+ LISTBASE_FOREACH (LineartEdgeChain *, rlc, &rb->chains) {
+ LISTBASE_FOREACH (LineartEdgeChainItem *, rlci, &rlc->chain) {
+ sub_v3_v3v3(dir, cam, rlci->gpos);
+ float orig_len = len_v3(dir);
+ normalize_v3(dir);
+ mul_v3_fl(dir, MIN2(dist, orig_len - rb->near_clip));
+ add_v3_v3(rlci->gpos, dir);
+ }
+ }
+ }
+ else {
+ LISTBASE_FOREACH (LineartEdgeChain *, rlc, &rb->chains) {
+ LISTBASE_FOREACH (LineartEdgeChainItem *, rlci, &rlc->chain) {
+ sub_v3_v3v3(dir, cam, rlci->gpos);
+ float len_lim = dot_v3v3(view, dir) - rb->near_clip;
+ normalize_v3_v3(view_clamp, view);
+ mul_v3_fl(view_clamp, MIN2(dist, len_lim));
+ add_v3_v3(rlci->gpos, view_clamp);
+ }
}
}
}
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 8b93afe9e64..3812d2c5898 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -4447,7 +4447,7 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph,
MOD_lineart_chain_split_angle(rb, rb->angle_splitting_threshold);
}
- if (enable_stroke_depth_offset && lmd->stroke_depth_offset > FLT_EPSILON) {
+ if (enable_stroke_depth_offset && (!compare_ff(lmd->stroke_depth_offset, 0.0f, 1e-7))) {
MOD_lineart_chain_offset_towards_camera(
rb, lmd->stroke_depth_offset, lmd->flags & LRT_GPENCIL_OFFSET_TOWARDS_CUSTOM_CAMERA);
}
diff --git a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
index 4224a395774..bd097eb5d69 100644
--- a/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
+++ b/source/blender/makesdna/DNA_gpencil_modifier_defaults.h
@@ -311,6 +311,7 @@
.stroke_depth_offset = 0.05,\
.chain_smooth_tolerance = 0.0f,\
.overscan = 0.1f,\
+ .stroke_depth_offset = 0.05,\
}
#define _DNA_DEFAULT_LengthGpencilModifierData \
diff --git a/source/blender/makesrna/intern/rna_gpencil_modifier.c b/source/blender/makesrna/intern/rna_gpencil_modifier.c
index e3144903500..a2faac99dbb 100644
--- a/source/blender/makesrna/intern/rna_gpencil_modifier.c
+++ b/source/blender/makesrna/intern/rna_gpencil_modifier.c
@@ -3059,7 +3059,6 @@ static void rna_def_modifier_gpencillineart(BlenderRNA *brna)
"Move strokes slightly towards the camera to avoid clipping while "
"preserve depth for the viewport");
RNA_def_property_ui_range(prop, 0.0f, 0.5f, 0.001f, 4);
- RNA_def_property_range(prop, 0.0f, 0.5f);
RNA_def_property_update(prop, NC_SCENE, "rna_GpencilModifier_update");
prop = RNA_def_property(srna, "source_camera", PROP_POINTER, PROP_NONE);
More information about the Bf-blender-cvs
mailing list