mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
convert Flip CustomModelAnimType to use a euclidian modulo function
This commit is contained in:
parent
5c8c13f80f
commit
f60b1246cc
12
src/Model.c
12
src/Model.c
@ -526,6 +526,14 @@ void CustomModel_BuildPart(struct CustomModel* cm, struct CustomModelPartDef* pa
|
|||||||
part->rotationOrigin.X, part->rotationOrigin.Y, part->rotationOrigin.Z);
|
part->rotationOrigin.X, part->rotationOrigin.Y, part->rotationOrigin.Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* C's % operator/fmod act differently on negatives vs positives,
|
||||||
|
but we want the function to be consistent on both so that the user can
|
||||||
|
specify direction using the "a" parameter in "Game.Time * anim->a".
|
||||||
|
*/
|
||||||
|
static float EuclidianMod(float x, float y) {
|
||||||
|
return x - Math_Floor(x / y) * y;
|
||||||
|
}
|
||||||
|
|
||||||
static struct ModelVertex oldVertices[MODEL_BOX_VERTICES];
|
static struct ModelVertex oldVertices[MODEL_BOX_VERTICES];
|
||||||
static float CustomModel_GetAnimationValue(
|
static float CustomModel_GetAnimationValue(
|
||||||
struct CustomModelAnim* anim,
|
struct CustomModelAnim* anim,
|
||||||
@ -595,12 +603,12 @@ static float CustomModel_GetAnimationValue(
|
|||||||
case CustomModelAnimType_FlipRotate:
|
case CustomModelAnimType_FlipRotate:
|
||||||
case CustomModelAnimType_FlipTranslate:
|
case CustomModelAnimType_FlipTranslate:
|
||||||
case CustomModelAnimType_FlipSize:
|
case CustomModelAnimType_FlipSize:
|
||||||
return Math_Modf((float)Game.Time * anim->a + anim->c, anim->d) * anim->b;
|
return EuclidianMod((float)Game.Time * anim->a + anim->c, anim->d) * anim->b;
|
||||||
|
|
||||||
case CustomModelAnimType_FlipRotateVelocity:
|
case CustomModelAnimType_FlipRotateVelocity:
|
||||||
case CustomModelAnimType_FlipTranslateVelocity:
|
case CustomModelAnimType_FlipTranslateVelocity:
|
||||||
case CustomModelAnimType_FlipSizeVelocity:
|
case CustomModelAnimType_FlipSizeVelocity:
|
||||||
return Math_Modf(e->Anim.WalkTime * anim->a + anim->c, anim->d) * anim->b;
|
return EuclidianMod(e->Anim.WalkTime * anim->a + anim->c, anim->d) * anim->b;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user