WIP: Compositor: add aspect ratio display in node viewer #106338
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -739,6 +739,11 @@ class NODE_PT_backdrop(Panel):
|
|||
|
||||
col.separator()
|
||||
|
||||
col.prop(snode, "backdrop_aspect_ratio_x", text="Aspect Ratio X")
|
||||
col.prop(snode, "backdrop_aspect_ratio_y", text="Y")
|
||||
|
||||
col.separator()
|
||||
|
||||
col.operator("node.backimage_move", text="Move")
|
||||
col.operator("node.backimage_fit", text="Fit")
|
||||
|
||||
|
|
|
@ -94,13 +94,17 @@ class SpaceNodeAccessor : public AbstractSpaceAccessor {
|
|||
float image_display_offset[2];
|
||||
mul_v2_v2fl(display_resolution, image_resolution, snode->zoom);
|
||||
mul_v2_v2fl(image_display_offset, image_offset, snode->zoom);
|
||||
|
||||
BLI_assert(snode->yasp != 0 && snode->xasp != 0);
|
||||
const float yasp = snode->yasp / snode->xasp;
|
||||
|
||||
const float scale_x = display_resolution[0] / region->winx;
|
||||
const float scale_y = display_resolution[1] / region->winy;
|
||||
const float scale_y = display_resolution[1] / region->winy * yasp;
|
||||
const float translate_x = ((region->winx - display_resolution[0]) * 0.5f + snode->xof +
|
||||
image_display_offset[0]) /
|
||||
region->winx;
|
||||
const float translate_y = ((region->winy - display_resolution[1]) * 0.5f + snode->yof +
|
||||
image_display_offset[1]) /
|
||||
const float translate_y = ((region->winy - display_resolution[1] * yasp) * 0.5f + snode->yof +
|
||||
image_display_offset[1] * yasp) /
|
||||
region->winy;
|
||||
|
||||
r_uv_to_texture[0][0] = scale_x;
|
||||
|
|
|
@ -72,8 +72,12 @@ static void gizmo_node_backdrop_prop_matrix_get(const wmGizmo * /*gz*/,
|
|||
float(*matrix)[4] = (float(*)[4])value_p;
|
||||
BLI_assert(gz_prop->type->array_length == 16);
|
||||
const SpaceNode *snode = (const SpaceNode *)gz_prop->custom_func.user_data;
|
||||
|
||||
BLI_assert(snode->xasp != 0 && snode->yasp != 0);
|
||||
const float yasp = snode->yasp / snode->xasp;
|
||||
|
||||
matrix[0][0] = snode->zoom;
|
||||
matrix[1][1] = snode->zoom;
|
||||
matrix[1][1] = snode->zoom * yasp;
|
||||
matrix[3][0] = snode->xof;
|
||||
matrix[3][1] = snode->yof;
|
||||
}
|
||||
|
|
|
@ -242,6 +242,8 @@ static SpaceLink *node_create(const ScrArea * /*area*/, const Scene * /*scene*/)
|
|||
|
||||
/* backdrop */
|
||||
snode->zoom = 1.0f;
|
||||
snode->xasp = 1.0f;
|
||||
snode->yasp = 1.0f;
|
||||
|
||||
/* select the first tree type for valid type */
|
||||
NODE_TREE_TYPES_BEGIN (treetype) {
|
||||
|
|
|
@ -1578,6 +1578,9 @@ typedef struct SpaceNode {
|
|||
/** Zoom for backdrop. */
|
||||
float zoom;
|
||||
|
||||
/** Aspect ratio for drawing the backdrop */
|
||||
float xasp, yasp;
|
||||
|
||||
/**
|
||||
* XXX nodetree pointer info is all in the path stack now,
|
||||
* remove later on and use bNodeTreePath instead.
|
||||
|
|
|
@ -7518,6 +7518,28 @@ static void rna_def_space_node(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Backdrop Offset", "Backdrop offset");
|
||||
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_NODE_VIEW, NULL);
|
||||
|
||||
prop = RNA_def_property(srna, "backdrop_aspect_ratio_x", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "xasp");
|
||||
RNA_def_property_range(prop, 0.1f, FLT_MAX);
|
||||
RNA_def_property_float_default(prop, 1.0f);
|
||||
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
|
||||
RNA_def_property_ui_text(
|
||||
prop,
|
||||
"Aspect Ratio X",
|
||||
"Backdrop display aspect ratio in horizontal direction. Doesn't affect render.");
|
||||
RNA_def_property_update(
|
||||
prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update");
|
||||
|
||||
prop = RNA_def_property(srna, "backdrop_aspect_ratio_y", PROP_FLOAT, PROP_NONE);
|
||||
RNA_def_property_float_sdna(prop, NULL, "yasp");
|
||||
RNA_def_property_range(prop, 0.1f, FLT_MAX);
|
||||
RNA_def_property_ui_range(prop, 0.1f, 5000.0f, 1, 2);
|
||||
RNA_def_property_float_default(prop, 1.0f);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Y", "Backdrop display aspect ratio in vertical direction. Doesn't affect render.");
|
||||
RNA_def_property_update(
|
||||
prop, NC_SPACE | ND_SPACE_NODE_VIEW, "rna_SpaceNodeEditor_show_backdrop_update");
|
||||
|
||||
prop = RNA_def_property(srna, "backdrop_channels", PROP_ENUM, PROP_NONE);
|
||||
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
|
||||
RNA_def_property_enum_items(prop, backdrop_channels_items);
|
||||
|
|
Loading…
Reference in New Issue