1#include <game/sLib/s_lib.hpp>
6float sLib::addCalc(
float *value,
float target,
float smoothing,
float maxStep,
float minStep) {
7 if (*value != target) {
8 float dist = target - *value;
9 float step = smoothing * dist;
11 if (step >= minStep || step <= -minStep) {
15 if (step < -maxStep) {
21 }
else if (step > 0.0f) {
24 if (*value > target) {
30 if (step > -minStep) {
32 if (*value < target) {
40 float dist = target - *value;
41 return (dist > 0.0f) ? dist : -dist;
46 T dist = target - *value;
47 if (*value != target) {
48 T step = dist / smoothing;
50 if (step > minStep || step < -minStep) {
54 else if (step < -maxStep) {
60 }
else if (dist >= 0) {
62 dist = target - *value;
69 dist = target - *value;
76 return target - *value;
85 T dist = target - *value;
86 T step = dist / smoothing;
90 }
else if (step < -maxStep) {
103 if (*value == target) {
108 if (*value > target) {
113 if (step * (*value - target) >= 0) {
139 if (*value == target) {
144 s16 dist = *value - target;
150 dist = *value - target;
152 if (step * dist >= 0) {
162 if (*value == target) {
167 s16 increment = step;
171 step = (step == 0x8000) ? 0x7fff : (s16)-step;
175 s16 dist = *value - target;
184 if (increment * step > 0) {
185 s16 dist = *value - target;
186 if (increment * dist >= 0) {
T addCalcAngleT(T *value, T target, T smoothing, T maxStep, T minStep)
Smoothly moves value towards target using proportional scaling.
BOOL chaseT(T *value, T target, T step)
Moves value towards target by a fixed step amount.
float addCalc(float *value, float target, float smoothing, float maxStep, float minStep)
Smoothly moves value towards target using proportional scaling.
s16 addCalcAngle(s16 *value, s16 target, s16 smoothing, s16 maxStep, s16 minStep)
Smoothly moves value towards target using proportional scaling.
BOOL chaseAngleByRotDir(s16 *value, s16 target, s16 step)
Moves value towards target by a fixed step amount.
vprintfFunc p_VPrintfFuncPtr
Pointer to std::printf.
BOOL chaseAngle(s16 *value, s16 target, s16 step)
Moves value towards target by a fixed step amount.
BOOL chase(s16 *value, s16 target, s16 step)
Moves value towards target by a fixed step amount.