Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpencil_modifiers')
-rw-r--r--source/blender/gpencil_modifiers/CMakeLists.txt1
-rw-r--r--source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h1
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c14
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h2
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c1
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c17
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillength.c223
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c32
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c66
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c73
-rw-r--r--source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c59
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h88
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c586
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c1038
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h43
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c3
-rw-r--r--source/blender/gpencil_modifiers/intern/lineart/lineart_util.c16
17 files changed, 1356 insertions, 907 deletions
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 9690f47c862..f39306ac9d0 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -54,6 +54,7 @@ set(SRC
intern/MOD_gpencilcolor.c
intern/MOD_gpencilhook.c
intern/MOD_gpencillattice.c
+ intern/MOD_gpencillength.c
intern/MOD_gpencillineart.c
intern/MOD_gpencilmirror.c
intern/MOD_gpencilmultiply.c
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index e6ce7983a0f..f8a28f2e5cb 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -35,6 +35,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Array;
extern GpencilModifierTypeInfo modifierType_Gpencil_Build;
extern GpencilModifierTypeInfo modifierType_Gpencil_Opacity;
extern GpencilModifierTypeInfo modifierType_Gpencil_Lattice;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Length;
extern GpencilModifierTypeInfo modifierType_Gpencil_Mirror;
extern GpencilModifierTypeInfo modifierType_Gpencil_Smooth;
extern GpencilModifierTypeInfo modifierType_Gpencil_Hook;
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
index a156fca5b7b..94285b5032e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.c
@@ -203,6 +203,20 @@ void gpencil_modifier_curve_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiTemplateCurveMapping(layout, ptr, "curve", 0, false, false, false, false);
}
+void gpencil_modifier_fading_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiLayout *layout = panel->layout;
+ uiLayoutSetPropSep(layout, true);
+
+ uiItemR(layout, ptr, "object", 0, NULL, ICON_CUBE);
+ uiLayout *sub = uiLayoutColumn(layout, true);
+ uiItemR(sub, ptr, "fading_start", 0, NULL, ICON_NONE);
+ uiItemR(sub, ptr, "fading_end", 0, IFACE_("End"), ICON_NONE);
+ uiItemR(layout, ptr, "fading_end_factor", 0, NULL, ICON_NONE);
+}
+
/**
* Draw modifier error message.
*/
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
index 782b36d47ed..75907aaa781 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_ui_common.h
@@ -37,6 +37,8 @@ void gpencil_modifier_masking_panel_draw(Panel *panel, bool use_material, bool u
void gpencil_modifier_curve_header_draw(const bContext *C, Panel *panel);
void gpencil_modifier_curve_panel_draw(const bContext *C, Panel *panel);
+void gpencil_modifier_fading_draw(const bContext *UNUSED(C), Panel *panel);
+
void gpencil_modifier_panel_end(struct uiLayout *layout, PointerRNA *ptr);
struct PointerRNA *gpencil_modifier_panel_get_property_pointers(struct Panel *panel,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 2dc00079f91..b28a44a0521 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -54,6 +54,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
INIT_GP_TYPE(Build);
INIT_GP_TYPE(Opacity);
INIT_GP_TYPE(Lattice);
+ INIT_GP_TYPE(Length);
INIT_GP_TYPE(Mirror);
INIT_GP_TYPE(Smooth);
INIT_GP_TYPE(Hook);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
index d7fc08e38f3..d9f0fc9bddd 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
@@ -455,8 +455,10 @@ static void generate_geometry(
/* Compute start and end frames for the animation effect
* By default, the upper bound is given by the "maximum length" setting
*/
- float start_frame = gpf->framenum + mmd->start_delay;
- float end_frame = start_frame + mmd->length;
+ float start_frame = is_percentage ? gpf->framenum : gpf->framenum + mmd->start_delay;
+ /* When use percentage don't need a limit in the upper bound, so use a maximum value for the last
+ * frame. */
+ float end_frame = is_percentage ? start_frame + 9999 : start_frame + mmd->length;
if (gpf->next) {
/* Use the next frame or upper bound as end frame, whichever is lower/closer */
@@ -547,6 +549,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, &ob_ptr);
int mode = RNA_enum_get(ptr, "mode");
+ const bool use_percentage = RNA_boolean_get(ptr, "use_percentage");
uiLayoutSetPropSep(layout, true);
@@ -558,8 +561,12 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiItemS(layout);
uiItemR(layout, ptr, "transition", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "start_delay", 0, NULL, ICON_NONE);
- uiItemR(layout, ptr, "length", 0, IFACE_("Frames"), ICON_NONE);
+ row = uiLayoutRow(layout, true);
+ uiLayoutSetActive(row, !use_percentage);
+ uiItemR(row, ptr, "start_delay", 0, NULL, ICON_NONE);
+ row = uiLayoutRow(layout, true);
+ uiLayoutSetActive(row, !use_percentage);
+ uiItemR(row, ptr, "length", 0, IFACE_("Frames"), ICON_NONE);
uiItemS(layout);
@@ -567,7 +574,7 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayoutSetPropDecorate(row, false);
uiItemR(row, ptr, "use_percentage", 0, "", ICON_NONE);
sub = uiLayoutRow(row, true);
- uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_percentage"));
+ uiLayoutSetActive(sub, use_percentage);
uiItemR(sub, ptr, "percentage_factor", 0, "", ICON_NONE);
uiItemDecoratorR(row, ptr, "percentage_factor", 0);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
new file mode 100644
index 00000000000..fd94ac92bc3
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
@@ -0,0 +1,223 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017, Blender Foundation
+ * This is a new part of Blender
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "BLI_listbase.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+
+#include "BLT_translation.h"
+
+#include "DNA_defaults.h"
+#include "DNA_gpencil_modifier_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+
+#include "BKE_context.h"
+#include "BKE_gpencil_geom.h"
+#include "BKE_gpencil_modifier.h"
+#include "BKE_lib_query.h"
+#include "BKE_main.h"
+#include "BKE_modifier.h"
+#include "BKE_screen.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "RNA_access.h"
+
+#include "MOD_gpencil_modifiertypes.h"
+#include "MOD_gpencil_ui_common.h"
+#include "MOD_gpencil_util.h"
+
+#include "DEG_depsgraph.h"
+
+static void initData(GpencilModifierData *md)
+{
+ LengthGpencilModifierData *gpmd = (LengthGpencilModifierData *)md;
+
+ BLI_assert(MEMCMP_STRUCT_AFTER_IS_ZERO(gpmd, modifier));
+
+ MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(LengthGpencilModifierData), modifier);
+}
+
+static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
+{
+ BKE_gpencil_modifier_copydata_generic(md, target);
+}
+
+static bool gpencil_modify_stroke(bGPDstroke *gps,
+ float length,
+ const float overshoot_fac,
+ const short len_mode)
+{
+ bool changed = false;
+ if (length == 0.0f) {
+ return changed;
+ }
+
+ if (length > 0.0f) {
+ BKE_gpencil_stroke_stretch(gps, length, overshoot_fac, len_mode);
+ }
+ else {
+ changed |= BKE_gpencil_stroke_shrink(gps, fabs(length), len_mode);
+ }
+
+ return changed;
+}
+
+static void applyLength(LengthGpencilModifierData *lmd, bGPdata *gpd, bGPDstroke *gps)
+{
+ bool changed = false;
+ const float len = (lmd->mode == GP_LENGTH_ABSOLUTE) ? 1.0f :
+ BKE_gpencil_stroke_length(gps, true);
+ if (len < FLT_EPSILON) {
+ return;
+ }
+
+ changed |= gpencil_modify_stroke(gps, len * lmd->start_fac, lmd->overshoot_fac, 1);
+ changed |= gpencil_modify_stroke(gps, len * lmd->end_fac, lmd->overshoot_fac, 2);
+
+ if (changed) {
+ BKE_gpencil_stroke_geometry_update(gpd, gps);
+ }
+}
+
+static void bakeModifier(Main *UNUSED(bmain),
+ Depsgraph *UNUSED(depsgraph),
+ GpencilModifierData *md,
+ Object *ob)
+{
+
+ bGPdata *gpd = ob->data;
+
+ LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
+ LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
+ LengthGpencilModifierData *lmd = (LengthGpencilModifierData *)md;
+ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
+ applyLength(lmd, gpd, gps);
+ }
+ }
+ }
+}
+
+/* -------------------------------- */
+
+/* Generic "generateStrokes" callback */
+static void deformStroke(GpencilModifierData *md,
+ Depsgraph *UNUSED(depsgraph),
+ Object *ob,
+ bGPDlayer *gpl,
+ bGPDframe *UNUSED(gpf),
+ bGPDstroke *gps)
+{
+ bGPdata *gpd = ob->data;
+ LengthGpencilModifierData *lmd = (LengthGpencilModifierData *)md;
+ if (is_stroke_affected_by_modifier(ob,
+ lmd->layername,
+ lmd->material,
+ lmd->pass_index,
+ lmd->layer_pass,
+ 1,
+ gpl,
+ gps,
+ lmd->flag & GP_LENGTH_INVERT_LAYER,
+ lmd->flag & GP_LENGTH_INVERT_PASS,
+ lmd->flag & GP_LENGTH_INVERT_LAYERPASS,
+ lmd->flag & GP_LENGTH_INVERT_MATERIAL)) {
+ applyLength(lmd, gpd, gps);
+ }
+}
+
+static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk, void *userData)
+{
+ LengthGpencilModifierData *mmd = (LengthGpencilModifierData *)md;
+
+ walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
+}
+
+static void panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiLayoutSetPropSep(layout, true);
+ uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
+
+ uiLayout *col = uiLayoutColumn(layout, true);
+
+ uiItemR(col, ptr, "start_factor", 0, IFACE_("Start"), ICON_NONE);
+ uiItemR(col, ptr, "end_factor", 0, IFACE_("End"), ICON_NONE);
+
+ uiItemR(layout, ptr, "overshoot_factor", UI_ITEM_R_SLIDER, IFACE_("Overshoot"), ICON_NONE);
+
+ gpencil_modifier_panel_end(layout, ptr);
+}
+
+static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ gpencil_modifier_masking_panel_draw(panel, true, false);
+}
+
+static void panelRegister(ARegionType *region_type)
+{
+ PanelType *panel_type = gpencil_modifier_panel_register(
+ region_type, eGpencilModifierType_Length, panel_draw);
+ gpencil_modifier_subpanel_register(
+ region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
+}
+
+GpencilModifierTypeInfo modifierType_Gpencil_Length = {
+ /* name */ "Length",
+ /* structName */ "LengthGpencilModifierData",
+ /* structSize */ sizeof(LengthGpencilModifierData),
+ /* type */ eGpencilModifierTypeType_Gpencil,
+ /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
+
+ /* copyData */ copyData,
+
+ /* deformStroke */ deformStroke,
+ /* generateStrokes */ NULL,
+ /* bakeModifier */ bakeModifier,
+ /* remapTime */ NULL,
+
+ /* initData */ initData,
+ /* freeData */ NULL,
+ /* isDisabled */ NULL,
+ /* updateDepsgraph */ NULL,
+ /* dependsOnTime */ NULL,
+ /* foreachIDLink */ foreachIDLink,
+ /* foreachTexLink */ NULL,
+ /* panelRegister */ panelRegister,
+};
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index 080a3caa32f..cc79810d2a2 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -194,6 +194,24 @@ static bool isDisabled(GpencilModifierData *md, int UNUSED(userRenderParams))
return isModifierDisabled(md);
}
+static void add_this_collection(Collection *c,
+ const ModifierUpdateDepsgraphContext *ctx,
+ const int mode)
+{
+ FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (c, ob, mode) {
+ if (ELEM(ob->type, OB_MESH, OB_MBALL, OB_CURVE, OB_SURF, OB_FONT)) {
+ if (ob->lineart.usage != OBJECT_LRT_EXCLUDE) {
+ DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_GEOMETRY, "Line Art Modifier");
+ DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
+ }
+ }
+ if (ob->type == OB_EMPTY && (ob->transflag & OB_DUPLICOLLECTION)) {
+ add_this_collection(ob->instance_collection, ctx, mode);
+ }
+ }
+ FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
+}
+
static void updateDepsgraph(GpencilModifierData *md,
const ModifierUpdateDepsgraphContext *ctx,
const int mode)
@@ -208,15 +226,7 @@ static void updateDepsgraph(GpencilModifierData *md,
ctx->node, lmd->source_object, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
}
else {
- FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_BEGIN (ctx->scene->master_collection, ob, mode) {
- if (ELEM(ob->type, OB_MESH, OB_MBALL, OB_CURVE, OB_SURF, OB_FONT)) {
- if (ob->lineart.usage != OBJECT_LRT_EXCLUDE) {
- DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_GEOMETRY, "Line Art Modifier");
- DEG_add_object_relation(ctx->node, ob, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
- }
- }
- }
- FOREACH_COLLECTION_VISIBLE_OBJECT_RECURSIVE_END;
+ add_this_collection(ctx->scene->master_collection, ctx, mode);
}
DEG_add_object_relation(
ctx->node, ctx->scene->camera, DEG_OB_COMP_TRANSFORM, "Line Art Modifier");
@@ -335,7 +345,7 @@ static void occlusion_panel_draw(const bContext *UNUSED(C), Panel *panel)
if (use_multiple_levels) {
uiLayout *col = uiLayoutColumn(layout, true);
uiItemR(col, ptr, "level_start", 0, NULL, ICON_NONE);
- uiItemR(col, ptr, "level_end", 0, NULL, ICON_NONE);
+ uiItemR(col, ptr, "level_end", 0, IFACE_("End"), ICON_NONE);
}
else {
uiItemR(layout, ptr, "level_start", 0, IFACE_("Level"), ICON_NONE);
@@ -367,7 +377,7 @@ static void transparency_panel_draw(const bContext *UNUSED(C), Panel *panel)
uiLayout *row = uiLayoutRow(layout, true);
uiLayoutSetPropDecorate(row, false);
- uiLayout *sub = uiLayoutRow(row, true);
+ uiLayout *sub = uiLayoutRowWithHeading(row, true, IFACE_("Masks"));
char text[2] = "0";
PropertyRNA *prop = RNA_struct_find_property(ptr, "use_transparency_mask");
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
index bffb324f07f..cd29a006aae 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
@@ -26,7 +26,11 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLT_translation.h"
+
+#include "BLI_hash.h"
#include "BLI_math.h"
+#include "BLI_rand.h"
#include "DNA_defaults.h"
#include "DNA_gpencil_modifier_types.h"
@@ -71,7 +75,7 @@ static void deformStroke(GpencilModifierData *md,
Depsgraph *UNUSED(depsgraph),
Object *ob,
bGPDlayer *gpl,
- bGPDframe *UNUSED(gpf),
+ bGPDframe *gpf,
bGPDstroke *gps)
{
OffsetGpencilModifierData *mmd = (OffsetGpencilModifierData *)md;
@@ -94,6 +98,46 @@ static void deformStroke(GpencilModifierData *md,
mmd->flag & GP_OFFSET_INVERT_MATERIAL)) {
return;
}
+
+ int seed = mmd->seed;
+ /* Make sure different modifiers get different seeds. */
+ seed += BLI_hash_string(ob->id.name + 2);
+ seed += BLI_hash_string(md->name);
+
+ float rand[3][3];
+ float rand_offset = BLI_hash_int_01(seed);
+
+ /* Get stroke index for random offset. */
+ int rnd_index = BLI_findindex(&gpf->strokes, gps);
+ for (int j = 0; j < 3; j++) {
+ const uint primes[3] = {2, 3, 7};
+ double offset[3] = {0.0f, 0.0f, 0.0f};
+ double r[3];
+ /* To ensure a nice distribution, we use halton sequence and offset using the seed. */
+ BLI_halton_3d(primes, offset, rnd_index, r);
+
+ if ((mmd->flag & GP_OFFSET_UNIFORM_RANDOM_SCALE) && j == 2) {
+ float rand_value;
+ rand_value = fmodf(r[0] * 2.0f - 1.0f + rand_offset, 1.0f);
+ rand_value = fmodf(sin(rand_value * 12.9898f + j * 78.233f) * 43758.5453f, 1.0f);
+ copy_v3_fl(rand[j], rand_value);
+ }
+ else {
+ for (int i = 0; i < 3; i++) {
+ rand[j][i] = fmodf(r[i] * 2.0f - 1.0f + rand_offset, 1.0f);
+ rand[j][i] = fmodf(sin(rand[j][i] * 12.9898f + j * 78.233f) * 43758.5453f, 1.0f);
+ }
+ }
+ }
+ /* Calculate Random matrix. */
+ float mat_rnd[4][4];
+ float rnd_loc[3], rnd_rot[3];
+ float rnd_scale[3] = {1.0f, 1.0f, 1.0f};
+ mul_v3_v3v3(rnd_loc, mmd->rnd_offset, rand[0]);
+ mul_v3_v3v3(rnd_rot, mmd->rnd_rot, rand[1]);
+ madd_v3_v3v3(rnd_scale, mmd->rnd_scale, rand[2]);
+ loc_eul_size_to_mat4(mat_rnd, rnd_loc, rnd_rot, rnd_scale);
+
bGPdata *gpd = ob->data;
for (int i = 0; i < gps->totpoints; i++) {
@@ -106,6 +150,9 @@ static void deformStroke(GpencilModifierData *md,
if (weight < 0.0f) {
continue;
}
+ /* Apply randomness matrix. */
+ mul_m4_v3(mat_rnd, &pt->x);
+
/* Calculate matrix. */
mul_v3_v3fl(loc, mmd->loc, weight);
mul_v3_v3fl(rot, mmd->rot, weight);
@@ -161,6 +208,21 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
gpencil_modifier_panel_end(layout, ptr);
}
+static void random_panel_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiLayoutSetPropSep(layout, true);
+
+ uiItemR(layout, ptr, "random_offset", 0, IFACE_("Offset"), ICON_NONE);
+ uiItemR(layout, ptr, "random_rotation", 0, IFACE_("Rotation"), ICON_NONE);
+ uiItemR(layout, ptr, "random_scale", 0, IFACE_("Scale"), ICON_NONE);
+ uiItemR(layout, ptr, "use_uniform_random_scale", 0, NULL, ICON_NONE);
+ uiItemR(layout, ptr, "seed", 0, NULL, ICON_NONE);
+}
+
static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
gpencil_modifier_masking_panel_draw(panel, true, true);
@@ -171,6 +233,8 @@ static void panelRegister(ARegionType *region_type)
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Offset, panel_draw);
gpencil_modifier_subpanel_register(
+ region_type, "randomize", "Randomize", NULL, random_panel_draw, panel_type);
+ gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
}
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
index c193fc49362..ea37558fa7f 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
@@ -47,6 +47,8 @@
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -84,6 +86,39 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
tgmd->curve_intensity = BKE_curvemapping_copy(gmd->curve_intensity);
}
+static float give_opacity_fading_factor(OpacityGpencilModifierData *mmd,
+ Object *ob_this,
+ float *pos,
+ bool apply_obmat)
+{
+ float factor_depth = 1.0f;
+
+ if (((mmd->flag & GP_OPACITY_FADING) == 0) || ((mmd->object) == NULL)) {
+ return factor_depth;
+ }
+
+ float gvert[3];
+ if (apply_obmat) {
+ mul_v3_m4v3(gvert, ob_this->obmat, pos);
+ }
+ float dist = len_v3v3(mmd->object->obmat[3], gvert);
+ float fading_max = MAX2(mmd->fading_start, mmd->fading_end);
+ float fading_min = MIN2(mmd->fading_start, mmd->fading_end);
+
+ /* Better with ratiof() function from line art. */
+ if (dist > fading_max) {
+ factor_depth = 0.0f;
+ }
+ else if (dist <= fading_max && dist > fading_min) {
+ factor_depth = (fading_max - dist) / (fading_max - fading_min);
+ }
+ else {
+ factor_depth = 1.0f;
+ }
+
+ return factor_depth;
+}
+
/* opacity strokes */
static void deformStroke(GpencilModifierData *md,
Depsgraph *UNUSED(depsgraph),
@@ -138,6 +173,9 @@ static void deformStroke(GpencilModifierData *md,
factor_curve *= BKE_curvemapping_evaluateF(mmd->curve_intensity, 0, value);
}
+ float factor_depth = give_opacity_fading_factor(mmd, ob, &pt->x, true);
+ factor_curve = interpf(factor_curve, mmd->fading_end_factor, factor_depth);
+
if (def_nr < 0) {
if (mmd->flag & GP_OPACITY_NORMALIZE) {
pt->strength = factor_curve;
@@ -167,6 +205,10 @@ static void deformStroke(GpencilModifierData *md,
/* Fill using opacity factor. */
if (mmd->modify_color != GP_MODIFY_COLOR_STROKE) {
gps->fill_opacity_fac = mmd->factor;
+
+ float factor_depth = give_opacity_fading_factor(mmd, ob, ob->obmat[3], true);
+ gps->fill_opacity_fac = interpf(mmd->factor, mmd->fading_end_factor, factor_depth);
+
CLAMP(gps->fill_opacity_fac, 0.0f, 1.0f);
}
}
@@ -201,6 +243,18 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
+ walk(userData, ob, (ID **)&mmd->object, IDWALK_CB_NOP);
+}
+
+static void updateDepsgraph(GpencilModifierData *md,
+ const ModifierUpdateDepsgraphContext *ctx,
+ const int UNUSED(mode))
+{
+ OpacityGpencilModifierData *mmd = (OpacityGpencilModifierData *)md;
+ if (mmd->object != NULL) {
+ DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Opacity Modifier");
+ }
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Opacity Modifier");
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -228,6 +282,20 @@ static void panel_draw(const bContext *UNUSED(C), Panel *panel)
gpencil_modifier_panel_end(layout, ptr);
}
+static void fading_header_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiItemR(layout, ptr, "use_fading", 0, NULL, ICON_NONE);
+}
+
+static void fading_panel_draw(const bContext *C, Panel *panel)
+{
+ gpencil_modifier_fading_draw(C, panel);
+}
+
static void mask_panel_draw(const bContext *UNUSED(C), Panel *panel)
{
PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
@@ -266,6 +334,9 @@ static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Opacity, panel_draw);
+
+ gpencil_modifier_subpanel_register(
+ region_type, "fading", "", fading_header_draw, fading_panel_draw, panel_type);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(
@@ -289,7 +360,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Opacity = {
/* initData */ initData,
/* freeData */ freeData,
/* isDisabled */ NULL,
- /* updateDepsgraph */ NULL,
+ /* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
index a13f8d64755..512e3af063a 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
@@ -43,6 +43,8 @@
#include "BKE_screen.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
#include "UI_interface.h"
#include "UI_resources.h"
@@ -128,6 +130,30 @@ static void deformStroke(GpencilModifierData *md,
}
float curvef = 1.0f;
+
+ float factor_depth = 1.0f;
+
+ if (mmd->flag & GP_THICK_FADING) {
+ if (mmd->object) {
+ float gvert[3];
+ mul_v3_m4v3(gvert, ob->obmat, &pt->x);
+ float dist = len_v3v3(mmd->object->obmat[3], gvert);
+ float fading_max = MAX2(mmd->fading_start, mmd->fading_end);
+ float fading_min = MIN2(mmd->fading_start, mmd->fading_end);
+
+ /* Better with ratiof() function from line art. */
+ if (dist > fading_max) {
+ factor_depth = 0.0f;
+ }
+ else if (dist <= fading_max && dist > fading_min) {
+ factor_depth = (fading_max - dist) / (fading_max - fading_min);
+ }
+ else {
+ factor_depth = 1.0f;
+ }
+ }
+ }
+
if ((mmd->flag & GP_THICK_CUSTOM_CURVE) && (mmd->curve_thickness)) {
/* Normalize value to evaluate curve. */
float value = (float)i / (gps->totpoints - 1);
@@ -144,6 +170,9 @@ static void deformStroke(GpencilModifierData *md,
weight *= curvef;
}
+ float fac_begin = mmd->flag & GP_THICK_NORMALIZE ? 1 : mmd->thickness_fac;
+ target *= interpf(fac_begin, mmd->fading_end_factor, factor_depth);
+
pt->pressure = interpf(target, pt->pressure, weight);
CLAMP_MIN(pt->pressure, 0.0f);
@@ -171,6 +200,32 @@ static void foreachIDLink(GpencilModifierData *md, Object *ob, IDWalkFunc walk,
ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md;
walk(userData, ob, (ID **)&mmd->material, IDWALK_CB_USER);
+ walk(userData, ob, (ID **)&mmd->object, IDWALK_CB_NOP);
+}
+
+static void updateDepsgraph(GpencilModifierData *md,
+ const ModifierUpdateDepsgraphContext *ctx,
+ const int UNUSED(mode))
+{
+ ThickGpencilModifierData *mmd = (ThickGpencilModifierData *)md;
+ if (mmd->object != NULL) {
+ DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_TRANSFORM, "Thickness Modifier");
+ }
+ DEG_add_object_relation(ctx->node, ctx->object, DEG_OB_COMP_TRANSFORM, "Thickness Modifier");
+}
+
+static void fading_header_draw(const bContext *UNUSED(C), Panel *panel)
+{
+ uiLayout *layout = panel->layout;
+
+ PointerRNA *ptr = gpencil_modifier_panel_get_property_pointers(panel, NULL);
+
+ uiItemR(layout, ptr, "use_fading", 0, NULL, ICON_NONE);
+}
+
+static void fading_panel_draw(const bContext *C, Panel *panel)
+{
+ gpencil_modifier_fading_draw(C, panel);
}
static void panel_draw(const bContext *UNUSED(C), Panel *panel)
@@ -202,6 +257,8 @@ static void panelRegister(ARegionType *region_type)
{
PanelType *panel_type = gpencil_modifier_panel_register(
region_type, eGpencilModifierType_Thick, panel_draw);
+ gpencil_modifier_subpanel_register(
+ region_type, "fading", "", fading_header_draw, fading_panel_draw, panel_type);
PanelType *mask_panel_type = gpencil_modifier_subpanel_register(
region_type, "mask", "Influence", NULL, mask_panel_draw, panel_type);
gpencil_modifier_subpanel_register(region_type,
@@ -229,7 +286,7 @@ GpencilModifierTypeInfo modifierType_Gpencil_Thick = {
/* initData */ initData,
/* freeData */ freeData,
/* isDisabled */ NULL,
- /* updateDepsgraph */ NULL,
+ /* updateDepsgraph */ updateDepsgraph,
/* dependsOnTime */ NULL,
/* foreachIDLink */ foreachIDLink,
/* foreachTexLink */ NULL,
diff --git a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
index 56cd7fa1456..e679dce2f2d 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/MOD_lineart.h
@@ -93,8 +93,8 @@ typedef struct LineartElementLinkNode {
float crease_threshold;
} LineartElementLinkNode;
-typedef struct LineartLineSegment {
- struct LineartLineSegment *next, *prev;
+typedef struct LineartEdgeSegment {
+ struct LineartEdgeSegment *next, *prev;
/** at==0: left at==1: right (this is in 2D projected space) */
double at;
/** Occlusion level after "at" point */
@@ -107,7 +107,7 @@ typedef struct LineartLineSegment {
* enough for most cases.
*/
unsigned char transparency_mask;
-} LineartLineSegment;
+} LineartEdgeSegment;
typedef struct LineartVert {
double gloc[3];
@@ -163,8 +163,8 @@ typedef struct LineartEdge {
struct Object *object_ref;
} LineartEdge;
-typedef struct LineartLineChain {
- struct LineartLineChain *next, *prev;
+typedef struct LineartEdgeChain {
+ struct LineartEdgeChain *next, *prev;
ListBase chain;
/** Calculated before draw command. */
@@ -179,10 +179,10 @@ typedef struct LineartLineChain {
unsigned char transparency_mask;
struct Object *object_ref;
-} LineartLineChain;
+} LineartEdgeChain;
-typedef struct LineartLineChainItem {
- struct LineartLineChainItem *next, *prev;
+typedef struct LineartEdgeChainItem {
+ struct LineartEdgeChainItem *next, *prev;
/** Need z value for fading */
float pos[3];
/** For restoring position to 3d space */
@@ -192,12 +192,12 @@ typedef struct LineartLineChainItem {
char occlusion;
unsigned char transparency_mask;
size_t index;
-} LineartLineChainItem;
+} LineartEdgeChainItem;
typedef struct LineartChainRegisterEntry {
struct LineartChainRegisterEntry *next, *prev;
- LineartLineChain *rlc;
- LineartLineChainItem *rlci;
+ LineartEdgeChain *ec;
+ LineartEdgeChainItem *eci;
char picked;
/* left/right mark.
@@ -237,31 +237,14 @@ typedef struct LineartRenderBuffer {
int triangle_size;
- unsigned int contour_count;
- unsigned int contour_processed;
- LineartEdge *contour_managed;
- /** A single linked list (cast to #LinkNode). */
- LineartEdge *contours;
-
- unsigned int intersection_count;
- unsigned int intersection_processed;
- LineartEdge *intersection_managed;
- LineartEdge *intersection_lines;
-
- unsigned int crease_count;
- unsigned int crease_processed;
- LineartEdge *crease_managed;
- LineartEdge *crease_lines;
-
- unsigned int material_line_count;
- unsigned int material_processed;
- LineartEdge *material_managed;
- LineartEdge *material_lines;
-
- unsigned int edge_mark_count;
- unsigned int edge_mark_processed;
- LineartEdge *edge_mark_managed;
- LineartEdge *edge_marks;
+ /* Although using ListBase here, LineartEdge is single linked list.
+ * list.last is used to store worker progress along the list.
+ * See lineart_main_occlusion_begin() for more info. */
+ ListBase contour;
+ ListBase intersection;
+ ListBase crease;
+ ListBase material;
+ ListBase edge_mark;
ListBase chains;
@@ -322,9 +305,11 @@ typedef enum eLineartTriangleFlags {
LRT_TRIANGLE_NO_INTERSECTION = (1 << 4),
} eLineartTriangleFlags;
-/** Controls how many edges a worker thread is processing at one request.
+/**
+ * Controls how many edges a worker thread is processing at one request.
* There's no significant performance impact on choosing different values.
- * Don't make it too small so that the worker thread won't request too many times. */
+ * Don't make it too small so that the worker thread won't request too many times.
+ */
#define LRT_THREAD_EDGE_COUNT 1000
typedef struct LineartRenderTaskInfo {
@@ -332,20 +317,13 @@ typedef struct LineartRenderTaskInfo {
int thread_id;
- LineartEdge *contour;
- LineartEdge *contour_end;
-
- LineartEdge *intersection;
- LineartEdge *intersection_end;
-
- LineartEdge *crease;
- LineartEdge *crease_end;
-
- LineartEdge *material;
- LineartEdge *material_end;
-
- LineartEdge *edge_mark;
- LineartEdge *edge_mark_end;
+ /* These lists only denote the part of the main edge list that the thread should iterate over.
+ * Be careful to not iterate outside of these bounds as it is not thread safe to do so. */
+ ListBase contour;
+ ListBase intersection;
+ ListBase crease;
+ ListBase material;
+ ListBase edge_mark;
} LineartRenderTaskInfo;
@@ -388,7 +366,7 @@ typedef struct LineartBoundingArea {
short triangle_count;
ListBase linked_triangles;
- ListBase linked_lines;
+ ListBase linked_edges;
/** Reserved for image space reduction && multi-thread chaining. */
ListBase linked_chains;
@@ -527,7 +505,7 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb);
void MOD_lineart_chain_discard_short(LineartRenderBuffer *rb, const float threshold);
void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshold_rad);
-int MOD_lineart_chain_count(const LineartLineChain *rlc);
+int MOD_lineart_chain_count(const LineartEdgeChain *ec);
void MOD_lineart_chain_clear_picked_flag(struct LineartRenderBuffer *rb);
bool MOD_lineart_compute_feature_lines(struct Depsgraph *depsgraph,
@@ -563,6 +541,6 @@ void MOD_lineart_gpencil_generate(LineartRenderBuffer *rb,
const char *vgname,
int modifier_flags);
-float MOD_lineart_chain_compute_length(LineartLineChain *rlc);
+float MOD_lineart_chain_compute_length(LineartEdgeChain *ec);
void ED_operatortypes_lineart(void);
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
index 464316b6a10..c8e4e93843a 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_chain.c
@@ -31,16 +31,16 @@
#include <math.h>
-#define LRT_OTHER_RV(e, rv) ((rv) == (e)->v1 ? (e)->v2 : ((rv) == (e)->v2 ? (e)->v1 : NULL))
+#define LRT_OTHER_VERT(e, vt) ((vt) == (e)->v1 ? (e)->v2 : ((vt) == (e)->v2 ? (e)->v1 : NULL))
/* Get a connected line, only for lines who has the exact given vert, or (in the case of
* intersection lines) who has a vert that has the exact same position. */
static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
- LineartVert *rv,
- LineartVert **new_rv,
+ LineartVert *vt,
+ LineartVert **new_vt,
int match_flag)
{
- LISTBASE_FOREACH (LinkData *, lip, &ba->linked_lines) {
+ LISTBASE_FOREACH (LinkData *, lip, &ba->linked_edges) {
LineartEdge *n_e = lip->data;
if ((!(n_e->flags & LRT_EDGE_FLAG_ALL_TYPE)) || (n_e->flags & LRT_EDGE_FLAG_CHAIN_PICKED)) {
@@ -51,18 +51,18 @@ static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
continue;
}
- *new_rv = LRT_OTHER_RV(n_e, rv);
- if (*new_rv) {
+ *new_vt = LRT_OTHER_VERT(n_e, vt);
+ if (*new_vt) {
return n_e;
}
if (n_e->flags & LRT_EDGE_FLAG_INTERSECTION) {
- if (rv->fbcoord[0] == n_e->v1->fbcoord[0] && rv->fbcoord[1] == n_e->v1->fbcoord[1]) {
- *new_rv = LRT_OTHER_RV(n_e, n_e->v1);
+ if (vt->fbcoord[0] == n_e->v1->fbcoord[0] && vt->fbcoord[1] == n_e->v1->fbcoord[1]) {
+ *new_vt = LRT_OTHER_VERT(n_e, n_e->v1);
return n_e;
}
- if (rv->fbcoord[0] == n_e->v2->fbcoord[0] && rv->fbcoord[1] == n_e->v2->fbcoord[1]) {
- *new_rv = LRT_OTHER_RV(n_e, n_e->v2);
+ if (vt->fbcoord[0] == n_e->v2->fbcoord[0] && vt->fbcoord[1] == n_e->v2->fbcoord[1]) {
+ *new_vt = LRT_OTHER_VERT(n_e, n_e->v2);
return n_e;
}
}
@@ -71,33 +71,33 @@ static LineartEdge *lineart_line_get_connected(LineartBoundingArea *ba,
return NULL;
}
-static LineartLineChain *lineart_chain_create(LineartRenderBuffer *rb)
+static LineartEdgeChain *lineart_chain_create(LineartRenderBuffer *rb)
{
- LineartLineChain *rlc;
- rlc = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartLineChain));
+ LineartEdgeChain *ec;
+ ec = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdgeChain));
- BLI_addtail(&rb->chains, rlc);
+ BLI_addtail(&rb->chains, ec);
- return rlc;
+ return ec;
}
-static bool lineart_point_overlapping(LineartLineChainItem *rlci,
+static bool lineart_point_overlapping(LineartEdgeChainItem *eci,
float x,
float y,
double threshold)
{
- if (!rlci) {
+ if (!eci) {
return false;
}
- if (((rlci->pos[0] + threshold) >= x) && ((rlci->pos[0] - threshold) <= x) &&
- ((rlci->pos[1] + threshold) >= y) && ((rlci->pos[1] - threshold) <= y)) {
+ if (((eci->pos[0] + threshold) >= x) && ((eci->pos[0] - threshold) <= x) &&
+ ((eci->pos[1] + threshold) >= y) && ((eci->pos[1] - threshold) <= y)) {
return true;
}
return false;
}
-static LineartLineChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
- LineartLineChain *rlc,
+static LineartEdgeChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
+ LineartEdgeChain *ec,
float *fbcoord,
float *gpos,
float *normal,
@@ -106,35 +106,35 @@ static LineartLineChainItem *lineart_chain_append_point(LineartRenderBuffer *rb,
unsigned char transparency_mask,
size_t index)
{
- LineartLineChainItem *rlci;
+ LineartEdgeChainItem *eci;
- if (lineart_point_overlapping(rlc->chain.last, fbcoord[0], fbcoord[1], 1e-5)) {
+ if (lineart_point_overlapping(ec->chain.last, fbcoord[0], fbcoord[1], 1e-5)) {
/* Because the new chain point is overlapping, just replace the type and occlusion level of the
* current point. This makes it so that the line to the point after this one has the correct
* type and level. */
- LineartLineChainItem *old_rlci = rlc->chain.last;
+ LineartEdgeChainItem *old_rlci = ec->chain.last;
old_rlci->line_type = type;
old_rlci->occlusion = level;
old_rlci->transparency_mask = transparency_mask;
return old_rlci;
}
- rlci = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartLineChainItem));
+ eci = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdgeChainItem));
- copy_v2_v2(rlci->pos, fbcoord);
- copy_v3_v3(rlci->gpos, gpos);
- rlci->index = index;
- copy_v3_v3(rlci->normal, normal);
- rlci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
- rlci->occlusion = level;
- rlci->transparency_mask = transparency_mask;
- BLI_addtail(&rlc->chain, rlci);
+ copy_v2_v2(eci->pos, fbcoord);
+ copy_v3_v3(eci->gpos, gpos);
+ eci->index = index;
+ copy_v3_v3(eci->normal, normal);
+ eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
+ eci->occlusion = level;
+ eci->transparency_mask = transparency_mask;
+ BLI_addtail(&ec->chain, eci);
- return rlci;
+ return eci;
}
-static LineartLineChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb,
- LineartLineChain *rlc,
+static LineartEdgeChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb,
+ LineartEdgeChain *ec,
float *fbcoord,
float *gpos,
float *normal,
@@ -143,32 +143,32 @@ static LineartLineChainItem *lineart_chain_prepend_point(LineartRenderBuffer *rb
unsigned char transparency_mask,
size_t index)
{
- LineartLineChainItem *rlci;
+ LineartEdgeChainItem *eci;
- if (lineart_point_overlapping(rlc->chain.first, fbcoord[0], fbcoord[1], 1e-5)) {
- return rlc->chain.first;
+ if (lineart_point_overlapping(ec->chain.first, fbcoord[0], fbcoord[1], 1e-5)) {
+ return ec->chain.first;
}
- rlci = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartLineChainItem));
+ eci = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdgeChainItem));
- copy_v2_v2(rlci->pos, fbcoord);
- copy_v3_v3(rlci->gpos, gpos);
- rlci->index = index;
- copy_v3_v3(rlci->normal, normal);
- rlci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
- rlci->occlusion = level;
- rlci->transparency_mask = transparency_mask;
- BLI_addhead(&rlc->chain, rlci);
+ copy_v2_v2(eci->pos, fbcoord);
+ copy_v3_v3(eci->gpos, gpos);
+ eci->index = index;
+ copy_v3_v3(eci->normal, normal);
+ eci->line_type = type & LRT_EDGE_FLAG_ALL_TYPE;
+ eci->occlusion = level;
+ eci->transparency_mask = transparency_mask;
+ BLI_addhead(&ec->chain, eci);
- return rlci;
+ return eci;
}
void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
{
- LineartLineChain *rlc;
- LineartLineChainItem *rlci;
+ LineartEdgeChain *ec;
+ LineartEdgeChainItem *eci;
LineartBoundingArea *ba;
- LineartLineSegment *rls;
+ LineartEdgeSegment *es;
int last_occlusion;
unsigned char last_transparency;
/* Used when converting from double. */
@@ -192,14 +192,14 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
- rlc = lineart_chain_create(rb);
+ ec = lineart_chain_create(rb);
/* One chain can only have one object_ref,
* so we assign it based on the first segment we found. */
- rlc->object_ref = e->object_ref;
+ ec->object_ref = e->object_ref;
LineartEdge *new_e = e;
- LineartVert *new_rv;
+ LineartVert *new_vt;
float N[3] = {0};
if (e->t1) {
@@ -218,19 +218,19 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
/* Step 1: grow left. */
ba = MOD_lineart_get_bounding_area(rb, e->v1->fbcoord[0], e->v1->fbcoord[1]);
- new_rv = e->v1;
- rls = e->segments.first;
- VERT_COORD_TO_FLOAT(new_rv);
+ new_vt = e->v1;
+ es = e->segments.first;
+ VERT_COORD_TO_FLOAT(new_vt);
lineart_chain_prepend_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
e->flags,
- rls->occlusion,
- rls->transparency_mask,
+ es->occlusion,
+ es->transparency_mask,
e->v1_obindex);
- while (ba && (new_e = lineart_line_get_connected(ba, new_rv, &new_rv, e->flags))) {
+ while (ba && (new_e = lineart_line_get_connected(ba, new_vt, &new_vt, e->flags))) {
new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
if (new_e->t1 || new_e->t2) {
@@ -248,41 +248,41 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
normalize_v3(N);
}
- if (new_rv == new_e->v1) {
- for (rls = new_e->segments.last; rls; rls = rls->prev) {
+ if (new_vt == new_e->v1) {
+ for (es = new_e->segments.last; es; es = es->prev) {
double gpos[3], lpos[3];
double *lfb = new_e->v1->fbcoord, *rfb = new_e->v2->fbcoord;
- double global_at = lfb[3] * rls->at / (rls->at * lfb[3] + (1 - rls->at) * rfb[3]);
- interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, rls->at);
+ double global_at = lfb[3] * es->at / (es->at * lfb[3] + (1 - es->at) * rfb[3]);
+ interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, new_e->v1->gloc, new_e->v2->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
lineart_chain_prepend_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
new_e->flags,
- rls->occlusion,
- rls->transparency_mask,
+ es->occlusion,
+ es->transparency_mask,
new_e->v1_obindex);
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
}
}
- else if (new_rv == new_e->v2) {
- rls = new_e->segments.first;
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
- rls = rls->next;
- for (; rls; rls = rls->next) {
+ else if (new_vt == new_e->v2) {
+ es = new_e->segments.first;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
+ es = es->next;
+ for (; es; es = es->next) {
double gpos[3], lpos[3];
double *lfb = new_e->v1->fbcoord, *rfb = new_e->v2->fbcoord;
- double global_at = lfb[3] * rls->at / (rls->at * lfb[3] + (1 - rls->at) * rfb[3]);
- interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, rls->at);
+ double global_at = lfb[3] * es->at / (es->at * lfb[3] + (1 - es->at) * rfb[3]);
+ interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, new_e->v1->gloc, new_e->v2->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
lineart_chain_prepend_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
@@ -290,12 +290,12 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
last_occlusion,
last_transparency,
new_e->v2_obindex);
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
}
VERT_COORD_TO_FLOAT(new_e->v2);
lineart_chain_prepend_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
@@ -304,7 +304,7 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
last_transparency,
new_e->v2_obindex);
}
- ba = MOD_lineart_get_bounding_area(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
+ ba = MOD_lineart_get_bounding_area(rb, new_vt->fbcoord[0], new_vt->fbcoord[1]);
}
/* Restore normal value. */
@@ -324,31 +324,31 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
}
/* Step 2: Adding all cuts from the given line, so we can continue connecting the right side
* of the line. */
- rls = e->segments.first;
- last_occlusion = ((LineartLineSegment *)rls)->occlusion;
- last_transparency = ((LineartLineSegment *)rls)->transparency_mask;
- for (rls = rls->next; rls; rls = rls->next) {
+ es = e->segments.first;
+ last_occlusion = ((LineartEdgeSegment *)es)->occlusion;
+ last_transparency = ((LineartEdgeSegment *)es)->transparency_mask;
+ for (es = es->next; es; es = es->next) {
double gpos[3], lpos[3];
double *lfb = e->v1->fbcoord, *rfb = e->v2->fbcoord;
- double global_at = lfb[3] * rls->at / (rls->at * lfb[3] + (1 - rls->at) * rfb[3]);
- interp_v3_v3v3_db(lpos, e->v1->fbcoord, e->v2->fbcoord, rls->at);
+ double global_at = lfb[3] * es->at / (es->at * lfb[3] + (1 - es->at) * rfb[3]);
+ interp_v3_v3v3_db(lpos, e->v1->fbcoord, e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, e->v1->gloc, e->v2->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
lineart_chain_append_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
e->flags,
- rls->occlusion,
- rls->transparency_mask,
+ es->occlusion,
+ es->transparency_mask,
e->v1_obindex);
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
}
VERT_COORD_TO_FLOAT(e->v2)
lineart_chain_append_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
@@ -359,8 +359,8 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
/* Step 3: grow right. */
ba = MOD_lineart_get_bounding_area(rb, e->v2->fbcoord[0], e->v2->fbcoord[1]);
- new_rv = e->v2;
- while (ba && (new_e = lineart_line_get_connected(ba, new_rv, &new_rv, e->flags))) {
+ new_vt = e->v2;
+ while (ba && (new_e = lineart_line_get_connected(ba, new_vt, &new_vt, e->flags))) {
new_e->flags |= LRT_EDGE_FLAG_CHAIN_PICKED;
if (new_e->t1 || new_e->t2) {
@@ -379,27 +379,27 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
}
/* Fix leading vertex type. */
- rlci = rlc->chain.last;
- rlci->line_type = new_e->flags & LRT_EDGE_FLAG_ALL_TYPE;
+ eci = ec->chain.last;
+ eci->line_type = new_e->flags & LRT_EDGE_FLAG_ALL_TYPE;
- if (new_rv == new_e->v1) {
- rls = new_e->segments.last;
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
+ if (new_vt == new_e->v1) {
+ es = new_e->segments.last;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
/* Fix leading vertex occlusion. */
- rlci->occlusion = last_occlusion;
- rlci->transparency_mask = last_transparency;
- for (rls = new_e->segments.last; rls; rls = rls->prev) {
+ eci->occlusion = last_occlusion;
+ eci->transparency_mask = last_transparency;
+ for (es = new_e->segments.last; es; es = es->prev) {
double gpos[3], lpos[3];
double *lfb = new_e->v1->fbcoord, *rfb = new_e->v2->fbcoord;
- double global_at = lfb[3] * rls->at / (rls->at * lfb[3] + (1 - rls->at) * rfb[3]);
- interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, rls->at);
+ double global_at = lfb[3] * es->at / (es->at * lfb[3] + (1 - es->at) * rfb[3]);
+ interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, new_e->v1->gloc, new_e->v2->gloc, global_at);
- last_occlusion = rls->prev ? rls->prev->occlusion : last_occlusion;
- last_transparency = rls->prev ? rls->prev->transparency_mask : last_transparency;
+ last_occlusion = es->prev ? es->prev->occlusion : last_occlusion;
+ last_transparency = es->prev ? es->prev->transparency_mask : last_transparency;
POS_TO_FLOAT(lpos, gpos)
lineart_chain_append_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
@@ -409,35 +409,35 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
new_e->v1_obindex);
}
}
- else if (new_rv == new_e->v2) {
- rls = new_e->segments.first;
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
- rlci->occlusion = last_occlusion;
- rlci->transparency_mask = last_transparency;
- rls = rls->next;
- for (; rls; rls = rls->next) {
+ else if (new_vt == new_e->v2) {
+ es = new_e->segments.first;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
+ eci->occlusion = last_occlusion;
+ eci->transparency_mask = last_transparency;
+ es = es->next;
+ for (; es; es = es->next) {
double gpos[3], lpos[3];
double *lfb = new_e->v1->fbcoord, *rfb = new_e->v2->fbcoord;
- double global_at = lfb[3] * rls->at / (rls->at * lfb[3] + (1 - rls->at) * rfb[3]);
- interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, rls->at);
+ double global_at = lfb[3] * es->at / (es->at * lfb[3] + (1 - es->at) * rfb[3]);
+ interp_v3_v3v3_db(lpos, new_e->v1->fbcoord, new_e->v2->fbcoord, es->at);
interp_v3_v3v3_db(gpos, new_e->v1->gloc, new_e->v2->gloc, global_at);
POS_TO_FLOAT(lpos, gpos)
lineart_chain_append_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
new_e->flags,
- rls->occlusion,
- rls->transparency_mask,
+ es->occlusion,
+ es->transparency_mask,
new_e->v2_obindex);
- last_occlusion = rls->occlusion;
- last_transparency = rls->transparency_mask;
+ last_occlusion = es->occlusion;
+ last_transparency = es->transparency_mask;
}
VERT_COORD_TO_FLOAT(new_e->v2)
lineart_chain_append_point(rb,
- rlc,
+ ec,
use_fbcoord,
use_gpos,
N,
@@ -446,57 +446,57 @@ void MOD_lineart_chain_feature_lines(LineartRenderBuffer *rb)
last_transparency,
new_e->v2_obindex);
}
- ba = MOD_lineart_get_bounding_area(rb, new_rv->fbcoord[0], new_rv->fbcoord[1]);
+ ba = MOD_lineart_get_bounding_area(rb, new_vt->fbcoord[0], new_vt->fbcoord[1]);
}
if (rb->fuzzy_everything) {
- rlc->type = LRT_EDGE_FLAG_CONTOUR;
+ ec->type = LRT_EDGE_FLAG_CONTOUR;
}
else {
- rlc->type = (e->flags & LRT_EDGE_FLAG_ALL_TYPE);
+ ec->type = (e->flags & LRT_EDGE_FLAG_ALL_TYPE);
}
}
LRT_ITER_ALL_LINES_END
}
-static LineartBoundingArea *lineart_bounding_area_get_rlci_recursive(LineartRenderBuffer *rb,
- LineartBoundingArea *root,
- LineartLineChainItem *rlci)
+static LineartBoundingArea *lineart_bounding_area_get_eci_recursive(LineartRenderBuffer *rb,
+ LineartBoundingArea *root,
+ LineartEdgeChainItem *eci)
{
if (root->child == NULL) {
return root;
}
LineartBoundingArea *ch = root->child;
-#define IN_BOUND(ba, rlci) \
- ba.l <= rlci->pos[0] && ba.r >= rlci->pos[0] && ba.b <= rlci->pos[1] && ba.u >= rlci->pos[1]
+#define IN_BOUND(ba, eci) \
+ ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1]
- if (IN_BOUND(ch[0], rlci)) {
- return lineart_bounding_area_get_rlci_recursive(rb, &ch[0], rlci);
+ if (IN_BOUND(ch[0], eci)) {
+ return lineart_bounding_area_get_eci_recursive(rb, &ch[0], eci);
}
- if (IN_BOUND(ch[1], rlci)) {
- return lineart_bounding_area_get_rlci_recursive(rb, &ch[1], rlci);
+ if (IN_BOUND(ch[1], eci)) {
+ return lineart_bounding_area_get_eci_recursive(rb, &ch[1], eci);
}
- if (IN_BOUND(ch[2], rlci)) {
- return lineart_bounding_area_get_rlci_recursive(rb, &ch[2], rlci);
+ if (IN_BOUND(ch[2], eci)) {
+ return lineart_bounding_area_get_eci_recursive(rb, &ch[2], eci);
}
- if (IN_BOUND(ch[3], rlci)) {
- return lineart_bounding_area_get_rlci_recursive(rb, &ch[3], rlci);
+ if (IN_BOUND(ch[3], eci)) {
+ return lineart_bounding_area_get_eci_recursive(rb, &ch[3], eci);
}
#undef IN_BOUND
return NULL;
}
static LineartBoundingArea *lineart_bounding_area_get_end_point(LineartRenderBuffer *rb,
- LineartLineChainItem *rlci)
+ LineartEdgeChainItem *eci)
{
- if (!rlci) {
+ if (!eci) {
return NULL;
}
- LineartBoundingArea *root = MOD_lineart_get_parent_bounding_area(rb, rlci->pos[0], rlci->pos[1]);
+ LineartBoundingArea *root = MOD_lineart_get_parent_bounding_area(rb, eci->pos[0], eci->pos[1]);
if (root == NULL) {
return NULL;
}
- return lineart_bounding_area_get_rlci_recursive(rb, root, rlci);
+ return lineart_bounding_area_get_eci_recursive(rb, root, eci);
}
/**
@@ -507,61 +507,61 @@ static LineartBoundingArea *lineart_bounding_area_get_end_point(LineartRenderBuf
*/
static void lineart_bounding_area_link_point_recursive(LineartRenderBuffer *rb,
LineartBoundingArea *root,
- LineartLineChain *rlc,
- LineartLineChainItem *rlci)
+ LineartEdgeChain *ec,
+ LineartEdgeChainItem *eci)
{
if (root->child == NULL) {
LineartChainRegisterEntry *cre = lineart_list_append_pointer_pool_sized(
- &root->linked_chains, &rb->render_data_pool, rlc, sizeof(LineartChainRegisterEntry));
+ &root->linked_chains, &rb->render_data_pool, ec, sizeof(LineartChainRegisterEntry));
- cre->rlci = rlci;
+ cre->eci = eci;
- if (rlci == rlc->chain.first) {
+ if (eci == ec->chain.first) {
cre->is_left = 1;
}
}
else {
LineartBoundingArea *ch = root->child;
-#define IN_BOUND(ba, rlci) \
- ba.l <= rlci->pos[0] && ba.r >= rlci->pos[0] && ba.b <= rlci->pos[1] && ba.u >= rlci->pos[1]
+#define IN_BOUND(ba, eci) \
+ ba.l <= eci->pos[0] && ba.r >= eci->pos[0] && ba.b <= eci->pos[1] && ba.u >= eci->pos[1]
- if (IN_BOUND(ch[0], rlci)) {
- lineart_bounding_area_link_point_recursive(rb, &ch[0], rlc, rlci);
+ if (IN_BOUND(ch[0], eci)) {
+ lineart_bounding_area_link_point_recursive(rb, &ch[0], ec, eci);
}
- else if (IN_BOUND(ch[1], rlci)) {
- lineart_bounding_area_link_point_recursive(rb, &ch[1], rlc, rlci);
+ else if (IN_BOUND(ch[1], eci)) {
+ lineart_bounding_area_link_point_recursive(rb, &ch[1], ec, eci);
}
- else if (IN_BOUND(ch[2], rlci)) {
- lineart_bounding_area_link_point_recursive(rb, &ch[2], rlc, rlci);
+ else if (IN_BOUND(ch[2], eci)) {
+ lineart_bounding_area_link_point_recursive(rb, &ch[2], ec, eci);
}
- else if (IN_BOUND(ch[3], rlci)) {
- lineart_bounding_area_link_point_recursive(rb, &ch[3], rlc, rlci);
+ else if (IN_BOUND(ch[3], eci)) {
+ lineart_bounding_area_link_point_recursive(rb, &ch[3], ec, eci);
}
#undef IN_BOUND
}
}
-static void lineart_bounding_area_link_chain(LineartRenderBuffer *rb, LineartLineChain *rlc)
+static void lineart_bounding_area_link_chain(LineartRenderBuffer *rb, LineartEdgeChain *ec)
{
- LineartLineChainItem *pl = rlc->chain.first;
- LineartLineChainItem *pr = rlc->chain.last;
+ LineartEdgeChainItem *pl = ec->chain.first;
+ LineartEdgeChainItem *pr = ec->chain.last;
LineartBoundingArea *ba1 = MOD_lineart_get_parent_bounding_area(rb, pl->pos[0], pl->pos[1]);
LineartBoundingArea *ba2 = MOD_lineart_get_parent_bounding_area(rb, pr->pos[0], pr->pos[1]);
if (ba1) {
- lineart_bounding_area_link_point_recursive(rb, ba1, rlc, pl);
+ lineart_bounding_area_link_point_recursive(rb, ba1, ec, pl);
}
if (ba2) {
- lineart_bounding_area_link_point_recursive(rb, ba2, rlc, pr);
+ lineart_bounding_area_link_point_recursive(rb, ba2, ec, pr);
}
}
void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
{
- LineartLineChain *rlc, *new_rlc;
- LineartLineChainItem *rlci, *next_rlci;
+ LineartEdgeChain *ec, *new_rlc;
+ LineartEdgeChainItem *eci, *next_rlci;
ListBase swap = {0};
swap.first = rb->chains.first;
@@ -569,59 +569,59 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
rb->chains.last = rb->chains.first = NULL;
- while ((rlc = BLI_pophead(&swap)) != NULL) {
- rlc->next = rlc->prev = NULL;
- BLI_addtail(&rb->chains, rlc);
- LineartLineChainItem *first_rlci = (LineartLineChainItem *)rlc->chain.first;
+ while ((ec = BLI_pophead(&swap)) != NULL) {
+ ec->next = ec->prev = NULL;
+ BLI_addtail(&rb->chains, ec);
+ LineartEdgeChainItem *first_rlci = (LineartEdgeChainItem *)ec->chain.first;
int fixed_occ = first_rlci->occlusion;
unsigned char fixed_mask = first_rlci->transparency_mask;
- rlc->level = fixed_occ;
- rlc->transparency_mask = fixed_mask;
- for (rlci = first_rlci->next; rlci; rlci = next_rlci) {
- next_rlci = rlci->next;
- if (rlci->occlusion != fixed_occ || rlci->transparency_mask != fixed_mask) {
+ ec->level = fixed_occ;
+ ec->transparency_mask = fixed_mask;
+ for (eci = first_rlci->next; eci; eci = next_rlci) {
+ next_rlci = eci->next;
+ if (eci->occlusion != fixed_occ || eci->transparency_mask != fixed_mask) {
if (next_rlci) {
- if (lineart_point_overlapping(next_rlci, rlci->pos[0], rlci->pos[1], 1e-5)) {
+ if (lineart_point_overlapping(next_rlci, eci->pos[0], eci->pos[1], 1e-5)) {
continue;
}
}
else {
/* Set the same occlusion level for the end vertex, so when further connection is needed
* the backwards occlusion info is also correct. */
- rlci->occlusion = fixed_occ;
- rlci->transparency_mask = fixed_mask;
+ eci->occlusion = fixed_occ;
+ eci->transparency_mask = fixed_mask;
/* No need to split at the last point anyway. */
break;
}
new_rlc = lineart_chain_create(rb);
- new_rlc->chain.first = rlci;
- new_rlc->chain.last = rlc->chain.last;
- rlc->chain.last = rlci->prev;
- ((LineartLineChainItem *)rlc->chain.last)->next = 0;
- rlci->prev = 0;
+ new_rlc->chain.first = eci;
+ new_rlc->chain.last = ec->chain.last;
+ ec->chain.last = eci->prev;
+ ((LineartEdgeChainItem *)ec->chain.last)->next = 0;
+ eci->prev = 0;
/* End the previous one. */
lineart_chain_append_point(rb,
- rlc,
- rlci->pos,
- rlci->gpos,
- rlci->normal,
- rlci->line_type,
+ ec,
+ eci->pos,
+ eci->gpos,
+ eci->normal,
+ eci->line_type,
fixed_occ,
fixed_mask,
- rlci->index);
- new_rlc->object_ref = rlc->object_ref;
- new_rlc->type = rlc->type;
- rlc = new_rlc;
- fixed_occ = rlci->occlusion;
- fixed_mask = rlci->transparency_mask;
- rlc->level = fixed_occ;
- rlc->transparency_mask = fixed_mask;
+ eci->index);
+ new_rlc->object_ref = ec->object_ref;
+ new_rlc->type = ec->type;
+ ec = new_rlc;
+ fixed_occ = eci->occlusion;
+ fixed_mask = eci->transparency_mask;
+ ec->level = fixed_occ;
+ ec->transparency_mask = fixed_mask;
}
}
}
- LISTBASE_FOREACH (LineartLineChain *, irlc, &rb->chains) {
- lineart_bounding_area_link_chain(rb, irlc);
+ LISTBASE_FOREACH (LineartEdgeChain *, iec, &rb->chains) {
+ lineart_bounding_area_link_chain(rb, iec);
}
}
@@ -629,12 +629,12 @@ void MOD_lineart_chain_split_for_fixed_occlusion(LineartRenderBuffer *rb)
* Note: segment type (crease/material/contour...) is ambiguous after this.
*/
static void lineart_chain_connect(LineartRenderBuffer *UNUSED(rb),
- LineartLineChain *onto,
- LineartLineChain *sub,
+ LineartEdgeChain *onto,
+ LineartEdgeChain *sub,
int reverse_1,
int reverse_2)
{
- LineartLineChainItem *rlci;
+ LineartEdgeChainItem *eci;
if (onto->type == LRT_EDGE_FLAG_INTERSECTION) {
if (sub->object_ref) {
onto->object_ref = sub->object_ref;
@@ -650,38 +650,38 @@ static void lineart_chain_connect(LineartRenderBuffer *UNUSED(rb),
if (reverse_2) { /* L--R R-L. */
BLI_listbase_reverse(&sub->chain);
}
- rlci = sub->chain.first;
- if (lineart_point_overlapping(onto->chain.last, rlci->pos[0], rlci->pos[1], 1e-5)) {
+ eci = sub->chain.first;
+ if (lineart_point_overlapping(onto->chain.last, eci->pos[0], eci->pos[1], 1e-5)) {
BLI_pophead(&sub->chain);
if (sub->chain.first == NULL) {
return;
}
}
- ((LineartLineChainItem *)onto->chain.last)->next = sub->chain.first;
- ((LineartLineChainItem *)sub->chain.first)->prev = onto->chain.last;
+ ((LineartEdgeChainItem *)onto->chain.last)->next = sub->chain.first;
+ ((LineartEdgeChainItem *)sub->chain.first)->prev = onto->chain.last;
onto->chain.last = sub->chain.last;
}
else { /* L-R L--R. */
if (!reverse_2) { /* R-L L--R. */
BLI_listbase_reverse(&sub->chain);
}
- rlci = onto->chain.first;
- if (lineart_point_overlapping(sub->chain.last, rlci->pos[0], rlci->pos[1], 1e-5)) {
+ eci = onto->chain.first;
+ if (lineart_point_overlapping(sub->chain.last, eci->pos[0], eci->pos[1], 1e-5)) {
BLI_pophead(&onto->chain);
if (onto->chain.first == NULL) {
return;
}
}
- ((LineartLineChainItem *)sub->chain.last)->next = onto->chain.first;
- ((LineartLineChainItem *)onto->chain.first)->prev = sub->chain.last;
+ ((LineartEdgeChainItem *)sub->chain.last)->next = onto->chain.first;
+ ((LineartEdgeChainItem *)onto->chain.first)->prev = sub->chain.last;
onto->chain.first = sub->chain.first;
}
}
static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuffer *rb,
LineartBoundingArea *ba,
- LineartLineChain *rlc,
- LineartLineChainItem *rlci,
+ LineartEdgeChain *ec,
+ LineartEdgeChainItem *eci,
int occlusion,
unsigned char transparency_mask,
float dist,
@@ -694,12 +694,12 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
/* Keep using for loop because `cre` could be removed from the iteration before getting to the
* next one. */
LISTBASE_FOREACH_MUTABLE (LineartChainRegisterEntry *, cre, &ba->linked_chains) {
- if (cre->rlc->object_ref != rlc->object_ref) {
+ if (cre->ec->object_ref != ec->object_ref) {
if (!rb->fuzzy_everything) {
if (rb->fuzzy_intersections) {
/* If none of those are intersection lines... */
- if ((!(cre->rlc->type & LRT_EDGE_FLAG_INTERSECTION)) &&
- (!(rlc->type & LRT_EDGE_FLAG_INTERSECTION))) {
+ if ((!(cre->ec->type & LRT_EDGE_FLAG_INTERSECTION)) &&
+ (!(ec->type & LRT_EDGE_FLAG_INTERSECTION))) {
continue; /* We don't want to chain along different objects at the moment. */
}
}
@@ -708,18 +708,18 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
}
}
}
- if (cre->rlc->picked || cre->picked) {
+ if (cre->ec->picked || cre->picked) {
continue;
}
- if (cre->rlc == rlc || (!cre->rlc->chain.first) || (cre->rlc->level != occlusion) ||
- (cre->rlc->transparency_mask != transparency_mask)) {
+ if (cre->ec == ec || (!cre->ec->chain.first) || (cre->ec->level != occlusion) ||
+ (cre->ec->transparency_mask != transparency_mask)) {
continue;
}
if (!rb->fuzzy_everything) {
- if (cre->rlc->type != rlc->type) {
+ if (cre->ec->type != ec->type) {
if (rb->fuzzy_intersections) {
- if (!(cre->rlc->type == LRT_EDGE_FLAG_INTERSECTION ||
- rlc->type == LRT_EDGE_FLAG_INTERSECTION)) {
+ if (!(cre->ec->type == LRT_EDGE_FLAG_INTERSECTION ||
+ ec->type == LRT_EDGE_FLAG_INTERSECTION)) {
continue; /* Fuzzy intersections but no intersection line found. */
}
}
@@ -729,7 +729,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
}
}
- float new_len = len_v2v2(cre->rlci->pos, rlci->pos);
+ float new_len = len_v2v2(cre->eci->pos, eci->pos);
if (new_len < dist) {
closest_cre = cre;
dist = new_len;
@@ -748,7 +748,7 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
LISTBASE_FOREACH (LinkData *, ld, list) { \
LineartBoundingArea *sba = (LineartBoundingArea *)ld->data; \
adjacent_closest = lineart_chain_get_closest_cre( \
- rb, sba, rlc, rlci, occlusion, transparency_mask, dist, &adjacent_new_len, ba); \
+ rb, sba, ec, eci, occlusion, transparency_mask, dist, &adjacent_new_len, ba); \
if (adjacent_new_len < dist) { \
dist = adjacent_new_len; \
closest_cre = adjacent_closest; \
@@ -756,10 +756,10 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
} \
}
if (!caller_ba) {
- LRT_TEST_ADJACENT_AREAS(rlci->pos[0] - ba->l, &ba->lp);
- LRT_TEST_ADJACENT_AREAS(ba->r - rlci->pos[0], &ba->rp);
- LRT_TEST_ADJACENT_AREAS(ba->u - rlci->pos[1], &ba->up);
- LRT_TEST_ADJACENT_AREAS(rlci->pos[1] - ba->b, &ba->bp);
+ LRT_TEST_ADJACENT_AREAS(eci->pos[0] - ba->l, &ba->lp);
+ LRT_TEST_ADJACENT_AREAS(ba->r - eci->pos[0], &ba->rp);
+ LRT_TEST_ADJACENT_AREAS(ba->u - eci->pos[1], &ba->up);
+ LRT_TEST_ADJACENT_AREAS(eci->pos[1] - ba->b, &ba->bp);
}
if (result_new_len) {
(*result_new_len) = dist;
@@ -774,8 +774,8 @@ static LineartChainRegisterEntry *lineart_chain_get_closest_cre(LineartRenderBuf
*/
void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
{
- LineartLineChain *rlc;
- LineartLineChainItem *rlci_l, *rlci_r;
+ LineartEdgeChain *ec;
+ LineartEdgeChainItem *rlci_l, *rlci_r;
LineartBoundingArea *ba_l, *ba_r;
LineartChainRegisterEntry *closest_cre_l, *closest_cre_r, *closest_cre;
float dist = rb->chaining_image_threshold;
@@ -793,24 +793,24 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
rb->chains.last = rb->chains.first = NULL;
- while ((rlc = BLI_pophead(&swap)) != NULL) {
- rlc->next = rlc->prev = NULL;
- if (rlc->picked) {
+ while ((ec = BLI_pophead(&swap)) != NULL) {
+ ec->next = ec->prev = NULL;
+ if (ec->picked) {
continue;
}
- BLI_addtail(&rb->chains, rlc);
+ BLI_addtail(&rb->chains, ec);
- occlusion = rlc->level;
- transparency_mask = rlc->transparency_mask;
+ occlusion = ec->level;
+ transparency_mask = ec->transparency_mask;
- rlci_l = rlc->chain.first;
- rlci_r = rlc->chain.last;
+ rlci_l = ec->chain.first;
+ rlci_r = ec->chain.last;
while ((ba_l = lineart_bounding_area_get_end_point(rb, rlci_l)) &&
(ba_r = lineart_bounding_area_get_end_point(rb, rlci_r))) {
closest_cre_l = lineart_chain_get_closest_cre(
- rb, ba_l, rlc, rlci_l, occlusion, transparency_mask, dist, &dist_l, NULL);
+ rb, ba_l, ec, rlci_l, occlusion, transparency_mask, dist, &dist_l, NULL);
closest_cre_r = lineart_chain_get_closest_cre(
- rb, ba_r, rlc, rlci_r, occlusion, transparency_mask, dist, &dist_r, NULL);
+ rb, ba_r, ec, rlci_r, occlusion, transparency_mask, dist, &dist_r, NULL);
if (closest_cre_l && closest_cre_r) {
if (dist_l < dist_r) {
closest_cre = closest_cre_l;
@@ -834,56 +834,56 @@ void MOD_lineart_chain_connect(LineartRenderBuffer *rb)
break;
}
closest_cre->picked = 1;
- closest_cre->rlc->picked = 1;
+ closest_cre->ec->picked = 1;
if (closest_cre->is_left) {
- lineart_chain_connect(rb, rlc, closest_cre->rlc, reverse_main, 0);
+ lineart_chain_connect(rb, ec, closest_cre->ec, reverse_main, 0);
}
else {
- lineart_chain_connect(rb, rlc, closest_cre->rlc, reverse_main, 1);
+ lineart_chain_connect(rb, ec, closest_cre->ec, reverse_main, 1);
}
- BLI_remlink(&swap, closest_cre->rlc);
- rlci_l = rlc->chain.first;
- rlci_r = rlc->chain.last;
+ BLI_remlink(&swap, closest_cre->ec);
+ rlci_l = ec->chain.first;
+ rlci_r = ec->chain.last;
}
- rlc->picked = 1;
+ ec->picked = 1;
}
}
/**
* Length is in image space.
*/
-float MOD_lineart_chain_compute_length(LineartLineChain *rlc)
+float MOD_lineart_chain_compute_length(LineartEdgeChain *ec)
{
- LineartLineChainItem *rlci;
+ LineartEdgeChainItem *eci;
float offset_accum = 0;
float dist;
float last_point[2];
- rlci = rlc->chain.first;
- copy_v2_v2(last_point, rlci->pos);
- for (rlci = rlc->chain.first; rlci; rlci = rlci->next) {
- dist = len_v2v2(rlci->pos, last_point);
+ eci = ec->chain.first;
+ copy_v2_v2(last_point, eci->pos);
+ for (eci = ec->chain.first; eci; eci = eci->next) {
+ dist = len_v2v2(eci->pos, last_point);
offset_accum += dist;
- copy_v2_v2(last_point, rlci->pos);
+ copy_v2_v2(last_point, eci->pos);
}
return offset_accum;
}
void MOD_lineart_chain_discard_short(LineartRenderBuffer *rb, const float threshold)
{
- LineartLineChain *rlc, *next_rlc;
- for (rlc = rb->chains.first; rlc; rlc = next_rlc) {
- next_rlc = rlc->next;
- if (MOD_lineart_chain_compute_length(rlc) < threshold) {
- BLI_remlink(&rb->chains, rlc);
+ LineartEdgeChain *ec, *next_rlc;
+ for (ec = rb->chains.first; ec; ec = next_rlc) {
+ next_rlc = ec->next;
+ if (MOD_lineart_chain_compute_length(ec) < threshold) {
+ BLI_remlink(&rb->chains, ec);
}
}
}
-int MOD_lineart_chain_count(const LineartLineChain *rlc)
+int MOD_lineart_chain_count(const LineartEdgeChain *ec)
{
int count = 0;
- LISTBASE_FOREACH (LineartLineChainItem *, rlci, &rlc->chain) {
+ LISTBASE_FOREACH (LineartEdgeChainItem *, eci, &ec->chain) {
count++;
}
return count;
@@ -894,8 +894,8 @@ void MOD_lineart_chain_clear_picked_flag(LineartRenderBuffer *rb)
if (rb == NULL) {
return;
}
- LISTBASE_FOREACH (LineartLineChain *, rlc, &rb->chains) {
- rlc->picked = 0;
+ LISTBASE_FOREACH (LineartEdgeChain *, ec, &rb->chains) {
+ ec->picked = 0;
}
}
@@ -905,8 +905,8 @@ void MOD_lineart_chain_clear_picked_flag(LineartRenderBuffer *rb)
*/
void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshold_rad)
{
- LineartLineChain *rlc, *new_rlc;
- LineartLineChainItem *rlci, *next_rlci, *prev_rlci;
+ LineartEdgeChain *ec, *new_rlc;
+ LineartEdgeChainItem *eci, *next_rlci, *prev_rlci;
ListBase swap = {0};
swap.first = rb->chains.first;
@@ -914,43 +914,43 @@ void MOD_lineart_chain_split_angle(LineartRenderBuffer *rb, float angle_threshol
rb->chains.last = rb->chains.first = NULL;
- while ((rlc = BLI_pophead(&swap)) != NULL) {
- rlc->next = rlc->prev = NULL;
- BLI_addtail(&rb->chains, rlc);
- LineartLineChainItem *first_rlci = (LineartLineChainItem *)rlc->chain.first;
- for (rlci = first_rlci->next; rlci; rlci = next_rlci) {
- next_rlci = rlci->next;
- prev_rlci = rlci->prev;
+ while ((ec = BLI_pophead(&swap)) != NULL) {
+ ec->next = ec->prev = NULL;
+ BLI_addtail(&rb->chains, ec);
+ LineartEdgeChainItem *first_rlci = (LineartEdgeChainItem *)ec->chain.first;
+ for (eci = first_rlci->next; eci; eci = next_rlci) {
+ next_rlci = eci->next;
+ prev_rlci = eci->prev;
float angle = M_PI;
if (next_rlci && prev_rlci) {
- angle = angle_v2v2v2(prev_rlci->pos, rlci->pos, next_rlci->pos);
+ angle = angle_v2v2v2(prev_rlci->pos, eci->pos, next_rlci->pos);
}
else {
break; /* No need to split at the last point anyway.*/
}
if (angle < angle_threshold_rad) {
new_rlc = lineart_chain_create(rb);
- new_rlc->chain.first = rlci;
- new_rlc->chain.last = rlc->chain.last;
- rlc->chain.last = rlci->prev;
- ((LineartLineChainItem *)rlc->chain.last)->next = 0;
- rlci->prev = 0;
+ new_rlc->chain.first = eci;
+ new_rlc->chain.last = ec->chain.last;
+ ec->chain.last = eci->prev;
+ ((LineartEdgeChainItem *)ec->chain.last)->next = 0;
+ eci->prev = 0;
/* End the previous one. */
lineart_chain_append_point(rb,
- rlc,
- rlci->pos,
- rlci->gpos,
- rlci->normal,
- rlci->line_type,
- rlc->level,
- rlci->transparency_mask,
- rlci->index);
- new_rlc->object_ref = rlc->object_ref;
- new_rlc->type = rlc->type;
- new_rlc->level = rlc->level;
- new_rlc->transparency_mask = rlc->transparency_mask;
- rlc = new_rlc;
+ ec,
+ eci->pos,
+ eci->gpos,
+ eci->normal,
+ eci->line_type,
+ ec->level,
+ eci->transparency_mask,
+ eci->index);
+ new_rlc->object_ref = ec->object_ref;
+ new_rlc->type = ec->type;
+ new_rlc->level = ec->level;
+ new_rlc->transparency_mask = ec->transparency_mask;
+ ec = new_rlc;
}
}
}
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
index 3778e60d813..ae8157e1a97 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_cpu.c
@@ -63,7 +63,7 @@
static LineartBoundingArea *lineart_edge_first_bounding_area(LineartRenderBuffer *rb,
LineartEdge *e);
-static void lineart_bounding_area_link_line(LineartRenderBuffer *rb,
+static void lineart_bounding_area_link_edge(LineartRenderBuffer *rb,
LineartBoundingArea *root_ba,
LineartEdge *e);
@@ -86,14 +86,14 @@ static bool lineart_get_edge_bounding_areas(LineartRenderBuffer *rb,
static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
LineartBoundingArea *root_ba,
- LineartTriangle *rt,
+ LineartTriangle *tri,
double *LRUB,
int recursive,
int recursive_level,
bool do_intersection);
static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl,
- const LineartTriangle *rt,
+ const LineartTriangle *tri,
const LineartEdge *e,
const double *override_camera_loc,
const bool override_cam_is_persp,
@@ -107,35 +107,35 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *spl,
static void lineart_add_edge_to_list(LineartRenderBuffer *rb, LineartEdge *e);
-static void lineart_discard_segment(LineartRenderBuffer *rb, LineartLineSegment *rls)
+static void lineart_discard_segment(LineartRenderBuffer *rb, LineartEdgeSegment *es)
{
BLI_spin_lock(&rb->lock_cuts);
- memset(rls, 0, sizeof(LineartLineSegment));
+ memset(es, 0, sizeof(LineartEdgeSegment));
/* Storing the node for potentially reuse the memory for new segment data.
* Line Art data is not freed after all calculations are done. */
- BLI_addtail(&rb->wasted_cuts, rls);
+ BLI_addtail(&rb->wasted_cuts, es);
BLI_spin_unlock(&rb->lock_cuts);
}
-static LineartLineSegment *lineart_give_segment(LineartRenderBuffer *rb)
+static LineartEdgeSegment *lineart_give_segment(LineartRenderBuffer *rb)
{
BLI_spin_lock(&rb->lock_cuts);
/* See if there is any already allocated memory we can reuse. */
if (rb->wasted_cuts.first) {
- LineartLineSegment *rls = (LineartLineSegment *)BLI_pophead(&rb->wasted_cuts);
+ LineartEdgeSegment *es = (LineartEdgeSegment *)BLI_pophead(&rb->wasted_cuts);
BLI_spin_unlock(&rb->lock_cuts);
- memset(rls, 0, sizeof(LineartLineSegment));
- return rls;
+ memset(es, 0, sizeof(LineartEdgeSegment));
+ return es;
}
BLI_spin_unlock(&rb->lock_cuts);
/* Otherwise allocate some new memory. */
- return (LineartLineSegment *)lineart_mem_aquire_thread(&rb->render_data_pool,
- sizeof(LineartLineSegment));
+ return (LineartEdgeSegment *)lineart_mem_acquire_thread(&rb->render_data_pool,
+ sizeof(LineartEdgeSegment));
}
/**
@@ -144,9 +144,9 @@ static LineartLineSegment *lineart_give_segment(LineartRenderBuffer *rb)
static void lineart_edge_cut(
LineartRenderBuffer *rb, LineartEdge *e, double start, double end, uchar transparency_mask)
{
- LineartLineSegment *rls, *irls, *next_rls, *prev_rls;
- LineartLineSegment *cut_start_before = 0, *cut_end_before = 0;
- LineartLineSegment *ns = 0, *ns2 = 0;
+ LineartEdgeSegment *es, *ies, *next_es, *prev_es;
+ LineartEdgeSegment *cut_start_before = 0, *cut_end_before = 0;
+ LineartEdgeSegment *ns = 0, *ns2 = 0;
int untouched = 0;
/* If for some reason the occlusion function may give a result that has zero length, or reversed
@@ -173,18 +173,18 @@ static void lineart_edge_cut(
/* Begin looking for starting position of the segment. */
/* Not using a list iteration macro because of it more clear when using for loops to iterate
* through the segments. */
- for (rls = e->segments.first; rls; rls = rls->next) {
- if (LRT_DOUBLE_CLOSE_ENOUGH(rls->at, start)) {
- cut_start_before = rls;
+ for (es = e->segments.first; es; es = es->next) {
+ if (LRT_DOUBLE_CLOSE_ENOUGH(es->at, start)) {
+ cut_start_before = es;
ns = cut_start_before;
break;
}
- if (rls->next == NULL) {
+ if (es->next == NULL) {
break;
}
- irls = rls->next;
- if (irls->at > start + 1e-09 && start > rls->at) {
- cut_start_before = irls;
+ ies = es->next;
+ if (ies->at > start + 1e-09 && start > es->at) {
+ cut_start_before = ies;
ns = lineart_give_segment(rb);
break;
}
@@ -192,25 +192,25 @@ static void lineart_edge_cut(
if (!cut_start_before && LRT_DOUBLE_CLOSE_ENOUGH(1, end)) {
untouched = 1;
}
- for (rls = cut_start_before; rls; rls = rls->next) {
+ for (es = cut_start_before; es; es = es->next) {
/* We tried to cut at existing cutting point (e.g. where the line's occluded by a triangle
* strip). */
- if (LRT_DOUBLE_CLOSE_ENOUGH(rls->at, end)) {
- cut_end_before = rls;
+ if (LRT_DOUBLE_CLOSE_ENOUGH(es->at, end)) {
+ cut_end_before = es;
ns2 = cut_end_before;
break;
}
- /* This check is to prevent `rls->at == 1.0` (where we don't need to cut because we are at the
+ /* This check is to prevent `es->at == 1.0` (where we don't need to cut because we are at the
* end point). */
- if (!rls->next && LRT_DOUBLE_CLOSE_ENOUGH(1, end)) {
- cut_end_before = rls;
+ if (!es->next && LRT_DOUBLE_CLOSE_ENOUGH(1, end)) {
+ cut_end_before = es;
ns2 = cut_end_before;
untouched = 1;
break;
}
/* When an actual cut is needed in the line. */
- if (rls->at > end) {
- cut_end_before = rls;
+ if (es->at > end) {
+ cut_end_before = es;
ns2 = lineart_give_segment(rb);
break;
}
@@ -233,9 +233,9 @@ static void lineart_edge_cut(
if (cut_start_before) {
if (cut_start_before != ns) {
/* Insert cutting points for when a new cut is needed. */
- irls = cut_start_before->prev ? cut_start_before->prev : NULL;
- ns->occlusion = irls ? irls->occlusion : 0;
- ns->transparency_mask = irls->transparency_mask;
+ ies = cut_start_before->prev ? cut_start_before->prev : NULL;
+ ns->occlusion = ies ? ies->occlusion : 0;
+ ns->transparency_mask = ies->transparency_mask;
BLI_insertlinkbefore(&e->segments, cut_start_before, ns);
}
/* Otherwise we already found a existing cutting point, no need to insert a new one. */
@@ -243,24 +243,24 @@ static void lineart_edge_cut(
else {
/* We have yet to reach a existing cutting point even after we searched the whole line, so we
* append the new cut to the end. */
- irls = e->segments.last;
- ns->occlusion = irls->occlusion;
- ns->transparency_mask = irls->transparency_mask;
+ ies = e->segments.last;
+ ns->occlusion = ies->occlusion;
+ ns->transparency_mask = ies->transparency_mask;
BLI_addtail(&e->segments, ns);
}
if (cut_end_before) {
/* The same manipulation as on "cut_start_before". */
if (cut_end_before != ns2) {
- irls = cut_end_before->prev ? cut_end_before->prev : NULL;
- ns2->occlusion = irls ? irls->occlusion : 0;
- ns2->transparency_mask = irls ? irls->transparency_mask : 0;
+ ies = cut_end_before->prev ? cut_end_before->prev : NULL;
+ ns2->occlusion = ies ? ies->occlusion : 0;
+ ns2->transparency_mask = ies ? ies->transparency_mask : 0;
BLI_insertlinkbefore(&e->segments, cut_end_before, ns2);
}
}
else {
- irls = e->segments.last;
- ns2->occlusion = irls->occlusion;
- ns2->transparency_mask = irls->transparency_mask;
+ ies = e->segments.last;
+ ns2->occlusion = ies->occlusion;
+ ns2->transparency_mask = ies->transparency_mask;
BLI_addtail(&e->segments, ns2);
}
@@ -276,29 +276,29 @@ static void lineart_edge_cut(
}
/* Register 1 level of occlusion for all touched segments. */
- for (rls = ns; rls && rls != ns2; rls = rls->next) {
- rls->occlusion++;
- rls->transparency_mask |= transparency_mask;
+ for (es = ns; es && es != ns2; es = es->next) {
+ es->occlusion++;
+ es->transparency_mask |= transparency_mask;
}
/* Reduce adjacent cutting points of the same level, which saves memory. */
char min_occ = 127;
- prev_rls = NULL;
- for (rls = e->segments.first; rls; rls = next_rls) {
- next_rls = rls->next;
+ prev_es = NULL;
+ for (es = e->segments.first; es; es = next_es) {
+ next_es = es->next;
- if (prev_rls && prev_rls->occlusion == rls->occlusion &&
- prev_rls->transparency_mask == rls->transparency_mask) {
- BLI_remlink(&e->segments, rls);
+ if (prev_es && prev_es->occlusion == es->occlusion &&
+ prev_es->transparency_mask == es->transparency_mask) {
+ BLI_remlink(&e->segments, es);
/* This puts the node back to the render buffer, if more cut happens, these unused nodes get
* picked first. */
- lineart_discard_segment(rb, rls);
+ lineart_discard_segment(rb, es);
continue;
}
- min_occ = MIN2(min_occ, rls->occlusion);
+ min_occ = MIN2(min_occ, es->occlusion);
- prev_rls = rls;
+ prev_es = es;
}
e->min_occ = min_occ;
}
@@ -306,12 +306,12 @@ static void lineart_edge_cut(
/**
* To see if given line is connected to an adjacent intersection line.
*/
-BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartEdge *e, LineartTriangle *rt)
+BLI_INLINE bool lineart_occlusion_is_adjacent_intersection(LineartEdge *e, LineartTriangle *tri)
{
LineartVertIntersection *v1 = (void *)e->v1;
LineartVertIntersection *v2 = (void *)e->v2;
- return ((v1->base.flag && v1->intersecting_with == rt) ||
- (v2->base.flag && v2->intersecting_with == rt));
+ return ((v1->base.flag && v1->intersecting_with == tri) ||
+ (v2->base.flag && v2->intersecting_with == tri));
}
static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *e, int thread_id)
@@ -319,7 +319,7 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
double x = e->v1->fbcoord[0], y = e->v1->fbcoord[1];
LineartBoundingArea *ba = lineart_edge_first_bounding_area(rb, e);
LineartBoundingArea *nba = ba;
- LineartTriangleThread *rt;
+ LineartTriangleThread *tri;
/* These values are used for marching along the line. */
double l, r;
@@ -335,15 +335,15 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
while (nba) {
LISTBASE_FOREACH (LinkData *, lip, &nba->linked_triangles) {
- rt = lip->data;
+ tri = lip->data;
/* If we are already testing the line in this thread, then don't do it. */
- if (rt->testing_e[thread_id] == e || (rt->base.flags & LRT_TRIANGLE_INTERSECTION_ONLY) ||
- lineart_occlusion_is_adjacent_intersection(e, (LineartTriangle *)rt)) {
+ if (tri->testing_e[thread_id] == e || (tri->base.flags & LRT_TRIANGLE_INTERSECTION_ONLY) ||
+ lineart_occlusion_is_adjacent_intersection(e, (LineartTriangle *)tri)) {
continue;
}
- rt->testing_e[thread_id] = e;
+ tri->testing_e[thread_id] = e;
if (lineart_triangle_edge_image_space_occlusion(&rb->lock_task,
- (const LineartTriangle *)rt,
+ (const LineartTriangle *)tri,
e,
rb->camera_pos,
rb->cam_is_persp,
@@ -354,7 +354,7 @@ static void lineart_occlusion_single_line(LineartRenderBuffer *rb, LineartEdge *
rb->shift_y,
&l,
&r)) {
- lineart_edge_cut(rb, e, l, r, rt->base.transparency_mask);
+ lineart_edge_cut(rb, e, l, r, tri->base.transparency_mask);
if (e->min_occ > rb->max_occlusion_level) {
/* No need to calculate any longer on this line because no level more than set value is
* going to show up in the rendered result. */
@@ -376,18 +376,18 @@ static int lineart_occlusion_make_task_info(LineartRenderBuffer *rb, LineartRend
BLI_spin_lock(&rb->lock_task);
#define LRT_ASSIGN_OCCLUSION_TASK(name) \
- if (rb->name##_managed) { \
- data = rb->name##_managed; \
- rti->name = (void *)data; \
+ if (rb->name.last) { \
+ data = rb->name.last; \
+ rti->name.first = (void *)data; \
for (i = 0; i < LRT_THREAD_EDGE_COUNT && data; i++) { \
data = data->next; \
} \
- rti->name##_end = data; \
- rb->name##_managed = data; \
+ rti->name.last = data; \
+ rb->name.last = data; \
res = 1; \
} \
else { \
- rti->name = NULL; \
+ rti->name.first = rti->name.last = NULL; \
}
LRT_ASSIGN_OCCLUSION_TASK(contour);
@@ -410,23 +410,23 @@ static void lineart_occlusion_worker(TaskPool *__restrict UNUSED(pool), LineartR
while (lineart_occlusion_make_task_info(rb, rti)) {
- for (eip = rti->contour; eip && eip != rti->contour_end; eip = eip->next) {
+ for (eip = rti->contour.first; eip && eip != rti->contour.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
- for (eip = rti->crease; eip && eip != rti->crease_end; eip = eip->next) {
+ for (eip = rti->crease.first; eip && eip != rti->crease.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
- for (eip = rti->intersection; eip && eip != rti->intersection_end; eip = eip->next) {
+ for (eip = rti->intersection.first; eip && eip != rti->intersection.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
- for (eip = rti->material; eip && eip != rti->material_end; eip = eip->next) {
+ for (eip = rti->material.first; eip && eip != rti->material.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
- for (eip = rti->edge_mark; eip && eip != rti->edge_mark_end; eip = eip->next) {
+ for (eip = rti->edge_mark.first; eip && eip != rti->edge_mark.last; eip = eip->next) {
lineart_occlusion_single_line(rb, eip, rti->thread_id);
}
}
@@ -444,11 +444,13 @@ static void lineart_main_occlusion_begin(LineartRenderBuffer *rb)
"Task Pool");
int i;
- rb->contour_managed = rb->contours;
- rb->crease_managed = rb->crease_lines;
- rb->intersection_managed = rb->intersection_lines;
- rb->material_managed = rb->material_lines;
- rb->edge_mark_managed = rb->edge_marks;
+ /* The "last" entry is used to store worker progress in the whole list.
+ * These list themselves are single-direction linked, with list.first being the head. */
+ rb->contour.last = rb->contour.first;
+ rb->crease.last = rb->crease.first;
+ rb->intersection.last = rb->intersection.first;
+ rb->material.last = rb->material.first;
+ rb->edge_mark.last = rb->edge_mark.first;
TaskPool *tp = BLI_task_pool_create(NULL, TASK_PRIORITY_HIGH);
@@ -631,8 +633,8 @@ static LineartElementLinkNode *lineart_memory_get_triangle_space(LineartRenderBu
/* We don't need to allocate a whole bunch of triangles because the amount of clipped triangles
* are relatively small. */
- LineartTriangle *render_triangles = lineart_mem_aquire(&rb->render_data_pool,
- 64 * rb->triangle_size);
+ LineartTriangle *render_triangles = lineart_mem_acquire(&rb->render_data_pool,
+ 64 * rb->triangle_size);
reln = lineart_list_append_pointer_pool_sized(&rb->triangle_buffer_pointers,
&rb->render_data_pool,
@@ -648,8 +650,8 @@ static LineartElementLinkNode *lineart_memory_get_vert_space(LineartRenderBuffer
{
LineartElementLinkNode *reln;
- LineartVert *render_vertices = lineart_mem_aquire(&rb->render_data_pool,
- sizeof(LineartVert) * 64);
+ LineartVert *render_vertices = lineart_mem_acquire(&rb->render_data_pool,
+ sizeof(LineartVert) * 64);
reln = lineart_list_append_pointer_pool_sized(&rb->vertex_buffer_pointers,
&rb->render_data_pool,
@@ -665,7 +667,7 @@ static LineartElementLinkNode *lineart_memory_get_edge_space(LineartRenderBuffer
{
LineartElementLinkNode *reln;
- LineartEdge *render_edges = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartEdge) * 64);
+ LineartEdge *render_edges = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdge) * 64);
reln = lineart_list_append_pointer_pool_sized(&rb->line_buffer_pointers,
&rb->render_data_pool,
@@ -678,24 +680,24 @@ static LineartElementLinkNode *lineart_memory_get_edge_space(LineartRenderBuffer
return reln;
}
-static void lineart_triangle_post(LineartTriangle *rt, LineartTriangle *orig)
+static void lineart_triangle_post(LineartTriangle *tri, LineartTriangle *orig)
{
/* Just re-assign normal and set cull flag. */
- copy_v3_v3_db(rt->gn, orig->gn);
- rt->flags = LRT_CULL_GENERATED;
+ copy_v3_v3_db(tri->gn, orig->gn);
+ tri->flags = LRT_CULL_GENERATED;
}
-static void lineart_triangle_set_cull_flag(LineartTriangle *rt, uchar flag)
+static void lineart_triangle_set_cull_flag(LineartTriangle *tri, uchar flag)
{
- uchar intersection_only = (rt->flags & LRT_TRIANGLE_INTERSECTION_ONLY);
- rt->flags = flag;
- rt->flags |= intersection_only;
+ uchar intersection_only = (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY);
+ tri->flags = flag;
+ tri->flags |= intersection_only;
}
-static bool lineart_edge_match(LineartTriangle *rt, LineartEdge *e, int v1, int v2)
+static bool lineart_edge_match(LineartTriangle *tri, LineartEdge *e, int v1, int v2)
{
- return ((rt->v[v1] == e->v1 && rt->v[v2] == e->v2) ||
- (rt->v[v2] == e->v1 && rt->v[v1] == e->v2));
+ return ((tri->v[v1] == e->v1 && tri->v[v2] == e->v2) ||
+ (tri->v[v2] == e->v1 && tri->v[v1] == e->v2));
}
/**
@@ -703,7 +705,7 @@ static bool lineart_edge_match(LineartTriangle *rt, LineartEdge *e, int v1, int
* reversed by the caller so don't need to implement one in a different direction.
*/
static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
- LineartTriangle *rt,
+ LineartTriangle *tri,
int in0,
int in1,
int in2,
@@ -728,26 +730,26 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
char new_flag = 0;
LineartEdge *new_e, *e, *old_e;
- LineartLineSegment *rls;
- LineartTriangleAdjacent *rta;
+ LineartEdgeSegment *es;
+ LineartTriangleAdjacent *ta;
- if (rt->flags & (LRT_CULL_USED | LRT_CULL_GENERATED | LRT_CULL_DISCARD)) {
+ if (tri->flags & (LRT_CULL_USED | LRT_CULL_GENERATED | LRT_CULL_DISCARD)) {
return;
}
- /* See definition of rt->intersecting_verts and the usage in
+ /* See definition of tri->intersecting_verts and the usage in
* lineart_geometry_object_load() for details. */
- rta = (void *)rt->intersecting_verts;
+ ta = (void *)tri->intersecting_verts;
- LineartVert *rv = &((LineartVert *)v_eln->pointer)[v_count];
- LineartTriangle *rt1 = (void *)(((uchar *)t_eln->pointer) + rb->triangle_size * t_count);
- LineartTriangle *rt2 = (void *)(((uchar *)t_eln->pointer) + rb->triangle_size * (t_count + 1));
+ LineartVert *vt = &((LineartVert *)v_eln->pointer)[v_count];
+ LineartTriangle *tri1 = (void *)(((uchar *)t_eln->pointer) + rb->triangle_size * t_count);
+ LineartTriangle *tri2 = (void *)(((uchar *)t_eln->pointer) + rb->triangle_size * (t_count + 1));
new_e = &((LineartEdge *)e_eln->pointer)[e_count];
- /* Init `rl` to the last `rl` entry. */
+ /* Init `edge` to the last `edge` entry. */
e = new_e;
-#define INCREASE_RL \
+#define INCREASE_EDGE \
e_count++; \
v1_obi = e->v1_obindex; \
v2_obi = e->v2_obindex; \
@@ -755,40 +757,40 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
e = new_e; \
e->v1_obindex = v1_obi; \
e->v2_obindex = v2_obi; \
- rls = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartLineSegment)); \
- BLI_addtail(&e->segments, rls);
+ es = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdgeSegment)); \
+ BLI_addtail(&e->segments, es);
-#define SELECT_RL(e_num, v1_link, v2_link, newrt) \
- if (rta->e[e_num]) { \
- old_e = rta->e[e_num]; \
+#define SELECT_EDGE(e_num, v1_link, v2_link, new_tri) \
+ if (ta->e[e_num]) { \
+ old_e = ta->e[e_num]; \
new_flag = old_e->flags; \
old_e->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
- INCREASE_RL \
+ INCREASE_EDGE \
e->v1 = (v1_link); \
e->v2 = (v2_link); \
e->flags = new_flag; \
e->object_ref = ob; \
- e->t1 = ((old_e->t1 == rt) ? (newrt) : (old_e->t1)); \
- e->t2 = ((old_e->t2 == rt) ? (newrt) : (old_e->t2)); \
+ e->t1 = ((old_e->t1 == tri) ? (new_tri) : (old_e->t1)); \
+ e->t2 = ((old_e->t2 == tri) ? (new_tri) : (old_e->t2)); \
lineart_add_edge_to_list(rb, e); \
}
-#define RELINK_RL(e_num, newrt) \
- if (rta->e[e_num]) { \
- old_e = rta->e[e_num]; \
- old_e->t1 = ((old_e->t1 == rt) ? (newrt) : (old_e->t1)); \
- old_e->t2 = ((old_e->t2 == rt) ? (newrt) : (old_e->t2)); \
+#define RELINK_EDGE(e_num, new_tri) \
+ if (ta->e[e_num]) { \
+ old_e = ta->e[e_num]; \
+ old_e->t1 = ((old_e->t1 == tri) ? (new_tri) : (old_e->t1)); \
+ old_e->t2 = ((old_e->t2 == tri) ? (new_tri) : (old_e->t2)); \
}
-#define REMOVE_TRIANGLE_RL \
- if (rta->e[0]) { \
- rta->e[0]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+#define REMOVE_TRIANGLE_EDGE \
+ if (ta->e[0]) { \
+ ta->e[0]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
} \
- if (rta->e[1]) { \
- rta->e[1]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ if (ta->e[1]) { \
+ ta->e[1]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
} \
- if (rta->e[2]) { \
- rta->e[2]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
+ if (ta->e[2]) { \
+ ta->e[2]->flags = LRT_EDGE_FLAG_CHAIN_PICKED; \
}
switch (in0 + in1 + in2) {
@@ -797,13 +799,13 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
case 3:
/* Triangle completely behind near plane, throw it away
* also remove render lines form being computed. */
- lineart_triangle_set_cull_flag(rt, LRT_CULL_DISCARD);
- REMOVE_TRIANGLE_RL
+ lineart_triangle_set_cull_flag(tri, LRT_CULL_DISCARD);
+ REMOVE_TRIANGLE_EDGE
return;
case 2:
/* Two points behind near plane, cut those and
* generate 2 new points, 3 lines and 1 triangle. */
- lineart_triangle_set_cull_flag(rt, LRT_CULL_USED);
+ lineart_triangle_set_cull_flag(tri, LRT_CULL_USED);
/**
* (!in0) means "when point 0 is visible".
@@ -828,136 +830,136 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
if (!in0) {
/* Cut point for line 2---|-----0. */
- sub_v3_v3v3_db(vv1, rt->v[0]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[2]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[0]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[2]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
/* Assign it to a new point. */
- interp_v3_v3v3_db(rv[0].gloc, rt->v[0]->gloc, rt->v[2]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[2]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[0]->gloc, tri->v[2]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[2]->index;
/* Cut point for line 1---|-----0. */
- sub_v3_v3v3_db(vv1, rt->v[0]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[1]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[0]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[1]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
/* Assign it to another new point. */
- interp_v3_v3v3_db(rv[1].gloc, rt->v[0]->gloc, rt->v[1]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[1]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[0]->gloc, tri->v[1]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[1]->index;
/* New line connecting two new points. */
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
/* NOTE: inverting `e->v1/v2` (left/right point) doesn't matter as long as
- * `rt->rl` and `rt->v` has the same sequence. and the winding direction
+ * `tri->edge` and `tri->v` has the same sequence. and the winding direction
* can be either CW or CCW but needs to be consistent throughout the calculation. */
- e->v1 = &rv[1];
- e->v2 = &rv[0];
+ e->v1 = &vt[1];
+ e->v2 = &vt[0];
/* Only one adjacent triangle, because the other side is the near plane. */
/* Use `tl` or `tr` doesn't matter. */
- e->t1 = rt1;
+ e->t1 = tri1;
e->object_ref = ob;
/* New line connecting original point 0 and a new point, only when it's a selected line. */
- SELECT_RL(2, rt->v[0], &rv[0], rt1)
+ SELECT_EDGE(2, tri->v[0], &vt[0], tri1)
/* New line connecting original point 0 and another new point. */
- SELECT_RL(0, rt->v[0], &rv[1], rt1)
+ SELECT_EDGE(0, tri->v[0], &vt[1], tri1)
/* Re-assign triangle point array to two new points. */
- rt1->v[0] = rt->v[0];
- rt1->v[1] = &rv[1];
- rt1->v[2] = &rv[0];
+ tri1->v[0] = tri->v[0];
+ tri1->v[1] = &vt[1];
+ tri1->v[2] = &vt[0];
- lineart_triangle_post(rt1, rt);
+ lineart_triangle_post(tri1, tri);
v_count += 2;
t_count += 1;
}
else if (!in2) {
- sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[2]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[0].gloc, rt->v[2]->gloc, rt->v[0]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[0]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[2]->gloc, tri->v[0]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[0]->index;
- sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[1]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[2]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[1]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[1].gloc, rt->v[2]->gloc, rt->v[1]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[1]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[2]->gloc, tri->v[1]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[1]->index;
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
- e->v1 = &rv[0];
- e->v2 = &rv[1];
- e->t1 = rt1;
+ e->v1 = &vt[0];
+ e->v2 = &vt[1];
+ e->t1 = tri1;
e->object_ref = ob;
- SELECT_RL(2, rt->v[2], &rv[0], rt1)
- SELECT_RL(1, rt->v[2], &rv[1], rt1)
+ SELECT_EDGE(2, tri->v[2], &vt[0], tri1)
+ SELECT_EDGE(1, tri->v[2], &vt[1], tri1)
- rt1->v[0] = &rv[0];
- rt1->v[1] = &rv[1];
- rt1->v[2] = rt->v[2];
+ tri1->v[0] = &vt[0];
+ tri1->v[1] = &vt[1];
+ tri1->v[2] = tri->v[2];
- lineart_triangle_post(rt1, rt);
+ lineart_triangle_post(tri1, tri);
v_count += 2;
t_count += 1;
}
else if (!in1) {
- sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[2]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[1]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[2]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[0].gloc, rt->v[1]->gloc, rt->v[2]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[2]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[1]->gloc, tri->v[2]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[2]->index;
- sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[1]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[1].gloc, rt->v[1]->gloc, rt->v[0]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[0]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[1]->gloc, tri->v[0]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[0]->index;
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
- e->v1 = &rv[1];
- e->v2 = &rv[0];
- e->t1 = rt1;
+ e->v1 = &vt[1];
+ e->v2 = &vt[0];
+ e->t1 = tri1;
e->object_ref = ob;
- SELECT_RL(1, rt->v[1], &rv[0], rt1)
- SELECT_RL(0, rt->v[1], &rv[1], rt1)
+ SELECT_EDGE(1, tri->v[1], &vt[0], tri1)
+ SELECT_EDGE(0, tri->v[1], &vt[1], tri1)
- rt1->v[0] = &rv[0];
- rt1->v[1] = rt->v[1];
- rt1->v[2] = &rv[1];
+ tri1->v[0] = &vt[0];
+ tri1->v[1] = tri->v[1];
+ tri1->v[2] = &vt[1];
- lineart_triangle_post(rt1, rt);
+ lineart_triangle_post(tri1, tri);
v_count += 2;
t_count += 1;
@@ -966,7 +968,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
case 1:
/* One point behind near plane, cut those and
* generate 2 new points, 4 lines and 2 triangles. */
- lineart_triangle_set_cull_flag(rt, LRT_CULL_USED);
+ lineart_triangle_set_cull_flag(tri, LRT_CULL_USED);
/**
* (in0) means "when point 0 is invisible".
@@ -993,152 +995,152 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
*/
if (in0) {
/* Cut point for line 0---|------1. */
- sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[1]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot2 / (dot1 + dot2);
/* Assign to a new point. */
- interp_v3_v3v3_db(rv[0].gloc, rt->v[0]->gloc, rt->v[1]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[0]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[0]->gloc, tri->v[1]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[0]->index;
/* Cut point for line 0---|------2. */
- sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[2]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot2 / (dot1 + dot2);
/* Assign to other new point. */
- interp_v3_v3v3_db(rv[1].gloc, rt->v[0]->gloc, rt->v[2]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[0]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[0]->gloc, tri->v[2]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[0]->index;
/* New line connects two new points. */
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
- e->v1 = &rv[1];
- e->v2 = &rv[0];
- e->t1 = rt1;
+ e->v1 = &vt[1];
+ e->v2 = &vt[0];
+ e->t1 = tri1;
e->object_ref = ob;
/* New line connects new point 0 and old point 1,
* this is a border line. */
- SELECT_RL(0, rt->v[1], &rv[0], rt1)
- SELECT_RL(2, rt->v[2], &rv[1], rt2)
- RELINK_RL(1, rt2)
+ SELECT_EDGE(0, tri->v[1], &vt[0], tri1)
+ SELECT_EDGE(2, tri->v[2], &vt[1], tri2)
+ RELINK_EDGE(1, tri2)
/* We now have one triangle closed. */
- rt1->v[0] = rt->v[1];
- rt1->v[1] = &rv[1];
- rt1->v[2] = &rv[0];
+ tri1->v[0] = tri->v[1];
+ tri1->v[1] = &vt[1];
+ tri1->v[2] = &vt[0];
/* Close the second triangle. */
- rt2->v[0] = &rv[1];
- rt2->v[1] = rt->v[1];
- rt2->v[2] = rt->v[2];
+ tri2->v[0] = &vt[1];
+ tri2->v[1] = tri->v[1];
+ tri2->v[2] = tri->v[2];
- lineart_triangle_post(rt1, rt);
- lineart_triangle_post(rt2, rt);
+ lineart_triangle_post(tri1, tri);
+ lineart_triangle_post(tri2, tri);
v_count += 2;
t_count += 2;
}
else if (in1) {
- sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[2]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[1]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[2]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[0].gloc, rt->v[1]->gloc, rt->v[2]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[1]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[1]->gloc, tri->v[2]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[1]->index;
- sub_v3_v3v3_db(vv1, rt->v[1]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[1]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[1].gloc, rt->v[1]->gloc, rt->v[0]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[1]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[1]->gloc, tri->v[0]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[1]->index;
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
- e->v1 = &rv[1];
- e->v2 = &rv[0];
- e->t1 = rt1;
+ e->v1 = &vt[1];
+ e->v2 = &vt[0];
+ e->t1 = tri1;
e->object_ref = ob;
- SELECT_RL(1, rt->v[2], &rv[0], rt1)
- SELECT_RL(0, rt->v[0], &rv[1], rt2)
- RELINK_RL(2, rt2)
+ SELECT_EDGE(1, tri->v[2], &vt[0], tri1)
+ SELECT_EDGE(0, tri->v[0], &vt[1], tri2)
+ RELINK_EDGE(2, tri2)
- rt1->v[0] = rt->v[2];
- rt1->v[1] = &rv[1];
- rt1->v[2] = &rv[0];
+ tri1->v[0] = tri->v[2];
+ tri1->v[1] = &vt[1];
+ tri1->v[2] = &vt[0];
- rt2->v[0] = &rv[1];
- rt2->v[1] = rt->v[2];
- rt2->v[2] = rt->v[0];
+ tri2->v[0] = &vt[1];
+ tri2->v[1] = tri->v[2];
+ tri2->v[2] = tri->v[0];
- lineart_triangle_post(rt1, rt);
- lineart_triangle_post(rt2, rt);
+ lineart_triangle_post(tri1, tri);
+ lineart_triangle_post(tri2, tri);
v_count += 2;
t_count += 2;
}
else if (in2) {
- sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[0]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[2]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[0]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[0].gloc, rt->v[2]->gloc, rt->v[0]->gloc, a);
- mul_v4_m4v3_db(rv[0].fbcoord, vp, rv[0].gloc);
- rv[0].index = rt->v[2]->index;
+ interp_v3_v3v3_db(vt[0].gloc, tri->v[2]->gloc, tri->v[0]->gloc, a);
+ mul_v4_m4v3_db(vt[0].fbcoord, vp, vt[0].gloc);
+ vt[0].index = tri->v[2]->index;
- sub_v3_v3v3_db(vv1, rt->v[2]->gloc, cam_pos);
- sub_v3_v3v3_db(vv2, cam_pos, rt->v[1]->gloc);
+ sub_v3_v3v3_db(vv1, tri->v[2]->gloc, cam_pos);
+ sub_v3_v3v3_db(vv2, cam_pos, tri->v[1]->gloc);
dot1 = dot_v3v3_db(vv1, view_dir);
dot2 = dot_v3v3_db(vv2, view_dir);
a = dot1 / (dot1 + dot2);
- interp_v3_v3v3_db(rv[1].gloc, rt->v[2]->gloc, rt->v[1]->gloc, a);
- mul_v4_m4v3_db(rv[1].fbcoord, vp, rv[1].gloc);
- rv[1].index = rt->v[2]->index;
+ interp_v3_v3v3_db(vt[1].gloc, tri->v[2]->gloc, tri->v[1]->gloc, a);
+ mul_v4_m4v3_db(vt[1].fbcoord, vp, vt[1].gloc);
+ vt[1].index = tri->v[2]->index;
- INCREASE_RL
+ INCREASE_EDGE
if (allow_boundaries) {
e->flags = LRT_EDGE_FLAG_CONTOUR;
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
}
- e->v1 = &rv[1];
- e->v2 = &rv[0];
- e->t1 = rt1;
+ e->v1 = &vt[1];
+ e->v2 = &vt[0];
+ e->t1 = tri1;
e->object_ref = ob;
- SELECT_RL(2, rt->v[0], &rv[0], rt1)
- SELECT_RL(1, rt->v[1], &rv[1], rt2)
- RELINK_RL(0, rt2)
+ SELECT_EDGE(2, tri->v[0], &vt[0], tri1)
+ SELECT_EDGE(1, tri->v[1], &vt[1], tri2)
+ RELINK_EDGE(0, tri2)
- rt1->v[0] = rt->v[0];
- rt1->v[1] = &rv[1];
- rt1->v[2] = &rv[0];
+ tri1->v[0] = tri->v[0];
+ tri1->v[1] = &vt[1];
+ tri1->v[2] = &vt[0];
- rt2->v[0] = &rv[1];
- rt2->v[1] = rt->v[0];
- rt2->v[2] = rt->v[1];
+ tri2->v[0] = &vt[1];
+ tri2->v[1] = tri->v[0];
+ tri2->v[2] = tri->v[1];
- lineart_triangle_post(rt1, rt);
- lineart_triangle_post(rt2, rt);
+ lineart_triangle_post(tri1, tri);
+ lineart_triangle_post(tri2, tri);
v_count += 2;
t_count += 2;
@@ -1149,10 +1151,10 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
*r_e_count = e_count;
*r_t_count = t_count;
-#undef INCREASE_RL
-#undef SELECT_RL
-#undef RELINK_RL
-#undef REMOVE_TRIANGLE_RL
+#undef INCREASE_EDGE
+#undef SELECT_EDGE
+#undef RELINK_EDGE
+#undef REMOVE_TRIANGLE_EDGE
}
/**
@@ -1163,7 +1165,7 @@ static void lineart_triangle_cull_single(LineartRenderBuffer *rb,
*/
static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
{
- LineartTriangle *rt;
+ LineartTriangle *tri;
LineartElementLinkNode *v_eln, *t_eln, *e_eln;
double(*vp)[4] = rb->view_projection;
int i;
@@ -1219,25 +1221,25 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
in0 = 0, in1 = 0, in2 = 0; \
if (clip_far) { \
/* Point outside far plane. */ \
- if (rt->v[0]->fbcoord[use_w] > clip_end) { \
+ if (tri->v[0]->fbcoord[use_w] > clip_end) { \
in0 = 1; \
} \
- if (rt->v[1]->fbcoord[use_w] > clip_end) { \
+ if (tri->v[1]->fbcoord[use_w] > clip_end) { \
in1 = 1; \
} \
- if (rt->v[2]->fbcoord[use_w] > clip_end) { \
+ if (tri->v[2]->fbcoord[use_w] > clip_end) { \
in2 = 1; \
} \
} \
else { \
/* Point inside near plane. */ \
- if (rt->v[0]->fbcoord[use_w] < clip_start) { \
+ if (tri->v[0]->fbcoord[use_w] < clip_start) { \
in0 = 1; \
} \
- if (rt->v[1]->fbcoord[use_w] < clip_start) { \
+ if (tri->v[1]->fbcoord[use_w] < clip_start) { \
in1 = 1; \
} \
- if (rt->v[2]->fbcoord[use_w] < clip_start) { \
+ if (tri->v[2]->fbcoord[use_w] < clip_start) { \
in2 = 1; \
} \
}
@@ -1259,12 +1261,12 @@ static void lineart_main_cull_triangles(LineartRenderBuffer *rb, bool clip_far)
ob = reln->object_ref;
for (i = 0; i < reln->element_count; i++) {
/* Select the triangle in the array. */
- rt = (void *)(((uchar *)reln->pointer) + rb->triangle_size * i);
+ tri = (void *)(((uchar *)reln->pointer) + rb->triangle_size * i);
LRT_CULL_DECIDE_INSIDE
LRT_CULL_ENSURE_MEMORY
lineart_triangle_cull_single(rb,
- rt,
+ tri,
in0,
in1,
in2,
@@ -1299,20 +1301,20 @@ static void lineart_main_free_adjacent_data(LineartRenderBuffer *rb)
MEM_freeN(ld->data);
}
LISTBASE_FOREACH (LineartElementLinkNode *, reln, &rb->triangle_buffer_pointers) {
- LineartTriangle *rt = reln->pointer;
+ LineartTriangle *tri = reln->pointer;
int i;
for (i = 0; i < reln->element_count; i++) {
- /* See definition of rt->intersecting_verts and the usage in
+ /* See definition of tri->intersecting_verts and the usage in
* lineart_geometry_object_load() for detailed. */
- rt->intersecting_verts = NULL;
- rt = (LineartTriangle *)(((uchar *)rt) + rb->triangle_size);
+ tri->intersecting_verts = NULL;
+ tri = (LineartTriangle *)(((uchar *)tri) + rb->triangle_size);
}
}
}
static void lineart_main_perspective_division(LineartRenderBuffer *rb)
{
- LineartVert *rv;
+ LineartVert *vt;
int i;
if (!rb->cam_is_persp) {
@@ -1320,18 +1322,18 @@ static void lineart_main_perspective_division(LineartRenderBuffer *rb)
}
LISTBASE_FOREACH (LineartElementLinkNode *, reln, &rb->vertex_buffer_pointers) {
- rv = reln->pointer;
+ vt = reln->pointer;
for (i = 0; i < reln->element_count; i++) {
/* Do not divide Z, we use Z to back transform cut points in later chaining process. */
- rv[i].fbcoord[0] /= rv[i].fbcoord[3];
- rv[i].fbcoord[1] /= rv[i].fbcoord[3];
+ vt[i].fbcoord[0] /= vt[i].fbcoord[3];
+ vt[i].fbcoord[1] /= vt[i].fbcoord[3];
/* Re-map z into (0-1) range, because we no longer need NDC (Normalized Device Coordinates)
* at the moment.
* The algorithm currently doesn't need Z for operation, we use W instead. If Z is needed in
* the future, the line below correctly transforms it to view space coordinates. */
- // `rv[i].fbcoord[2] = -2 * rv[i].fbcoord[2] / (far - near) - (far + near) / (far - near);
- rv[i].fbcoord[0] -= rb->shift_x * 2;
- rv[i].fbcoord[1] -= rb->shift_y * 2;
+ // `vt[i].fbcoord[2] = -2 * vt[i].fbcoord[2] / (far - near) - (far + near) / (far - near);
+ vt[i].fbcoord[0] -= rb->shift_x * 2;
+ vt[i].fbcoord[1] -= rb->shift_y * 2;
}
}
}
@@ -1343,10 +1345,10 @@ static void lineart_vert_transform(
BMVert *v, int index, LineartVert *RvBuf, double (*mv_mat)[4], double (*mvp_mat)[4])
{
double co[4];
- LineartVert *rv = &RvBuf[index];
+ LineartVert *vt = &RvBuf[index];
copy_v3db_v3fl(co, v->co);
- mul_v3_m4v3_db(rv->gloc, mv_mat, co);
- mul_v4_m4v3_db(rv->fbcoord, mvp_mat, co);
+ mul_v3_m4v3_db(vt->gloc, mv_mat, co);
+ mul_v4_m4v3_db(vt->fbcoord, mvp_mat, co);
}
/**
@@ -1381,12 +1383,12 @@ static char lineart_identify_feature_line(LineartRenderBuffer *rb,
return LRT_EDGE_FLAG_CONTOUR;
}
- LineartTriangle *rt1, *rt2;
+ LineartTriangle *tri1, *tri2;
LineartVert *l;
/* The mesh should already be triangulated now, so we can assume each face is a triangle. */
- rt1 = lineart_triangle_from_index(rb, rt_array, BM_elem_index_get(ll->f));
- rt2 = lineart_triangle_from_index(rb, rt_array, BM_elem_index_get(lr->f));
+ tri1 = lineart_triangle_from_index(rb, rt_array, BM_elem_index_get(ll->f));
+ tri2 = lineart_triangle_from_index(rb, rt_array, BM_elem_index_get(lr->f));
l = &rv_array[BM_elem_index_get(e->v1)];
@@ -1403,14 +1405,14 @@ static char lineart_identify_feature_line(LineartRenderBuffer *rb,
view_vector = rb->view_vector;
}
- dot_1 = dot_v3v3_db(view_vector, rt1->gn);
- dot_2 = dot_v3v3_db(view_vector, rt2->gn);
+ dot_1 = dot_v3v3_db(view_vector, tri1->gn);
+ dot_2 = dot_v3v3_db(view_vector, tri2->gn);
if ((result = dot_1 * dot_2) <= 0 && (dot_1 + dot_2)) {
return LRT_EDGE_FLAG_CONTOUR;
}
- if (rb->use_crease && (dot_v3v3_db(rt1->gn, rt2->gn) < crease_threshold)) {
+ if (rb->use_crease && (dot_v3v3_db(tri1->gn, tri2->gn) < crease_threshold)) {
if (!no_crease) {
return LRT_EDGE_FLAG_CREASE;
}
@@ -1431,35 +1433,35 @@ static void lineart_add_edge_to_list(LineartRenderBuffer *rb, LineartEdge *e)
{
switch (e->flags) {
case LRT_EDGE_FLAG_CONTOUR:
- lineart_prepend_edge_direct(&rb->contours, e);
+ lineart_prepend_edge_direct(&rb->contour.first, e);
break;
case LRT_EDGE_FLAG_CREASE:
- lineart_prepend_edge_direct(&rb->crease_lines, e);
+ lineart_prepend_edge_direct(&rb->crease.first, e);
break;
case LRT_EDGE_FLAG_MATERIAL:
- lineart_prepend_edge_direct(&rb->material_lines, e);
+ lineart_prepend_edge_direct(&rb->material.first, e);
break;
case LRT_EDGE_FLAG_EDGE_MARK:
- lineart_prepend_edge_direct(&rb->edge_marks, e);
+ lineart_prepend_edge_direct(&rb->edge_mark.first, e);
break;
case LRT_EDGE_FLAG_INTERSECTION:
- lineart_prepend_edge_direct(&rb->intersection_lines, e);
+ lineart_prepend_edge_direct(&rb->intersection.first, e);
break;
}
}
-static void lineart_triangle_adjacent_assign(LineartTriangle *rt,
- LineartTriangleAdjacent *rta,
+static void lineart_triangle_adjacent_assign(LineartTriangle *tri,
+ LineartTriangleAdjacent *ta,
LineartEdge *e)
{
- if (lineart_edge_match(rt, e, 0, 1)) {
- rta->e[0] = e;
+ if (lineart_edge_match(tri, e, 0, 1)) {
+ ta->e[0] = e;
}
- else if (lineart_edge_match(rt, e, 1, 2)) {
- rta->e[1] = e;
+ else if (lineart_edge_match(tri, e, 1, 2)) {
+ ta->e[1] = e;
}
- else if (lineart_edge_match(rt, e, 2, 0)) {
- rta->e[2] = e;
+ else if (lineart_edge_match(tri, e, 2, 0)) {
+ ta->e[2] = e;
}
}
@@ -1477,7 +1479,7 @@ static void lineart_geometry_object_load(Depsgraph *dg,
BMEdge *e;
BMLoop *loop;
LineartEdge *la_e;
- LineartTriangle *rt;
+ LineartTriangle *tri;
LineartTriangleAdjacent *orta;
double new_mvp[4][4], new_mv[4][4], normal[4][4];
float imat[4][4];
@@ -1510,7 +1512,7 @@ static void lineart_geometry_object_load(Depsgraph *dg,
use_mesh = DEG_get_evaluated_object(dg, ob)->data;
}
else {
- use_mesh = BKE_mesh_new_from_object(NULL, ob, false);
+ use_mesh = BKE_mesh_new_from_object(NULL, ob, false, false);
}
/* In case we can not get any mesh geometry data from the object */
@@ -1576,8 +1578,8 @@ static void lineart_geometry_object_load(Depsgraph *dg,
/* Only allocate memory for verts and tris as we don't know how many lines we will generate
* yet. */
- orv = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartVert) * bm->totvert);
- ort = lineart_mem_aquire(&rb->render_data_pool, bm->totface * rb->triangle_size);
+ orv = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartVert) * bm->totvert);
+ ort = lineart_mem_acquire(&rb->render_data_pool, bm->totface * rb->triangle_size);
orig_ob = ob->id.orig_id ? (Object *)ob->id.orig_id : ob;
@@ -1621,39 +1623,39 @@ static void lineart_geometry_object_load(Depsgraph *dg,
* index to come close together. */
(*global_vindex) += bm->totvert;
- rt = ort;
+ tri = ort;
for (i = 0; i < bm->totface; i++) {
f = BM_face_at_index(bm, i);
loop = f->l_first;
- rt->v[0] = &orv[BM_elem_index_get(loop->v)];
+ tri->v[0] = &orv[BM_elem_index_get(loop->v)];
loop = loop->next;
- rt->v[1] = &orv[BM_elem_index_get(loop->v)];
+ tri->v[1] = &orv[BM_elem_index_get(loop->v)];
loop = loop->next;
- rt->v[2] = &orv[BM_elem_index_get(loop->v)];
+ tri->v[2] = &orv[BM_elem_index_get(loop->v)];
/* Transparency bit assignment. */
Material *mat = BKE_object_material_get(ob, f->mat_nr + 1);
- rt->transparency_mask = ((mat && (mat->lineart.flags & LRT_MATERIAL_TRANSPARENCY_ENABLED)) ?
- mat->lineart.transparency_mask :
- 0);
+ tri->transparency_mask = ((mat && (mat->lineart.flags & LRT_MATERIAL_TRANSPARENCY_ENABLED)) ?
+ mat->lineart.transparency_mask :
+ 0);
double gn[3];
copy_v3db_v3fl(gn, f->no);
- mul_v3_mat3_m4v3_db(rt->gn, normal, gn);
- normalize_v3_db(rt->gn);
+ mul_v3_mat3_m4v3_db(tri->gn, normal, gn);
+ normalize_v3_db(tri->gn);
if (usage == OBJECT_LRT_INTERSECTION_ONLY) {
- rt->flags |= LRT_TRIANGLE_INTERSECTION_ONLY;
+ tri->flags |= LRT_TRIANGLE_INTERSECTION_ONLY;
}
else if (ELEM(usage, OBJECT_LRT_NO_INTERSECTION, OBJECT_LRT_OCCLUSION_ONLY)) {
- rt->flags |= LRT_TRIANGLE_NO_INTERSECTION;
+ tri->flags |= LRT_TRIANGLE_NO_INTERSECTION;
}
/* Re-use this field to refer to adjacent info, will be cleared after culling stage. */
- rt->intersecting_verts = (void *)&orta[i];
+ tri->intersecting_verts = (void *)&orta[i];
- rt = (LineartTriangle *)(((uchar *)rt) + rb->triangle_size);
+ tri = (LineartTriangle *)(((uchar *)tri) + rb->triangle_size);
}
/* Use BM_ELEM_TAG in f->head.hflag to store needed faces in the first iteration. */
@@ -1675,7 +1677,7 @@ static void lineart_geometry_object_load(Depsgraph *dg,
e->head.hflag = eflag;
}
- o_la_e = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartEdge) * allocate_la_e);
+ o_la_e = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdge) * allocate_la_e);
reln = lineart_list_append_pointer_pool_sized(
&rb->line_buffer_pointers, &rb->render_data_pool, o_la_e, sizeof(LineartElementLinkNode));
reln->element_count = allocate_la_e;
@@ -1707,9 +1709,9 @@ static void lineart_geometry_object_load(Depsgraph *dg,
la_e->flags = e->head.hflag;
la_e->object_ref = orig_ob;
- LineartLineSegment *rls = lineart_mem_aquire(&rb->render_data_pool,
- sizeof(LineartLineSegment));
- BLI_addtail(&la_e->segments, rls);
+ LineartEdgeSegment *es = lineart_mem_acquire(&rb->render_data_pool,
+ sizeof(LineartEdgeSegment));
+ BLI_addtail(&la_e->segments, es);
if (ELEM(usage, OBJECT_LRT_INHERIT, OBJECT_LRT_INCLUDE, OBJECT_LRT_NO_INTERSECTION)) {
lineart_add_edge_to_list(rb, la_e);
}
@@ -1817,8 +1819,23 @@ static void lineart_main_load_geometries(
double asp = ((double)rb->w / (double)rb->h);
if (cam->type == CAM_PERSP) {
- if (asp < 1) {
- fov /= asp;
+ if (cam->sensor_fit == CAMERA_SENSOR_FIT_AUTO) {
+ if (asp < 1) {
+ fov /= asp;
+ }
+ else {
+ fov *= asp;
+ }
+ }
+ else if (cam->sensor_fit == CAMERA_SENSOR_FIT_HOR) {
+ if (asp < 1) {
+ fov /= asp;
+ }
+ }
+ else if (cam->sensor_fit == CAMERA_SENSOR_FIT_VERT) {
+ if (asp > 1) {
+ fov *= asp;
+ }
}
lineart_matrix_perspective_44d(proj, fov, asp, cam->clip_start, cam->clip_end);
}
@@ -1860,51 +1877,51 @@ static void lineart_main_load_geometries(
* Returns the two other verts of the triangle given a vertex. Returns false if the given vertex
* doesn't belong to this triangle.
*/
-static bool lineart_triangle_get_other_verts(const LineartTriangle *rt,
- const LineartVert *rv,
+static bool lineart_triangle_get_other_verts(const LineartTriangle *tri,
+ const LineartVert *vt,
LineartVert **l,
LineartVert **r)
{
- if (rt->v[0] == rv) {
- *l = rt->v[1];
- *r = rt->v[2];
+ if (tri->v[0] == vt) {
+ *l = tri->v[1];
+ *r = tri->v[2];
return true;
}
- if (rt->v[1] == rv) {
- *l = rt->v[2];
- *r = rt->v[0];
+ if (tri->v[1] == vt) {
+ *l = tri->v[2];
+ *r = tri->v[0];
return true;
}
- if (rt->v[2] == rv) {
- *l = rt->v[0];
- *r = rt->v[1];
+ if (tri->v[2] == vt) {
+ *l = tri->v[0];
+ *r = tri->v[1];
return true;
}
return false;
}
-static bool lineart_edge_from_triangle(const LineartTriangle *rt,
+static bool lineart_edge_from_triangle(const LineartTriangle *tri,
const LineartEdge *e,
bool allow_overlapping_edges)
{
/* Normally we just determine from the pointer address. */
- if (e->t1 == rt || e->t2 == rt) {
+ if (e->t1 == tri || e->t2 == tri) {
return true;
}
/* If allows overlapping, then we compare the vertex coordinates one by one to determine if one
* edge is from specific triangle. This is slower but can handle edge split cases very well. */
if (allow_overlapping_edges) {
-#define LRT_TRI_SAME_POINT(rt, i, pt) \
- ((LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[0], pt->gloc[0]) && \
- LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[1], pt->gloc[1]) && \
- LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[2], pt->gloc[2])) || \
- (LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[0], pt->gloc[0]) && \
- LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[1], pt->gloc[1]) && \
- LRT_DOUBLE_CLOSE_ENOUGH(rt->v[i]->gloc[2], pt->gloc[2])))
- if ((LRT_TRI_SAME_POINT(rt, 0, e->v1) || LRT_TRI_SAME_POINT(rt, 1, e->v1) ||
- LRT_TRI_SAME_POINT(rt, 2, e->v1)) &&
- (LRT_TRI_SAME_POINT(rt, 0, e->v2) || LRT_TRI_SAME_POINT(rt, 1, e->v2) ||
- LRT_TRI_SAME_POINT(rt, 2, e->v2))) {
+#define LRT_TRI_SAME_POINT(tri, i, pt) \
+ ((LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[0], pt->gloc[0]) && \
+ LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[1], pt->gloc[1]) && \
+ LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[2], pt->gloc[2])) || \
+ (LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[0], pt->gloc[0]) && \
+ LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[1], pt->gloc[1]) && \
+ LRT_DOUBLE_CLOSE_ENOUGH(tri->v[i]->gloc[2], pt->gloc[2])))
+ if ((LRT_TRI_SAME_POINT(tri, 0, e->v1) || LRT_TRI_SAME_POINT(tri, 1, e->v1) ||
+ LRT_TRI_SAME_POINT(tri, 2, e->v1)) &&
+ (LRT_TRI_SAME_POINT(tri, 0, e->v2) || LRT_TRI_SAME_POINT(tri, 1, e->v2) ||
+ LRT_TRI_SAME_POINT(tri, 2, e->v2))) {
return true;
}
#undef LRT_TRI_SAME_POINT
@@ -1946,7 +1963,7 @@ static bool lineart_edge_from_triangle(const LineartTriangle *rt,
* in ratio from `e->v1` to `e->v2`. The line is later cut with these two values.
*/
static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
- const LineartTriangle *rt,
+ const LineartTriangle *tri,
const LineartEdge *e,
const double *override_camera_loc,
const bool override_cam_is_persp,
@@ -1973,8 +1990,8 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
double gloc[4], trans[4];
double cut = -1;
- double *LFBC = e->v1->fbcoord, *RFBC = e->v2->fbcoord, *FBC0 = rt->v[0]->fbcoord,
- *FBC1 = rt->v[1]->fbcoord, *FBC2 = rt->v[2]->fbcoord;
+ double *LFBC = e->v1->fbcoord, *RFBC = e->v2->fbcoord, *FBC0 = tri->v[0]->fbcoord,
+ *FBC1 = tri->v[1]->fbcoord, *FBC2 = tri->v[2]->fbcoord;
/* Overlapping not possible, return early. */
if ((MAX3(FBC0[0], FBC1[0], FBC2[0]) < MIN2(LFBC[0], RFBC[0])) ||
@@ -1986,7 +2003,7 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
}
/* If the the line is one of the edge in the triangle, then it's not occluded. */
- if (lineart_edge_from_triangle(rt, e, allow_overlapping_edges)) {
+ if (lineart_edge_from_triangle(tri, e, allow_overlapping_edges)) {
return false;
}
@@ -1998,8 +2015,8 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
/* Sort the intersection distance. */
INTERSECT_SORT_MIN_TO_MAX_3(is[0], is[1], is[2], order);
- sub_v3_v3v3_db(Lv, e->v1->gloc, rt->v[0]->gloc);
- sub_v3_v3v3_db(Rv, e->v2->gloc, rt->v[0]->gloc);
+ sub_v3_v3v3_db(Lv, e->v1->gloc, tri->v[0]->gloc);
+ sub_v3_v3v3_db(Rv, e->v2->gloc, tri->v[0]->gloc);
copy_v3_v3_db(Cv, camera_dir);
@@ -2010,12 +2027,12 @@ static bool lineart_triangle_edge_image_space_occlusion(SpinLock *UNUSED(spl),
copy_v4_v4_db(vd4, override_camera_loc);
}
if (override_cam_is_persp) {
- sub_v3_v3v3_db(Cv, vd4, rt->v[0]->gloc);
+ sub_v3_v3v3_db(Cv, vd4, tri->v[0]->gloc);
}
- dot_l = dot_v3v3_db(Lv, rt->gn);
- dot_r = dot_v3v3_db(Rv, rt->gn);
- dot_f = dot_v3v3_db(Cv, rt->gn);
+ dot_l = dot_v3v3_db(Lv, tri->gn);
+ dot_r = dot_v3v3_db(Rv, tri->gn);
+ dot_f = dot_v3v3_db(Cv, tri->gn);
if (!dot_f) {
return false;
@@ -2256,17 +2273,17 @@ static LineartVert *lineart_triangle_share_point(const LineartTriangle *l,
/**
* To save time and prevent overlapping lines when computing intersection lines.
*/
-static bool lineart_vert_already_intersected_2v(LineartVertIntersection *rv,
+static bool lineart_vert_already_intersected_2v(LineartVertIntersection *vt,
LineartVertIntersection *v1,
LineartVertIntersection *v2)
{
- return ((rv->isec1 == v1->base.index && rv->isec2 == v2->base.index) ||
- (rv->isec2 == v2->base.index && rv->isec1 == v1->base.index));
+ return ((vt->isec1 == v1->base.index && vt->isec2 == v2->base.index) ||
+ (vt->isec2 == v2->base.index && vt->isec1 == v1->base.index));
}
-static void lineart_vert_set_intersection_2v(LineartVert *rv, LineartVert *v1, LineartVert *v2)
+static void lineart_vert_set_intersection_2v(LineartVert *vt, LineartVert *v1, LineartVert *v2)
{
- LineartVertIntersection *irv = (LineartVertIntersection *)rv;
+ LineartVertIntersection *irv = (LineartVertIntersection *)vt;
irv->isec1 = v1->index;
irv->isec2 = v2->index;
}
@@ -2279,7 +2296,7 @@ static void lineart_vert_set_intersection_2v(LineartVert *rv, LineartVert *v1, L
static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *rb,
LineartVert *v1,
LineartVert *v2,
- LineartTriangle *rt,
+ LineartTriangle *tri,
LineartTriangle *testing,
LineartVert *last)
{
@@ -2291,11 +2308,11 @@ static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *r
LineartVert *l = v1, *r = v2;
for (LinkNode *ln = (void *)testing->intersecting_verts; ln; ln = ln->next) {
- LineartVertIntersection *rv = ln->link;
- if (rv->intersecting_with == rt &&
+ LineartVertIntersection *vt = ln->link;
+ if (vt->intersecting_with == tri &&
lineart_vert_already_intersected_2v(
- rv, (LineartVertIntersection *)l, (LineartVertIntersection *)r)) {
- return (LineartVert *)rv;
+ vt, (LineartVertIntersection *)l, (LineartVertIntersection *)r)) {
+ return (LineartVert *)vt;
}
}
@@ -2329,7 +2346,7 @@ static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *r
/* This is an intersection vert, the size is bigger than LineartVert,
* allocated separately. */
- result = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartVertIntersection));
+ result = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartVertIntersection));
/* Indicate the data structure difference. */
result->flag = LRT_VERT_HAS_INTERSECTION_DATA;
@@ -2345,7 +2362,7 @@ static LineartVert *lineart_triangle_2v_intersection_test(LineartRenderBuffer *r
* Test if two triangles intersect. Generates one intersection line if the check succeeds.
*/
static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
- LineartTriangle *rt,
+ LineartTriangle *tri,
LineartTriangle *testing)
{
LineartVert *v1 = 0, *v2 = 0;
@@ -2364,62 +2381,62 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
ZMax = rb->far_clip;
ZMin = rb->near_clip;
copy_v3_v3_db(cl, rb->camera_pos);
- LineartVert *share = lineart_triangle_share_point(testing, rt);
+ LineartVert *share = lineart_triangle_share_point(testing, tri);
if (share) {
/* If triangles have sharing points like `abc` and `acd`, then we only need to detect `bc`
* against `acd` or `cd` against `abc`. */
LineartVert *new_share;
- lineart_triangle_get_other_verts(rt, share, &sv1, &sv2);
+ lineart_triangle_get_other_verts(tri, share, &sv1, &sv2);
- v1 = new_share = lineart_mem_aquire(&rb->render_data_pool, (sizeof(LineartVertIntersection)));
+ v1 = new_share = lineart_mem_acquire(&rb->render_data_pool, (sizeof(LineartVertIntersection)));
new_share->flag = LRT_VERT_HAS_INTERSECTION_DATA;
copy_v3_v3_db(new_share->gloc, share->gloc);
- v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, rt, testing, 0);
+ v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, tri, testing, 0);
if (v2 == NULL) {
lineart_triangle_get_other_verts(testing, share, &sv1, &sv2);
- v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, testing, rt, 0);
+ v2 = lineart_triangle_2v_intersection_test(rb, sv1, sv2, testing, tri, 0);
if (v2 == NULL) {
return 0;
}
lineart_prepend_pool(&testing->intersecting_verts, &rb->render_data_pool, new_share);
}
else {
- lineart_prepend_pool(&rt->intersecting_verts, &rb->render_data_pool, new_share);
+ lineart_prepend_pool(&tri->intersecting_verts, &rb->render_data_pool, new_share);
}
}
else {
/* If not sharing any points, then we need to try all the possibilities. */
- E0T = lineart_triangle_2v_intersection_test(rb, rt->v[0], rt->v[1], rt, testing, 0);
+ E0T = lineart_triangle_2v_intersection_test(rb, tri->v[0], tri->v[1], tri, testing, 0);
if (E0T && (!(*next))) {
(*next) = E0T;
- lineart_vert_set_intersection_2v((*next), rt->v[0], rt->v[1]);
+ lineart_vert_set_intersection_2v((*next), tri->v[0], tri->v[1]);
next = &v2;
}
- E1T = lineart_triangle_2v_intersection_test(rb, rt->v[1], rt->v[2], rt, testing, v1);
+ E1T = lineart_triangle_2v_intersection_test(rb, tri->v[1], tri->v[2], tri, testing, v1);
if (E1T && (!(*next))) {
(*next) = E1T;
- lineart_vert_set_intersection_2v((*next), rt->v[1], rt->v[2]);
+ lineart_vert_set_intersection_2v((*next), tri->v[1], tri->v[2]);
next = &v2;
}
if (!(*next)) {
- E2T = lineart_triangle_2v_intersection_test(rb, rt->v[2], rt->v[0], rt, testing, v1);
+ E2T = lineart_triangle_2v_intersection_test(rb, tri->v[2], tri->v[0], tri, testing, v1);
}
if (E2T && (!(*next))) {
(*next) = E2T;
- lineart_vert_set_intersection_2v((*next), rt->v[2], rt->v[0]);
+ lineart_vert_set_intersection_2v((*next), tri->v[2], tri->v[0]);
next = &v2;
}
if (!(*next)) {
TE0 = lineart_triangle_2v_intersection_test(
- rb, testing->v[0], testing->v[1], testing, rt, v1);
+ rb, testing->v[0], testing->v[1], testing, tri, v1);
}
if (TE0 && (!(*next))) {
(*next) = TE0;
@@ -2428,7 +2445,7 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
}
if (!(*next)) {
TE1 = lineart_triangle_2v_intersection_test(
- rb, testing->v[1], testing->v[2], testing, rt, v1);
+ rb, testing->v[1], testing->v[2], testing, tri, v1);
}
if (TE1 && (!(*next))) {
(*next) = TE1;
@@ -2437,7 +2454,7 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
}
if (!(*next)) {
TE2 = lineart_triangle_2v_intersection_test(
- rb, testing->v[2], testing->v[0], testing, rt, v1);
+ rb, testing->v[2], testing->v[0], testing, tri, v1);
}
if (TE2 && (!(*next))) {
(*next) = TE2;
@@ -2469,53 +2486,51 @@ static LineartEdge *lineart_triangle_intersect(LineartRenderBuffer *rb,
v1->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(v1->fbcoord[2]) * (ZMax - ZMin));
v2->fbcoord[2] = ZMin * ZMax / (ZMax - fabs(v2->fbcoord[2]) * (ZMax - ZMin));
- ((LineartVertIntersection *)v1)->intersecting_with = rt;
+ ((LineartVertIntersection *)v1)->intersecting_with = tri;
((LineartVertIntersection *)v2)->intersecting_with = testing;
- result = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartEdge));
+ result = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdge));
result->v1 = v1;
result->v2 = v2;
- result->t1 = rt;
+ result->t1 = tri;
result->t2 = testing;
- LineartLineSegment *rls = lineart_mem_aquire(&rb->render_data_pool, sizeof(LineartLineSegment));
- BLI_addtail(&result->segments, rls);
+ LineartEdgeSegment *es = lineart_mem_acquire(&rb->render_data_pool, sizeof(LineartEdgeSegment));
+ BLI_addtail(&result->segments, es);
/* Don't need to OR flags right now, just a type mark. */
result->flags = LRT_EDGE_FLAG_INTERSECTION;
- lineart_prepend_edge_direct(&rb->intersection_lines, result);
+ lineart_prepend_edge_direct(&rb->intersection.first, result);
int r1, r2, c1, c2, row, col;
if (lineart_get_edge_bounding_areas(rb, result, &r1, &r2, &c1, &c2)) {
for (row = r1; row != r2 + 1; row++) {
for (col = c1; col != c2 + 1; col++) {
- lineart_bounding_area_link_line(
+ lineart_bounding_area_link_edge(
rb, &rb->initial_bounding_areas[row * LRT_BA_ROWS + col], result);
}
}
}
- rb->intersection_count++;
-
return result;
}
static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
- LineartTriangle *rt,
+ LineartTriangle *tri,
LineartBoundingArea *ba)
{
/* Testing_triangle->testing[0] is used to store pairing triangle reference.
* See definition of LineartTriangleThread for more info. */
LineartTriangle *testing_triangle;
- LineartTriangleThread *rtt;
+ LineartTriangleThread *tt;
LinkData *lip, *next_lip;
- double *G0 = rt->v[0]->gloc, *G1 = rt->v[1]->gloc, *G2 = rt->v[2]->gloc;
+ double *G0 = tri->v[0]->gloc, *G1 = tri->v[1]->gloc, *G2 = tri->v[2]->gloc;
/* If this is not the smallest subdiv bounding area.*/
if (ba->child) {
- lineart_triangle_intersect_in_bounding_area(rb, rt, &ba->child[0]);
- lineart_triangle_intersect_in_bounding_area(rb, rt, &ba->child[1]);
- lineart_triangle_intersect_in_bounding_area(rb, rt, &ba->child[2]);
- lineart_triangle_intersect_in_bounding_area(rb, rt, &ba->child[3]);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[0]);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[1]);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[2]);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, &ba->child[3]);
return;
}
@@ -2523,16 +2538,16 @@ static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
for (lip = ba->linked_triangles.first; lip; lip = next_lip) {
next_lip = lip->next;
testing_triangle = lip->data;
- rtt = (LineartTriangleThread *)testing_triangle;
+ tt = (LineartTriangleThread *)testing_triangle;
- if (testing_triangle == rt || rtt->testing_e[0] == (LineartEdge *)rt) {
+ if (testing_triangle == tri || tt->testing_e[0] == (LineartEdge *)tri) {
continue;
}
- rtt->testing_e[0] = (LineartEdge *)rt;
+ tt->testing_e[0] = (LineartEdge *)tri;
if ((testing_triangle->flags & LRT_TRIANGLE_NO_INTERSECTION) ||
((testing_triangle->flags & LRT_TRIANGLE_INTERSECTION_ONLY) &&
- (rt->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) {
+ (tri->flags & LRT_TRIANGLE_INTERSECTION_ONLY))) {
continue;
}
@@ -2546,12 +2561,12 @@ static void lineart_triangle_intersect_in_bounding_area(LineartRenderBuffer *rb,
(MAX3(G0[0], G1[0], G2[0]) < MIN3(RG0[0], RG1[0], RG2[0])) ||
(MIN3(G0[1], G1[1], G2[1]) > MAX3(RG0[1], RG1[1], RG2[1])) ||
(MAX3(G0[1], G1[1], G2[1]) < MIN3(RG0[1], RG1[1], RG2[1])) ||
- lineart_triangle_share_edge(rt, testing_triangle)) {
+ lineart_triangle_share_edge(tri, testing_triangle)) {
continue;
}
/* If we do need to compute intersection, then finally do it. */
- lineart_triangle_intersect(rb, rt, testing_triangle);
+ lineart_triangle_intersect(rb, tri, testing_triangle);
}
}
@@ -2583,22 +2598,11 @@ static void lineart_destroy_render_data(LineartRenderBuffer *rb)
return;
}
- rb->contour_count = 0;
- rb->contour_managed = NULL;
- rb->intersection_count = 0;
- rb->intersection_managed = NULL;
- rb->material_line_count = 0;
- rb->material_managed = NULL;
- rb->crease_count = 0;
- rb->crease_managed = NULL;
- rb->edge_mark_count = 0;
- rb->edge_mark_managed = NULL;
-
- rb->contours = NULL;
- rb->intersection_lines = NULL;
- rb->crease_lines = NULL;
- rb->material_lines = NULL;
- rb->edge_marks = NULL;
+ memset(&rb->contour, 0, sizeof(ListBase));
+ memset(&rb->crease, 0, sizeof(ListBase));
+ memset(&rb->intersection, 0, sizeof(ListBase));
+ memset(&rb->edge_mark, 0, sizeof(ListBase));
+ memset(&rb->material, 0, sizeof(ListBase));
BLI_listbase_clear(&rb->chains);
BLI_listbase_clear(&rb->wasted_cuts);
@@ -2714,7 +2718,7 @@ static void lineart_main_bounding_area_make_initial(LineartRenderBuffer *rb)
rb->height_per_tile = span_h;
rb->bounding_area_count = sp_w * sp_h;
- rb->initial_bounding_areas = lineart_mem_aquire(
+ rb->initial_bounding_areas = lineart_mem_acquire(
&rb->render_data_pool, sizeof(LineartBoundingArea) * rb->bounding_area_count);
/* Initialize tiles. */
@@ -2908,9 +2912,9 @@ static void lineart_bounding_area_split(LineartRenderBuffer *rb,
LineartBoundingArea *root,
int recursive_level)
{
- LineartBoundingArea *ba = lineart_mem_aquire(&rb->render_data_pool,
- sizeof(LineartBoundingArea) * 4);
- LineartTriangle *rt;
+ LineartBoundingArea *ba = lineart_mem_acquire(&rb->render_data_pool,
+ sizeof(LineartBoundingArea) * 4);
+ LineartTriangle *tri;
LineartEdge *e;
ba[0].l = root->cx;
@@ -2945,35 +2949,35 @@ static void lineart_bounding_area_split(LineartRenderBuffer *rb,
lineart_bounding_areas_connect_new(rb, root);
- while ((rt = lineart_list_pop_pointer_no_free(&root->linked_triangles)) != NULL) {
+ while ((tri = lineart_list_pop_pointer_no_free(&root->linked_triangles)) != NULL) {
LineartBoundingArea *cba = root->child;
double b[4];
- b[0] = MIN3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[1] = MAX3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[2] = MAX3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
- b[3] = MIN3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
+ b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[2] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
+ b[3] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
if (LRT_BOUND_AREA_CROSSES(b, &cba[0].l)) {
- lineart_bounding_area_link_triangle(rb, &cba[0], rt, b, 0, recursive_level + 1, false);
+ lineart_bounding_area_link_triangle(rb, &cba[0], tri, b, 0, recursive_level + 1, false);
}
if (LRT_BOUND_AREA_CROSSES(b, &cba[1].l)) {
- lineart_bounding_area_link_triangle(rb, &cba[1], rt, b, 0, recursive_level + 1, false);
+ lineart_bounding_area_link_triangle(rb, &cba[1], tri, b, 0, recursive_level + 1, false);
}
if (LRT_BOUND_AREA_CROSSES(b, &cba[2].l)) {
- lineart_bounding_area_link_triangle(rb, &cba[2], rt, b, 0, recursive_level + 1, false);
+ lineart_bounding_area_link_triangle(rb, &cba[2], tri, b, 0, recursive_level + 1, false);
}
if (LRT_BOUND_AREA_CROSSES(b, &cba[3].l)) {
- lineart_bounding_area_link_triangle(rb, &cba[3], rt, b, 0, recursive_level + 1, false);
+ lineart_bounding_area_link_triangle(rb, &cba[3], tri, b, 0, recursive_level + 1, false);
}
}
- while ((e = lineart_list_pop_pointer_no_free(&root->linked_lines)) != NULL) {
- lineart_bounding_area_link_line(rb, root, e);
+ while ((e = lineart_list_pop_pointer_no_free(&root->linked_edges)) != NULL) {
+ lineart_bounding_area_link_edge(rb, root, e);
}
rb->bounding_area_count += 3;
}
-static bool lineart_bounding_area_line_intersect(LineartRenderBuffer *UNUSED(fb),
+static bool lineart_bounding_area_edge_intersect(LineartRenderBuffer *UNUSED(fb),
const double l[2],
const double r[2],
LineartBoundingArea *ba)
@@ -3017,11 +3021,11 @@ static bool lineart_bounding_area_line_intersect(LineartRenderBuffer *UNUSED(fb)
}
static bool lineart_bounding_area_triangle_intersect(LineartRenderBuffer *fb,
- LineartTriangle *rt,
+ LineartTriangle *tri,
LineartBoundingArea *ba)
{
double p1[2], p2[2], p3[2], p4[2];
- double *FBC1 = rt->v[0]->fbcoord, *FBC2 = rt->v[1]->fbcoord, *FBC3 = rt->v[2]->fbcoord;
+ double *FBC1 = tri->v[0]->fbcoord, *FBC2 = tri->v[1]->fbcoord, *FBC3 = tri->v[2]->fbcoord;
p3[0] = p1[0] = (double)ba->l;
p2[1] = p1[1] = (double)ba->b;
@@ -3041,9 +3045,9 @@ static bool lineart_bounding_area_triangle_intersect(LineartRenderBuffer *fb,
return true;
}
- if ((lineart_bounding_area_line_intersect(fb, FBC1, FBC2, ba)) ||
- (lineart_bounding_area_line_intersect(fb, FBC2, FBC3, ba)) ||
- (lineart_bounding_area_line_intersect(fb, FBC3, FBC1, ba))) {
+ if ((lineart_bounding_area_edge_intersect(fb, FBC1, FBC2, ba)) ||
+ (lineart_bounding_area_edge_intersect(fb, FBC2, FBC3, ba)) ||
+ (lineart_bounding_area_edge_intersect(fb, FBC3, FBC1, ba))) {
return true;
}
@@ -3056,17 +3060,17 @@ static bool lineart_bounding_area_triangle_intersect(LineartRenderBuffer *fb,
*/
static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
LineartBoundingArea *root_ba,
- LineartTriangle *rt,
+ LineartTriangle *tri,
double *LRUB,
int recursive,
int recursive_level,
bool do_intersection)
{
- if (!lineart_bounding_area_triangle_intersect(rb, rt, root_ba)) {
+ if (!lineart_bounding_area_triangle_intersect(rb, tri, root_ba)) {
return;
}
if (root_ba->child == NULL) {
- lineart_list_append_pointer_pool(&root_ba->linked_triangles, &rb->render_data_pool, rt);
+ lineart_list_append_pointer_pool(&root_ba->linked_triangles, &rb->render_data_pool, tri);
root_ba->triangle_count++;
/* If splitting doesn't improve triangle separation, then shouldn't allow splitting anymore.
* Here we use recursive limit. This is especially useful in orthographic render,
@@ -3076,7 +3080,7 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
lineart_bounding_area_split(rb, root_ba, recursive_level);
}
if (recursive && do_intersection && rb->use_intersections) {
- lineart_triangle_intersect_in_bounding_area(rb, rt, root_ba);
+ lineart_triangle_intersect_in_bounding_area(rb, tri, root_ba);
}
}
else {
@@ -3084,54 +3088,54 @@ static void lineart_bounding_area_link_triangle(LineartRenderBuffer *rb,
double *B1 = LRUB;
double b[4];
if (!LRUB) {
- b[0] = MIN3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[1] = MAX3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[2] = MAX3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
- b[3] = MIN3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
+ b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[2] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
+ b[3] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
B1 = b;
}
if (LRT_BOUND_AREA_CROSSES(B1, &ba[0].l)) {
lineart_bounding_area_link_triangle(
- rb, &ba[0], rt, B1, recursive, recursive_level + 1, do_intersection);
+ rb, &ba[0], tri, B1, recursive, recursive_level + 1, do_intersection);
}
if (LRT_BOUND_AREA_CROSSES(B1, &ba[1].l)) {
lineart_bounding_area_link_triangle(
- rb, &ba[1], rt, B1, recursive, recursive_level + 1, do_intersection);
+ rb, &ba[1], tri, B1, recursive, recursive_level + 1, do_intersection);
}
if (LRT_BOUND_AREA_CROSSES(B1, &ba[2].l)) {
lineart_bounding_area_link_triangle(
- rb, &ba[2], rt, B1, recursive, recursive_level + 1, do_intersection);
+ rb, &ba[2], tri, B1, recursive, recursive_level + 1, do_intersection);
}
if (LRT_BOUND_AREA_CROSSES(B1, &ba[3].l)) {
lineart_bounding_area_link_triangle(
- rb, &ba[3], rt, B1, recursive, recursive_level + 1, do_intersection);
+ rb, &ba[3], tri, B1, recursive, recursive_level + 1, do_intersection);
}
}
}
-static void lineart_bounding_area_link_line(LineartRenderBuffer *rb,
+static void lineart_bounding_area_link_edge(LineartRenderBuffer *rb,
LineartBoundingArea *root_ba,
LineartEdge *e)
{
if (root_ba->child == NULL) {
- lineart_list_append_pointer_pool(&root_ba->linked_lines, &rb->render_data_pool, e);
+ lineart_list_append_pointer_pool(&root_ba->linked_edges, &rb->render_data_pool, e);
}
else {
- if (lineart_bounding_area_line_intersect(
+ if (lineart_bounding_area_edge_intersect(
rb, e->v1->fbcoord, e->v2->fbcoord, &root_ba->child[0])) {
- lineart_bounding_area_link_line(rb, &root_ba->child[0], e);
+ lineart_bounding_area_link_edge(rb, &root_ba->child[0], e);
}
- if (lineart_bounding_area_line_intersect(
+ if (lineart_bounding_area_edge_intersect(
rb, e->v1->fbcoord, e->v2->fbcoord, &root_ba->child[1])) {
- lineart_bounding_area_link_line(rb, &root_ba->child[1], e);
+ lineart_bounding_area_link_edge(rb, &root_ba->child[1], e);
}
- if (lineart_bounding_area_line_intersect(
+ if (lineart_bounding_area_edge_intersect(
rb, e->v1->fbcoord, e->v2->fbcoord, &root_ba->child[2])) {
- lineart_bounding_area_link_line(rb, &root_ba->child[2], e);
+ lineart_bounding_area_link_edge(rb, &root_ba->child[2], e);
}
- if (lineart_bounding_area_line_intersect(
+ if (lineart_bounding_area_edge_intersect(
rb, e->v1->fbcoord, e->v2->fbcoord, &root_ba->child[3])) {
- lineart_bounding_area_link_line(rb, &root_ba->child[3], e);
+ lineart_bounding_area_link_edge(rb, &root_ba->child[3], e);
}
}
}
@@ -3147,7 +3151,7 @@ static void lineart_main_link_lines(LineartRenderBuffer *rb)
if (lineart_get_edge_bounding_areas(rb, e, &r1, &r2, &c1, &c2)) {
for (row = r1; row != r2 + 1; row++) {
for (col = c1; col != c2 + 1; col++) {
- lineart_bounding_area_link_line(
+ lineart_bounding_area_link_edge(
rb, &rb->initial_bounding_areas[row * LRT_BA_ROWS + col], e);
}
}
@@ -3157,7 +3161,7 @@ static void lineart_main_link_lines(LineartRenderBuffer *rb)
}
static bool lineart_get_triangle_bounding_areas(LineartRenderBuffer *rb,
- LineartTriangle *rt,
+ LineartTriangle *tri,
int *rowbegin,
int *rowend,
int *colbegin,
@@ -3166,14 +3170,14 @@ static bool lineart_get_triangle_bounding_areas(LineartRenderBuffer *rb,
double sp_w = rb->width_per_tile, sp_h = rb->height_per_tile;
double b[4];
- if (!rt->v[0] || !rt->v[1] || !rt->v[2]) {
+ if (!tri->v[0] || !tri->v[1] || !tri->v[2]) {
return false;
}
- b[0] = MIN3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[1] = MAX3(rt->v[0]->fbcoord[0], rt->v[1]->fbcoord[0], rt->v[2]->fbcoord[0]);
- b[2] = MIN3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
- b[3] = MAX3(rt->v[0]->fbcoord[1], rt->v[1]->fbcoord[1], rt->v[2]->fbcoord[1]);
+ b[0] = MIN3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[1] = MAX3(tri->v[0]->fbcoord[0], tri->v[1]->fbcoord[0], tri->v[2]->fbcoord[0]);
+ b[2] = MIN3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
+ b[3] = MAX3(tri->v[0]->fbcoord[1], tri->v[1]->fbcoord[1], tri->v[2]->fbcoord[1]);
if (b[0] > 1 || b[1] < -1 || b[2] > 1 || b[3] < -1) {
return false;
@@ -3340,33 +3344,33 @@ LineartBoundingArea *MOD_lineart_get_bounding_area(LineartRenderBuffer *rb, doub
*/
static void lineart_main_add_triangles(LineartRenderBuffer *rb)
{
- LineartTriangle *rt;
+ LineartTriangle *tri;
int i, lim;
int x1, x2, y1, y2;
int r, co;
LISTBASE_FOREACH (LineartElementLinkNode *, reln, &rb->triangle_buffer_pointers) {
- rt = reln->pointer;
+ tri = reln->pointer;
lim = reln->element_count;
for (i = 0; i < lim; i++) {
- if ((rt->flags & LRT_CULL_USED) || (rt->flags & LRT_CULL_DISCARD)) {
- rt = (void *)(((uchar *)rt) + rb->triangle_size);
+ if ((tri->flags & LRT_CULL_USED) || (tri->flags & LRT_CULL_DISCARD)) {
+ tri = (void *)(((uchar *)tri) + rb->triangle_size);
continue;
}
- if (lineart_get_triangle_bounding_areas(rb, rt, &y1, &y2, &x1, &x2)) {
+ if (lineart_get_triangle_bounding_areas(rb, tri, &y1, &y2, &x1, &x2)) {
for (co = x1; co <= x2; co++) {
for (r = y1; r <= y2; r++) {
lineart_bounding_area_link_triangle(rb,
&rb->initial_bounding_areas[r * LRT_BA_ROWS + co],
- rt,
+ tri,
0,
1,
0,
- (!(rt->flags & LRT_TRIANGLE_NO_INTERSECTION)));
+ (!(tri->flags & LRT_TRIANGLE_NO_INTERSECTION)));
}
}
} /* Else throw away. */
- rt = (void *)(((uchar *)rt) + rb->triangle_size);
+ tri = (void *)(((uchar *)tri) + rb->triangle_size);
}
}
}
@@ -3641,6 +3645,8 @@ bool MOD_lineart_compute_feature_lines(Depsgraph *depsgraph, LineartGpencilModif
Scene *scene = DEG_get_evaluated_scene(depsgraph);
int intersections_only = 0; /* Not used right now, but preserve for future. */
+ BKE_scene_camera_switch_update(scene);
+
if (!scene->camera) {
return false;
}
@@ -3800,52 +3806,52 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
bool invert_input = modifier_flags & LRT_GPENCIL_INVERT_SOURCE_VGROUP;
bool match_output = modifier_flags & LRT_GPENCIL_MATCH_OUTPUT_VGROUP;
- LISTBASE_FOREACH (LineartLineChain *, rlc, &rb->chains) {
+ LISTBASE_FOREACH (LineartEdgeChain *, ec, &rb->chains) {
- if (rlc->picked) {
+ if (ec->picked) {
continue;
}
- if (!(rlc->type & (types & enabled_types))) {
+ if (!(ec->type & (types & enabled_types))) {
continue;
}
- if (rlc->level > level_end || rlc->level < level_start) {
+ if (ec->level > level_end || ec->level < level_start) {
continue;
}
- if (orig_ob && orig_ob != rlc->object_ref) {
+ if (orig_ob && orig_ob != ec->object_ref) {
continue;
}
- if (orig_col && rlc->object_ref) {
- if (!BKE_collection_has_object_recursive_instanced(orig_col, (Object *)rlc->object_ref)) {
+ if (orig_col && ec->object_ref) {
+ if (!BKE_collection_has_object_recursive_instanced(orig_col, (Object *)ec->object_ref)) {
continue;
}
}
if (transparency_flags & LRT_GPENCIL_TRANSPARENCY_ENABLE) {
if (transparency_flags & LRT_GPENCIL_TRANSPARENCY_MATCH) {
- if (rlc->transparency_mask != transparency_mask) {
+ if (ec->transparency_mask != transparency_mask) {
continue;
}
}
else {
- if (!(rlc->transparency_mask & transparency_mask)) {
+ if (!(ec->transparency_mask & transparency_mask)) {
continue;
}
}
}
/* Preserved: If we ever do asynchronous generation, this picked flag should be set here. */
- // rlc->picked = 1;
+ // ec->picked = 1;
int array_idx = 0;
- int count = MOD_lineart_chain_count(rlc);
+ int count = MOD_lineart_chain_count(ec);
bGPDstroke *gps = BKE_gpencil_stroke_add(gpf, color_idx, count, thickness, false);
float *stroke_data = MEM_callocN(sizeof(float) * count * GP_PRIM_DATABUF_SIZE,
"line art add stroke");
- LISTBASE_FOREACH (LineartLineChainItem *, rlci, &rlc->chain) {
- stroke_data[array_idx] = rlci->gpos[0];
- stroke_data[array_idx + 1] = rlci->gpos[1];
- stroke_data[array_idx + 2] = rlci->gpos[2];
+ LISTBASE_FOREACH (LineartEdgeChainItem *, eci, &ec->chain) {
+ stroke_data[array_idx] = eci->gpos[0];
+ stroke_data[array_idx + 1] = eci->gpos[1];
+ stroke_data[array_idx + 2] = eci->gpos[2];
mul_m4_v3(gp_obmat_inverse, &stroke_data[array_idx]);
stroke_data[array_idx + 3] = 1; /* thickness. */
stroke_data[array_idx + 4] = opacity; /* hardness?. */
@@ -3859,7 +3865,7 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
MEM_freeN(stroke_data);
if (source_vgname && vgname) {
- Object *eval_ob = DEG_get_evaluated_object(depsgraph, rlc->object_ref);
+ Object *eval_ob = DEG_get_evaluated_object(depsgraph, ec->object_ref);
int gpdg = -1;
if ((match_output || (gpdg = BKE_object_defgroup_name_index(gpencil_object, vgname)) >= 0)) {
if (eval_ob && eval_ob->type == OB_MESH) {
@@ -3875,8 +3881,8 @@ static void lineart_gpencil_generate(LineartRenderBuffer *rb,
}
}
int sindex = 0, vindex;
- LISTBASE_FOREACH (LineartLineChainItem *, rlci, &rlc->chain) {
- vindex = rlci->index;
+ LISTBASE_FOREACH (LineartEdgeChainItem *, eci, &ec->chain) {
+ vindex = eci->index;
if (vindex >= me->totvert) {
break;
}
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
index 2c3130b46c9..9ed98b38f07 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_intern.h
@@ -54,11 +54,11 @@ void lineart_list_remove_pointer_item_no_free(ListBase *h, LinkData *lip);
struct LineartStaticMemPoolNode *lineart_mem_new_static_pool(struct LineartStaticMemPool *smp,
size_t size);
-void *lineart_mem_aquire(struct LineartStaticMemPool *smp, size_t size);
-void *lineart_mem_aquire_thread(struct LineartStaticMemPool *smp, size_t size);
+void *lineart_mem_acquire(struct LineartStaticMemPool *smp, size_t size);
+void *lineart_mem_acquire_thread(struct LineartStaticMemPool *smp, size_t size);
void lineart_mem_destroy(struct LineartStaticMemPool *smp);
-void lineart_prepend_edge_direct(struct LineartEdge **first, void *node);
+void lineart_prepend_edge_direct(void **list_head, void *node);
void lineart_prepend_pool(LinkNode **first, struct LineartStaticMemPool *smp, void *link);
void lineart_matrix_ortho_44d(double (*mProjection)[4],
@@ -76,29 +76,42 @@ int lineart_count_intersection_segment_count(struct LineartRenderBuffer *rb);
void lineart_count_and_print_render_buffer_memory(struct LineartRenderBuffer *rb);
#define LRT_ITER_ALL_LINES_BEGIN \
- LineartEdge *e, *next_e, **current_list; \
- e = rb->contours; \
- for (current_list = &rb->contours; e; e = next_e) { \
+ LineartEdge *e, *next_e; \
+ void **current_head; \
+ e = rb->contour.first; \
+ if (!e) { \
+ e = rb->crease.first; \
+ } \
+ if (!e) { \
+ e = rb->material.first; \
+ } \
+ if (!e) { \
+ e = rb->edge_mark.first; \
+ } \
+ if (!e) { \
+ e = rb->intersection.first; \
+ } \
+ for (current_head = &rb->contour.first; e; e = next_e) { \
next_e = e->next;
#define LRT_ITER_ALL_LINES_NEXT \
while (!next_e) { \
- if (current_list == &rb->contours) { \
- current_list = &rb->crease_lines; \
+ if (current_head == &rb->contour.first) { \
+ current_head = &rb->crease.first; \
} \
- else if (current_list == &rb->crease_lines) { \
- current_list = &rb->material_lines; \
+ else if (current_head == &rb->crease.first) { \
+ current_head = &rb->material.first; \
} \
- else if (current_list == &rb->material_lines) { \
- current_list = &rb->edge_marks; \
+ else if (current_head == &rb->material.first) { \
+ current_head = &rb->edge_mark.first; \
} \
- else if (current_list == &rb->edge_marks) { \
- current_list = &rb->intersection_lines; \
+ else if (current_head == &rb->edge_mark.first) { \
+ current_head = &rb->intersection.first; \
} \
else { \
break; \
} \
- next_e = *current_list; \
+ next_e = *current_head; \
}
#define LRT_ITER_ALL_LINES_END \
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
index 0c6b4ebf30c..c023c63ebc9 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_ops.c
@@ -364,7 +364,8 @@ static int lineart_gpencil_bake_strokes_commom_modal(bContext *C,
static void lineart_gpencil_clear_strokes_exec_common(Object *ob)
{
- if (ob->type != OB_GPENCIL) {
+ /* TODO: move these checks to an operator poll function. */
+ if ((ob == NULL) || ob->type != OB_GPENCIL) {
return;
}
LISTBASE_FOREACH (GpencilModifierData *, md, &ob->greasepencil_modifiers) {
diff --git a/source/blender/gpencil_modifiers/intern/lineart/lineart_util.c b/source/blender/gpencil_modifiers/intern/lineart/lineart_util.c
index 4d136fe0d0e..d05f931f75d 100644
--- a/source/blender/gpencil_modifiers/intern/lineart/lineart_util.c
+++ b/source/blender/gpencil_modifiers/intern/lineart/lineart_util.c
@@ -43,7 +43,7 @@ void *lineart_list_append_pointer_pool(ListBase *h, LineartStaticMemPool *smp, v
if (h == NULL) {
return 0;
}
- lip = lineart_mem_aquire(smp, sizeof(LinkData));
+ lip = lineart_mem_acquire(smp, sizeof(LinkData));
lip->data = data;
BLI_addtail(h, lip);
return lip;
@@ -57,7 +57,7 @@ void *lineart_list_append_pointer_pool_sized(ListBase *h,
if (h == NULL) {
return 0;
}
- lip = lineart_mem_aquire(smp, size);
+ lip = lineart_mem_acquire(smp, size);
lip->data = data;
BLI_addtail(h, lip);
return lip;
@@ -92,7 +92,7 @@ LineartStaticMemPoolNode *lineart_mem_new_static_pool(LineartStaticMemPool *smp,
BLI_addhead(&smp->pools, smpn);
return smpn;
}
-void *lineart_mem_aquire(LineartStaticMemPool *smp, size_t size)
+void *lineart_mem_acquire(LineartStaticMemPool *smp, size_t size)
{
LineartStaticMemPoolNode *smpn = smp->pools.first;
void *ret;
@@ -107,7 +107,7 @@ void *lineart_mem_aquire(LineartStaticMemPool *smp, size_t size)
return ret;
}
-void *lineart_mem_aquire_thread(LineartStaticMemPool *smp, size_t size)
+void *lineart_mem_acquire_thread(LineartStaticMemPool *smp, size_t size)
{
void *ret;
@@ -135,16 +135,16 @@ void lineart_mem_destroy(LineartStaticMemPool *smp)
}
}
-void lineart_prepend_edge_direct(LineartEdge **first, void *node)
+void lineart_prepend_edge_direct(void **list_head, void *node)
{
LineartEdge *e_n = (LineartEdge *)node;
- e_n->next = (*first);
- (*first) = e_n;
+ e_n->next = (*list_head);
+ (*list_head) = e_n;
}
void lineart_prepend_pool(LinkNode **first, LineartStaticMemPool *smp, void *link)
{
- LinkNode *ln = lineart_mem_aquire_thread(smp, sizeof(LinkNode));
+ LinkNode *ln = lineart_mem_acquire_thread(smp, sizeof(LinkNode));
ln->next = (*first);
ln->link = link;
(*first) = ln;