From 090d30b724de78f0f59f3ef2cddcce36b0a13944 Mon Sep 17 00:00:00 2001 From: Prakxo Date: Mon, 8 Jan 2024 11:58:57 +0000 Subject: [PATCH] consistent usage of F32_IS_ZERO --- src/ac_train0_move.c_inc | 6 +++--- src/ac_train1_move.c_inc | 4 ++-- src/c_keyframe.c | 24 ++++++++++++------------ src/m_camera2.c | 6 +++--- src/m_collision_obj.c | 4 ++-- src/m_train_control.c | 2 +- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/ac_train0_move.c_inc b/src/ac_train0_move.c_inc index 0d415ea0..9e4ac8c7 100644 --- a/src/ac_train0_move.c_inc +++ b/src/ac_train0_move.c_inc @@ -84,7 +84,7 @@ static void aTR0_steam_work(ACTOR* actor, GAME* game){ static f32 calc_speed1(ACTOR* actor){ TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - if(fabsf(train0->tr_speed) < 0.008f){ + if(F32_IS_ZERO(train0->tr_speed)){ return 0.8f + train0->actor_class.speed; } @@ -97,7 +97,7 @@ static f32 calc_speed1(ACTOR* actor){ static f32 calc_speed2(ACTOR* actor){ TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor; - int should_stop = fabsf(train0->actor_class.speed) < 0.008f; + int should_stop = F32_IS_ZERO(train0->actor_class.speed); return should_stop == FALSE ? train0->actor_class.speed : -0.23f; } @@ -182,7 +182,7 @@ static void aTR0_actor_move(ACTOR* actor, GAME* game){ aTR0_animation(actor); aTR0_move(actor); - if(!(fabsf(train0->actor_class.speed) < 0.008f)){ + if(!F32_IS_ZERO(train0->actor_class.speed)){ aTR0_set_effect(actor,game); aTR0_steam_work(actor,game); } diff --git a/src/ac_train1_move.c_inc b/src/ac_train1_move.c_inc index 7b952699..1cce22c0 100644 --- a/src/ac_train1_move.c_inc +++ b/src/ac_train1_move.c_inc @@ -8,7 +8,7 @@ static f32 calc_speed1(ACTOR* actor0, ACTOR* actor1) { TRAIN0_ACTOR* train0 = (TRAIN0_ACTOR*)actor0; TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor1; - if (fabsf(actor1->speed) < 0.008f) { + if (F32_IS_ZERO(actor1->speed)) { return 0.8f + train0->tr_speed; } @@ -21,7 +21,7 @@ static f32 calc_speed1(ACTOR* actor0, ACTOR* actor1) { static f32 calc_speed2(ACTOR* actor){ TRAIN1_ACTOR* train1 = (TRAIN1_ACTOR*)actor; - int should_stop = fabsf(train1->tr0_pos) < 0.008f; + int should_stop = F32_IS_ZERO(train1->tr0_pos); return should_stop == FALSE ? train1->tr0_pos : -0.23f; } diff --git a/src/c_keyframe.c b/src/c_keyframe.c index 7a967136..689da84f 100644 --- a/src/c_keyframe.c +++ b/src/c_keyframe.c @@ -162,7 +162,7 @@ static s16 cKF_KeyCalc(s16 index, s16 next_index, s16* data_src, f32 frame) { if (s_vec[i].x > frame) { sub = s_vec[i].x - s_vec[j].x; - if (!(fabsf(sub) < 0.008f)) { + if (!(F32_IS_ZERO(sub))) { f32 t = (frame - s_vec[j].x) / sub; f32 tension = sub * (1.0f / 30.0f); f32 calc = cKF_HermitCalc(t, tension, s_vec[j].y, s_vec[i].y, s_vec[j].z, s_vec[i].z); @@ -283,7 +283,7 @@ static void cKF_SkeletonInfo_R_morphJoint(cKF_SkeletonInfo_R_c* keyframe) { s_xyz* current_joint = keyframe->current_joint; s_xyz* target_joint = keyframe->target_joint; - if (!(fabsf(keyframe->morph_counter) < 0.008f)) { + if (!(F32_IS_ZERO(keyframe->morph_counter))) { step = 0.5f / fabsf(keyframe->morph_counter); } else { step = 0.0f; @@ -370,7 +370,7 @@ extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) { int t = 0; int index = 0; - s16* joint = (fabsf(keyframe->morph_counter) < 0.008f) + s16* joint = (F32_IS_ZERO(keyframe->morph_counter)) ? &keyframe->current_joint->x : &keyframe->target_joint->x; int joint_num = 32; @@ -425,7 +425,7 @@ extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) { } if (keyframe->rotation_diff_table != NULL) { - c_joint = (fabsf(keyframe->morph_counter) < 0.008f) + c_joint = (F32_IS_ZERO(keyframe->morph_counter)) ? keyframe->current_joint : keyframe->target_joint; @@ -439,7 +439,7 @@ extern int cKF_SkeletonInfo_R_play(cKF_SkeletonInfo_R_c* keyframe) { } } - if (fabsf(keyframe->morph_counter) < 0.008f) { + if (F32_IS_ZERO(keyframe->morph_counter)) { ret = cKF_FrameControl_play(&keyframe->frame_control); } else if (keyframe->morph_counter > 0.0f) { cKF_SkeletonInfo_R_morphJoint(keyframe); @@ -808,7 +808,7 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, if ((info1 == NULL) || (info2 == NULL) || (flag == NULL)) { return 0; } - joint = (fabsf(info1->morph_counter) < 0.008f) ? &info1->current_joint->x + joint = (F32_IS_ZERO(info1->morph_counter)) ? &info1->current_joint->x : &info1->target_joint->x; if (info1 != NULL) { @@ -823,7 +823,7 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, cKF_SkeletonInfo_R_combine_rotation(&joint, &combinet, &combine3, flag); if (info1->rotation_diff_table != NULL) { - applyjoint = (fabsf(info1->morph_counter) < 0.008f) ? info1->current_joint + applyjoint = (F32_IS_ZERO(info1->morph_counter)) ? info1->current_joint : info1->target_joint; applyjoint += 1; @@ -835,7 +835,7 @@ extern int cKF_SkeletonInfo_R_combine_play(cKF_SkeletonInfo_R_c* info1, applyjoint++; } } - if (fabsf(info1->morph_counter) < 0.008f) { + if (F32_IS_ZERO(info1->morph_counter)) { cKF_FrameControl_play(&info2->frame_control); return cKF_FrameControl_play(&info1->frame_control); } @@ -877,7 +877,7 @@ extern void cKF_SkeletonInfo_R_T_combine_play(int* arg1, int* arg2, int* arg3, return; } - joint = (fabsf(info1->morph_counter) < 0.008f) ? &info1->current_joint->x + joint = (F32_IS_ZERO(info1->morph_counter)) ? &info1->current_joint->x : &info1->target_joint->x; if (info1 != NULL) { @@ -895,7 +895,7 @@ extern void cKF_SkeletonInfo_R_T_combine_play(int* arg1, int* arg2, int* arg3, cKF_SkeletonInfo_R_combine_rotation(&joint, &combinet, &combine3, flag); if (info1->rotation_diff_table != NULL) { - applyjoint = (fabsf(info1->morph_counter) < 0.008f) ? info1->current_joint + applyjoint = (F32_IS_ZERO(info1->morph_counter)) ? info1->current_joint : info1->target_joint; applyjoint += 1; @@ -907,7 +907,7 @@ extern void cKF_SkeletonInfo_R_T_combine_play(int* arg1, int* arg2, int* arg3, applyjoint++; } } - if (fabsf(info1->morph_counter) < 0.008f) { + if (F32_IS_ZERO(info1->morph_counter)) { *arg1 = cKF_FrameControl_play(&info1->frame_control); *arg2 = cKF_FrameControl_play(&info2->frame_control); *arg3 = cKF_FrameControl_play(&info3->frame_control); @@ -1155,4 +1155,4 @@ extern void cKF_SkeletonInfo_R_AnimationMove_CulcTransToWorld( if (animation_flag & 2) { base->y = calcp->y + trans->y * (cur_joint->y - calcy); } -} \ No newline at end of file +} diff --git a/src/m_camera2.c b/src/m_camera2.c index 17ed1bc5..99f8fe97 100644 --- a/src/m_camera2.c +++ b/src/m_camera2.c @@ -27,7 +27,7 @@ static void Camera2_DirectionCalc(GAME_PLAY* play) { dir = camera->direction; mag = Math3d_normalizeXyz_t(&eye_minus_center); - if (fabsf(mag) < 0.008f) { + if (F32_IS_ZERO(mag)) { camera->direction.x = 0; camera->direction.y = 0; camera->direction.z = 0; @@ -198,7 +198,7 @@ static void Camera2_SetView(GAME_PLAY* play) { view = &play->view; center = &camera->lookat.center; - if (fabsf(Math3DLength(eye, center)) < 0.008f) { + if (F32_IS_ZERO(Math3DLength(eye, center))) { eye->z = center->z + 1.0f; } @@ -221,7 +221,7 @@ static void Camera2_SetView(GAME_PLAY* play) { } } - if (fabsf(camera->perspective.fov_y) < 0.008f) { + if (F32_IS_ZERO(camera->perspective.fov_y)) { camera->perspective.fov_y += 1.0f; } diff --git a/src/m_collision_obj.c b/src/m_collision_obj.c index 05924eab..2cea60e9 100644 --- a/src/m_collision_obj.c +++ b/src/m_collision_obj.c @@ -462,7 +462,7 @@ void CollisionCheck_setOC_HitInfo(ClObj_c* col1, ClObjElem_c* colelem1, xyz_t* p comweight = weight1 + weight2; - if (fabsf(comweight) < 0.008f) + if (F32_IS_ZERO(comweight)) { weight1 = weight2 = 1.0f; comweight = 2.0f; @@ -529,7 +529,7 @@ void CollisionCheck_setOC_HitInfo(ClObj_c* col1, ClObjElem_c* colelem1, xyz_t* p actor1->speed = 0.0f; } - if (!(fabsf(xzdist) < 0.008f)) + if (!(F32_IS_ZERO(xzdist))) { xdiff *= diff / xzdist; diff --git a/src/m_train_control.c b/src/m_train_control.c index 7b803995..31ac381a 100644 --- a/src/m_train_control.c +++ b/src/m_train_control.c @@ -331,7 +331,7 @@ static void mTRC_trainControl(GAME_PLAY* play, int state) { case mTRC_ACTION_BEGIN_STOP: { chase_f(&speed, 0.0f, 0.005f); - if (fabsf(speed) < 0.008f) { + if (F32_IS_ZERO(speed)) { signal = TRUE; timer = 48; action = mTRC_ACTION_SIGNAL_STOPPED;