Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/gpencil/gpencil_draw_utils.c
| Show All 24 Lines | |||||
| #include "BLI_polyfill_2d.h" | #include "BLI_polyfill_2d.h" | ||||
| #include "DRW_engine.h" | #include "DRW_engine.h" | ||||
| #include "DRW_render.h" | #include "DRW_render.h" | ||||
| #include "BKE_brush.h" | #include "BKE_brush.h" | ||||
| #include "BKE_gpencil.h" | #include "BKE_gpencil.h" | ||||
| #include "BKE_gpencil_modifier.h" | |||||
| #include "BKE_image.h" | #include "BKE_image.h" | ||||
| #include "BKE_material.h" | #include "BKE_material.h" | ||||
| #include "ED_gpencil.h" | #include "ED_gpencil.h" | ||||
| #include "ED_view3d.h" | #include "ED_view3d.h" | ||||
| #include "DNA_gpencil_types.h" | #include "DNA_gpencil_types.h" | ||||
| #include "DNA_material_types.h" | #include "DNA_material_types.h" | ||||
| #include "DNA_view3d_types.h" | #include "DNA_view3d_types.h" | ||||
| #include "DNA_modifier_types.h" | #include "DNA_gpencil_modifier_types.h" | ||||
| /* If builtin shaders are needed */ | /* If builtin shaders are needed */ | ||||
| #include "GPU_shader.h" | #include "GPU_shader.h" | ||||
| #include "GPU_texture.h" | #include "GPU_texture.h" | ||||
| /* For EvaluationContext... */ | /* For EvaluationContext... */ | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | #include "DEG_depsgraph_query.h" | ||||
| ▲ Show 20 Lines • Show All 697 Lines • ▼ Show 20 Lines | static void gpencil_draw_strokes( | ||||
| */ | */ | ||||
| Depsgraph *depsgraph = DRW_context_state_get()->depsgraph; | Depsgraph *depsgraph = DRW_context_state_get()->depsgraph; | ||||
| /* get parent matrix and save as static data */ | /* get parent matrix and save as static data */ | ||||
| ED_gpencil_parent_location(depsgraph, ob, gpd, gpl, viewmatrix); | ED_gpencil_parent_location(depsgraph, ob, gpd, gpl, viewmatrix); | ||||
| copy_m4_m4(derived_gpf->runtime.viewmatrix, viewmatrix); | copy_m4_m4(derived_gpf->runtime.viewmatrix, viewmatrix); | ||||
| /* apply geometry modifiers */ | /* apply geometry modifiers */ | ||||
| if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) { | if ((cache->is_dirty) && (ob->greasepencil_modifiers.first) && (!is_multiedit)) { | ||||
| if (!stl->storage->simplify_modif) { | if (!stl->storage->simplify_modif) { | ||||
| if (BKE_gpencil_has_geometry_modifiers(ob)) { | if (BKE_gpencil_has_geometry_modifiers(ob)) { | ||||
| BKE_gpencil_geometry_modifiers(depsgraph, ob, gpl, derived_gpf, stl->storage->is_render); | BKE_gpencil_geometry_modifiers(depsgraph, ob, gpl, derived_gpf, stl->storage->is_render); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (src_gpf) { | if (src_gpf) { | ||||
| ▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | if ((gpl->actframe->framenum == derived_gpf->framenum) || | ||||
| fillgrp = stl->shgroups[id].shgrps_fill; | fillgrp = stl->shgroups[id].shgrps_fill; | ||||
| strokegrp = stl->shgroups[id].shgrps_stroke; | strokegrp = stl->shgroups[id].shgrps_stroke; | ||||
| /* copy color to temp fields to apply temporal changes in the stroke */ | /* copy color to temp fields to apply temporal changes in the stroke */ | ||||
| copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba); | copy_v4_v4(gps->runtime.tmp_stroke_rgba, gp_style->stroke_rgba); | ||||
| copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba); | copy_v4_v4(gps->runtime.tmp_fill_rgba, gp_style->fill_rgba); | ||||
| /* apply modifiers (only modify geometry, but not create ) */ | /* apply modifiers (only modify geometry, but not create ) */ | ||||
| if ((cache->is_dirty) && (ob->modifiers.first) && (!is_multiedit)) { | if ((cache->is_dirty) && (ob->greasepencil_modifiers.first) && (!is_multiedit)) { | ||||
| if (!stl->storage->simplify_modif) { | if (!stl->storage->simplify_modif) { | ||||
| BKE_gpencil_stroke_modifiers(depsgraph, ob, gpl, derived_gpf, gps, stl->storage->is_render); | BKE_gpencil_stroke_modifiers(depsgraph, ob, gpl, derived_gpf, gps, stl->storage->is_render); | ||||
| } | } | ||||
| } | } | ||||
| /* fill */ | /* fill */ | ||||
| if ((fillgrp) && (!stl->storage->simplify_fill)) { | if ((fillgrp) && (!stl->storage->simplify_fill)) { | ||||
| gpencil_add_fill_shgroup( | gpencil_add_fill_shgroup( | ||||
| ▲ Show 20 Lines • Show All 324 Lines • ▼ Show 20 Lines | void DRW_gpencil_populate_datablock(GPENCIL_e_data *e_data, void *vedata, Scene *scene, Object *ob, bGPdata *gpd) | ||||
| /* check if playing animation */ | /* check if playing animation */ | ||||
| bool playing = (bool)stl->storage->playing; | bool playing = (bool)stl->storage->playing; | ||||
| GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra_eval); | GpencilBatchCache *cache = gpencil_batch_cache_get(ob, cfra_eval); | ||||
| cache->cache_idx = 0; | cache->cache_idx = 0; | ||||
| /* init general modifiers data */ | /* init general modifiers data */ | ||||
| if (!stl->storage->simplify_modif) { | if (!stl->storage->simplify_modif) { | ||||
| if ((cache->is_dirty) && (ob->modifiers.first)) { | if ((cache->is_dirty) && (ob->greasepencil_modifiers.first)) { | ||||
| BKE_gpencil_lattice_init(ob); | BKE_gpencil_lattice_init(ob); | ||||
| } | } | ||||
| } | } | ||||
| /* draw normal strokes */ | /* draw normal strokes */ | ||||
| for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| /* don't draw layer if hidden */ | /* don't draw layer if hidden */ | ||||
| if (gpl->flag & GP_LAYER_HIDE) | if (gpl->flag & GP_LAYER_HIDE) | ||||
| continue; | continue; | ||||
| Show All 36 Lines | for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { | ||||
| /* draw normal strokes */ | /* draw normal strokes */ | ||||
| gpencil_draw_strokes( | gpencil_draw_strokes( | ||||
| cache, e_data, vedata, ts, ob, gpd, gpl, gpf, derived_gpf, | cache, e_data, vedata, ts, ob, gpd, gpl, gpf, derived_gpf, | ||||
| gpl->opacity, gpl->tintcolor, false); | gpl->opacity, gpl->tintcolor, false); | ||||
| } | } | ||||
| /* clear any lattice data */ | /* clear any lattice data */ | ||||
| if ((cache->is_dirty) && (ob->modifiers.first)) { | if ((cache->is_dirty) && (ob->greasepencil_modifiers.first)) { | ||||
| BKE_gpencil_lattice_clear(ob); | BKE_gpencil_lattice_clear(ob); | ||||
| } | } | ||||
| cache->is_dirty = false; | cache->is_dirty = false; | ||||
| } | } | ||||
| /* Helper for gpencil_instance_modifiers() | /* Helper for gpencil_instance_modifiers() | ||||
| * See also MOD_gpencilinstance.c -> gp_bakeModifier() | * See also MOD_gpencilinstance.c -> gp_bakeModifier() | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if ((ob) && (ob->data)) { | if ((ob) && (ob->data)) { | ||||
| bGPdata *gpd = ob->data; | bGPdata *gpd = ob->data; | ||||
| if (GPENCIL_ANY_EDIT_MODE(gpd)) { | if (GPENCIL_ANY_EDIT_MODE(gpd)) { | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| for (ModifierData *md = ob->modifiers.first; md; md = md->next) { | for (GpencilModifierData *md = ob->greasepencil_modifiers.first; md; md = md->next) { | ||||
| if (((md->mode & eModifierMode_Realtime) && (stl->storage->is_render == false)) || | if (((md->mode & eGpencilModifierMode_Realtime) && (stl->storage->is_render == false)) || | ||||
| ((md->mode & eModifierMode_Render) && (stl->storage->is_render == true))) | ((md->mode & eGpencilModifierMode_Render) && (stl->storage->is_render == true))) | ||||
| { | { | ||||
| if (md->type == eModifierType_Gpencil_Instance) { | if (md->type == eGpencilModifierType_Instance) { | ||||
| InstanceGpencilModifierData *mmd = (InstanceGpencilModifierData *)md; | InstanceGpencilModifierData *mmd = (InstanceGpencilModifierData *)md; | ||||
| /* Only add instances if the "Make Objects" flag is set | /* Only add instances if the "Make Objects" flag is set | ||||
| * FIXME: This is a workaround for z-ordering weirdness when all instances are in the same object | * FIXME: This is a workaround for z-ordering weirdness when all instances are in the same object | ||||
| */ | */ | ||||
| if (mmd->flag & GP_INSTANCE_MAKE_OBJECTS) { | if (mmd->flag & GP_INSTANCE_MAKE_OBJECTS) { | ||||
| gp_instance_modifier_make_instances(stl, ob, mmd); | gp_instance_modifier_make_instances(stl, ob, mmd); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||