Rename cmplx32 into cmplxf for better consistency

This commit is contained in:
Andrei Alexeyev 2020-05-09 09:31:20 +03:00
parent bd5082c0f0
commit 54ca97587c
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
10 changed files with 29 additions and 30 deletions

View file

@ -264,7 +264,7 @@ static void player_draw_indicators(EntityInterface *ent) {
float focus_opacity = indicators->focus_alpha;
int t = global.frames - indicators->focus_time;
cmplx32 pos = plr->pos;
cmplxf pos = plr->pos;
if(focus_opacity > 0) {
float trans_frames = 12;

View file

@ -315,7 +315,7 @@ TASK(reimu_spirit_bomb_orb_visual, { BoxedProjectile orb; }) {
ENT_ARRAY_FOREACH_COUNTER(&components, int i, Projectile *p, {
real t = global.frames - p->birthtime;
cmplx32 offset = (10 + pow(t, 0.5)) * cdir(2.0 * M_PI / 3*i + sqrt(1 + t * t / 300));
cmplxf offset = (10 + pow(t, 0.5)) * cdir(2.0 * M_PI / 3*i + sqrt(1 + t * t / 300));
p->pos = pos + offset;
});

View file

@ -909,7 +909,7 @@ SpriteParams projectile_sprite_params(Projectile *proj, SpriteParamsBuffer *spbu
return sp;
}
static void projectile_draw_sprite(Sprite *s, const Color *clr, float opacity, cmplx32 scale) {
static void projectile_draw_sprite(Sprite *s, const Color *clr, float opacity, cmplxf scale) {
if(opacity <= 0 || crealf(scale) == 0) {
return;
}
@ -1056,15 +1056,15 @@ void ScaleFade(Projectile *p, int t, ProjDrawRuleArgs args) {
}
static void pdraw_scalefade_func(Projectile *p, int t, ProjDrawRuleArgs args) {
cmplx32 scale0 = args[0].as_cmplx;
cmplx32 scale1 = args[1].as_cmplx;
cmplxf scale0 = args[0].as_cmplx;
cmplxf scale1 = args[1].as_cmplx;
float opacity0 = args[2].as_float[0];
float opacity1 = args[2].as_float[1];
float opacity_exp = args[3].as_float[0];
float timefactor = t / p->timeout;
cmplx32 scale = clerpf(scale0, scale1, timefactor);
cmplxf scale = clerpf(scale0, scale1, timefactor);
float opacity = lerpf(opacity0, opacity1, timefactor);
opacity = powf(opacity, opacity_exp);
@ -1076,7 +1076,8 @@ static void pdraw_scalefade_func(Projectile *p, int t, ProjDrawRuleArgs args) {
r_draw_sprite(&sp);
}
ProjDrawRule pdraw_timeout_scalefade_exp(cmplx32 scale0, cmplx32 scale1, float opacity0, float opacity1, float opacity_exp) {
ProjDrawRule pdraw_timeout_scalefade_exp(cmplxf scale0,
cmplxf scale1, float opacity0, float opacity1, float opacity_exp) {
if(cimagf(scale0) == 0) {
scale0 = CMPLXF(crealf(scale0), crealf(scale0));
}
@ -1094,11 +1095,12 @@ ProjDrawRule pdraw_timeout_scalefade_exp(cmplx32 scale0, cmplx32 scale1, float o
};
}
ProjDrawRule pdraw_timeout_scalefade(cmplx32 scale0, cmplx32 scale1, float opacity0, float opacity1) {
ProjDrawRule pdraw_timeout_scalefade(
cmplxf scale0, cmplxf scale1, float opacity0, float opacity1) {
return pdraw_timeout_scalefade_exp(scale0, scale1, opacity0, opacity1, 1.0f);
}
ProjDrawRule pdraw_timeout_scale(cmplx32 scale0, cmplx32 scale1) {
ProjDrawRule pdraw_timeout_scale(cmplxf scale0, cmplxf scale1) {
// TODO: specialized code path without fade component
return pdraw_timeout_scalefade(scale0, scale1, 1, 1);
}

View file

@ -44,7 +44,7 @@ typedef bool (*ProjPredicate)(Projectile *p);
typedef union {
float as_float[2];
cmplx32 as_cmplx;
cmplxf as_cmplx;
void *as_ptr;
} ProjDrawRuleArgs[RULE_ARGC];
@ -119,7 +119,7 @@ DEFINE_ENTITY_TYPE(Projectile, {
ProjFlags flags;
uint clear_flags;
cmplx32 scale;
cmplxf scale;
float opacity;
// XXX: this is in frames of course, but needs to be float
@ -161,7 +161,7 @@ typedef struct ProjArgs {
int max_viewport_dist;
drawlayer_t layer;
cmplx32 scale;
cmplxf scale;
float opacity;
// XXX: this is in frames of course, but needs to be float
@ -248,9 +248,9 @@ void GrowFade(Projectile *p, int t, ProjDrawRuleArgs) DEPRECATED_DRAW_RULE;
void ScaleFade(Projectile *p, int t, ProjDrawRuleArgs) DEPRECATED_DRAW_RULE;
ProjDrawRule pdraw_basic(void);
ProjDrawRule pdraw_timeout_scalefade_exp(cmplx32 scale0, cmplx32 scale1, float opacity0, float opacity1, float opacity_exp);
ProjDrawRule pdraw_timeout_scalefade(cmplx32 scale0, cmplx32 scale1, float opacity0, float opacity1);
ProjDrawRule pdraw_timeout_scale(cmplx32 scale0, cmplx32 scale1);
ProjDrawRule pdraw_timeout_scalefade_exp(cmplxf scale0, cmplxf scale1, float opacity0, float opacity1, float opacity_exp);
ProjDrawRule pdraw_timeout_scalefade(cmplxf scale0, cmplxf scale1, float opacity0, float opacity1);
ProjDrawRule pdraw_timeout_scale(cmplxf scale0, cmplxf scale1);
ProjDrawRule pdraw_timeout_fade(float opacity0, float opacity1);
ProjDrawRule pdraw_petal(float rot_angle, vec3 rot_axis);
ProjDrawRule pdraw_petal_random(void);

View file

@ -371,7 +371,7 @@ typedef union SpriteScaleParams {
float y;
};
cmplx32 as_cmplx;
cmplxf as_cmplx;
} SpriteScaleParams;
typedef struct SpriteRotationParams {

View file

@ -287,7 +287,7 @@ static void animate_bg_midboss(int anim_time) {
fapproach_asymptotic_p(&stage_3d_context.cam.rot.pitch, 30, 0.01 * camera_shift_rate, 1e-4);
float a = glm_rad(stage_3d_context.cam.rot.roll + 67.5);
cmplx32 p = cdir(a) * -2200;
cmplxf p = cdir(a) * -2200;
fapproach_asymptotic_p(&stage_3d_context.cam.pos[0], crealf(p), 0.01 * camera_shift_rate, 1e-4);
fapproach_asymptotic_p(&stage_3d_context.cam.pos[1], cimagf(p), 0.01 * camera_shift_rate, 1e-4);
@ -309,7 +309,7 @@ static void animate_bg_post_midboss(int anim_time) {
fapproach_asymptotic_p(&stage_3d_context.cam.rot.pitch, -10, 0.01 * camera_shift_rate, 1e-4);
float a = glm_rad(stage_3d_context.cam.rot.roll + 67.5);
cmplx32 p = cdir(a) * center_distance;
cmplxf p = cdir(a) * center_distance;
fapproach_asymptotic_p(&stage_3d_context.cam.pos[0], crealf(p), 0.01 * camera_shift_rate, 1e-4);
fapproach_asymptotic_p(&stage_3d_context.cam.pos[1], cimagf(p), 0.01 * camera_shift_rate, 1e-4);

View file

@ -155,14 +155,11 @@ typedef signed char schar;
#undef real
typedef double real;
#undef cmplx32
typedef _Complex float cmplx32;
#undef cmplx64
typedef _Complex double cmplx64;
#undef cmplxf
typedef _Complex float cmplxf;
#undef cmplx
typedef cmplx64 cmplx;
typedef _Complex double cmplx;
// These definitions are common but non-standard, so we provide our own
#undef M_PI

View file

@ -13,12 +13,12 @@
typedef union FloatOffset {
struct { float x, y; };
cmplx32 as_cmplx;
cmplxf as_cmplx;
} FloatOffset;
typedef union FloatExtent {
struct { float w, h; };
cmplx32 as_cmplx;
cmplxf as_cmplx;
} FloatExtent;
typedef struct FloatRect {

View file

@ -23,7 +23,7 @@ cmplx clerp(cmplx v0, cmplx v1, double f) {
return f * (v1 - v0) + v0;
}
cmplx32 clerpf(cmplx32 v0, cmplx32 v1, float f) {
cmplxf clerpf(cmplxf v0, cmplxf v1, float f) {
return f * (v1 - v0) + v0;
}
@ -138,7 +138,7 @@ cmplx cwmul(cmplx c0, cmplx c1) {
return CMPLX(creal(c0)*creal(c1), cimag(c0)*cimag(c1));
}
cmplx32 cwmulf(cmplx32 c0, cmplx32 c1) {
cmplxf cwmulf(cmplxf c0, cmplxf c1) {
return CMPLXF(crealf(c0)*crealf(c1), cimagf(c0)*cimagf(c1));
}

View file

@ -19,7 +19,7 @@
double lerp(double v0, double v1, double f) attr_const;
float lerpf(float v0, float v1, float f) attr_const;
cmplx clerp(cmplx v0, cmplx v1, double f) attr_const;
cmplx32 clerpf(cmplx32 v0, cmplx32 v1, float f) attr_const;
cmplxf clerpf(cmplxf v0, cmplxf v1, float f) attr_const;
intmax_t imin(intmax_t, intmax_t) attr_const;
intmax_t imax(intmax_t, intmax_t) attr_const;
uintmax_t umin(uintmax_t, uintmax_t) attr_const;
@ -43,7 +43,7 @@ cmplx cclampabs(cmplx c, double maxabs) attr_const;
cmplx cwclamp(cmplx c, cmplx cmin, cmplx cmax) attr_const;
cmplx cdir(double angle) attr_const;
cmplx cwmul(cmplx c0, cmplx c1) attr_const;
cmplx32 cwmulf(cmplx32 c0, cmplx32 c1) attr_const;
cmplxf cwmulf(cmplxf c0, cmplxf c1) attr_const;
cmplx cswap(cmplx c) attr_const;
double psin(double) attr_const;
double pcos(double) attr_const;