This Map maps a scene frame number (key) to a GreasePencilFrame. This struct holds an index (drawing_index) to the drawing in the GreasePencil->drawings array. The frame number indicates the first frame the drawing is shown. The end time is implicitly defined by the next greater frame number (key) in the map. If the value mapped to (index) is -1, no drawing is shown at this frame. Frames with such a value are GreasePencilFrame::end() in the code.
In this example there are three drawings (drawing #0, drawing #1 and drawing #2). The first drawing starts at frame 0 and ends at frame 5 (exclusive). The second drawing starts at frame 5 and ends at frame 10. Finally, the third drawing starts at frame 12 and ends at frame 16.
#pragma once
#include <atomic>
struct Brush;
struct Depsgraph;
struct Main;
struct GreasePencilBatchCache;
};
namespace bke::bake {
struct BakeMaterialsList;
}
namespace bke {
struct AttributeAccessorFunctions;
namespace greasepencil {
struct FillCache {
};
struct TriangleCache {
};
class DrawingRuntime {
public:
mutable SharedCache<std::optional<FillCache>>
fill_cache;
};
public:
const bke::CurvesGeometry &
strokes()
const;
std::optional<GroupedSpan<int>>
fills()
const;
std::optional<GroupedSpan<int3>>
triangles()
const;
VArray<float>
radii()
const;
};
public:
};
MutableSpan<GreasePencilDrawingBase *> dst_drawings);
class LayerGroup;
class Layer;
#define TREENODE_COMMON_METHODS \
StringRefNull name() const; \
void set_name(StringRef new_name); \
bool is_visible() const; \
void set_visible(bool visible); \
bool is_locked() const; \
void set_locked(bool locked); \
bool is_editable() const; \
bool is_selected() const; \
void set_selected(bool selected); \
bool use_onion_skinning() const; \
bool use_masks() const; \
bool ignore_locked_materials() const; \
bool is_child_of(const LayerGroup &group) const;
#define TREENODE_COMMON_METHODS_FORWARD_IMPL(class_name) \
inline StringRefNull class_name::name() const \
{ \
return this->as_node().name(); \
} \
inline void class_name::set_name(const StringRef new_name) \
{ \
return this->as_node().set_name(new_name); \
} \
inline bool class_name::is_visible() const \
{ \
return this->as_node().is_visible(); \
} \
inline void class_name::set_visible(const bool visible) \
{ \
this->as_node().set_visible(visible); \
} \
inline bool class_name::is_locked() const \
{ \
return this->as_node().is_locked(); \
} \
inline void class_name::set_locked(const bool locked) \
{ \
this->as_node().set_locked(locked); \
} \
inline bool class_name::is_editable() const \
{ \
return this->as_node().is_editable(); \
} \
inline bool class_name::is_selected() const \
{ \
return this->as_node().is_selected(); \
} \
inline void class_name::set_selected(const bool selected) \
{ \
this->as_node().set_selected(selected); \
} \
inline bool class_name::use_onion_skinning() const \
{ \
return this->as_node().use_onion_skinning(); \
} \
inline bool class_name::use_masks() const \
{ \
return this->as_node().use_masks(); \
} \
inline bool class_name::ignore_locked_materials() const \
{ \
return this->as_node().ignore_locked_materials(); \
} \
inline bool class_name::is_child_of(const LayerGroup &group) const \
{ \
return this->as_node().is_child_of(group); \
}
public:
public:
};
public:
};
struct LayerTransformData {
};
class LayerRuntime {
public:
Map<FramesMapKeyT, GreasePencilFrame>
frames_;
public:
};
public:
explicit Layer(StringRef name);
const Map<FramesMapKeyT, GreasePencilFrame> &
frames()
const;
const GreasePencilFrame *
frame_at(
const int frame_number)
const;
GreasePencilFrame *
frame_at(
const int frame_number);
private:
std::optional<FramesMapKeyT> frame_key_at(int frame_number) const;
GreasePencilFrame *add_frame_internal(int frame_number);
};
class LayerGroupRuntime {
public:
};
public:
public:
protected:
bool unlink_node(TreeNode &link,
bool keep_children =
false);
private:
void ensure_nodes_cache() const;
void tag_nodes_cache_dirty() const;
};
{
}
{
}
{
}
{
}
{
}
{
}
{
}
inline bool TreeNode::is_visible() const
{
}
inline void TreeNode::set_visible(const bool visible)
{
}
inline bool TreeNode::is_locked() const
{
}
inline void TreeNode::set_locked(const bool locked)
{
}
inline bool TreeNode::is_editable() const
{
return this->is_visible() && !this->is_locked();
}
inline bool TreeNode::is_selected() const
{
}
inline void TreeNode::set_selected(const bool selected)
{
}
inline bool TreeNode::use_onion_skinning() const
{
}
inline bool TreeNode::use_masks() const
{
}
inline bool TreeNode::ignore_locked_materials() const
{
}
inline bool TreeNode::is_child_of(const LayerGroup &group) const
{
return true;
}
return parent->is_child_of(group);
}
return false;
}
{
}
{
return *reinterpret_cast<const TreeNode *>(this);
}
{
return *reinterpret_cast<TreeNode *>(this);
}
{
return *reinterpret_cast<const TreeNode *>(this);
}
{
return *reinterpret_cast<TreeNode *>(this);
}
{
}
{
}
{
}
}
class GreasePencilRuntime {
public:
public:
};
class GreasePencilDrawingEditHints {
public:
std::optional<Span<float3>>
positions()
const;
};
class GreasePencilEditHints {
public:
{
}
std::optional<Array<GreasePencilDrawingEditHints>>
drawing_hints;
};
}
inline bke::greasepencil::Drawing &GreasePencilDrawing::wrap()
{
return *reinterpret_cast<bke::greasepencil::Drawing *>(this);
}
inline const bke::greasepencil::Drawing &GreasePencilDrawing::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::Drawing *>(this);
}
inline bke::greasepencil::DrawingReference &GreasePencilDrawingReference::wrap()
{
return *reinterpret_cast<bke::greasepencil::DrawingReference *>(this);
}
inline const bke::greasepencil::DrawingReference &GreasePencilDrawingReference::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::DrawingReference *>(this);
}
inline GreasePencilFrame GreasePencilFrame::end()
{
return GreasePencilFrame{-1, {}, 0};
}
inline bool GreasePencilFrame::is_end() const
{
}
inline bool GreasePencilFrame::is_implicit_hold() const
{
}
inline bool GreasePencilFrame::is_selected() const
{
}
inline bke::greasepencil::TreeNode &GreasePencilLayerTreeNode::wrap()
{
return *reinterpret_cast<bke::greasepencil::TreeNode *>(this);
}
inline const bke::greasepencil::TreeNode &GreasePencilLayerTreeNode::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::TreeNode *>(this);
}
inline bke::greasepencil::Layer &GreasePencilLayer::wrap()
{
return *reinterpret_cast<bke::greasepencil::Layer *>(this);
}
inline const bke::greasepencil::Layer &GreasePencilLayer::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::Layer *>(this);
}
inline bke::greasepencil::LayerMask &GreasePencilLayerMask::wrap()
{
return *reinterpret_cast<bke::greasepencil::LayerMask *>(this);
}
inline const bke::greasepencil::LayerMask &GreasePencilLayerMask::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::LayerMask *>(this);
}
inline bke::greasepencil::LayerGroup &GreasePencilLayerTreeGroup::wrap()
{
return *reinterpret_cast<bke::greasepencil::LayerGroup *>(this);
}
inline const bke::greasepencil::LayerGroup &GreasePencilLayerTreeGroup::wrap() const
{
return *reinterpret_cast<const bke::greasepencil::LayerGroup *>(this);
}
inline const GreasePencilDrawingBase *GreasePencil::drawing(
const int64_t index)
const
{
return this->drawings()[
index];
}
inline GreasePencilDrawingBase *GreasePencil::drawing(
const int64_t index)
{
return this->drawings()[
index];
}
inline const bke::greasepencil::Layer &GreasePencil::layer(
const int64_t index)
const
{
return *this->layers()[
index];
}
inline bke::greasepencil::Layer &GreasePencil::layer(
const int64_t index)
{
return *this->layers_for_write()[
index];
}
inline const bke::greasepencil::LayerGroup &GreasePencil::root_group() const
{
return this->root_group_ptr->wrap();
}
inline bke::greasepencil::LayerGroup &GreasePencil::root_group()
{
return this->root_group_ptr->wrap();
}
inline bool GreasePencil::has_active_layer() const
{
return (this->active_node != nullptr) && (this->active_node->wrap().is_layer());
}
inline bool GreasePencil::has_active_group() const
{
return (this->active_node != nullptr) && (this->active_node->wrap().is_group());
}
bke::greasepencil::Layer &dst);
bke::greasepencil::LayerGroup &dst);
GreasePencil *grease_pencil_dst);
GreasePencil *grease_pencil_dst);
MutableSpan<float3> all_positions,
MutableSpan<float> all_radii);
const char *name,
int *r_index);
const char *name,
int *r_index);
Brush *brush);
Brush *brush);
}
#define TREENODE_COMMON_METHODS_FORWARD_IMPL(class_name)
#define TREENODE_COMMON_METHODS
#define SET_FLAG_FROM_TEST(value, test, flag)
SIMD_FORCE_INLINE btVector3 transform(const btVector3 &point) const
btGeneric6DofConstraint & operator=(btGeneric6DofConstraint &other)
constexpr StringRefNull()
std::optional< MutableSpan< float3 > > positions_for_write()
const greasepencil::Drawing * drawing_orig
std::optional< Span< float3 > > positions() const
ImplicitSharingPtrAndData positions_data
std::optional< Array< float3x3 > > deform_mats
GreasePencilEditHints(const GreasePencil &grease_pencil_id_orig)
const GreasePencil & grease_pencil_id_orig
std::optional< Array< GreasePencilDrawingEditHints > > drawing_hints
draw::GreasePencilBatchCache * batch_cache
std::unique_ptr< bake::BakeMaterialsList > bake_materials
SharedCache< std::optional< FillCache > > fill_cache
SharedCache< Vector< float3 > > curve_plane_normals_cache
SharedCache< Vector< float4x2 > > curve_texture_matrices
SharedCache< std::optional< TriangleCache > > triangle_cache
std::atomic< int > user_count
VArray< ColorGeometry4f > vertex_colors() const
Span< float3 > curve_plane_normals() const
std::optional< GroupedSpan< int > > fills() const
MutableSpan< float > opacities_for_write()
Span< float4x2 > texture_matrices() const
MutableSpan< float > radii_for_write()
bke::CurvesGeometry & strokes_for_write()
void tag_triangles_changed()
const bke::CurvesGeometry & strokes() const
VArray< float > radii() const
void tag_positions_changed()
void tag_texture_matrices_changed()
std::optional< GroupedSpan< int3 > > triangles() const
bool is_instanced() const
void tag_topology_changed()
VArray< ColorGeometry4f > fill_colors() const
VArray< float > opacities() const
MutableSpan< ColorGeometry4f > fill_colors_for_write()
MutableSpan< ColorGeometry4f > vertex_colors_for_write()
void set_texture_matrices(Span< float4x2 > matrices, const IndexMask &selection)
GroupedSpan< float3 > intersection_points() const
Vector< LayerGroup * > layer_group_cache_
Vector< Layer * > layer_cache_
bool is_visibility_animated_
Vector< TreeNode * > nodes_cache_
CacheMutex nodes_cache_mutex_
void move_node_top(TreeNode &node)
void prepare_for_dna_write()
void set_expanded(bool expanded)
TreeNode & add_node(TreeNode &node)
void move_node_down(TreeNode &node, int step=1)
void move_node_bottom(TreeNode &node)
bool unlink_node(TreeNode &link, bool keep_children=false)
const TreeNode & as_node() const
int64_t num_direct_nodes() const
int64_t num_nodes_total() const
Span< TreeNode * > nodes_for_write()
const TreeNode * find_node_by_name(StringRef name) const
Span< const Layer * > layers() const
void update_from_dna_read()
Span< Layer * > layers_for_write()
void add_node_before(TreeNode &node, TreeNode &link)
void add_node_after(TreeNode &node, TreeNode &link)
void move_node_up(TreeNode &node, int step=1)
void print_nodes(StringRef header) const
Span< const LayerGroup * > groups() const
Span< LayerGroup * > groups_for_write()
Span< const TreeNode * > nodes() const
SharedCache< Vector< FramesMapKeyT > > sorted_keys_cache_
Map< FramesMapKeyT, GreasePencilFrame > frames_
LayerTransformData trans_data_
bool is_visibility_animated_
Vector< LayerMask > masks_
SortedKeysIterator sorted_keys_iterator_at(int frame_number) const
StringRefNull parent_bone_name() const
int sorted_keys_index_at(int frame_number) const
float4x4 to_world_space(const Object &object) const
StringRefNull view_layer_name() const
void set_local_transform(const float4x4 &transform)
void set_view_layer_name(StringRef new_name)
void tag_frames_map_keys_changed()
bool remove_frame(FramesMapKeyT key)
const Map< FramesMapKeyT, GreasePencilFrame > & frames() const
float4x4 local_transform() const
GreasePencilFrame * add_frame(FramesMapKeyT key, int duration=0)
const TreeNode & as_node() const
const GreasePencilFrame * frame_at(const int frame_number) const
void tag_frames_map_changed()
bool has_drawing_at(const int frame_number) const
const int * SortedKeysIterator
int drawing_index_at(const int frame_number) const
int get_frame_duration_at(const int frame_number) const
std::optional< int > start_frame_at(int frame_number) const
float4x4 to_object_space(const Object &object) const
void update_from_dna_read()
Span< FramesMapKeyT > sorted_keys() const
float4x4 parent_inverse() const
void prepare_for_dna_write()
const LayerGroup & parent_group() const
Map< FramesMapKeyT, GreasePencilFrame > & frames_for_write()
void set_parent_bone_name(StringRef new_name)
const TreeNode * parent_node() const
const LayerGroup & as_group() const
const Layer & as_layer() const
const LayerGroup * parent_group() const
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void ensure_non_empty_layer_names(Main &bmain, GreasePencil &grease_pencil)
constexpr float LEGACY_RADIUS_CONVERSION_FACTOR
const AttributeAccessorFunctions & get_attribute_accessor_functions()
void copy_drawing_array(Span< const GreasePencilDrawingBase * > src_drawings, MutableSpan< GreasePencilDrawingBase * > dst_drawings)
@ GP_LAYER_TREE_NODE_HIDE_ONION_SKINNING
@ GP_LAYER_TREE_NODE_HIDE
@ GP_LAYER_TREE_NODE_LOCKED
@ GP_LAYER_TREE_NODE_IGNORE_LOCKED_MATERIALS
@ GP_LAYER_TREE_NODE_SELECT
@ GP_LAYER_TREE_NODE_HIDE_MASKS
bool BKE_grease_pencil_has_curve_with_type(const GreasePencil &grease_pencil, CurveType type)
void BKE_object_eval_grease_pencil(Depsgraph *depsgraph, Scene *scene, Object *object)
GreasePencil * BKE_grease_pencil_copy_for_eval(const GreasePencil *grease_pencil_src)
void BKE_grease_pencil_copy_layer_group_parameters(const bke::greasepencil::LayerGroup &src, bke::greasepencil::LayerGroup &dst)
bool BKE_grease_pencil_drawing_attribute_required(const GreasePencilDrawing *, StringRef name)
void BKE_grease_pencil_point_coords_get(const GreasePencil &grease_pencil, MutableSpan< float3 > all_positions, MutableSpan< float > all_radii)
void BKE_grease_pencil_copy_layer_parameters(const bke::greasepencil::Layer &src, bke::greasepencil::Layer &dst)
GreasePencil * BKE_grease_pencil_add(Main *bmain, const char *name)
bool BKE_grease_pencil_material_index_used(GreasePencil *grease_pencil, int index)
void BKE_grease_pencil_point_coords_apply_with_mat4(GreasePencil &grease_pencil, Span< float3 > all_positions, Span< float > all_radii, const float4x4 &mat)
Material * BKE_grease_pencil_object_material_new(Main *bmain, Object *ob, const char *name, int *r_index)
void BKE_grease_pencil_eval_geometry(Depsgraph *depsgraph, GreasePencil *grease_pencil)
void BKE_grease_pencil_nomain_to_grease_pencil(GreasePencil *grease_pencil_src, GreasePencil *grease_pencil_dst)
void BKE_grease_pencil_duplicate_drawing_array(const GreasePencil *grease_pencil_src, GreasePencil *grease_pencil_dst)
int BKE_grease_pencil_object_material_index_get_by_name(Object *ob, const char *name)
void BKE_grease_pencil_brush_material_set(struct Brush *brush, struct Material *material)
void BKE_grease_pencil_material_index_remove(GreasePencil *grease_pencil, int index)
void BKE_grease_pencil_copy_parameters(const GreasePencil &src, GreasePencil &dst)
Material * BKE_grease_pencil_object_material_ensure_by_name(Main *bmain, Object *ob, const char *name, int *r_index)
void BKE_grease_pencil_vgroup_name_update(Object *ob, const char *old_name, const char *new_name)
bool BKE_grease_pencil_references_cyclic_check(const GreasePencil *id_reference, const GreasePencil *grease_pencil)
void BKE_grease_pencil_point_coords_apply(GreasePencil &grease_pencil, Span< float3 > all_positions, Span< float > all_radii)
Material * BKE_grease_pencil_object_material_from_brush_get(Object *ob, const Brush *brush)
Material * BKE_grease_pencil_object_material_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
void BKE_grease_pencil_material_remap(GreasePencil *grease_pencil, const uint *remap, int totcol)
GreasePencilLayerTreeNodeType
GreasePencil * BKE_grease_pencil_new_nomain()
int BKE_grease_pencil_stroke_point_count(const GreasePencil &grease_pencil)
Material * BKE_grease_pencil_object_material_alt_ensure_from_brush(Main *bmain, Object *ob, Brush *brush)
void BKE_grease_pencil_palette_ensure(Main *bmain, Scene *scene)
bke::greasepencil::DrawingRuntime * runtime
GreasePencilFrameFlag flag
GreasePencilLayerTreeNodeType type
GreasePencilLayerTreeNodeFlag flag
struct GreasePencilLayerTreeGroup * parent
Vector< int > fill_offsets
Vector< float3 > intersection_points
Vector< int > intersection_point_offsets
Vector< int > triangle_offsets