[Bf-blender-cvs] [4a89c0cd588] greasepencil-object: New Simplify panel
Antonio Vazquez
noreply at git.blender.org
Sun Sep 10 10:03:04 CEST 2017
Commit: 4a89c0cd5883d1d3d8549fc14fa40d099b7f4baa
Author: Antonio Vazquez
Date: Sun Sep 10 10:02:40 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB4a89c0cd5883d1d3d8549fc14fa40d099b7f4baa
New Simplify panel
These options allow to speed up the viewport similar to mesh simplify.
Note: The render options are disabled while the render workflow is defined.
===================================================================
M release/scripts/startup/bl_ui/properties_scene.py
M source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M source/blender/draw/engines/gpencil/gpencil_engine.c
M source/blender/draw/engines/gpencil/gpencil_engine.h
M source/blender/makesdna/DNA_scene_types.h
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_scene.py b/release/scripts/startup/bl_ui/properties_scene.py
index 02d92d0a692..204388f6271 100644
--- a/release/scripts/startup/bl_ui/properties_scene.py
+++ b/release/scripts/startup/bl_ui/properties_scene.py
@@ -440,6 +440,41 @@ class SCENE_PT_simplify(SceneButtonsPanel, Panel):
col.prop(rd, "simplify_ao_sss", text="AO and SSS")
col.prop(rd, "use_simplify_triangulate")
+
+class SCENE_PT_gp_simplify(SceneButtonsPanel, Panel):
+ bl_label = "Simplify Grease Pencil"
+ COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
+
+ def draw_header(self, context):
+ ts = context.tool_settings
+ self.layout.prop(ts, "gpencil_simplify", text="")
+
+ def draw(self, context):
+ layout = self.layout
+
+ ts = context.tool_settings
+
+ layout.active = ts.gpencil_simplify
+
+ row = layout.row()
+ row.prop(ts, "gpencil_simplify_onplay", text="Only on Play")
+
+ split = layout.split()
+
+ col = split.column()
+ col.label(text="Viewport:")
+ col.prop(ts, "gpencil_simplify_view_fill", text="Fill")
+ col.prop(ts, "gpencil_simplify_view_modifier", text="Modifiers")
+ col.prop(ts, "gpencil_simplify_view_vfx", text="VFX")
+
+ col = split.column()
+ # TODO: keep disable while render workflow is defined
+ col.active = False
+ col.label(text="Render:")
+ col.prop(ts, "gpencil_simplify_render_fill", text="Fill")
+ col.prop(ts, "gpencil_simplify_render_modifier", text="Modifiers")
+ col.prop(ts, "gpencil_simplify_render_vfx", text="VFX")
+
class SCENE_PT_custom_props(SceneButtonsPanel, PropertyPanel, Panel):
COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME', 'BLENDER_CLAY', 'BLENDER_EEVEE'}
_context_path = "scene"
@@ -460,6 +495,7 @@ classes = (
SCENE_PT_rigid_body_cache,
SCENE_PT_rigid_body_field_weights,
SCENE_PT_simplify,
+ SCENE_PT_gp_simplify,
SCENE_PT_custom_props,
)
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index bf202b96f9e..ccb224bab3b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -689,6 +689,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
DRWShadingGroup *strokegrp;
float viewmatrix[4][4];
bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
+ bool playing = (bool)stl->storage->playing;
/* get parent matrix and save as static data */
ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
@@ -701,8 +702,10 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
/* apply geometry modifiers */
if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
- if (BKE_gpencil_has_geometry_modifiers(ob)) {
- BKE_gpencil_geometry_modifiers(ob, gpl, derived_gpf);
+ if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+ if (BKE_gpencil_has_geometry_modifiers(ob)) {
+ BKE_gpencil_geometry_modifiers(ob, gpl, derived_gpf);
+ }
}
}
@@ -735,7 +738,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
if ((gpl->actframe->framenum == derived_gpf->framenum) || (!is_multiedit) || ((gpd->flag & GP_DATA_STROKE_MULTIEDIT_LINES) == 0)) {
int id = stl->storage->shgroup_id;
if ((gps->totpoints > 1) && ((gps->palcolor->flag & PAC_COLOR_DOT) == 0)) {
- if (gps->totpoints > 2) {
+ if ((gps->totpoints > 2) && (!GP_SIMPLIFY_FILL(ts, playing))) {
stl->shgroups[id].shgrps_fill = DRW_gpencil_shgroup_fill_create(e_data, vedata, psl->stroke_pass, e_data->gpencil_fill_sh, gpd, gps->palcolor, id);
}
else {
@@ -754,10 +757,12 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
/* apply modifiers (only modify geometry, but not create ) */
if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) {
- BKE_gpencil_stroke_modifiers(ob, gpl, derived_gpf, gps);
+ if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+ BKE_gpencil_stroke_modifiers(ob, gpl, derived_gpf, gps);
+ }
}
/* fill */
- if (fillgrp) {
+ if ((fillgrp) && (!GP_SIMPLIFY_FILL(ts, playing))) {
gpencil_add_fill_shgroup(cache, fillgrp, ob, gpd, gpl, derived_gpf, gps, tintcolor, false, custonion);
}
/* stroke */
@@ -987,8 +992,10 @@ void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene
cache->cache_idx = 0;
/* init general modifiers data */
- if ((cache->is_dirty) && (ob->modifiers.first)) {
- BKE_gpencil_lattice_init(ob);
+ if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+ if ((cache->is_dirty) && (ob->modifiers.first)) {
+ BKE_gpencil_lattice_init(ob);
+ }
}
/* draw normal strokes */
for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.c b/source/blender/draw/engines/gpencil/gpencil_engine.c
index 75bf81a24f7..2158a186c7b 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.c
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.c
@@ -28,6 +28,7 @@
#include "BKE_global.h"
#include "BKE_paint.h"
+#include "BKE_gpencil.h"
#include "DNA_gpencil_types.h"
#include "DNA_view3d_types.h"
@@ -168,6 +169,9 @@ static void GPENCIL_cache_init(void *vedata)
GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
Object *ob = NULL;
bGPdata *gpd = NULL;
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ ToolSettings *ts = scene->toolsettings;
if (!stl->g_data) {
/* Alloc transient pointers */
@@ -222,11 +226,21 @@ static void GPENCIL_cache_init(void *vedata)
/* drawing buffer pass */
const DRWContextState *draw_ctx = DRW_context_state_get();
/* detect if playing animation */
+ int oldsts = stl->storage->playing;
stl->storage->playing = 0;
if (draw_ctx->evil_C) {
if (ED_screen_animation_playing(CTX_wm_manager(draw_ctx->evil_C))) {
stl->storage->playing = 1;
}
+ else {
+ /* if animation was active and simplify on play was enabled, cache is dirty */
+ if ((oldsts == 1) && (stl->storage->playing == 0) &&
+ (ts->gpencil_flags & GP_TOOL_FLAG_SIMPLIFY) &&
+ (ts->gpencil_flags & GP_TOOL_FLAG_SIMPLIFY_ON_PLAY))
+ {
+ BKE_gpencil_batch_cache_alldirty();
+ }
+ }
}
ob = draw_ctx->obact;
if (ob) {
@@ -304,6 +318,7 @@ static void GPENCIL_cache_populate(void *vedata, Object *ob)
const DRWContextState *draw_ctx = DRW_context_state_get();
Scene *scene = draw_ctx->scene;
ToolSettings *ts = scene->toolsettings;
+ bool playing = (bool)stl->storage->playing;
/* object datablock (this is not draw now) */
if (ob->type == OB_GPENCIL && ob->gpd) {
@@ -314,8 +329,10 @@ static void GPENCIL_cache_populate(void *vedata, Object *ob)
stl->g_data->gp_object_cache = gpencil_object_cache_allocate(stl->g_data->gp_object_cache, &stl->g_data->gp_cache_size, &stl->g_data->gp_cache_used);
/* add for drawing later */
gpencil_object_cache_add(stl->g_data->gp_object_cache, ob, &stl->g_data->gp_cache_used);
- /* generate duplicated instances using array modifiers */
- gpencil_array_modifiers(stl, ob);
+ /* generate duplicated instances using array modifiers */
+ if (!GP_SIMPLIFY_MODIF(ts, playing)) {
+ gpencil_array_modifiers(stl, ob);
+ }
/* draw current painting strokes */
DRW_gpencil_populate_buffer_strokes(vedata, ts, ob);
}
@@ -329,6 +346,7 @@ static void GPENCIL_cache_finish(void *vedata)
ToolSettings *ts = scene->toolsettings;
tGPencilObjectCache *cache;
bool is_multiedit = false;
+ bool playing = (bool)stl->storage->playing;
/* Draw all pending objects */
if (stl->g_data->gp_cache_used > 0) {
@@ -353,9 +371,11 @@ static void GPENCIL_cache_finish(void *vedata)
stl->g_data->gp_object_cache[i].init_grp, stl->g_data->gp_object_cache[i].end_grp);
}
/* VFX pass */
- cache = &stl->g_data->gp_object_cache[i];
- if ((!is_multiedit) && (ob->modifiers.first)) {
- DRW_gpencil_vfx_modifiers(i, &e_data, vedata, ob, cache);
+ if (!GP_SIMPLIFY_VFX(ts, playing)) {
+ cache = &stl->g_data->gp_object_cache[i];
+ if ((!is_multiedit) && (ob->modifiers.first)) {
+ DRW_gpencil_vfx_modifiers(i, &e_data, vedata, ob, cache);
+ }
}
}
}
@@ -476,6 +496,11 @@ static void GPENCIL_draw_scene(void *vedata)
tGPencilObjectCache *cache;
float clearcol[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ const DRWContextState *draw_ctx = DRW_context_state_get();
+ Scene *scene = draw_ctx->scene;
+ ToolSettings *ts = scene->toolsettings;
+ bool playing = (bool)stl->storage->playing;
+
/* attach temp textures */
DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_depth_tx, 0, 0);
DRW_framebuffer_texture_attach(fbl->temp_color_fb, e_data.temp_fbcolor_color_tx, 0, 0);
@@ -522,7 +547,7 @@ static void GPENCIL_draw_scene(void *vedata)
/* vfx modifiers passes
* if any vfx modifier exist, the init_vfx_wave_sh will be not NULL.
*/
- if ((cache->init_vfx_wave_sh) && (cache->end_vfx_wave_sh)) {
+ if ((cache->init_vfx_wave_sh) && (cache->end_vfx_wave_sh) && (!GP_SIMPLIFY_VFX(ts, playing))) {
/* add vfx and combine result with default framebuffer */
gpencil_vfx_passes(vedata, cache);
}
diff --git a/source/blender/draw/engines/gpencil/gpencil_engine.h b/source/blender/draw/engines/gpencil/gpencil_engine.h
index b025e11ce56..04728d9d4da 100644
--- a/source/blender/draw/engines/gpencil/gpencil_engine.h
+++ b/source/blender/draw/engines/gpencil/gpencil_engine.h
@@ -43,6 +43,12 @@ struct GPENCIL_StorageList;
#define GPENCIL_COLOR_TEXTURE 1
#define GPENCIL_COLOR_PATTERN 2
+#define GP_SIMPLIFY(ts) ((ts->gpencil_flags & GP_TOOL_FLAG_SIMPLIFY))
+#define GP_SIMPLIFY_ONPLAY(playing) ((playing == true) && (ts->gpencil_flags & GP_TOOL_FLAG_SIMPLIFY_ON_PLAY)) || ((ts->gpencil_flags & GP_TOOL_FLAG_SIMPLIFY_ON_PLAY) == 0)
+#define GP_SIMPLIFY_FILL(ts, playing) (GP_SIMPLIFY_ONPLAY(playing) && ((GP_SIMPLIFY(ts)) && (ts->gpencil_flags & GP_TO
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list