Initial Grease Pencil 3.0 stage #106848
|
@ -0,0 +1,28 @@
|
||||||
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "DNA_grease_pencil_types.h"
|
||||||
|
|
||||||
|
/** \file
|
||||||
|
* \ingroup bke
|
||||||
|
* \brief Low-level operations for grease pencil that cannot be defined in the C++ header yet.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
BKE_GREASEPENCIL_BATCH_DIRTY_ALL = 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void (*BKE_grease_pencil_batch_cache_dirty_tag_cb)(GreasePencil *grease_pencil, int mode);
|
||||||
|
extern void (*BKE_grease_pencil_batch_cache_free_cb)(GreasePencil *grease_pencil);
|
||||||
|
|
||||||
|
void BKE_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode);
|
||||||
|
void BKE_grease_pencil_batch_cache_free(GreasePencil *grease_pencil);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -390,6 +390,7 @@ set(SRC
|
||||||
BKE_gpencil_geom_legacy.h
|
BKE_gpencil_geom_legacy.h
|
||||||
BKE_gpencil_modifier_legacy.h
|
BKE_gpencil_modifier_legacy.h
|
||||||
BKE_gpencil_update_cache_legacy.h
|
BKE_gpencil_update_cache_legacy.h
|
||||||
|
BKE_grease_pencil.h
|
||||||
BKE_grease_pencil.hh
|
BKE_grease_pencil.hh
|
||||||
BKE_icons.h
|
BKE_icons.h
|
||||||
BKE_idprop.h
|
BKE_idprop.h
|
||||||
|
|
|
@ -95,10 +95,12 @@ static void grease_pencil_free_data(ID *id)
|
||||||
GreasePencil *grease_pencil = (GreasePencil *)id;
|
GreasePencil *grease_pencil = (GreasePencil *)id;
|
||||||
BKE_animdata_free(&grease_pencil->id, false);
|
BKE_animdata_free(&grease_pencil->id, false);
|
||||||
|
|
||||||
|
MEM_SAFE_FREE(grease_pencil->material_array);
|
||||||
|
|
||||||
grease_pencil->free_drawing_array();
|
grease_pencil->free_drawing_array();
|
||||||
grease_pencil->free_layer_tree_storage();
|
grease_pencil->free_layer_tree_storage();
|
||||||
|
|
||||||
MEM_SAFE_FREE(grease_pencil->material_array);
|
BKE_grease_pencil_batch_cache_free(grease_pencil);
|
||||||
|
|
||||||
MEM_delete(grease_pencil->runtime);
|
MEM_delete(grease_pencil->runtime);
|
||||||
grease_pencil->runtime = nullptr;
|
grease_pencil->runtime = nullptr;
|
||||||
|
@ -228,6 +230,20 @@ IDTypeInfo IDType_ID_GP = {
|
||||||
/*lib_override_apply_post*/ nullptr,
|
/*lib_override_apply_post*/ nullptr,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace blender::bke::gpencil {
|
||||||
|
|
||||||
|
LayerGroup &TreeNode::as_group()
|
||||||
|
{
|
||||||
|
return *static_cast<LayerGroup *>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
Layer &TreeNode::as_layer()
|
||||||
|
{
|
||||||
|
return *static_cast<Layer *>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace blender::bke::gpencil
|
||||||
|
|
||||||
void *BKE_grease_pencil_add(Main *bmain, const char *name)
|
void *BKE_grease_pencil_add(Main *bmain, const char *name)
|
||||||
{
|
{
|
||||||
GreasePencil *grease_pencil = static_cast<GreasePencil *>(BKE_id_new(bmain, ID_GP, name));
|
GreasePencil *grease_pencil = static_cast<GreasePencil *>(BKE_id_new(bmain, ID_GP, name));
|
||||||
|
@ -276,20 +292,26 @@ BoundBox *BKE_grease_pencil_boundbox_get(Object *ob)
|
||||||
return ob->runtime.bb;
|
return ob->runtime.bb;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace blender::bke::gpencil {
|
/* Draw Cache */
|
||||||
|
|
||||||
LayerGroup &TreeNode::as_group()
|
void (*BKE_grease_pencil_batch_cache_dirty_tag_cb)(GreasePencil *grease_pencil,
|
||||||
|
int mode) = nullptr;
|
||||||
|
void (*BKE_grease_pencil_batch_cache_free_cb)(GreasePencil *grease_pencil) = nullptr;
|
||||||
|
|
||||||
|
void BKE_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode)
|
||||||
{
|
{
|
||||||
return *static_cast<LayerGroup *>(this);
|
if (grease_pencil->runtime && grease_pencil->runtime->batch_cache) {
|
||||||
|
BKE_grease_pencil_batch_cache_dirty_tag_cb(grease_pencil, mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Layer &TreeNode::as_layer()
|
void BKE_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
|
||||||
{
|
{
|
||||||
return *static_cast<Layer *>(this);
|
if (grease_pencil->runtime && grease_pencil->runtime->batch_cache) {
|
||||||
|
BKE_grease_pencil_batch_cache_free_cb(grease_pencil);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace blender::bke::gpencil
|
|
||||||
|
|
||||||
blender::Span<GreasePencilDrawingOrReference *> GreasePencil::drawings() const
|
blender::Span<GreasePencilDrawingOrReference *> GreasePencil::drawings() const
|
||||||
{
|
{
|
||||||
return blender::Span<GreasePencilDrawingOrReference *>{this->drawing_array,
|
return blender::Span<GreasePencilDrawingOrReference *>{this->drawing_array,
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "BKE_effect.h"
|
#include "BKE_effect.h"
|
||||||
#include "BKE_gpencil_legacy.h"
|
#include "BKE_gpencil_legacy.h"
|
||||||
#include "BKE_gpencil_modifier_legacy.h"
|
#include "BKE_gpencil_modifier_legacy.h"
|
||||||
|
#include "BKE_grease_pencil.h"
|
||||||
#include "BKE_image.h"
|
#include "BKE_image.h"
|
||||||
#include "BKE_key.h"
|
#include "BKE_key.h"
|
||||||
#include "BKE_lattice.h"
|
#include "BKE_lattice.h"
|
||||||
|
@ -321,6 +322,8 @@ void BKE_object_batch_cache_dirty_tag(Object *ob)
|
||||||
break;
|
break;
|
||||||
case OB_GREASE_PENCIL:
|
case OB_GREASE_PENCIL:
|
||||||
/* TODO: tag batches. */
|
/* TODO: tag batches. */
|
||||||
|
BKE_grease_pencil_batch_cache_dirty_tag((struct GreasePencil *)ob->data,
|
||||||
|
BKE_GREASEPENCIL_BATCH_DIRTY_ALL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "DNA_curve_types.h"
|
#include "DNA_curve_types.h"
|
||||||
#include "DNA_curves_types.h"
|
#include "DNA_curves_types.h"
|
||||||
|
#include "DNA_grease_pencil_types.h"
|
||||||
#include "DNA_lattice_types.h"
|
#include "DNA_lattice_types.h"
|
||||||
#include "DNA_mesh_types.h"
|
#include "DNA_mesh_types.h"
|
||||||
#include "DNA_meta_types.h"
|
#include "DNA_meta_types.h"
|
||||||
|
@ -3298,6 +3299,8 @@ void drw_batch_cache_validate(Object *ob)
|
||||||
case OB_VOLUME:
|
case OB_VOLUME:
|
||||||
DRW_volume_batch_cache_validate((Volume *)ob->data);
|
DRW_volume_batch_cache_validate((Volume *)ob->data);
|
||||||
break;
|
break;
|
||||||
|
case OB_GREASE_PENCIL:
|
||||||
|
DRW_grease_pencil_batch_cache_validate((GreasePencil *)ob->data);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ struct Mesh;
|
||||||
struct PointCloud;
|
struct PointCloud;
|
||||||
struct Volume;
|
struct Volume;
|
||||||
struct bGPdata;
|
struct bGPdata;
|
||||||
|
struct GreasePencil;
|
||||||
|
|
||||||
#include "BKE_mesh_types.h"
|
#include "BKE_mesh_types.h"
|
||||||
|
|
||||||
|
@ -63,6 +64,10 @@ void DRW_volume_batch_cache_dirty_tag(struct Volume *volume, int mode);
|
||||||
void DRW_volume_batch_cache_validate(struct Volume *volume);
|
void DRW_volume_batch_cache_validate(struct Volume *volume);
|
||||||
void DRW_volume_batch_cache_free(struct Volume *volume);
|
void DRW_volume_batch_cache_free(struct Volume *volume);
|
||||||
|
|
||||||
|
void DRW_grease_pencil_batch_cache_dirty_tag(struct GreasePencil *grase_pencil, int mode);
|
||||||
|
void DRW_grease_pencil_batch_cache_validate(struct GreasePencil *grase_pencil);
|
||||||
|
void DRW_grease_pencil_batch_cache_free(struct GreasePencil *grase_pencil);
|
||||||
|
|
||||||
/** \} */
|
/** \} */
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "BKE_curves.hh"
|
#include "BKE_curves.hh"
|
||||||
|
#include "BKE_grease_pencil.h"
|
||||||
#include "BKE_grease_pencil.hh"
|
#include "BKE_grease_pencil.hh"
|
||||||
|
|
||||||
#include "BLI_task.hh"
|
#include "BLI_task.hh"
|
||||||
|
@ -18,6 +19,8 @@
|
||||||
|
|
||||||
#include "GPU_batch.h"
|
#include "GPU_batch.h"
|
||||||
|
|
||||||
|
#include "draw_cache_impl.h"
|
||||||
|
|
||||||
#include "../engines/gpencil/gpencil_defines.h"
|
#include "../engines/gpencil/gpencil_defines.h"
|
||||||
|
|
||||||
namespace blender::draw {
|
namespace blender::draw {
|
||||||
|
@ -116,7 +119,7 @@ static GreasePencilBatchCache *grease_pencil_batch_cache_init(GreasePencil &grea
|
||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void grese_pencil_batch_cache_clear(GreasePencil &grease_pencil)
|
static void grease_pencil_batch_cache_clear(GreasePencil &grease_pencil)
|
||||||
{
|
{
|
||||||
BLI_assert(grease_pencil.runtime != nullptr);
|
BLI_assert(grease_pencil.runtime != nullptr);
|
||||||
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
||||||
|
@ -140,7 +143,7 @@ static GreasePencilBatchCache *grease_pencil_batch_cache_get(GreasePencil &greas
|
||||||
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
||||||
grease_pencil.runtime->batch_cache);
|
grease_pencil.runtime->batch_cache);
|
||||||
if (!grease_pencil_batch_cache_valid(grease_pencil)) {
|
if (!grease_pencil_batch_cache_valid(grease_pencil)) {
|
||||||
grese_pencil_batch_cache_clear(grease_pencil);
|
grease_pencil_batch_cache_clear(grease_pencil);
|
||||||
return grease_pencil_batch_cache_init(grease_pencil, cfra);
|
return grease_pencil_batch_cache_init(grease_pencil, cfra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,6 +301,43 @@ static void grease_pencil_batches_ensure(GreasePencil &grease_pencil, int cfra)
|
||||||
|
|
||||||
} // namespace blender::draw
|
} // namespace blender::draw
|
||||||
|
|
||||||
|
void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode)
|
||||||
|
{
|
||||||
|
using namespace blender::draw;
|
||||||
|
BLI_assert(grease_pencil->runtime != nullptr);
|
||||||
|
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
|
||||||
|
grease_pencil->runtime->batch_cache);
|
||||||
|
if (cache == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (mode) {
|
||||||
|
case BKE_GREASEPENCIL_BATCH_DIRTY_ALL:
|
||||||
|
cache->is_dirty = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
BLI_assert_unreachable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_grease_pencil_batch_cache_validate(GreasePencil *grease_pencil)
|
||||||
|
{
|
||||||
|
using namespace blender::draw;
|
||||||
|
BLI_assert(grease_pencil->runtime != nullptr);
|
||||||
|
if (!grease_pencil_batch_cache_valid(*grease_pencil)) {
|
||||||
|
grease_pencil_batch_cache_clear(*grease_pencil);
|
||||||
|
/* TODO: pass correct frame here? */
|
||||||
|
grease_pencil_batch_cache_init(*grease_pencil, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
|
||||||
|
{
|
||||||
|
using namespace blender::draw;
|
||||||
|
grease_pencil_batch_cache_clear(*grease_pencil);
|
||||||
|
MEM_delete(static_cast<GreasePencilBatchCache *>(grease_pencil->runtime->batch_cache));
|
||||||
|
grease_pencil->runtime->batch_cache = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
GPUBatch *DRW_cache_grease_pencil_get(Object *ob, int cfra)
|
GPUBatch *DRW_cache_grease_pencil_get(Object *ob, int cfra)
|
||||||
{
|
{
|
||||||
using namespace blender::draw;
|
using namespace blender::draw;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "BKE_editmesh.h"
|
#include "BKE_editmesh.h"
|
||||||
#include "BKE_global.h"
|
#include "BKE_global.h"
|
||||||
#include "BKE_gpencil_legacy.h"
|
#include "BKE_gpencil_legacy.h"
|
||||||
|
#include "BKE_grease_pencil.h"
|
||||||
#include "BKE_lattice.h"
|
#include "BKE_lattice.h"
|
||||||
#include "BKE_main.h"
|
#include "BKE_main.h"
|
||||||
#include "BKE_mball.h"
|
#include "BKE_mball.h"
|
||||||
|
@ -3052,6 +3053,9 @@ void DRW_engines_register(void)
|
||||||
BKE_volume_batch_cache_dirty_tag_cb = DRW_volume_batch_cache_dirty_tag;
|
BKE_volume_batch_cache_dirty_tag_cb = DRW_volume_batch_cache_dirty_tag;
|
||||||
BKE_volume_batch_cache_free_cb = DRW_volume_batch_cache_free;
|
BKE_volume_batch_cache_free_cb = DRW_volume_batch_cache_free;
|
||||||
|
|
||||||
|
BKE_grease_pencil_batch_cache_dirty_tag_cb = DRW_grease_pencil_batch_cache_dirty_tag;
|
||||||
|
BKE_grease_pencil_batch_cache_free_cb = DRW_grease_pencil_batch_cache_free;
|
||||||
|
|
||||||
BKE_subsurf_modifier_free_gpu_cache_cb = DRW_subdiv_cache_free;
|
BKE_subsurf_modifier_free_gpu_cache_cb = DRW_subdiv_cache_free;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue