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
path: root/source
diff options
context:
space:
mode:
authorAleksi Juvani <aleksijuvani>2022-04-07 00:58:59 +0300
committerFabian Schempp <fabianschempp@googlemail.com>2022-04-11 01:31:59 +0300
commitf9a85210e9f33c968c01b2a42c3f6e08397bf52d (patch)
tree74883c1975a943485bac7d94220a6d8603f0141e /source
parent19d8fb86432522b98cfbf4c1bafd09f3b83d8c3d (diff)
Fix: Division by zero in UV packing function
If all islands had a size of zero, a division by zero would occur in `GEO_uv_parametrizer_pack`, causing the UV coordinates to be set to NaN. An alternative approach would be to skip packing islands with a zero size, but If UV coordinates are for example outside the 0-1 range, it's better if they get moved into that range. Differential Revision: https://developer.blender.org/D14522
Diffstat (limited to 'source')
-rw-r--r--source/blender/geometry/intern/uv_parametrizer.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/source/blender/geometry/intern/uv_parametrizer.c b/source/blender/geometry/intern/uv_parametrizer.c
index 7b63dcb5ff0..dd97a996b18 100644
--- a/source/blender/geometry/intern/uv_parametrizer.c
+++ b/source/blender/geometry/intern/uv_parametrizer.c
@@ -4841,10 +4841,10 @@ void GEO_uv_parametrizer_pack(ParamHandle *handle,
BLI_box_pack_2d(boxarray, phandle->ncharts - unpacked, &tot_width, &tot_height);
if (tot_height > tot_width) {
- scale = 1.0f / tot_height;
+ scale = tot_height != 0.0f ? (1.0f / tot_height) : 1.0f;
}
else {
- scale = 1.0f / tot_width;
+ scale = tot_width != 0.0f ? (1.0f / tot_width) : 1.0f;
}
for (i = 0; i < phandle->ncharts - unpacked; i++) {