Blender V5.3
blender::bke::greasepencil::Layer Class Reference

#include <BKE_grease_pencil.hh>

Inherits blender::GreasePencilLayer.

Public Types

using SortedKeysIterator = const int *

Public Member Functions

 Layer ()
 Layer (StringRef name)
 Layer (const Layer &other)
 ~Layer ()
const TreeNode & as_node () const
TreeNode & as_node ()
const LayerGroup & parent_group () const
LayerGroup & parent_group ()
const Map< FramesMapKeyT, GreasePencilFrame > & frames () const
Map< FramesMapKeyT, GreasePencilFrame > & frames_for_write ()
bool is_empty () const
GreasePencilFrame * add_frame (FramesMapKeyT key, int duration=0)
bool remove_frame (FramesMapKeyT key)
Span< FramesMapKeyT > sorted_keys () const
int drawing_index_at (const int frame_number) const
bool has_drawing_at (const int frame_number) const
std::optional< int > start_frame_at (int frame_number) const
int sorted_keys_index_at (int frame_number) const
SortedKeysIterator sorted_keys_iterator_at (int frame_number) const
const GreasePencilFrame * frame_at (const int frame_number) const
GreasePencilFrame * frame_at (const int frame_number)
int get_frame_duration_at (const int frame_number) const
void tag_frames_map_changed ()
void tag_frames_map_keys_changed ()
void prepare_for_dna_write ()
void update_from_dna_read ()
float4x4 parent_inverse () const
float4x4 local_transform () const
void set_local_transform (const float4x4 &transform)
float4x4 to_object_space (const Object &object) const
float4x4 to_world_space (const Object &object) const
StringRefNull parent_bone_name () const
void set_parent_bone_name (StringRef new_name)
StringRefNull view_layer_name () const
void set_view_layer_name (StringRef new_name)

Public Attributes

 TREENODE_COMMON_METHODS
Public Attributes inherited from blender::GreasePencilLayer
GreasePencilLayerTreeNode base
GreasePencilLayerFramesMapStorage frames_storage
GreasePencilLayerBlendMode blend_mode = GP_LAYER_BLEND_NONE
char _pad [3] = {}
float opacity = 0
ListBaseT< GreasePencilLayerMask > masks = {nullptr, nullptr}
int active_mask_index = 0
char _pad2 [4] = {}
struct Object * parent = nullptr
char * parsubstr = nullptr
float parentinv [4][4] = {}
float translation [3] = {}
float rotation [3] = {}
float scale [3] = {1.0f, 1.0f, 1.0f}
char _pad3 [4] = {}
char * viewlayername = nullptr
bke::greasepencil::LayerRuntime * runtime = nullptr

Detailed Description

A layer maps drawings to scene frames. It can be thought of as one independent channel in the timeline.

Definition at line 521 of file BKE_grease_pencil.hh.

Member Typedef Documentation

◆ SortedKeysIterator

Constructor & Destructor Documentation

◆ Layer() [1/3]

◆ Layer() [2/3]

blender::bke::greasepencil::Layer::Layer ( StringRef name)
explicit

◆ Layer() [3/3]

◆ ~Layer()

Member Function Documentation

◆ add_frame()

GreasePencilFrame * blender::bke::greasepencil::Layer::add_frame ( FramesMapKeyT key,
int duration = 0 )

Adds a new frame into the layer frames map. Fails if there already exists a frame at key that is not an end-frame. End-frame at key and subsequent end-frames are removed.

If duration is 0, the frame is marked as an implicit hold (see GP_FRAME_IMPLICIT_HOLD). Otherwise adds an additional end-frame at key + duration, if necessary, to indicate the end of the added frame.

Returns
a pointer to the added frame on success, otherwise nullptr.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1741 of file grease_pencil.cc.

References blender::Span< T >::begin(), blender::BLI_assert(), blender::Span< T >::end(), blender::GreasePencilFrame::flag, frames_for_write(), blender::GP_FRAME_IMPLICIT_HOLD, sorted_keys(), and tag_frames_map_keys_changed().

Referenced by blender::bke::greasepencil::tests::TEST_F(), blender::bke::greasepencil::tests::TEST_F(), blender::bke::greasepencil::tests::TEST_F(), blender::bke::greasepencil::tests::TEST_F(), and blender::bke::greasepencil::tests::TEST_F().

◆ as_node() [1/2]

TreeNode & blender::bke::greasepencil::Layer::as_node ( )
inline

Definition at line 959 of file BKE_grease_pencil.hh.

◆ as_node() [2/2]

◆ drawing_index_at()

int blender::bke::greasepencil::Layer::drawing_index_at ( const int frame_number) const
Returns
the index of the active drawing at frame frame_number or -1 if there is no drawing. TODO: This should be a private API!
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1916 of file grease_pencil.cc.

References blender::GreasePencilFrame::drawing_index, and frame_at().

Referenced by blender::ed::greasepencil::merge_layers(), blender::bke::greasepencil::tests::TEST_F(), and blender::bke::greasepencil::tests::TEST_F().

◆ frame_at() [1/2]

GreasePencilFrame * blender::bke::greasepencil::Layer::frame_at ( const int frame_number)

Definition at line 1896 of file grease_pencil.cc.

References frames_for_write().

◆ frame_at() [2/2]

const GreasePencilFrame * blender::bke::greasepencil::Layer::frame_at ( const int frame_number) const

◆ frames()

◆ frames_for_write()

◆ get_frame_duration_at()

int blender::bke::greasepencil::Layer::get_frame_duration_at ( const int frame_number) const
Returns
the frame duration of the keyframe at frame_number. If there is no keyframe at frame_number
-1. If the keyframe is an implicit hold,
0.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1927 of file grease_pencil.cc.

References blender::math::distance(), frames(), sorted_keys(), and sorted_keys_iterator_at().

Referenced by blender::bke::greasepencil::tests::TEST_F().

◆ has_drawing_at()

bool blender::bke::greasepencil::Layer::has_drawing_at ( const int frame_number) const
Returns
true if there is a drawing on this layer at frame_number.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1922 of file grease_pencil.cc.

References frame_at().

◆ is_empty()

bool blender::bke::greasepencil::Layer::is_empty ( ) const
inline
Returns
true, if the layer contains no keyframes.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 965 of file BKE_grease_pencil.hh.

References frames(), and is_empty().

Referenced by is_empty().

◆ local_transform()

◆ parent_bone_name()

StringRefNull blender::bke::greasepencil::Layer::parent_bone_name ( ) const

Returns the name of the parent bone. Should only be used in case the parent object is an armature.

Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 2023 of file grease_pencil.cc.

References blender::GreasePencilLayer::parsubstr, and blender::StringRefNull::StringRefNull().

◆ parent_group() [1/2]

LayerGroup & blender::bke::greasepencil::Layer::parent_group ( )
inline

◆ parent_group() [2/2]

const LayerGroup & blender::bke::greasepencil::Layer::parent_group ( ) const
inline

◆ parent_inverse()

float4x4 blender::bke::greasepencil::Layer::parent_inverse ( ) const

◆ prepare_for_dna_write()

◆ remove_frame()

bool blender::bke::greasepencil::Layer::remove_frame ( FramesMapKeyT key)

Removes a frame with key from the frames map.

Fails if the map does not contain a frame with key or in the specific case where the previous frame has a fixed duration (is not marked as an implicit hold) and the frame to remove is an end frame.

Will remove end frame(s) after the frame to remove.

Returns
true on success.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1772 of file grease_pencil.cc.

References blender::Span< T >::begin(), blender::Span< T >::end(), frames(), frames_for_write(), sorted_keys(), tag_frames_map_changed(), and tag_frames_map_keys_changed().

◆ set_local_transform()

void blender::bke::greasepencil::Layer::set_local_transform ( const float4x4 & transform)

◆ set_parent_bone_name()

◆ set_view_layer_name()

◆ sorted_keys()

◆ sorted_keys_index_at()

int blender::bke::greasepencil::Layer::sorted_keys_index_at ( int frame_number) const
Returns
the index of the key of the active frame in sorted_keys or -1 if no such frame exists.
Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1867 of file grease_pencil.cc.

References blender::begin(), sorted_keys(), and sorted_keys_iterator_at().

◆ sorted_keys_iterator_at()

Layer::SortedKeysIterator blender::bke::greasepencil::Layer::sorted_keys_iterator_at ( int frame_number) const

◆ start_frame_at()

◆ tag_frames_map_changed()

◆ tag_frames_map_keys_changed()

void blender::bke::greasepencil::Layer::tag_frames_map_keys_changed ( )

Should be called whenever the keys in the frames map have changed. E.g. when new keys were added, removed or updated.

Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 1957 of file grease_pencil.cc.

References blender::GreasePencilLayer::runtime, blender::bke::greasepencil::LayerRuntime::sorted_keys_cache_, and tag_frames_map_changed().

Referenced by add_frame(), and remove_frame().

◆ to_object_space()

float4x4 blender::bke::greasepencil::Layer::to_object_space ( const Object & object) const

◆ to_world_space()

◆ update_from_dna_read()

◆ view_layer_name()

StringRefNull blender::bke::greasepencil::Layer::view_layer_name ( ) const

Returns the view layer name that this layer should be rendered in or an empty StringRefNull if no such name is set.

Examples
/usr/src/RPM/BUILD/blender5.3-5.3.0/source/blender/blenkernel/BKE_grease_pencil.hh.

Definition at line 2071 of file grease_pencil.cc.

References blender::StringRefNull::StringRefNull(), and blender::GreasePencilLayer::viewlayername.

Member Data Documentation

◆ TREENODE_COMMON_METHODS

blender::bke::greasepencil::Layer::TREENODE_COMMON_METHODS

Definition at line 531 of file BKE_grease_pencil.hh.


The documentation for this class was generated from the following files: