Merge branch 'blender-v4.3-release'

This commit is contained in:
Omar Emara
2024-10-22 11:54:27 +03:00
5 changed files with 80 additions and 2 deletions

View File

@@ -1062,7 +1062,10 @@ static void legacy_gpencil_to_grease_pencil(ConversionData &conversion_data,
new_layer.parent = gpl->parent;
new_layer.set_parent_bone_name(gpl->parsubstr);
copy_m4_m4(new_layer.parentinv, gpl->inverse);
/* GPv2 parent inverse matrix is only valid when parent is set. */
if (gpl->parent) {
copy_m4_m4(new_layer.parentinv, gpl->inverse);
}
copy_v3_v3(new_layer.translation, gpl->location);
copy_v3_v3(new_layer.rotation, gpl->rotation);

View File

@@ -6,8 +6,13 @@
* \ingroup edgreasepencil
*/
#include "BLI_math_matrix.h"
#include "BLI_math_matrix.hh"
#include "BLI_string.h"
#include "BKE_context.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_object.hh"
#include "BKE_report.hh"
#include "BLT_translation.hh"
@@ -18,6 +23,7 @@
#include "RNA_access.hh"
#include "RNA_define.hh"
#include "UI_interface.hh"
#include "DNA_scene_types.h"
@@ -26,6 +32,43 @@
namespace blender::ed::greasepencil {
bool grease_pencil_layer_parent_set(bke::greasepencil::Layer &layer,
Object *parent,
StringRefNull bone,
const bool keep_transform)
{
if (keep_transform) {
/* TODO apply current transform to geometry. */
}
layer.parent = parent;
BLI_strncpy(layer.parsubstr, bone.c_str(), sizeof(layer.parsubstr));
/* Calculate inverse parent matrix. */
if (parent) {
copy_m4_m4(layer.parentinv, parent->world_to_object().ptr());
}
else {
unit_m4(layer.parentinv);
}
return true;
}
void grease_pencil_layer_parent_clear(bke::greasepencil::Layer &layer, const bool keep_transform)
{
if (layer.parent == nullptr) {
return;
}
if (keep_transform) {
/* TODO apply current transform to geometry. */
}
layer.parent = nullptr;
layer.parsubstr[0] = 0;
copy_m4_m4(layer.parentinv, float4x4::identity().ptr());
}
void select_layer_channel(GreasePencil &grease_pencil, bke::greasepencil::Layer *layer)
{
using namespace blender::bke::greasepencil;

View File

@@ -235,6 +235,13 @@ struct KeyframeClipboard {
}
};
bool grease_pencil_layer_parent_set(bke::greasepencil::Layer &layer,
Object *parent,
StringRefNull bone,
bool keep_transform);
void grease_pencil_layer_parent_clear(bke::greasepencil::Layer &layer, bool keep_transform);
bool grease_pencil_copy_keyframes(bAnimContext *ac, KeyframeClipboard &clipboard);
bool grease_pencil_paste_keyframes(bAnimContext *ac,

View File

@@ -36,6 +36,8 @@
# include "DEG_depsgraph.hh"
# include "DEG_depsgraph_build.hh"
# include "ED_grease_pencil.hh"
static GreasePencil *rna_grease_pencil(const PointerRNA *ptr)
{
return reinterpret_cast<GreasePencil *>(ptr->owner_id);
@@ -357,6 +359,25 @@ static void rna_GreasePencilLayer_pass_index_set(PointerRNA *ptr, int value)
layer_passes.finish();
}
static void rna_GreasePencilLayer_parent_set(PointerRNA *ptr,
PointerRNA value,
ReportList * /*reports*/)
{
using namespace blender;
bke::greasepencil::Layer &layer = static_cast<GreasePencilLayer *>(ptr->data)->wrap();
Object *parent = static_cast<Object *>(value.data);
ed::greasepencil::grease_pencil_layer_parent_set(layer, parent, layer.parsubstr, false);
}
static void rna_GreasePencilLayer_bone_set(PointerRNA *ptr, const char *value)
{
using namespace blender;
bke::greasepencil::Layer &layer = static_cast<GreasePencilLayer *>(ptr->data)->wrap();
ed::greasepencil::grease_pencil_layer_parent_set(layer, layer.parent, value, false);
}
static void rna_GreasePencilLayer_tint_color_get(PointerRNA *ptr, float *values)
{
using namespace blender;
@@ -933,6 +954,8 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_pointer_funcs(
prop, nullptr, "rna_GreasePencilLayer_parent_set", nullptr, nullptr);
RNA_def_property_flag(prop, PROP_EDITABLE | PROP_ID_SELF_CHECK);
RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_LIBRARY);
RNA_def_property_ui_text(prop, "Parent", "Parent object");
@@ -940,6 +963,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
prop = RNA_def_property(srna, "parent_bone", PROP_STRING, PROP_NONE);
RNA_def_property_string_sdna(prop, nullptr, "parsubstr");
RNA_def_property_string_funcs(prop, nullptr, nullptr, "rna_GreasePencilLayer_bone_set");
RNA_def_property_ui_text(
prop,
"Parent Bone",

View File

@@ -423,8 +423,9 @@ class Context : public realtime_compositor::Context {
/* We assume the given pass is a Cryptomatte pass and retrieve its layer name. If it wasn't a
* Cryptomatte pass, the checks below will fail anyways. */
const std::string combined_pass_name = std::string(view_layer->name) + "." + pass_name;
StringRef cryptomatte_layer_name = bke::cryptomatte::BKE_cryptomatte_extract_layer_name(
std::string(view_layer->name) + "." + pass_name);
combined_pass_name);
struct StampCallbackData {
std::string cryptomatte_layer_name;