Merge branch 'blender-v3.4-release'
This commit is contained in:
commit
103fe4d1d1
|
@ -279,6 +279,11 @@ void BKE_nlastrip_set_active(struct AnimData *adt, struct NlaStrip *strip);
|
|||
* Does the given NLA-strip fall within the given bounds (times)?.
|
||||
*/
|
||||
bool BKE_nlastrip_within_bounds(struct NlaStrip *strip, float min, float max);
|
||||
/**
|
||||
* Return the distance from the given frame to the NLA strip, measured in frames.
|
||||
* If the given frame intersects the NLA strip, the distance is zero.
|
||||
*/
|
||||
float BKE_nlastrip_distance_to_frame(const struct NlaStrip *strip, float timeline_frame);
|
||||
/**
|
||||
* Recalculate the start and end frames for the current strip, after changing
|
||||
* the extents of the action or the mapping (repeats or scale factor) info.
|
||||
|
|
|
@ -119,16 +119,10 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts,
|
|||
}
|
||||
}
|
||||
else {
|
||||
if (ima->source == IMA_SRC_GENERATED) {
|
||||
opts->im_format.imtype = R_IMF_IMTYPE_PNG;
|
||||
opts->im_format.compress = ibuf->foptions.quality;
|
||||
opts->im_format.planes = ibuf->planes;
|
||||
if (!IMB_colormanagement_space_name_is_data(ima_colorspace)) {
|
||||
ima_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
|
||||
}
|
||||
}
|
||||
else {
|
||||
BKE_image_format_from_imbuf(&opts->im_format, ibuf);
|
||||
BKE_image_format_from_imbuf(&opts->im_format, ibuf);
|
||||
if (ima->source == IMA_SRC_GENERATED &&
|
||||
!IMB_colormanagement_space_name_is_data(ima_colorspace)) {
|
||||
ima_colorspace = IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DEFAULT_BYTE);
|
||||
}
|
||||
|
||||
/* use the multiview image settings as the default */
|
||||
|
|
|
@ -1360,6 +1360,17 @@ bool BKE_nlastrip_within_bounds(NlaStrip *strip, float min, float max)
|
|||
return true;
|
||||
}
|
||||
|
||||
float BKE_nlastrip_distance_to_frame(const NlaStrip *strip, const float timeline_frame)
|
||||
{
|
||||
if (timeline_frame < strip->start) {
|
||||
return strip->start - timeline_frame;
|
||||
}
|
||||
if (strip->end < timeline_frame) {
|
||||
return timeline_frame - strip->end;
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
/* Ensure that strip doesn't overlap those around it after resizing
|
||||
* by offsetting those which follow. */
|
||||
static void nlastrip_fix_resize_overlaps(NlaStrip *strip)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
#include "BLI_math_base.h"
|
||||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_nla.h"
|
||||
|
@ -286,20 +287,35 @@ static void nlaedit_strip_at_region_position(
|
|||
/* x-range to check is +/- 7 (in screen/region-space) on either side of mouse click
|
||||
* (that is the size of keyframe icons, so user should be expecting similar tolerances)
|
||||
*/
|
||||
float xmin = UI_view2d_region_to_view_x(v2d, region_x - 7);
|
||||
float xmax = UI_view2d_region_to_view_x(v2d, region_x + 7);
|
||||
const float mouse_x = UI_view2d_region_to_view_x(v2d, region_x);
|
||||
const float xmin = UI_view2d_region_to_view_x(v2d, region_x - 7);
|
||||
const float xmax = UI_view2d_region_to_view_x(v2d, region_x + 7);
|
||||
|
||||
bAnimListElem *ale = BLI_findlink(&anim_data, channel_index);
|
||||
if (ale != NULL) {
|
||||
if (ale->type == ANIMTYPE_NLATRACK) {
|
||||
NlaTrack *nlt = (NlaTrack *)ale->data;
|
||||
float best_distance = MAXFRAMEF;
|
||||
|
||||
LISTBASE_FOREACH (NlaStrip *, strip, &nlt->strips) {
|
||||
if (BKE_nlastrip_within_bounds(strip, xmin, xmax)) {
|
||||
const float distance = BKE_nlastrip_distance_to_frame(strip, mouse_x);
|
||||
|
||||
/* Skip if strip is further away from mouse cursor than any previous strip. */
|
||||
if (distance > best_distance) {
|
||||
continue;
|
||||
}
|
||||
|
||||
*r_ale = ale;
|
||||
*r_strip = strip;
|
||||
best_distance = distance;
|
||||
|
||||
BLI_remlink(&anim_data, ale);
|
||||
|
||||
/* Mouse cursor was directly on strip, no need to check other strips. */
|
||||
if (distance == 0.0f) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,8 +48,12 @@ static void rna_ImagePackedFile_save(ImagePackedFile *imapf, Main *bmain, Report
|
|||
}
|
||||
}
|
||||
|
||||
static void rna_Image_save_render(
|
||||
Image *image, bContext *C, ReportList *reports, const char *path, Scene *scene)
|
||||
static void rna_Image_save_render(Image *image,
|
||||
bContext *C,
|
||||
ReportList *reports,
|
||||
const char *path,
|
||||
Scene *scene,
|
||||
const int quality)
|
||||
{
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
|
@ -62,6 +66,9 @@ static void rna_Image_save_render(
|
|||
if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false, true)) {
|
||||
opts.save_copy = true;
|
||||
STRNCPY(opts.filepath, path);
|
||||
if (quality != 0) {
|
||||
opts.im_format.quality = clamp_i(quality, 0, 100);
|
||||
}
|
||||
|
||||
if (!BKE_image_save(reports, bmain, image, NULL, &opts)) {
|
||||
BKE_reportf(
|
||||
|
@ -77,12 +84,23 @@ static void rna_Image_save_render(
|
|||
WM_event_add_notifier(C, NC_IMAGE | NA_EDITED, image);
|
||||
}
|
||||
|
||||
static void rna_Image_save(Image *image, Main *bmain, bContext *C, ReportList *reports)
|
||||
static void rna_Image_save(Image *image,
|
||||
Main *bmain,
|
||||
bContext *C,
|
||||
ReportList *reports,
|
||||
const char *path,
|
||||
const int quality)
|
||||
{
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ImageSaveOptions opts;
|
||||
|
||||
if (BKE_image_save_options_init(&opts, bmain, scene, image, NULL, false, false)) {
|
||||
if (path && path[0]) {
|
||||
STRNCPY(opts.filepath, path);
|
||||
}
|
||||
if (quality != 0) {
|
||||
opts.im_format.quality = clamp_i(quality, 0, 100);
|
||||
}
|
||||
if (!BKE_image_save(reports, bmain, image, NULL, &opts)) {
|
||||
BKE_reportf(reports,
|
||||
RPT_ERROR,
|
||||
|
@ -245,13 +263,39 @@ void RNA_api_image(StructRNA *srna)
|
|||
RNA_def_function_ui_description(func,
|
||||
"Save image to a specific path using a scenes render settings");
|
||||
RNA_def_function_flag(func, FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
||||
parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "Save path");
|
||||
parm = RNA_def_string_file_path(func, "filepath", NULL, 0, "", "Output path");
|
||||
RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
|
||||
RNA_def_pointer(func, "scene", "Scene", "", "Scene to take image parameters from");
|
||||
RNA_def_int(func,
|
||||
"quality",
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
"Quality",
|
||||
"Quality for image formats that support lossy compression, uses default quality if "
|
||||
"not specified",
|
||||
0,
|
||||
100);
|
||||
|
||||
func = RNA_def_function(srna, "save", "rna_Image_save");
|
||||
RNA_def_function_ui_description(func, "Save image to its source path");
|
||||
RNA_def_function_ui_description(func, "Save image");
|
||||
RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_CONTEXT | FUNC_USE_REPORTS);
|
||||
RNA_def_string_file_path(func,
|
||||
"filepath",
|
||||
NULL,
|
||||
0,
|
||||
"",
|
||||
"Output path, uses image data-block filepath if not specified");
|
||||
RNA_def_int(func,
|
||||
"quality",
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
"Quality",
|
||||
"Quality for image formats that support lossy compression, uses default quality if "
|
||||
"not specified",
|
||||
0,
|
||||
100);
|
||||
|
||||
func = RNA_def_function(srna, "pack", "rna_Image_pack");
|
||||
RNA_def_function_ui_description(func, "Pack an image as embedded data into the .blend file");
|
||||
|
|
Loading…
Reference in New Issue