Initial Grease Pencil 3.0 stage #106848
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
filedescriptor marked this conversation as resolved
Outdated
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Needs copyright. Needs copyright.
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
#pragma once
|
||||
|
||||
|
@ -20,7 +21,7 @@
|
|||
|
||||
namespace blender::bke {
|
||||
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Decide on the namespace here. Should it maybe be just Decide on the namespace here. Should it maybe be just `gp`?
|
||||
namespace gpencil {
|
||||
namespace greasepencil {
|
||||
|
||||
class LayerGroup;
|
||||
class Layer;
|
||||
|
@ -513,15 +514,15 @@ class LayerGroup : public TreeNode {
|
|||
|
||||
namespace convert {
|
||||
|
||||
void legacy_gpencil_frame_to_curves_geometry(GreasePencilDrawing &drawing, bGPDframe &gpf);
|
||||
void legacy_gpencil_frame_to_grease_pencil_drawing(GreasePencilDrawing &drawing, bGPDframe &gpf);
|
||||
|
||||
void legacy_gpencil_to_grease_pencil(GreasePencil &grease_pencil, bGPdata &gpd);
|
||||
|
||||
} // namespace convert
|
||||
|
||||
} // namespace gpencil
|
||||
} // namespace greasepencil
|
||||
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
|
||||
struct StrokePoint {
|
||||
float3 position;
|
||||
|
|
|
@ -200,7 +200,7 @@ typedef struct Main {
|
|||
ListBase pointclouds;
|
||||
ListBase volumes;
|
||||
ListBase simulations;
|
||||
ListBase greasepencils;
|
||||
ListBase grease_pencils;
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Maybe Maybe `grease_pencils`?
|
||||
|
||||
/**
|
||||
* Must be generated, used and freed by same code - never assume this is valid data unless you
|
||||
|
|
|
@ -1580,7 +1580,6 @@ GVArray CurvesGeometry::adapt_domain(const GVArray &varray,
|
|||
/** \name File reading/writing.
|
||||
* \{ */
|
||||
|
||||
|
||||
void CurvesGeometry::blend_read(BlendDataReader &reader)
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Remove blank line. Remove blank line.
|
||||
{
|
||||
CustomData_blend_read(&reader, &this->point_data, this->point_num);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
|
@ -168,7 +169,7 @@ static void grease_pencil_blend_write(BlendWriter *writer, ID *id, const void *i
|
|||
|
||||
static void grease_pencil_blend_read_data(BlendDataReader *reader, ID *id)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
Hans Goudey
commented
C++ cast here C++ cast here
|
||||
GreasePencil *grease_pencil = (GreasePencil *)id;
|
||||
|
||||
/* Read animation data. */
|
||||
filedescriptor marked this conversation as resolved
Outdated
Bastien Montagne
commented
Code is missing re-reading Code is missing re-reading `active_layer` address...
|
||||
|
@ -250,7 +251,7 @@ IDTypeInfo IDType_ID_GP = {
|
|||
/*lib_override_apply_post*/ nullptr,
|
||||
};
|
||||
|
||||
namespace blender::bke::gpencil {
|
||||
namespace blender::bke::greasepencil {
|
||||
|
||||
TreeNode::PreOrderRange TreeNode::children_in_pre_order()
|
||||
{
|
||||
|
@ -277,7 +278,7 @@ const Layer &TreeNode::as_layer() const
|
|||
return *static_cast<const Layer *>(this);
|
||||
}
|
||||
|
||||
} // namespace blender::bke::gpencil
|
||||
} // namespace blender::bke::greasepencil
|
||||
|
||||
void *BKE_grease_pencil_add(Main *bmain, const char *name)
|
||||
{
|
||||
|
@ -517,7 +518,7 @@ void GreasePencil::add_empty_drawings(int n)
|
|||
|
||||
void GreasePencil::remove_drawing(int index_to_remove)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
/* In order to not change the indices of the drawings, we do the following to the drawing to be
|
||||
* removed:
|
||||
* - If the drawing (A) is not the last one:
|
||||
|
@ -585,7 +586,7 @@ void GreasePencil::remove_drawing(int index_to_remove)
|
|||
void GreasePencil::foreach_visible_drawing(
|
||||
int frame, blender::FunctionRef<void(GreasePencilDrawing &)> function)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
|
||||
blender::Span<GreasePencilDrawingOrReference *> drawings = this->drawings();
|
||||
for (TreeNode &node : this->root_group().children_in_pre_order()) {
|
||||
|
@ -608,12 +609,12 @@ void GreasePencil::foreach_visible_drawing(
|
|||
}
|
||||
}
|
||||
|
||||
const blender::bke::gpencil::Layer *GreasePencil::active_layer() const
|
||||
const blender::bke::greasepencil::Layer *GreasePencil::active_layer() const
|
||||
{
|
||||
return this->runtime->active_layer();
|
||||
}
|
||||
|
||||
blender::bke::gpencil::LayerGroup &GreasePencil::root_group()
|
||||
blender::bke::greasepencil::LayerGroup &GreasePencil::root_group()
|
||||
{
|
||||
BLI_assert(this->runtime != nullptr);
|
||||
return this->runtime->root_group();
|
||||
|
@ -697,7 +698,7 @@ void GreasePencil::free_drawing_array()
|
|||
this->drawing_array_size = 0;
|
||||
}
|
||||
|
||||
static void save_tree_node_to_storage(blender::bke::gpencil::TreeNode &node,
|
||||
static void save_tree_node_to_storage(blender::bke::greasepencil::TreeNode &node,
|
||||
GreasePencilLayerTreeNode *dst)
|
||||
{
|
||||
dst->type = node.type;
|
||||
|
@ -708,7 +709,7 @@ static void save_tree_node_to_storage(blender::bke::gpencil::TreeNode &node,
|
|||
}
|
||||
}
|
||||
|
||||
static void save_layer_to_storage(blender::bke::gpencil::Layer &node,
|
||||
static void save_layer_to_storage(blender::bke::greasepencil::Layer &node,
|
||||
GreasePencilLayerTreeNode **dst)
|
||||
{
|
||||
using namespace blender;
|
||||
|
@ -735,7 +736,7 @@ static void save_layer_to_storage(blender::bke::gpencil::Layer &node,
|
|||
*dst = reinterpret_cast<GreasePencilLayerTreeNode *>(new_leaf);
|
||||
}
|
||||
|
||||
static void save_layer_group_to_storage(blender::bke::gpencil::LayerGroup &node,
|
||||
static void save_layer_group_to_storage(blender::bke::greasepencil::LayerGroup &node,
|
||||
GreasePencilLayerTreeNode **dst)
|
||||
{
|
||||
GreasePencilLayerTreeGroup *new_group = MEM_cnew<GreasePencilLayerTreeGroup>(__func__);
|
||||
|
@ -751,7 +752,7 @@ static void save_layer_group_to_storage(blender::bke::gpencil::LayerGroup &node,
|
|||
|
||||
void GreasePencil::save_layer_tree_to_storage()
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
/* We always store the root group, so we have to add one here. */
|
||||
int num_tree_nodes = this->root_group().total_num_children() + 1;
|
||||
this->layer_tree_storage.nodes_num = num_tree_nodes;
|
||||
|
@ -781,11 +782,11 @@ void GreasePencil::save_layer_tree_to_storage()
|
|||
}
|
||||
}
|
||||
|
||||
static void read_layer_node_recursive(blender::bke::gpencil::LayerGroup ¤t_group,
|
||||
static void read_layer_node_recursive(blender::bke::greasepencil::LayerGroup ¤t_group,
|
||||
GreasePencilLayerTreeNode **nodes,
|
||||
int index)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
GreasePencilLayerTreeNode *node = nodes[index];
|
||||
Hans Goudey
commented
Please search the patch for this, I mentioned it last time too `offset_indices::OffsetIndices` -> `OffsetIndices`
Please search the patch for this, I mentioned it last time too
|
||||
switch (node->type) {
|
||||
case GREASE_PENCIL_LAYER_TREE_LEAF: {
|
||||
|
@ -812,7 +813,7 @@ static void read_layer_node_recursive(blender::bke::gpencil::LayerGroup ¤t
|
|||
|
||||
void GreasePencil::load_layer_tree_from_storage()
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
if (this->layer_tree_storage.nodes_num == 0 || !this->layer_tree_storage.nodes) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
/** \file
|
||||
* \ingroup bke
|
||||
|
@ -14,9 +15,9 @@
|
|||
#include "DNA_gpencil_legacy_types.h"
|
||||
#include "DNA_grease_pencil_types.h"
|
||||
|
||||
namespace blender::bke::gpencil::convert {
|
||||
namespace blender::bke::greasepencil::convert {
|
||||
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
`legacy_gpencil_frame_to_grease_pencil_drawing`
|
||||
void legacy_gpencil_frame_to_curves_geometry(GreasePencilDrawing &drawing, bGPDframe &gpf)
|
||||
void legacy_gpencil_frame_to_grease_pencil_drawing(GreasePencilDrawing &drawing, bGPDframe &gpf)
|
||||
{
|
||||
/* Get the number of points, number of strokes and the offsets for each stroke. */
|
||||
Hans Goudey
commented
Order return argument last, make the Order return argument last, make the `gpf` argument const
|
||||
Vector<int> offsets;
|
||||
|
@ -94,7 +95,7 @@ void legacy_gpencil_frame_to_curves_geometry(GreasePencilDrawing &drawing, bGPDf
|
|||
|
||||
void legacy_gpencil_to_grease_pencil(GreasePencil &grease_pencil, bGPdata &gpd)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
|
||||
int num_layers = 0;
|
||||
int num_drawings = 0;
|
||||
|
@ -120,7 +121,7 @@ void legacy_gpencil_to_grease_pencil(GreasePencil &grease_pencil, bGPdata &gpd)
|
|||
/* TODO: copy flag. */
|
||||
|
||||
/* Convert the frame to a drawing. */
|
||||
legacy_gpencil_frame_to_curves_geometry(drawing, *gpf);
|
||||
legacy_gpencil_frame_to_grease_pencil_drawing(drawing, *gpf);
|
||||
|
||||
GreasePencilFrame frame;
|
||||
frame.drawing_index = i;
|
||||
|
@ -131,4 +132,4 @@ void legacy_gpencil_to_grease_pencil(GreasePencil &grease_pencil, bGPdata &gpd)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace blender::bke::gpencil::convert
|
||||
} // namespace blender::bke::greasepencil::convert
|
|
@ -1,5 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2021 Blender Foundation. */
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
||||
|
@ -9,9 +9,9 @@
|
|||
#include "BKE_lib_id.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
|
||||
namespace blender::bke::gpencil::tests {
|
||||
namespace blender::bke::greasepencil::tests {
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Grease Pencil ID Tests. */
|
||||
|
@ -30,7 +30,7 @@ struct GreasePencilIDTestContext {
|
|||
}
|
||||
};
|
||||
|
||||
TEST(gpencil, create_grease_pencil_id)
|
||||
TEST(greasepencil, create_grease_pencil_id)
|
||||
{
|
||||
GreasePencilIDTestContext ctx;
|
||||
|
||||
|
@ -39,7 +39,7 @@ TEST(gpencil, create_grease_pencil_id)
|
|||
EXPECT_EQ(grease_pencil.root_group().total_num_children(), 0);
|
||||
}
|
||||
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Add tests for Add tests for `load_layer_tree_from_storage` and `save_layer_tree_to_storage`.
|
||||
TEST(gpencil, set_active_layer)
|
||||
TEST(greasepencil, set_active_layer)
|
||||
{
|
||||
GreasePencilIDTestContext ctx;
|
||||
|
||||
|
@ -75,7 +75,7 @@ TEST(gpencil, set_active_layer)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Drawing Array Tests. */
|
||||
|
||||
TEST(gpencil, add_empty_drawings)
|
||||
TEST(greasepencil, add_empty_drawings)
|
||||
{
|
||||
GreasePencilIDTestContext ctx;
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(BKE_id_new(ctx.bmain, ID_GP, "GP"));
|
||||
|
@ -83,7 +83,7 @@ TEST(gpencil, add_empty_drawings)
|
|||
EXPECT_EQ(grease_pencil.drawings().size(), 3);
|
||||
}
|
||||
|
||||
TEST(gpencil, remove_drawing)
|
||||
TEST(greasepencil, remove_drawing)
|
||||
{
|
||||
GreasePencilIDTestContext ctx;
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(BKE_id_new(ctx.bmain, ID_GP, "GP"));
|
||||
|
@ -126,12 +126,12 @@ TEST(gpencil, remove_drawing)
|
|||
/* --------------------------------------------------------------------------------------------- */
|
||||
/* Layer Tree Tests. */
|
||||
|
||||
TEST(gpencil, layer_tree_empty)
|
||||
TEST(greasepencil, layer_tree_empty)
|
||||
{
|
||||
LayerGroup root{};
|
||||
}
|
||||
|
||||
TEST(gpencil, layer_tree_build_simple)
|
||||
TEST(greasepencil, layer_tree_build_simple)
|
||||
{
|
||||
LayerGroup root{};
|
||||
|
||||
|
@ -162,7 +162,7 @@ struct GreasePencilLayerTreeExample {
|
|||
}
|
||||
};
|
||||
|
||||
TEST(gpencil, layer_tree_pre_order_iteration_callback)
|
||||
TEST(greasepencil, layer_tree_pre_order_iteration_callback)
|
||||
{
|
||||
GreasePencilLayerTreeExample ex;
|
||||
int i = 0;
|
||||
|
@ -170,7 +170,7 @@ TEST(gpencil, layer_tree_pre_order_iteration_callback)
|
|||
[&](TreeNode &child) { EXPECT_EQ(child.name, ex.names[i++]); });
|
||||
}
|
||||
|
||||
TEST(gpencil, layer_tree_pre_order_iteration_loop)
|
||||
TEST(greasepencil, layer_tree_pre_order_iteration_loop)
|
||||
{
|
||||
GreasePencilLayerTreeExample ex;
|
||||
int i = 0;
|
||||
|
@ -179,13 +179,13 @@ TEST(gpencil, layer_tree_pre_order_iteration_loop)
|
|||
}
|
||||
}
|
||||
|
||||
TEST(gpencil, layer_tree_total_size)
|
||||
TEST(greasepencil, layer_tree_total_size)
|
||||
{
|
||||
GreasePencilLayerTreeExample ex;
|
||||
EXPECT_EQ(ex.root.total_num_children(), 7);
|
||||
}
|
||||
|
||||
TEST(gpencil, layer_tree_node_types)
|
||||
TEST(greasepencil, layer_tree_node_types)
|
||||
{
|
||||
GreasePencilLayerTreeExample ex;
|
||||
int i = 0;
|
||||
|
@ -196,4 +196,4 @@ TEST(gpencil, layer_tree_node_types)
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace blender::bke::gpencil::tests
|
||||
} // namespace blender::bke::greasepencil::tests
|
|
@ -650,7 +650,7 @@ ListBase *which_libbase(Main *bmain, short type)
|
|||
case ID_SIM:
|
||||
return &(bmain->simulations);
|
||||
case ID_GP:
|
||||
return &(bmain->greasepencils);
|
||||
return &(bmain->grease_pencils);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ int set_listbasepointers(Main *bmain, ListBase *lb[/*INDEX_ID_MAX*/])
|
|||
lb[INDEX_ID_WM] = &(bmain->wm);
|
||||
lb[INDEX_ID_MSK] = &(bmain->masks);
|
||||
lb[INDEX_ID_SIM] = &(bmain->simulations);
|
||||
lb[INDEX_ID_GP] = &(bmain->greasepencils);
|
||||
lb[INDEX_ID_GP] = &(bmain->grease_pencils);
|
||||
|
||||
lb[INDEX_ID_NULL] = NULL;
|
||||
|
||||
|
|
|
@ -320,7 +320,6 @@ void BKE_object_batch_cache_dirty_tag(Object *ob)
|
|||
BKE_volume_batch_cache_dirty_tag((struct Volume *)ob->data, BKE_VOLUME_BATCH_DIRTY_ALL);
|
||||
break;
|
||||
case OB_GREASE_PENCIL:
|
||||
/* TODO: tag batches. */
|
||||
BKE_grease_pencil_batch_cache_dirty_tag((struct GreasePencil *)ob->data,
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Remove todo. Remove todo.
|
||||
BKE_GREASEPENCIL_BATCH_DIRTY_ALL);
|
||||
break;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "BLI_smaa_textures.h"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
Hans Goudey
commented
It looks like this should be in the Same with elsewhere in this diff. It looks like this should be in the `blender::draw::` namespace first, given the file path. Since `greasepencil` isn't a top-level module, a `blender::greasepencil` namespace probably doesn't make sense in general.
Same with elsewhere in this diff.
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -67,7 +67,7 @@ class AntiAliasing {
|
|||
}
|
||||
|
||||
luma_weight_ = scene->grease_pencil_settings.smaa_threshold;
|
||||
anti_aliasing_enabled_ = true;//GPENCIL_SIMPLIFY_AA(scene);
|
||||
anti_aliasing_enabled_ = true; // GPENCIL_SIMPLIFY_AA(scene);
|
||||
}
|
||||
|
||||
void begin_sync(TextureFromPool &color_tx, TextureFromPool &reveal_tx)
|
||||
|
@ -151,4 +151,4 @@ class AntiAliasing {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
|
@ -31,7 +31,7 @@
|
|||
#include "gpencil_shader_shared.h"
|
||||
#include "gpencil_vfx.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -192,7 +192,7 @@ class Instance {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Interface with legacy C DRW manager
|
||||
|
@ -206,7 +206,7 @@ struct GPENCIL_NEXT_Data {
|
|||
DRWViewportEmptyList *txl;
|
||||
DRWViewportEmptyList *psl;
|
||||
DRWViewportEmptyList *stl;
|
||||
gpencil::Instance *instance;
|
||||
greasepencil::Instance *instance;
|
||||
|
||||
char info[GPU_INFO_SIZE];
|
||||
};
|
||||
|
@ -220,7 +220,7 @@ static void gpencil_engine_init(void *vedata)
|
|||
|
||||
GPENCIL_NEXT_Data *ved = reinterpret_cast<GPENCIL_NEXT_Data *>(vedata);
|
||||
if (ved->instance == nullptr) {
|
||||
ved->instance = new gpencil::Instance();
|
||||
ved->instance = new greasepencil::Instance();
|
||||
}
|
||||
|
||||
const DRWContextState *ctx_state = DRW_context_state_get();
|
||||
|
@ -283,12 +283,12 @@ static void gpencil_instance_free(void *instance)
|
|||
if (!GPU_shader_storage_buffer_objects_support()) {
|
||||
return;
|
||||
}
|
||||
delete reinterpret_cast<gpencil::Instance *>(instance);
|
||||
delete reinterpret_cast<greasepencil::Instance *>(instance);
|
||||
}
|
||||
|
||||
static void gpencil_engine_free()
|
||||
{
|
||||
blender::gpencil::ShaderModule::module_free();
|
||||
blender::greasepencil::ShaderModule::module_free();
|
||||
}
|
||||
|
||||
static void gpencil_render_to_image(void *vedata,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "draw_manager.hh"
|
||||
#include "draw_pass.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -30,7 +30,7 @@ class LayerModule {
|
|||
layers_buf_.clear();
|
||||
}
|
||||
|
||||
void sync(const Object *object, const bke::gpencil::Layer &layer, bool &do_layer_blending)
|
||||
void sync(const Object *object, const bke::greasepencil::Layer &layer, bool &do_layer_blending)
|
||||
{
|
||||
UNUSED_VARS(object, layer);
|
||||
Sergey Sharybin
commented
In C++ use In C++ use `void sync(const Object * /*object*/, const bke::greasepencil::Layer & /*layer*/, bool &do_layer_blending)`
|
||||
/* TODO(fclem): All of this is placeholder. */
|
||||
|
@ -62,4 +62,4 @@ class LayerModule {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "draw_manager.hh"
|
||||
#include "draw_pass.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -127,4 +127,4 @@ class LightModule {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "draw_manager.hh"
|
||||
#include "draw_pass.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -317,4 +317,4 @@ class MaterialModule {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "gpencil_material.hh"
|
||||
#include "gpencil_shader.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -104,7 +104,7 @@ class ObjectModule {
|
|||
Framebuffer &main_fb,
|
||||
PassSortable &main_ps)
|
||||
{
|
||||
using namespace blender::bke::gpencil;
|
||||
using namespace blender::bke::greasepencil;
|
||||
|
||||
Object *object = object_ref.object;
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(object->data);
|
||||
|
@ -270,4 +270,4 @@ class ObjectModule {
|
|||
// }
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "gpencil_shader.hh"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
ShaderModule *ShaderModule::g_shader_module = nullptr;
|
||||
|
||||
|
@ -112,4 +112,4 @@ GPUShader *ShaderModule::static_shader_get(eShaderType shader_type)
|
|||
return shaders_[shader_type];
|
||||
}
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
#include "DRW_render.h"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
enum eShaderType {
|
||||
/* SMAA antialiasing */
|
||||
|
@ -62,4 +62,4 @@ class ShaderModule {
|
|||
const char *static_shader_create_info_name_get(eShaderType shader_type);
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
|
@ -17,7 +17,7 @@
|
|||
#include "gpencil_shader.hh"
|
||||
#include "gpencil_shader_shared.h"
|
||||
|
||||
namespace blender::gpencil {
|
||||
namespace blender::greasepencil {
|
||||
|
||||
using namespace draw;
|
||||
|
||||
|
@ -331,4 +331,4 @@ class VfxModule {
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace blender::gpencil
|
||||
} // namespace blender::greasepencil
|
||||
|
|
|
@ -31,14 +31,10 @@ struct GreasePencilBatchCache {
|
|||
/** Instancing Data */
|
||||
GPUVertBuf *vbo;
|
||||
GPUVertBuf *vbo_col;
|
||||
/** Indices in material order, then stroke order with fill first.
|
||||
* Strokes can be individually rendered using `gps->runtime.stroke_start` and
|
||||
* `gps->runtime.fill_start`. */
|
||||
/** Indices in material order, then stroke order with fill first. */
|
||||
filedescriptor marked this conversation as resolved
Outdated
Falk David
commented
Update this comment. Out of date. Update this comment. Out of date.
|
||||
GPUIndexBuf *ibo;
|
||||
/** Batches */
|
||||
GPUBatch *geom_batch;
|
||||
/** Stroke lines only */
|
||||
GPUBatch *lines_batch;
|
||||
|
||||
/** Cache is dirty. */
|
||||
bool is_dirty;
|
||||
|
@ -130,7 +126,6 @@ static void grease_pencil_batch_cache_clear(GreasePencil &grease_pencil)
|
|||
return;
|
||||
}
|
||||
|
||||
GPU_BATCH_DISCARD_SAFE(cache->lines_batch);
|
||||
GPU_BATCH_DISCARD_SAFE(cache->geom_batch);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->vbo);
|
||||
GPU_VERTBUF_DISCARD_SAFE(cache->vbo_col);
|
||||
|
|
|
@ -3087,7 +3087,7 @@ static int object_convert_exec(bContext *C, wmOperator *op)
|
|||
newob->data = new_grease_pencil;
|
||||
newob->type = OB_GREASE_PENCIL;
|
||||
|
||||
bke::gpencil::convert::legacy_gpencil_to_grease_pencil(*new_grease_pencil, *gpd);
|
||||
bke::greasepencil::convert::legacy_gpencil_to_grease_pencil(*new_grease_pencil, *gpd);
|
||||
|
||||
BKE_id_materials_copy(bmain, &gpd->id, &new_grease_pencil->id);
|
||||
|
||||
|
|
|
@ -652,6 +652,9 @@ static int gather_frames_to_render_for_id(LibraryIDLinkCallbackData *cb_data)
|
|||
* system that requires specific handling here. */
|
||||
gather_frames_to_render_for_grease_pencil(oglrender, (bGPdata *)id);
|
||||
break;
|
||||
case ID_GP:
|
||||
/* TODO: gather frames. */
|
||||
break;
|
||||
}
|
||||
|
||||
AnimData *adt = BKE_animdata_from_id(id);
|
||||
|
|
|
@ -31,11 +31,11 @@ namespace blender::ed::sculpt_paint {
|
|||
* \{ */
|
||||
|
||||
static bool start_brush_operation(bContext &C,
|
||||
wmOperator &op,
|
||||
wmOperator & /*op*/,
|
||||
PaintStroke *paint_stroke,
|
||||
const StrokeExtension &stroke_start)
|
||||
const StrokeExtension & /*stroke_start*/)
|
||||
{
|
||||
const BrushStrokeMode mode = static_cast<BrushStrokeMode>(RNA_enum_get(op.ptr, "mode"));
|
||||
// const BrushStrokeMode mode = static_cast<BrushStrokeMode>(RNA_enum_get(op.ptr, "mode"));
|
||||
|
||||
const Scene &scene = *CTX_data_scene(&C);
|
||||
const GpPaint &gp_paint = *scene.toolsettings->gp_paint;
|
||||
|
@ -44,7 +44,7 @@ static bool start_brush_operation(bContext &C,
|
|||
switch (brush.gpencil_tool) {
|
||||
case GPAINT_TOOL_DRAW:
|
||||
/* FIXME: Somehow store the unique_ptr in the PaintStroke. */
|
||||
operation = gpencil::new_paint_operation().release();
|
||||
operation = greasepencil::new_paint_operation().release();
|
||||
break;
|
||||
default:
|
||||
BLI_assert_unreachable();
|
||||
Sergey Sharybin
commented
I am not really sure what the goal is here. If the goal is to somehow ensure all cases are handled it is much better to not use I am not really sure what the goal is here. If the goal is to somehow ensure all cases are handled it is much better to not use `default` and let compiler tell you where cases are missing at the compile time.
|
||||
|
@ -85,7 +85,7 @@ static bool stroke_test_start(bContext *C, struct wmOperator *op, const float mo
|
|||
}
|
||||
|
||||
static void stroke_update_step(bContext *C,
|
||||
wmOperator *op,
|
||||
wmOperator * /*op*/,
|
||||
PaintStroke *stroke,
|
||||
PointerRNA *stroke_element)
|
||||
{
|
||||
|
@ -187,12 +187,12 @@ static void grease_pencil_draw_mode_enter(bContext *C)
|
|||
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
BKE_paint_ensure(scene->toolsettings, (Paint **)&scene->toolsettings->gp_paint);
|
||||
GpPaint *grease_pencil_paint = scene->toolsettings->gp_paint;
|
||||
// GpPaint *grease_pencil_paint = scene->toolsettings->gp_paint;
|
||||
|
||||
ob->mode = OB_MODE_PAINT_GPENCIL;
|
||||
|
||||
/* Setup cursor color. BKE_paint_init() could be used, but creates an additional brush. */
|
||||
Sergey Sharybin
commented
What's this commented out code is about? What's this commented out code is about?
|
||||
Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_GPENCIL);
|
||||
// Paint *paint = BKE_paint_get_active_from_paintmode(scene, PAINT_MODE_GPENCIL);
|
||||
// copy_v3_v3_uchar(paint->paint_cursor_col, PAINT_CURSOR_GREASE_PENCIL);
|
||||
// paint->paint_cursor_col[3] = 128;
|
||||
|
||||
|
|
|
@ -22,10 +22,10 @@ class GreasePencilStrokeOperation {
|
|||
virtual void on_stroke_done(const bContext &C) = 0;
|
||||
};
|
||||
|
||||
namespace gpencil {
|
||||
namespace greasepencil {
|
||||
|
||||
std::unique_ptr<GreasePencilStrokeOperation> new_paint_operation();
|
||||
|
||||
} // namespace gpencil
|
||||
} // namespace greasepencil
|
||||
|
||||
} // namespace blender::ed::sculpt_paint
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include "grease_pencil_intern.hh"
|
||||
|
||||
namespace blender::ed::sculpt_paint::gpencil {
|
||||
namespace blender::ed::sculpt_paint::greasepencil {
|
||||
|
||||
class PaintOperation : public GreasePencilStrokeOperation {
|
||||
|
||||
|
@ -33,9 +33,11 @@ class PaintOperation : public GreasePencilStrokeOperation {
|
|||
*/
|
||||
struct PaintOperationExecutor {
|
||||
|
||||
PaintOperationExecutor(const bContext &C) {}
|
||||
PaintOperationExecutor(const bContext & /*C*/) {}
|
||||
|
||||
void execute(PaintOperation &self, const bContext &C, const StrokeExtension &stroke_extension)
|
||||
void execute(PaintOperation & /*self*/,
|
||||
const bContext &C,
|
||||
const StrokeExtension &stroke_extension)
|
||||
{
|
||||
using namespace blender::bke;
|
||||
Depsgraph *depsgraph = CTX_data_depsgraph_pointer(&C);
|
||||
|
@ -45,7 +47,7 @@ struct PaintOperationExecutor {
|
|||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, obact);
|
||||
Hans Goudey
commented
It seems a bit weird to modifier the evaluated object here. Is that purposeful? Or am I missing something? It seems a bit weird to modifier the evaluated object here. Is that purposeful? Or am I missing something?
Falk David
commented
Yes, this is done on purpose so that the extra copy from orig to eval for rendering is not needed every update. Once drawing is done, the stroke is copied from the eval buffer to orig. Yes, this is done on purpose so that the extra copy from orig to eval for rendering is not needed every update. Once drawing is done, the stroke is copied from the eval buffer to orig.
Hans Goudey
commented
Okay, makes sense. This definitely deserves a comment, since typically changing the evaluated data isn't a good idea. Okay, makes sense. This definitely deserves a comment, since typically changing the evaluated data isn't a good idea.
|
||||
|
||||
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob_eval->data);
|
||||
const bke::gpencil::Layer *active_layer = grease_pencil.active_layer();
|
||||
const bke::greasepencil::Layer *active_layer = grease_pencil.active_layer();
|
||||
BLI_assert(active_layer != nullptr);
|
||||
int index = active_layer->drawing_at(scene->r.cfra);
|
||||
BLI_assert(index != -1);
|
||||
|
@ -81,8 +83,8 @@ void PaintOperation::on_stroke_done(const bContext &C)
|
|||
|
||||
GreasePencil &grease_pencil_orig = *static_cast<GreasePencil *>(obact->data);
|
||||
GreasePencil &grease_pencil_eval = *static_cast<GreasePencil *>(ob_eval->data);
|
||||
const bke::gpencil::Layer *active_layer_orig = grease_pencil_orig.active_layer();
|
||||
const bke::gpencil::Layer *active_layer_eval = grease_pencil_eval.active_layer();
|
||||
const bke::greasepencil::Layer *active_layer_orig = grease_pencil_orig.active_layer();
|
||||
const bke::greasepencil::Layer *active_layer_eval = grease_pencil_eval.active_layer();
|
||||
BLI_assert(active_layer_orig != nullptr && active_layer_eval != nullptr);
|
||||
int index_orig = active_layer_orig->drawing_at(scene->r.cfra);
|
||||
int index_eval = active_layer_eval->drawing_at(scene->r.cfra);
|
||||
|
@ -161,4 +163,4 @@ std::unique_ptr<GreasePencilStrokeOperation> new_paint_operation()
|
|||
return std::make_unique<PaintOperation>();
|
||||
}
|
||||
|
||||
} // namespace blender::ed::sculpt_paint::gpencil
|
||||
} // namespace blender::ed::sculpt_paint::greasepencil
|
|
@ -1,4 +1,5 @@
|
|||
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
/* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
* Copyright 2023 Blender Foundation. */
|
||||
|
||||
/** \file
|
||||
* \ingroup DNA
|
||||
|
@ -18,10 +19,10 @@ namespace blender::bke {
|
|||
class GreasePencilRuntime;
|
||||
class GreasePencilDrawingRuntime;
|
||||
struct StrokePoint;
|
||||
namespace gpencil {
|
||||
namespace greasepencil {
|
||||
class Layer;
|
||||
class LayerGroup;
|
||||
} // namespace gpencil
|
||||
} // namespace greasepencil
|
||||
} // namespace blender::bke
|
||||
using GreasePencilRuntimeHandle = blender::bke::GreasePencilRuntime;
|
||||
using GreasePencilDrawingRuntimeHandle = blender::bke::GreasePencilDrawingRuntime;
|
||||
|
@ -114,7 +115,7 @@ typedef struct GreasePencilFrame {
|
|||
} GreasePencilFrame;
|
||||
|
||||
/**
|
||||
* Storage for the Map in `blender::bke::gpencil::Layer`.
|
||||
* Storage for the Map in `blender::bke::greasepencil::Layer`.
|
||||
* See the description there for more detail.
|
||||
*/
|
||||
typedef struct GreasePencilLayerFramesMapStorage {
|
||||
|
@ -237,8 +238,8 @@ typedef struct GreasePencil {
|
|||
*/
|
||||
GreasePencilRuntimeHandle *runtime;
|
||||
#ifdef __cplusplus
|
||||
const blender::bke::gpencil::Layer *active_layer() const;
|
||||
blender::bke::gpencil::LayerGroup &root_group();
|
||||
const blender::bke::greasepencil::Layer *active_layer() const;
|
||||
blender::bke::greasepencil::LayerGroup &root_group();
|
||||
#endif
|
||||
} GreasePencil;
|
||||
|
||||
|
|
|
@ -484,6 +484,9 @@ StructRNA *ID_code_to_RNA_type(short idcode)
|
|||
return &RNA_Curve;
|
||||
case ID_GD_LEGACY:
|
||||
return &RNA_GreasePencil;
|
||||
case ID_GP:
|
||||
/* TODO. */
|
||||
break;
|
||||
case ID_GR:
|
||||
return &RNA_Collection;
|
||||
case ID_CV:
|
||||
Bastien Montagne
commented
Should not be ifdef'd Should not be ifdef'd
|
||||
|
|
|
@ -333,7 +333,7 @@ void RNA_def_main(BlenderRNA *brna)
|
|||
"GreasePencil",
|
||||
"rna_Main_gpencils_begin",
|
||||
"Grease Pencil (legacy)",
|
||||
"Grease Pencil data-blocks",
|
||||
"Grease Pencil (legacy) data-blocks",
|
||||
RNA_def_main_gpencil},
|
||||
{"movieclips",
|
||||
"MovieClip",
|
||||
|
|
Needs copyright.