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:
authorSybren A. Stüvel <sybren@blender.org>2020-11-27 12:15:20 +0300
committerSybren A. Stüvel <sybren@blender.org>2020-11-27 12:15:20 +0300
commite4b6afbe6bb4783a76ad2129ad1b57af56409986 (patch)
tree8d9e641c149cc12d8379e1faba138849653cf2c3 /source/blender/blenkernel/intern/fmodifier.c
parent45dca05b1cd2a5ead59144c93d790fdfe7c35ee6 (diff)
Cleanup: Animation, clean up FCurve Cycles modifier
Simplify conditions and declare variables `const` where possible. No functional changes.
Diffstat (limited to 'source/blender/blenkernel/intern/fmodifier.c')
-rw-r--r--source/blender/blenkernel/intern/fmodifier.c33
1 files changed, 16 insertions, 17 deletions
diff --git a/source/blender/blenkernel/intern/fmodifier.c b/source/blender/blenkernel/intern/fmodifier.c
index 6ebcef5caef..d0018a556ba 100644
--- a/source/blender/blenkernel/intern/fmodifier.c
+++ b/source/blender/blenkernel/intern/fmodifier.c
@@ -623,7 +623,7 @@ static void fcm_cycles_new_data(void *mdata)
static float fcm_cycles_time(
FCurve *fcu, FModifier *fcm, float UNUSED(cvalue), float evaltime, void *storage_)
{
- FMod_Cycles *data = (FMod_Cycles *)fcm->data;
+ const FMod_Cycles *data = (FMod_Cycles *)fcm->data;
tFCMED_Cycles *storage = storage_;
float prevkey[2], lastkey[2], cycyofs = 0.0f;
short side = 0, mode = 0;
@@ -640,10 +640,14 @@ static float fcm_cycles_time(
return evaltime;
}
+ if (fcu == NULL || (fcu->bezt == NULL && fcu->fpt == NULL)) {
+ return evaltime;
+ }
+
/* calculate new evaltime due to cyclic interpolation */
- if (fcu && fcu->bezt) {
- BezTriple *prevbezt = fcu->bezt;
- BezTriple *lastbezt = prevbezt + fcu->totvert - 1;
+ if (fcu->bezt) {
+ const BezTriple *prevbezt = fcu->bezt;
+ const BezTriple *lastbezt = prevbezt + fcu->totvert - 1;
prevkey[0] = prevbezt->vec[1][0];
prevkey[1] = prevbezt->vec[1][1];
@@ -651,9 +655,10 @@ static float fcm_cycles_time(
lastkey[0] = lastbezt->vec[1][0];
lastkey[1] = lastbezt->vec[1][1];
}
- else if (fcu && fcu->fpt) {
- FPoint *prevfpt = fcu->fpt;
- FPoint *lastfpt = prevfpt + fcu->totvert - 1;
+ else {
+ BLI_assert(fcu->fpt != NULL);
+ const FPoint *prevfpt = fcu->fpt;
+ const FPoint *lastfpt = prevfpt + fcu->totvert - 1;
prevkey[0] = prevfpt->vec[0];
prevkey[1] = prevfpt->vec[1];
@@ -661,9 +666,6 @@ static float fcm_cycles_time(
lastkey[0] = lastfpt->vec[0];
lastkey[1] = lastfpt->vec[1];
}
- else {
- return evaltime;
- }
/* check if modifier will do anything
* 1) if in data range, definitely don't do anything
@@ -691,12 +693,9 @@ static float fcm_cycles_time(
/* find relative place within a cycle */
{
- float cycdx = 0, cycdy = 0;
- float cycle = 0, cyct = 0;
-
/* calculate period and amplitude (total height) of a cycle */
- cycdx = lastkey[0] - prevkey[0];
- cycdy = lastkey[1] - prevkey[1];
+ const float cycdx = lastkey[0] - prevkey[0];
+ const float cycdy = lastkey[1] - prevkey[1];
/* check if cycle is infinitely small, to be point of being impossible to use */
if (cycdx == 0) {
@@ -704,10 +703,10 @@ static float fcm_cycles_time(
}
/* calculate the 'number' of the cycle */
- cycle = ((float)side * (evaltime - ofs) / cycdx);
+ const float cycle = ((float)side * (evaltime - ofs) / cycdx);
/* calculate the time inside the cycle */
- cyct = fmod(evaltime - ofs, cycdx);
+ const float cyct = fmod(evaltime - ofs, cycdx);
/* check that cyclic is still enabled for the specified time */
if (cycles == 0) {