Compositor: Turn Stabilize node options to inputs
This patch turns the options of the Stabilize node into inputs. Reference #137223. Pull Request: https://projects.blender.org/blender/blender/pulls/137911
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
|
||||
/* Blender file format version. */
|
||||
#define BLENDER_FILE_VERSION BLENDER_VERSION
|
||||
#define BLENDER_FILE_SUBVERSION 48
|
||||
#define BLENDER_FILE_SUBVERSION 49
|
||||
|
||||
/* Minimum Blender version that supports reading file written with the current
|
||||
* version. Older Blender versions will test this and cancel loading the file, showing a warning to
|
||||
|
||||
@@ -906,6 +906,10 @@ static void write_compositor_legacy_properties(bNodeTree &node_tree)
|
||||
write_input_to_property_short("Index", node->custom1);
|
||||
write_input_to_property_bool_short("Anti-Alias", node->custom2);
|
||||
}
|
||||
|
||||
if (node->type_legacy == CMP_NODE_STABILIZE2D) {
|
||||
write_input_to_property_bool_short("Invert", node->custom2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3417,6 +3417,46 @@ static void do_version_id_mask_node_options_to_inputs_animation(bNodeTree *node_
|
||||
});
|
||||
}
|
||||
|
||||
/* The options were converted into inputs. */
|
||||
static void do_version_stabilize_node_options_to_inputs(bNodeTree *node_tree, bNode *node)
|
||||
{
|
||||
if (!blender::bke::node_find_socket(*node, SOCK_IN, "Invert")) {
|
||||
bNodeSocket *input = blender::bke::node_add_static_socket(
|
||||
*node_tree, *node, SOCK_IN, SOCK_BOOLEAN, PROP_NONE, "Invert", "Invert");
|
||||
input->default_value_typed<bNodeSocketValueBoolean>()->value = bool(node->custom2);
|
||||
}
|
||||
}
|
||||
|
||||
/* The options were converted into inputs. */
|
||||
static void do_version_stabilize_node_options_to_inputs_animation(bNodeTree *node_tree,
|
||||
bNode *node)
|
||||
{
|
||||
/* Compute the RNA path of the node. */
|
||||
char escaped_node_name[sizeof(node->name) * 2 + 1];
|
||||
BLI_str_escape(escaped_node_name, node->name, sizeof(escaped_node_name));
|
||||
const std::string node_rna_path = fmt::format("nodes[\"{}\"]", escaped_node_name);
|
||||
|
||||
BKE_fcurves_id_cb(&node_tree->id, [&](ID * /*id*/, FCurve *fcurve) {
|
||||
/* The FCurve does not belong to the node since its RNA path doesn't start with the node's RNA
|
||||
* path. */
|
||||
if (!blender::StringRef(fcurve->rna_path).startswith(node_rna_path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Change the RNA path of the FCurve from the old properties to the new inputs, adjusting the
|
||||
* values of the FCurves frames when needed. */
|
||||
char *old_rna_path = fcurve->rna_path;
|
||||
if (BLI_str_endswith(fcurve->rna_path, "invert")) {
|
||||
fcurve->rna_path = BLI_sprintfN("%s.%s", node_rna_path.c_str(), "inputs[1].default_value");
|
||||
}
|
||||
|
||||
/* The RNA path was changed, free the old path. */
|
||||
if (fcurve->rna_path != old_rna_path) {
|
||||
MEM_freeN(old_rna_path);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void do_version_viewer_shortcut(bNodeTree *node_tree)
|
||||
{
|
||||
LISTBASE_FOREACH_MUTABLE (bNode *, node, &node_tree->nodes) {
|
||||
@@ -4196,6 +4236,19 @@ void do_versions_after_linking_400(FileData *fd, Main *bmain)
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 49)) {
|
||||
FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
|
||||
if (node_tree->type == NTREE_COMPOSIT) {
|
||||
LISTBASE_FOREACH (bNode *, node, &node_tree->nodes) {
|
||||
if (node->type_legacy == CMP_NODE_STABILIZE2D) {
|
||||
do_version_stabilize_node_options_to_inputs_animation(node_tree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
/**
|
||||
* Always bump subversion in BKE_blender_version.h when adding versioning
|
||||
* code here, and wrap it inside a MAIN_VERSION_FILE_ATLEAST check.
|
||||
@@ -9112,6 +9165,19 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain)
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
if (!MAIN_VERSION_FILE_ATLEAST(bmain, 405, 49)) {
|
||||
FOREACH_NODETREE_BEGIN (bmain, node_tree, id) {
|
||||
if (node_tree->type == NTREE_COMPOSIT) {
|
||||
LISTBASE_FOREACH (bNode *, node, &node_tree->nodes) {
|
||||
if (node->type_legacy == CMP_NODE_STABILIZE2D) {
|
||||
do_version_stabilize_node_options_to_inputs(node_tree, node);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FOREACH_NODETREE_END;
|
||||
}
|
||||
|
||||
/* Always run this versioning (keep at the bottom of the function). Meshes are written with the
|
||||
* legacy format which always needs to be converted to the new format on file load. To be moved
|
||||
* to a subversion check in 5.0. */
|
||||
|
||||
@@ -2950,11 +2950,6 @@ typedef enum CMPNodeCornerPinInterpolation {
|
||||
CMP_NODE_CORNER_PIN_INTERPOLATION_ANISOTROPIC = 3,
|
||||
} CMPNodeCornerPinInterpolation;
|
||||
|
||||
/* Stabilize 2D node. Stored in custom2. */
|
||||
typedef enum CMPNodeStabilizeInverse {
|
||||
CMP_NODE_STABILIZE_FLAG_INVERSE = 1,
|
||||
} CMPNodeStabilizeInverse;
|
||||
|
||||
#define CMP_NODE_PLANE_TRACK_DEFORM_MOTION_BLUR_SAMPLES_MAX 64
|
||||
|
||||
/* Plane track deform node. */
|
||||
|
||||
@@ -4012,6 +4012,9 @@ static const char node_input_despill_balance[] = "Despill Balance";
|
||||
/* ID Key node. */
|
||||
static const char node_input_index[] = "Index";
|
||||
|
||||
/* Stabilize 2D node. */
|
||||
static const char node_input_invert[] = "Invert";
|
||||
|
||||
/* --------------------------------------------------------------------
|
||||
* White Balance Node.
|
||||
*/
|
||||
@@ -9127,9 +9130,13 @@ static void def_cmp_stabilize2d(BlenderRNA * /*brna*/, StructRNA *srna)
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
|
||||
prop = RNA_def_property(srna, "invert", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "custom2", CMP_NODE_STABILIZE_FLAG_INVERSE);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Invert", "Invert stabilization to re-introduce motion to the frame");
|
||||
RNA_def_property_boolean_funcs(prop,
|
||||
"rna_node_property_to_input_getter<bool, node_input_invert>",
|
||||
"rna_node_property_to_input_setter<bool, node_input_invert>");
|
||||
RNA_def_property_ui_text(prop,
|
||||
"Invert",
|
||||
"Invert stabilization to re-introduce motion to the frame. "
|
||||
"(Deprecated: Use Invert input instead.)");
|
||||
RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update");
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,12 @@ static void cmp_node_stabilize2d_declare(NodeDeclarationBuilder &b)
|
||||
{
|
||||
b.add_input<decl::Color>("Image")
|
||||
.default_value({0.8f, 0.8f, 0.8f, 1.0f})
|
||||
.compositor_realization_mode(CompositorInputRealizationMode::None)
|
||||
.compositor_domain_priority(0);
|
||||
.compositor_realization_mode(CompositorInputRealizationMode::None);
|
||||
b.add_input<decl::Bool>("Invert")
|
||||
.default_value(false)
|
||||
.description("Invert stabilization to reintroduce motion to the image")
|
||||
.compositor_expects_single_value();
|
||||
|
||||
b.add_output<decl::Color>("Image");
|
||||
}
|
||||
|
||||
@@ -63,7 +67,6 @@ static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, Pointe
|
||||
}
|
||||
|
||||
uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
|
||||
uiItemR(layout, ptr, "invert", UI_ITEM_R_SPLIT_EMPTY_NAME, std::nullopt, ICON_NONE);
|
||||
}
|
||||
|
||||
using namespace blender::compositor;
|
||||
@@ -121,7 +124,7 @@ class Stabilize2DOperation : public NodeOperation {
|
||||
|
||||
bool do_inverse_stabilization()
|
||||
{
|
||||
return bnode().custom2 & CMP_NODE_STABILIZE_FLAG_INVERSE;
|
||||
return this->get_input("Invert").get_single_value_default(false);
|
||||
}
|
||||
|
||||
MovieClip *get_movie_clip()
|
||||
|
||||
Reference in New Issue
Block a user