Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Antalik <richardantalik@gmail.com>2021-05-12 21:25:16 +0300
committerRichard Antalik <richardantalik@gmail.com>2021-05-12 21:25:16 +0300
commitfa472d46fc260517032dcb3c9e626bf3dd51b3d2 (patch)
tree36099c570a443f572cba899adab71273175b005c /source/blender
parent1a94ae9e4757bfb326a855eeede10196d8f1ffc5 (diff)
parent5368859a669d8cd606a6ae6948f9c927ff8faf4d (diff)
Merge branch 'blender-v2.93-release'
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_image.h1
-rw-r--r--source/blender/blenkernel/intern/image.c31
-rw-r--r--source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl93
-rw-r--r--source/blender/editors/space_sequencer/sequencer_draw.c10
-rw-r--r--source/blender/editors/transform/transform_convert.c63
-rw-r--r--source/blender/sequencer/intern/image_cache.c13
-rw-r--r--source/blender/sequencer/intern/strip_time.c41
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c2
8 files changed, 190 insertions, 64 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index c51a5f7e5e1..d298e5dcf6d 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -325,6 +325,7 @@ int BKE_image_get_tile_from_pos(struct Image *ima,
const float uv[2],
float r_uv[2],
float r_ofs[2]);
+int BKE_image_find_nearest_tile(const struct Image *image, const float co[2]);
void BKE_image_get_size(struct Image *image, struct ImageUser *iuser, int *r_width, int *r_height);
void BKE_image_get_size_fl(struct Image *image, struct ImageUser *iuser, float r_size[2]);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 368b1c2e66b..2f7e2b41a73 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -735,6 +735,37 @@ int BKE_image_get_tile_from_pos(struct Image *ima,
return tile_number;
}
+/**
+ * Return the tile_number for the closest UDIM tile.
+ */
+int BKE_image_find_nearest_tile(const Image *image, const float co[2])
+{
+ const float co_floor[2] = {floorf(co[0]), floorf(co[1])};
+ /* Distance to the closest UDIM tile. */
+ float dist_best_sq = FLT_MAX;
+ int tile_number_best = -1;
+
+ LISTBASE_FOREACH (const ImageTile *, tile, &image->tiles) {
+ const int tile_index = tile->tile_number - 1001;
+ /* Coordinates of the current tile. */
+ const float tile_index_co[2] = {tile_index % 10, tile_index / 10};
+
+ if (equals_v2v2(co_floor, tile_index_co)) {
+ return tile->tile_number;
+ }
+
+ /* Distance between co[2] and UDIM tile. */
+ const float dist_sq = len_squared_v2v2(tile_index_co, co);
+
+ if (dist_sq < dist_best_sq) {
+ dist_best_sq = dist_sq;
+ tile_number_best = tile->tile_number;
+ }
+ }
+
+ return tile_number_best;
+}
+
static void image_init_color_management(Image *ima)
{
ImBuf *ibuf;
diff --git a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
index b554fd113df..94dd1a439db 100644
--- a/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/closure_eval_lib.glsl
@@ -51,53 +51,72 @@
closure_##t2##_##subroutine(in_##t2##_2, eval_##t2##_2, cl_common, sub_data, out_##t2##_2); \
closure_##t3##_##subroutine(in_##t3##_3, eval_##t3##_3, cl_common, sub_data, out_##t3##_3);
+#ifndef DEPTH_SHADER
/* Inputs are inout so that callers can get the final inputs used for evaluation. */
-#define CLOSURE_EVAL_FUNCTION_DECLARE(name, t0, t1, t2, t3) \
- void closure_##name##_eval(ClosureInputCommon in_common, \
- inout ClosureInput##t0 in_##t0##_0, \
- inout ClosureInput##t1 in_##t1##_1, \
- inout ClosureInput##t2 in_##t2##_2, \
- inout ClosureInput##t3 in_##t3##_3, \
- out ClosureOutput##t0 out_##t0##_0, \
- out ClosureOutput##t1 out_##t1##_1, \
- out ClosureOutput##t2 out_##t2##_2, \
- out ClosureOutput##t3 out_##t3##_3) \
- { \
- CLOSURE_EVAL_DECLARE(t0, t1, t2, t3); \
+# define CLOSURE_EVAL_FUNCTION_DECLARE(name, t0, t1, t2, t3) \
+ void closure_##name##_eval(ClosureInputCommon in_common, \
+ inout ClosureInput##t0 in_##t0##_0, \
+ inout ClosureInput##t1 in_##t1##_1, \
+ inout ClosureInput##t2 in_##t2##_2, \
+ inout ClosureInput##t3 in_##t3##_3, \
+ out ClosureOutput##t0 out_##t0##_0, \
+ out ClosureOutput##t1 out_##t1##_1, \
+ out ClosureOutput##t2 out_##t2##_2, \
+ out ClosureOutput##t3 out_##t3##_3) \
+ { \
+ CLOSURE_EVAL_DECLARE(t0, t1, t2, t3); \
\
- /* Starts at 1 because 0 is world cubemap. */ \
- for (int i = 1; cl_common.specular_accum > 0.0 && i < prbNumRenderCube && i < MAX_PROBE; \
- i++) { \
- ClosureCubemapData cube = closure_cubemap_eval_init(i, cl_common); \
- if (cube.attenuation > 1e-8) { \
- CLOSURE_META_SUBROUTINE_DATA(cubemap_eval, cube, t0, t1, t2, t3); \
+ /* Starts at 1 because 0 is world cubemap. */ \
+ for (int i = 1; cl_common.specular_accum > 0.0 && i < prbNumRenderCube && i < MAX_PROBE; \
+ i++) { \
+ ClosureCubemapData cube = closure_cubemap_eval_init(i, cl_common); \
+ if (cube.attenuation > 1e-8) { \
+ CLOSURE_META_SUBROUTINE_DATA(cubemap_eval, cube, t0, t1, t2, t3); \
+ } \
} \
- } \
\
- /* Starts at 1 because 0 is world irradiance. */ \
- for (int i = 1; cl_common.diffuse_accum > 0.0 && i < prbNumRenderGrid && i < MAX_GRID; i++) { \
- ClosureGridData grid = closure_grid_eval_init(i, cl_common); \
- if (grid.attenuation > 1e-8) { \
- CLOSURE_META_SUBROUTINE_DATA(grid_eval, grid, t0, t1, t2, t3); \
+ /* Starts at 1 because 0 is world irradiance. */ \
+ for (int i = 1; cl_common.diffuse_accum > 0.0 && i < prbNumRenderGrid && i < MAX_GRID; \
+ i++) { \
+ ClosureGridData grid = closure_grid_eval_init(i, cl_common); \
+ if (grid.attenuation > 1e-8) { \
+ CLOSURE_META_SUBROUTINE_DATA(grid_eval, grid, t0, t1, t2, t3); \
+ } \
} \
- } \
\
- CLOSURE_META_SUBROUTINE(indirect_end, t0, t1, t2, t3); \
+ CLOSURE_META_SUBROUTINE(indirect_end, t0, t1, t2, t3); \
\
- ClosurePlanarData planar = closure_planar_eval_init(cl_common); \
- if (planar.attenuation > 1e-8) { \
- CLOSURE_META_SUBROUTINE_DATA(planar_eval, planar, t0, t1, t2, t3); \
- } \
+ ClosurePlanarData planar = closure_planar_eval_init(cl_common); \
+ if (planar.attenuation > 1e-8) { \
+ CLOSURE_META_SUBROUTINE_DATA(planar_eval, planar, t0, t1, t2, t3); \
+ } \
\
- for (int i = 0; i < laNumLight && i < MAX_LIGHT; i++) { \
- ClosureLightData light = closure_light_eval_init(cl_common, i); \
- if (light.vis > 1e-8) { \
- CLOSURE_META_SUBROUTINE_DATA(light_eval, light, t0, t1, t2, t3); \
+ for (int i = 0; i < laNumLight && i < MAX_LIGHT; i++) { \
+ ClosureLightData light = closure_light_eval_init(cl_common, i); \
+ if (light.vis > 1e-8) { \
+ CLOSURE_META_SUBROUTINE_DATA(light_eval, light, t0, t1, t2, t3); \
+ } \
} \
- } \
\
- CLOSURE_META_SUBROUTINE(eval_end, t0, t1, t2, t3); \
- }
+ CLOSURE_META_SUBROUTINE(eval_end, t0, t1, t2, t3); \
+ }
+
+#else
+/* Inputs are inout so that callers can get the final inputs used for evaluation. */
+# define CLOSURE_EVAL_FUNCTION_DECLARE(name, t0, t1, t2, t3) \
+ void closure_##name##_eval(ClosureInputCommon in_common, \
+ inout ClosureInput##t0 in_##t0##_0, \
+ inout ClosureInput##t1 in_##t1##_1, \
+ inout ClosureInput##t2 in_##t2##_2, \
+ inout ClosureInput##t3 in_##t3##_3, \
+ out ClosureOutput##t0 out_##t0##_0, \
+ out ClosureOutput##t1 out_##t1##_1, \
+ out ClosureOutput##t2 out_##t2##_2, \
+ out ClosureOutput##t3 out_##t3##_3) \
+ { \
+ CLOSURE_EVAL_DECLARE(t0, t1, t2, t3); \
+ }
+#endif
#define CLOSURE_EVAL_FUNCTION(name, t0, t1, t2, t3) \
closure_##name##_eval(in_common, \
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 370a1942d20..b55c8035fa3 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -885,10 +885,12 @@ static void draw_seq_background(Scene *scene,
immUniformColor4ubv(col);
if (seq->startstill) {
- immRectf(pos, seq->startdisp, y1, (float)(seq->start), y2);
+ const float content_start = min_ff(seq->enddisp, seq->start);
+ immRectf(pos, seq->startdisp, y1, content_start, y2);
}
if (seq->endstill) {
- immRectf(pos, (float)(seq->start + seq->len), y1, seq->enddisp, y2);
+ const float content_end = max_ff(seq->startdisp, seq->start + seq->len);
+ immRectf(pos, content_end, y1, seq->enddisp, y2);
}
}
@@ -1105,6 +1107,10 @@ static void draw_seq_strip(const bContext *C,
x2 = (seq->endstill) ? (seq->start + seq->len) : seq->enddisp;
y2 = seq->machine + SEQ_STRIP_OFSTOP;
+ /* Limit body to strip bounds. Meta strip can end up with content outside of strip range. */
+ x1 = min_ff(x1, seq->enddisp);
+ x2 = max_ff(x2, seq->startdisp);
+
float text_margin_y;
bool y_threshold;
if ((sseq->flag & SEQ_SHOW_STRIP_NAME) || (sseq->flag & SEQ_SHOW_STRIP_SOURCE) ||
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 98db27c83f7..b4175faacf4 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -37,6 +37,7 @@
#include "BKE_context.h"
#include "BKE_fcurve.h"
#include "BKE_global.h"
+#include "BKE_image.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
#include "BKE_main.h"
@@ -505,9 +506,27 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
bool clipx = true, clipy = true;
float min[2], max[2];
- min[0] = min[1] = 0.0f;
- max[0] = t->aspect[0];
- max[1] = t->aspect[1];
+ /* Check if the current image in UV editor is a tiled image or not. */
+ const SpaceImage *sima = t->area->spacedata.first;
+ const Image *image = sima->image;
+ const bool is_tiled_image = image && (image->source == IMA_SRC_TILED);
+ /* Stores the coordinates of the closest UDIM tile.
+ * Also acts as an offset to the tile from the origin of UV space. */
+ float base_offset[2] = {0.0f, 0.0f};
+
+ /* If tiled image then constrain to correct/closest UDIM tile, else 0-1 UV space. */
+ if (is_tiled_image) {
+ int nearest_tile_index = BKE_image_find_nearest_tile(image, t->center_global);
+ if (nearest_tile_index != -1) {
+ nearest_tile_index -= 1001;
+ /* Getting coordinates of nearest tile from the tile index. */
+ base_offset[0] = nearest_tile_index % 10;
+ base_offset[1] = nearest_tile_index / 10;
+ }
+ }
+
+ min[0] = min[1] = FLT_MAX;
+ max[0] = max[1] = FLT_MIN;
FOREACH_TRANS_DATA_CONTAINER (t, tc) {
@@ -520,42 +539,48 @@ bool clipUVTransform(TransInfo *t, float vec[2], const bool resize)
}
if (resize) {
- if (min[0] < 0.0f && t->center_global[0] > 0.0f && t->center_global[0] < t->aspect[0] * 0.5f) {
- vec[0] *= t->center_global[0] / (t->center_global[0] - min[0]);
+ if (min[0] < base_offset[0] && t->center_global[0] > base_offset[0] &&
+ t->center_global[0] < base_offset[0] + (t->aspect[0] * 0.5f)) {
+ vec[0] *= (t->center_global[0] - base_offset[0]) / (t->center_global[0] - min[0]);
}
- else if (max[0] > t->aspect[0] && t->center_global[0] < t->aspect[0]) {
- vec[0] *= (t->center_global[0] - t->aspect[0]) / (t->center_global[0] - max[0]);
+ else if (max[0] > (base_offset[0] + t->aspect[0]) &&
+ t->center_global[0] < (base_offset[0] + t->aspect[0])) {
+ vec[0] *= (t->center_global[0] - (base_offset[0] + t->aspect[0])) /
+ (t->center_global[0] - max[0]);
}
else {
clipx = 0;
}
- if (min[1] < 0.0f && t->center_global[1] > 0.0f && t->center_global[1] < t->aspect[1] * 0.5f) {
- vec[1] *= t->center_global[1] / (t->center_global[1] - min[1]);
+ if (min[1] < base_offset[1] && t->center_global[1] > base_offset[1] &&
+ t->center_global[1] < base_offset[1] + (t->aspect[1] * 0.5f)) {
+ vec[1] *= (t->center_global[1] - base_offset[1]) / (t->center_global[1] - min[1]);
}
- else if (max[1] > t->aspect[1] && t->center_global[1] < t->aspect[1]) {
- vec[1] *= (t->center_global[1] - t->aspect[1]) / (t->center_global[1] - max[1]);
+ else if (max[1] > (base_offset[1] + t->aspect[1]) &&
+ t->center_global[1] < (base_offset[1] + t->aspect[1])) {
+ vec[1] *= (t->center_global[1] - (base_offset[1] + t->aspect[1])) /
+ (t->center_global[1] - max[1]);
}
else {
clipy = 0;
}
}
else {
- if (min[0] < 0.0f) {
- vec[0] -= min[0];
+ if (min[0] < base_offset[0]) {
+ vec[0] += base_offset[0] - min[0];
}
- else if (max[0] > t->aspect[0]) {
- vec[0] -= max[0] - t->aspect[0];
+ else if (max[0] > base_offset[0] + t->aspect[0]) {
+ vec[0] -= max[0] - base_offset[0] - t->aspect[0];
}
else {
clipx = 0;
}
- if (min[1] < 0.0f) {
- vec[1] -= min[1];
+ if (min[1] < base_offset[1]) {
+ vec[1] += base_offset[1] - min[1];
}
- else if (max[1] > t->aspect[1]) {
- vec[1] -= max[1] - t->aspect[1];
+ else if (max[1] > base_offset[1] + t->aspect[1]) {
+ vec[1] -= max[1] - base_offset[1] - t->aspect[1];
}
else {
clipy = 0;
diff --git a/source/blender/sequencer/intern/image_cache.c b/source/blender/sequencer/intern/image_cache.c
index 089bb5a6bec..7b873d5c66e 100644
--- a/source/blender/sequencer/intern/image_cache.c
+++ b/source/blender/sequencer/intern/image_cache.c
@@ -352,15 +352,18 @@ static void seq_disk_cache_update_file(SeqDiskCache *disk_cache, char *path)
}
/* Path format:
- * <cache dir>/<project name>/<scene name>-<timestamp>/<seq name>/DCACHE_FNAME_FORMAT
+ * <cache dir>/<project name>_seq_cache/<scene name>-<timestamp>/<seq name>/DCACHE_FNAME_FORMAT
*/
static void seq_disk_cache_get_project_dir(SeqDiskCache *disk_cache, char *path, size_t path_len)
{
- char main_name[FILE_MAX];
- BLI_split_file_part(BKE_main_blendfile_path(disk_cache->bmain), main_name, sizeof(main_name));
+ char cache_dir[FILE_MAX];
+ BLI_split_file_part(BKE_main_blendfile_path(disk_cache->bmain), cache_dir, sizeof(cache_dir));
+ /* Use suffix, so that the cache directory name does not conflict with the bmain's blend file. */
+ const char *suffix = "_seq_cache";
+ strncat(cache_dir, suffix, sizeof(cache_dir) - strlen(cache_dir));
BLI_strncpy(path, seq_disk_cache_base_dir(), path_len);
- BLI_path_append(path, path_len, main_name);
+ BLI_path_append(path, path_len, cache_dir);
}
static void seq_disk_cache_get_dir(
@@ -421,7 +424,7 @@ static void seq_disk_cache_handle_versioning(SeqDiskCache *disk_cache)
BLI_strncpy(path_version_file, path, sizeof(path_version_file));
BLI_path_append(path_version_file, sizeof(path_version_file), "cache_version");
- if (BLI_exists(path)) {
+ if (BLI_exists(path) && BLI_is_dir(path)) {
FILE *file = BLI_fopen(path_version_file, "r");
if (file) {
diff --git a/source/blender/sequencer/intern/strip_time.c b/source/blender/sequencer/intern/strip_time.c
index 21dc9aa2cdd..4a01b0e1938 100644
--- a/source/blender/sequencer/intern/strip_time.c
+++ b/source/blender/sequencer/intern/strip_time.c
@@ -39,6 +39,7 @@
#include "SEQ_render.h"
#include "SEQ_sequencer.h"
#include "SEQ_time.h"
+#include "SEQ_transform.h"
#include "strip_time.h"
#include "utils.h"
@@ -161,6 +162,36 @@ void SEQ_time_update_sequence_bounds(Scene *scene, Sequence *seq)
}
}
+static void seq_time_update_meta_strip(Scene *scene, Sequence *seq_meta)
+{
+ if (BLI_listbase_is_empty(&seq_meta->seqbase)) {
+ return;
+ }
+
+ int min = MAXFRAME * 2;
+ int max = -MAXFRAME * 2;
+ LISTBASE_FOREACH (Sequence *, seq, &seq_meta->seqbase) {
+ min = min_ii(seq->startdisp, min);
+ max = max_ii(seq->enddisp, max);
+ }
+
+ seq_meta->start = min + seq_meta->anim_startofs;
+ seq_meta->len = max - min;
+ seq_meta->len -= seq_meta->anim_startofs;
+ seq_meta->len -= seq_meta->anim_endofs;
+
+ seq_update_sound_bounds_recursive(scene, seq_meta);
+}
+
+static void seq_time_update_meta_strip_range(Scene *scene, Sequence *seq_meta)
+{
+ seq_time_update_meta_strip(scene, seq_meta);
+
+ /* Prevent metastrip to move in timeline. */
+ SEQ_transform_set_left_handle_frame(seq_meta, seq_meta->startdisp);
+ SEQ_transform_set_right_handle_frame(seq_meta, seq_meta->enddisp);
+}
+
void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
{
Sequence *seqm;
@@ -211,6 +242,16 @@ void SEQ_time_update_sequence(Scene *scene, Sequence *seq)
}
}
else {
+ if (seq->type == SEQ_TYPE_META) {
+ seq_time_update_meta_strip(scene, seq);
+ }
+
+ Editing *ed = SEQ_editing_get(scene, false);
+ MetaStack *ms = SEQ_meta_stack_active_get(ed);
+ if (ms != NULL) {
+ seq_time_update_meta_strip_range(scene, ms->parseq);
+ }
+
SEQ_time_update_sequence_bounds(scene, seq);
}
}
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 3aeb2f35c2f..5300649a0cd 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -452,7 +452,7 @@ static void *ocio_transform_ibuf(PlayState *ps,
display_buffer = ibuf->rect;
*r_glsl_used = IMB_colormanagement_setup_glsl_draw_from_space(&ps->view_settings,
&ps->display_settings,
- ibuf->float_colorspace,
+ ibuf->rect_colorspace,
ibuf->dither,
false,
false);