Skip to content

Commit

Permalink
Fixed bug in splines.
Browse files Browse the repository at this point in the history
  • Loading branch information
c-lipka committed Feb 27, 2016
1 parent 147066f commit 832d571
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion source/base/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define OFFICIAL_VERSION_STRING "3.7.1"
#define OFFICIAL_VERSION_NUMBER 371

#define POV_RAY_PRERELEASE "alpha.8497793"
#define POV_RAY_PRERELEASE "alpha.8498353"

#if (POV_RAY_IS_AUTOBUILD == 1) && ((POV_RAY_IS_OFFICIAL == 1) || (POV_RAY_IS_SEMI_OFFICIAL == 1))
#ifdef POV_RAY_PRERELEASE
Expand Down
20 changes: 16 additions & 4 deletions source/core/math/spline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,10 +668,22 @@ void Insert_Spline_Entry(GenericSpline * sp, DBL p, const EXPRESS& v)
* pre-computed coefficients */
sp->Coeffs_Computed = false;
i = findt(sp, p);
/* If p is already in spline, replace */
/* The clause after the || is needed because findt returns sp->SplineEntries.size()
* if p is greater than OR EQUAL TO the highest par in the spline */
if(!sp->SplineEntries.empty() && ((sp->SplineEntries[i].par == p) || (i == sp->SplineEntries.size() && sp->SplineEntries[i-1].par == p)))
// If p is already in the spline, replace it.
bool replace = false;
if (!sp->SplineEntries.empty())
{
// If p matches the _last_ spline entry, `findt()` is implemented to return `sp->SplineEntries.size()`
// instead of the index of the matching entry; this has some benefits in the other places `findt()` is used,
// but requires the following workaround here.
if (i == sp->SplineEntries.size() && (sp->SplineEntries[i-1].par == p))
{
--i;
replace = true;
}
else
replace = (sp->SplineEntries[i].par == p);
}
if(replace)
{
for(k=0; k<5; k++)
sp->SplineEntries[i].vec[k] = v[k];
Expand Down
2 changes: 1 addition & 1 deletion unix/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.1-alpha.8497793
3.7.1-alpha.8498353

0 comments on commit 832d571

Please sign in to comment.