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:
authorChris Blackbourn <chrisbblend@gmail.com>2022-08-06 00:52:23 +0300
committerChris Blackbourn <chrisbblend@gmail.com>2022-08-06 00:52:23 +0300
commit0d62e963b06eccaee2e9f33a10954e7768b81189 (patch)
tree78abea6b6783d63b45f595932193bf8dbf8cb16f
parent476de3b4637761ba3746e0559c725ee331f38473 (diff)
Cleanup: Simplify NULL handling for BKE_image_find_nearest_tile
Differential Revision: https://developer.blender.org/D15616
-rw-r--r--source/blender/blenkernel/BKE_image.h4
-rw-r--r--source/blender/editors/transform/transform_mode_resize.c9
-rw-r--r--source/blender/editors/transform/transform_mode_translate.c10
-rw-r--r--source/blender/editors/uvedit/uvedit_islands.c5
4 files changed, 8 insertions, 20 deletions
diff --git a/source/blender/blenkernel/BKE_image.h b/source/blender/blenkernel/BKE_image.h
index 8c66e92f762..202479675b0 100644
--- a/source/blender/blenkernel/BKE_image.h
+++ b/source/blender/blenkernel/BKE_image.h
@@ -420,9 +420,9 @@ void BKE_image_get_tile_uv(const struct Image *ima, const int tile_number, float
*/
int BKE_image_find_nearest_tile_with_offset(const struct Image *image,
const float co[2],
- float r_uv_offset[2]) ATTR_NONNULL(1, 2, 3);
+ float r_uv_offset[2]) ATTR_NONNULL(2, 3);
int BKE_image_find_nearest_tile(const struct Image *image, const float co[2])
- ATTR_NONNULL(1, 2) ATTR_WARN_UNUSED_RESULT;
+ ATTR_NONNULL(2) ATTR_WARN_UNUSED_RESULT;
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/editors/transform/transform_mode_resize.c b/source/blender/editors/transform/transform_mode_resize.c
index 1ccda96fecb..70599c3577c 100644
--- a/source/blender/editors/transform/transform_mode_resize.c
+++ b/source/blender/editors/transform/transform_mode_resize.c
@@ -126,19 +126,14 @@ static void constrain_scale_to_boundary(const float numerator,
static bool clip_uv_transform_resize(TransInfo *t, float vec[2])
{
- /* 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) {
- BKE_image_find_nearest_tile_with_offset(image, t->center_global, base_offset);
- }
+ const SpaceImage *sima = t->area->spacedata.first;
+ BKE_image_find_nearest_tile_with_offset(sima->image, t->center_global, base_offset);
/* Assume no change is required. */
float scale = 1.0f;
diff --git a/source/blender/editors/transform/transform_mode_translate.c b/source/blender/editors/transform/transform_mode_translate.c
index 04a41814b53..8f6ec7bd98f 100644
--- a/source/blender/editors/transform/transform_mode_translate.c
+++ b/source/blender/editors/transform/transform_mode_translate.c
@@ -437,19 +437,13 @@ static void applyTranslationValue(TransInfo *t, const float vec[3])
static bool clip_uv_transform_translation(TransInfo *t, float vec[2])
{
- /* 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) {
- BKE_image_find_nearest_tile_with_offset(image, t->center_global, base_offset);
- }
+ const SpaceImage *sima = t->area->spacedata.first;
+ BKE_image_find_nearest_tile_with_offset(sima->image, t->center_global, base_offset);
float min[2], max[2];
min[0] = min[1] = FLT_MAX;
diff --git a/source/blender/editors/uvedit/uvedit_islands.c b/source/blender/editors/uvedit/uvedit_islands.c
index 2afc60a4b5c..3877a9bb63b 100644
--- a/source/blender/editors/uvedit/uvedit_islands.c
+++ b/source/blender/editors/uvedit/uvedit_islands.c
@@ -259,9 +259,8 @@ static float uv_nearest_image_tile_distance(const Image *image,
const float coords[2],
float nearest_tile_co[2])
{
- if (BKE_image_find_nearest_tile_with_offset(image, coords, nearest_tile_co) == -1) {
- zero_v2(nearest_tile_co);
- }
+ BKE_image_find_nearest_tile_with_offset(image, coords, nearest_tile_co);
+
/* Add 0.5 to get tile center coordinates. */
float nearest_tile_center_co[2] = {nearest_tile_co[0], nearest_tile_co[1]};
add_v2_fl(nearest_tile_center_co, 0.5f);