[Bf-blender-cvs] [f2c5b7ea860] lanpr-under-gp: LANPR: generateStrokes functions added.
YimingWu
noreply at git.blender.org
Sun Jun 28 08:20:55 CEST 2020
Commit: f2c5b7ea860c932aee46c4c11be6efd135a9ce05
Author: YimingWu
Date: Sun Jun 28 14:18:51 2020 +0800
Branches: lanpr-under-gp
https://developer.blender.org/rBf2c5b7ea860c932aee46c4c11be6efd135a9ce05
LANPR: generateStrokes functions added.
===================================================================
M source/blender/editors/include/ED_lineart.h
M source/blender/editors/lineart/lineart_cpu.c
M source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
===================================================================
diff --git a/source/blender/editors/include/ED_lineart.h b/source/blender/editors/include/ED_lineart.h
index e81de82ef70..524bc9f5bdb 100644
--- a/source/blender/editors/include/ED_lineart.h
+++ b/source/blender/editors/include/ED_lineart.h
@@ -508,6 +508,19 @@ LineartBoundingArea *ED_lineart_get_point_bounding_area_deep(LineartRenderBuffer
double x,
double y);
+struct bGPDlayer;
+struct bGPDframe;
+
+void ED_lineart_generate_gpencil_from_chain(struct Depsgraph *depsgraph,
+ struct Object *ob,
+ struct bGPDlayer *UNUSED(gpl),
+ struct bGPDframe *gpf,
+ int level_start,
+ int level_end,
+ int material_nr,
+ struct Collection *col,
+ int types);
+
void ED_lineart_post_frame_update_external(struct Scene *s, struct Depsgraph *dg);
struct SceneLineart;
diff --git a/source/blender/editors/lineart/lineart_cpu.c b/source/blender/editors/lineart/lineart_cpu.c
index a4cb56ab0f2..196edbecfa3 100644
--- a/source/blender/editors/lineart/lineart_cpu.c
+++ b/source/blender/editors/lineart/lineart_cpu.c
@@ -3829,7 +3829,7 @@ static void lineart_compute_feature_lines_worker(TaskPool *__restrict UNUSED(poo
LRT_FeatureLineWorker *worker_data)
{
ED_lineart_compute_feature_lines_internal(worker_data->dg, worker_data->intersection_only);
- lineart_update_gp_strokes_actual(DEG_get_evaluated_scene(worker_data->dg), worker_data->dg);
+ // lineart_update_gp_strokes_actual(DEG_get_evaluated_scene(worker_data->dg), worker_data->dg);
ED_lineart_calculation_set_flag(LRT_RENDER_FINISHED);
}
@@ -3942,23 +3942,32 @@ static int lineart_object_line_types(Object *ob)
return result;
}
-static void lineart_generate_gpencil_from_chain(Depsgraph *depsgraph,
- Object *ob,
- bGPDlayer *UNUSED(gpl),
- bGPDframe *gpf,
- int level_start,
- int level_end,
- int material_nr,
- Collection *col,
- int types)
+void ED_lineart_generate_gpencil_from_chain(Depsgraph *depsgraph,
+ Object *ob,
+ bGPDlayer *UNUSED(gpl),
+ bGPDframe *gpf,
+ int level_start,
+ int level_end,
+ int material_nr,
+ Collection *col,
+ int types)
{
LineartRenderBuffer *rb = lineart_share.render_buffer_shared;
if (rb == NULL) {
- printf("NULL LRT rb!\n");
+ printf("NULL Lineart rb!\n");
return;
}
+ if ((!lineart_share.init_complete) || !ED_lineart_calculation_flag_check(LRT_RENDER_FINISHED)) {
+ /* cache not ready */
+ return;
+ }
+ else {
+ /* lock the cache, prevent rendering job from starting */
+ BLI_spin_lock(&lineart_share.lock_render_status);
+ }
+
int color_idx = 0;
short thickness = 100;
@@ -4012,6 +4021,9 @@ static void lineart_generate_gpencil_from_chain(Depsgraph *depsgraph,
BKE_gpencil_stroke_add_points(gps, stroke_data, count, mat);
gps->mat_nr = material_nr;
}
+
+ /* release render lock so cache is free to be manipulated. */
+ BLI_spin_unlock(&lineart_share.lock_render_status);
}
static void lineart_clear_gp_lineart_flags(Depsgraph *dg, int frame)
{
@@ -4069,7 +4081,7 @@ static void lineart_update_gp_strokes_single(Depsgraph *dg,
use_material = 0;
}
- lineart_generate_gpencil_from_chain(
+ ED_lineart_generate_gpencil_from_chain(
dg, ob, gpl, gpf, level_start, level_end, use_material, col, type);
DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
index b1c47f20f62..e6eae85829d 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillineart.c
@@ -54,6 +54,7 @@
#include "RNA_access.h"
#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
#include "MOD_gpencil_modifiertypes.h"
#include "MOD_gpencil_ui_common.h"
@@ -74,14 +75,69 @@ static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
BKE_gpencil_modifier_copydata_generic(md, target);
}
-static void deformStroke(GpencilModifierData *md,
- Depsgraph *UNUSED(depsgraph),
- Object *ob,
- bGPDlayer *gpl,
- bGPDframe *UNUSED(gpf),
- bGPDstroke *gps)
+static void generate_strokes_actual(
+ GpencilModifierData *md, Depsgraph *depsgraph, Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
{
LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
+ bGPdata *gpd = (bGPdata *)ob->data;
+
+ if (!gpl) {
+ return;
+ }
+
+ if (lmd->source_type == LRT_SOURCE_OBJECT) {
+ Object *source_object = lmd->source_object;
+ if (!source_object) {
+ return;
+ }
+ ED_lineart_generate_gpencil_from_chain(
+ depsgraph,
+ source_object,
+ gpl,
+ gpf,
+ lmd->level_start,
+ lmd->use_multiple_levels ? lmd->level_end : lmd->level_start,
+ lmd->target_gp_material ?
+ BKE_gpencil_object_material_index_get(ob, lmd->target_gp_material) :
+ 0,
+ NULL,
+ lmd->line_types & (~LRT_EDGE_FLAG_INTERSECTION));
+ /* Note that intersection lines will only be in collection */
+ }
+ else if (lmd->source_type == LRT_SOURCE_COLLECTION) {
+ Collection *source_collection = lmd->source_collection;
+ if (!source_collection) {
+ return;
+ }
+ ED_lineart_generate_gpencil_from_chain(
+ depsgraph,
+ NULL,
+ gpl,
+ gpf,
+ lmd->level_start,
+ lmd->use_multiple_levels ? lmd->level_end : lmd->level_start,
+ lmd->target_gp_material ?
+ BKE_gpencil_object_material_index_get(ob, lmd->target_gp_material) :
+ 0,
+ source_collection,
+ lmd->line_types);
+ }
+ else {
+ /* no other type selection for now. */
+ return;
+ }
+}
+
+static void generateStrokes(GpencilModifierData *md, Depsgraph *depsgraph, Object *ob)
+{
+ LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
+ bGPdata *gpd = ob->data;
+ Scene *scene = DEG_get_evaluated_scene(depsgraph);
+
+ bGPDlayer *gpl = BKE_gpencil_layer_get_by_name(gpd, lmd->target_gp_layer, 1);
+ bGPDframe *gpf = BKE_gpencil_layer_frame_get(gpl, scene->r.cfra, GP_GETFRAME_ADD_NEW);
+
+ generate_strokes_actual(md, depsgraph, ob, gpl, gpf);
}
static void bakeModifier(Main *UNUSED(bmain),
@@ -90,12 +146,12 @@ static void bakeModifier(Main *UNUSED(bmain),
Object *ob)
{
bGPdata *gpd = ob->data;
+ LineartGpencilModifierData *lmd = (LineartGpencilModifierData *)md;
LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) {
LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
- LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) {
- deformStroke(md, depsgraph, ob, gpl, gpf, gps);
- }
+ bGPDlayer *gpl = BKE_gpencil_layer_get_by_name(gpd, lmd->target_gp_layer, 1);
+ generate_strokes_actual(md, depsgraph, ob, gpl, gpf);
}
}
}
@@ -189,8 +245,8 @@ GpencilModifierTypeInfo modifierType_Gpencil_Lineart = {
/* copyData */ copyData,
- /* deformStroke */ deformStroke,
- /* generateStrokes */ NULL,
+ /* deformStroke */ NULL,
+ /* generateStrokes */ generateStrokes,
/* bakeModifier */ bakeModifier,
/* remapTime */ NULL,
More information about the Bf-blender-cvs
mailing list