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:
authorHans Goudey <h.goudey@me.com>2021-10-04 04:28:31 +0300
committerHans Goudey <h.goudey@me.com>2021-10-04 04:28:31 +0300
commitcc8fa3ee909927c817b881b39f806b0753c80b86 (patch)
tree083d4f90a23912a151ddfed1f20c35ddbe1e9431 /source/blender/blenkernel/intern/curveprofile.cc
parentdfdc9c62199ebb77007a59aa8e57aba1cb6988de (diff)
Fix T91904: Assert when loading empty CurveProfile
Somehow, the file from T71329 has an empty curve profile. While that may be a problem in itself, it's reasonable to avoid asserts or crashes when loading or drawing such a CurveProfile. This commit just makes sure the table always has a single vertex, and adds some checks in drawing code.
Diffstat (limited to 'source/blender/blenkernel/intern/curveprofile.cc')
-rw-r--r--source/blender/blenkernel/intern/curveprofile.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/curveprofile.cc b/source/blender/blenkernel/intern/curveprofile.cc
index 78ec05838c2..7f2a2bc342d 100644
--- a/source/blender/blenkernel/intern/curveprofile.cc
+++ b/source/blender/blenkernel/intern/curveprofile.cc
@@ -594,7 +594,8 @@ int BKE_curveprofile_table_size(const CurveProfile *profile)
/** Number of table points per control point. */
const int resolution = 16;
- return std::clamp((profile->path_len - 1) * resolution + 1, 0, PROF_TABLE_MAX);
+ /* Make sure there is always one sample, even if there are no control points. */
+ return std::clamp((profile->path_len - 1) * resolution + 1, 1, PROF_TABLE_MAX);
}
/**
@@ -1006,7 +1007,10 @@ static void curveprofile_make_table(CurveProfile *profile)
CurveProfilePoint *new_table = (CurveProfilePoint *)MEM_callocN(
sizeof(CurveProfilePoint) * (n_samples + 1), __func__);
- create_samples(profile, n_samples - 1, false, new_table);
+ if (n_samples > 1) {
+ create_samples(profile, n_samples - 1, false, new_table);
+ }
+
/* Manually add last point at the end of the profile */
new_table[n_samples - 1].x = 0.0f;
new_table[n_samples - 1].y = 1.0f;