GPv3: Add view layer name property
This adds the `viewlayername` property to grease pencil v3 layers. It's exposed as `viewlayer_render` in python. Note: this is not used in the renderer yet. Will be used in a following PR. Pull Request: https://projects.blender.org/blender/blender/pulls/119422
This commit is contained in:
parent
ecffea86b1
commit
a07a558ac5
|
@ -149,6 +149,9 @@ class DATA_PT_grease_pencil_layer_relations(LayerDataButtonsPanel, Panel):
|
|||
col = layout.row(align=True)
|
||||
col.prop(layer, "pass_index")
|
||||
|
||||
col = layout.row(align=True)
|
||||
col.prop_search(layer, "viewlayer_render", context.scene, "view_layers", text="View Layer")
|
||||
|
||||
|
||||
class DATA_PT_grease_pencil_custom_props(DataButtonsPanel, PropertyPanel, Panel):
|
||||
_context_path = "object.data"
|
||||
|
|
|
@ -456,6 +456,13 @@ class Layer : public ::GreasePencilLayer {
|
|||
StringRefNull parent_bone_name() const;
|
||||
void set_parent_bone_name(const char *new_name);
|
||||
|
||||
/**
|
||||
* Returns the view layer name that this layer should be rendered in or an empty
|
||||
* `StringRefNull` if no such name is set.
|
||||
*/
|
||||
StringRefNull view_layer_name() const;
|
||||
void set_view_layer_name(const char *new_name);
|
||||
|
||||
private:
|
||||
using SortedKeysIterator = const int *;
|
||||
|
||||
|
|
|
@ -672,6 +672,8 @@ Layer::Layer()
|
|||
zero_v3(this->rotation);
|
||||
copy_v3_fl(this->scale, 1.0f);
|
||||
|
||||
this->viewlayername = nullptr;
|
||||
|
||||
BLI_listbase_clear(&this->masks);
|
||||
|
||||
this->runtime = MEM_new<LayerRuntime>(__func__);
|
||||
|
@ -698,6 +700,8 @@ Layer::Layer(const Layer &other) : Layer()
|
|||
copy_v3_v3(this->rotation, other.rotation);
|
||||
copy_v3_v3(this->scale, other.scale);
|
||||
|
||||
this->set_view_layer_name(other.viewlayername);
|
||||
|
||||
/* Note: We do not duplicate the frame storage since it is only needed for writing to file. */
|
||||
this->runtime->frames_ = other.runtime->frames_;
|
||||
this->runtime->sorted_keys_cache_ = other.runtime->sorted_keys_cache_;
|
||||
|
@ -720,6 +724,7 @@ Layer::~Layer()
|
|||
}
|
||||
|
||||
MEM_SAFE_FREE(this->parsubstr);
|
||||
MEM_SAFE_FREE(this->viewlayername);
|
||||
|
||||
MEM_delete(this->runtime);
|
||||
this->runtime = nullptr;
|
||||
|
@ -1015,6 +1020,19 @@ float4x4 Layer::local_transform() const
|
|||
float3(this->translation), float3(this->rotation), float3(this->scale));
|
||||
}
|
||||
|
||||
StringRefNull Layer::view_layer_name() const
|
||||
{
|
||||
return (this->viewlayername != nullptr) ? StringRefNull(this->viewlayername) : StringRefNull();
|
||||
}
|
||||
|
||||
void Layer::set_view_layer_name(const char *new_name)
|
||||
{
|
||||
if (this->viewlayername != nullptr) {
|
||||
MEM_freeN(this->viewlayername);
|
||||
}
|
||||
this->viewlayername = BLI_strdup_null(new_name);
|
||||
}
|
||||
|
||||
LayerGroup::LayerGroup()
|
||||
{
|
||||
new (&this->base) TreeNode(GP_LAYER_TREE_GROUP);
|
||||
|
@ -2680,6 +2698,7 @@ static void read_layer(BlendDataReader *reader,
|
|||
BLO_read_data_address(reader, &node->base.name);
|
||||
node->base.parent = parent;
|
||||
BLO_read_data_address(reader, &node->parsubstr);
|
||||
BLO_read_data_address(reader, &node->viewlayername);
|
||||
|
||||
/* Read frames storage. */
|
||||
BLO_read_int32_array(reader, node->frames_storage.num, &node->frames_storage.keys);
|
||||
|
@ -2748,6 +2767,7 @@ static void write_layer(BlendWriter *writer, GreasePencilLayer *node)
|
|||
BLO_write_struct(writer, GreasePencilLayer, node);
|
||||
BLO_write_string(writer, node->base.name);
|
||||
BLO_write_string(writer, node->parsubstr);
|
||||
BLO_write_string(writer, node->viewlayername);
|
||||
|
||||
BLO_write_int32_array(writer, node->frames_storage.num, node->frames_storage.keys);
|
||||
BLO_write_struct_array(
|
||||
|
|
|
@ -436,6 +436,8 @@ void legacy_gpencil_to_grease_pencil(Main &bmain, GreasePencil &grease_pencil, b
|
|||
copy_v3_v3(new_layer.rotation, gpl->rotation);
|
||||
copy_v3_v3(new_layer.scale, gpl->scale);
|
||||
|
||||
new_layer.set_view_layer_name(gpl->viewlayername);
|
||||
|
||||
/* Convert the layer masks. */
|
||||
LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl->mask_layers) {
|
||||
LayerMask *new_mask = MEM_new<LayerMask>(mask->name);
|
||||
|
|
|
@ -303,6 +303,8 @@ typedef struct GreasePencilLayer {
|
|||
*/
|
||||
float translation[3], rotation[3], scale[3];
|
||||
char _pad2[4];
|
||||
/** Name of the view layer used to filter render output. */
|
||||
char *viewlayername;
|
||||
/**
|
||||
* Runtime struct pointer.
|
||||
*/
|
||||
|
|
|
@ -325,6 +325,13 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
|
|||
RNA_def_property_ui_range(prop, -FLT_MAX, FLT_MAX, 1, 3);
|
||||
RNA_def_property_ui_text(prop, "Scale", "Scale of the layer");
|
||||
RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_grease_pencil_update");
|
||||
|
||||
prop = RNA_def_property(srna, "viewlayer_render", PROP_STRING, PROP_NONE);
|
||||
RNA_def_property_string_sdna(prop, nullptr, "viewlayername");
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"ViewLayer",
|
||||
"Only include Layer in this View Layer render output (leave blank to include always)");
|
||||
}
|
||||
|
||||
static void rna_def_grease_pencil_layers_api(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
|
|
Loading…
Reference in New Issue