Merge branch 'master' into banjo-kazooie-var_renames
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
#include "core2/ba/anim.h"
|
||||
#include "core2/ba/physics.h"
|
||||
|
||||
|
||||
extern f32 func_802E4B38(void);
|
||||
extern f32 ml_mapRange_f(f32, f32, f32, f32, f32);
|
||||
@@ -53,14 +55,14 @@ void __baanim_update_scaleToHorizontalVelocity(void) {
|
||||
f32 scale;
|
||||
|
||||
scale = (baAnimScale.scalable_duration != 0) ? baAnimScale.duration_scale : 1.0f;
|
||||
_get_velocity(velocity);
|
||||
baphysics_get_velocity(velocity);
|
||||
temp_f12 = ml_mapRange_f(gu_sqrtf(velocity[0]*velocity[0] + velocity[2] * velocity[2]), baAnimScale.velocity_min, baAnimScale.velocity_max, baAnimScale.duration_min * scale, baAnimScale.duration_max * scale);
|
||||
animctrl_setDuration(playerAnimCtrl, ml_clamp_f(temp_f12, baAnimMinDuration, baAnimMaxDuration));
|
||||
animctrl_update(playerAnimCtrl);
|
||||
}
|
||||
|
||||
void __baanim_update_scaleToVerticalVelocity(void) {
|
||||
animctrl_setDuration(playerAnimCtrl, ml_clamp_f(ml_mapRange_f(mlAbsF(_get_vertVelocity()), baAnimScale.velocity_min, baAnimScale.velocity_max, baAnimScale.duration_min, baAnimScale.duration_max), baAnimMinDuration, baAnimMaxDuration));
|
||||
animctrl_setDuration(playerAnimCtrl, ml_clamp_f(ml_mapRange_f(mlAbsF(baphysics_get_vertical_velocity()), baAnimScale.velocity_min, baAnimScale.velocity_max, baAnimScale.duration_min, baAnimScale.duration_max), baAnimMinDuration, baAnimMaxDuration));
|
||||
animctrl_update(playerAnimCtrl);
|
||||
}
|
||||
|
||||
|
77
src/core2/ba/carry.c
Normal file
77
src/core2/ba/carry.c
Normal file
@@ -0,0 +1,77 @@
|
||||
#include "functions.h"
|
||||
|
||||
#include "core2/ba/carry.h"
|
||||
|
||||
|
||||
void bacarry_set_offsets(f32 arg0, f32 arg1);
|
||||
|
||||
/* .bss */
|
||||
struct {
|
||||
f32 height;
|
||||
f32 rotation;
|
||||
} bacarry_offsets;
|
||||
ActorMarker* baCarry_marker;
|
||||
u8 bacarry_active;
|
||||
|
||||
/* .code */
|
||||
void bacarry_init(void){
|
||||
baCarry_marker = NULL;
|
||||
bacarry_active = 0;
|
||||
bacarry_set_offsets(0.0f, 0.0f);
|
||||
}
|
||||
|
||||
void bacarry_end(void){}
|
||||
|
||||
void __bacarry_set_position_and_rotation(ActorMarker *marker, f32 arg1[3], f32 arg2[3]){
|
||||
Actor * actor = marker_getActor(marker);
|
||||
if(actor->unk138_22){
|
||||
actor->position_x = arg1[0];
|
||||
actor->position_y = arg1[1];
|
||||
actor->position_z = arg1[2];
|
||||
|
||||
actor->yaw = arg2[1];
|
||||
}
|
||||
}
|
||||
|
||||
void __bacarry_update(void){
|
||||
f32 banjoPos[3];
|
||||
f32 banjoRot[3];
|
||||
|
||||
|
||||
player_getRotation(banjoRot);
|
||||
baModel_getPosition(banjoPos);
|
||||
banjoRot[1] = mlNormalizeAngle(banjoRot[1] + bacarry_offsets.rotation);
|
||||
banjoPos[1] += bacarry_offsets.height;
|
||||
__bacarry_set_position_and_rotation(baCarry_marker, banjoPos, banjoRot);
|
||||
}
|
||||
|
||||
void bacarry_update(void){
|
||||
if(baCarry_marker != NULL){
|
||||
if(bacarry_active == 0){
|
||||
baCarry_marker = NULL;
|
||||
}
|
||||
else{
|
||||
__bacarry_update();
|
||||
bacarry_active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void bacarry_reset_marker(void){
|
||||
baCarry_marker = NULL;
|
||||
}
|
||||
|
||||
ActorMarker *bacarry_get_marker(void){
|
||||
return baCarry_marker;
|
||||
}
|
||||
|
||||
void bacarry_set_marker(ActorMarker *arg0){
|
||||
baCarry_marker = arg0;
|
||||
__bacarry_update();
|
||||
bacarry_active = 1;
|
||||
}
|
||||
|
||||
void bacarry_set_offsets(f32 height, f32 rotation){
|
||||
bacarry_offsets.height = height;
|
||||
bacarry_offsets.rotation = rotation;
|
||||
}
|
76
src/core2/ba/drone.c
Normal file
76
src/core2/ba/drone.c
Normal file
@@ -0,0 +1,76 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
|
||||
#include "core2/ba/drone.h"
|
||||
|
||||
/* .bss */
|
||||
struct {
|
||||
u8 type;
|
||||
// u8 pad1[3];
|
||||
f32 duration;
|
||||
f32 position[3];
|
||||
void (*unk14)(ActorMarker *);
|
||||
ActorMarker *unk18;
|
||||
}badrone;
|
||||
|
||||
/* .code */
|
||||
void badrone_set_type(BaDroneType type){
|
||||
badrone.type = type;
|
||||
}
|
||||
|
||||
BaDroneType badrone_get_type(void){
|
||||
return badrone.type;
|
||||
}
|
||||
|
||||
void badrone_get_position_and_duration(f32 position[3], f32 *duration){
|
||||
ml_vec3f_copy(position, badrone.position);
|
||||
*duration = badrone.duration;
|
||||
}
|
||||
|
||||
enum bs_e badrone_enter(void){
|
||||
badrone_set_type(BA_DRONE_ENTER);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
enum bs_e badrone_goto(f32 position[3], f32 duration, void (*arg2)(ActorMarker *), ActorMarker *arg3){
|
||||
ml_vec3f_copy(badrone.position, position);
|
||||
badrone.duration = duration;
|
||||
badrone.unk14 = arg2;
|
||||
badrone.unk18 = arg3;
|
||||
badrone_set_type(BA_DRONE_GOTO);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
enum bs_e badrone_look(void){
|
||||
badrone_set_type(BA_DRONE_LOOK);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
enum bs_e badrone_802926E8(void){
|
||||
badrone_set_type(BA_DRONE_UNKNOWN_3);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
enum bs_e badrone_vanish(void){
|
||||
badrone_set_type(BA_DRONE_VANISH);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
enum bs_e badrone_transform(void){
|
||||
miscflag_clear(0x19);
|
||||
badrone_set_type(BA_DRONE_TRANSFORM);
|
||||
return func_8029BD90();
|
||||
}
|
||||
|
||||
void badrone_goto_end(void){
|
||||
if(badrone.unk14){
|
||||
badrone.unk14(badrone.unk18);
|
||||
}
|
||||
}
|
||||
|
||||
void badrone_init(void){
|
||||
badrone.type = 0;
|
||||
badrone.unk14 = NULL;
|
||||
badrone.duration = 0.1f;
|
||||
ml_vec3f_clear(badrone.position);
|
||||
}
|
139
src/core2/ba/falldamage.c
Normal file
139
src/core2/ba/falldamage.c
Normal file
@@ -0,0 +1,139 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
typedef struct {
|
||||
s32 damage;
|
||||
s32 state;
|
||||
} struct_C0E0;
|
||||
|
||||
typedef struct{
|
||||
s16 height;
|
||||
u8 damage;
|
||||
u8 state;
|
||||
} struct_C0E0_1;
|
||||
|
||||
typedef struct{
|
||||
u8 pad0[0xC];
|
||||
struct_C0E0_1 unkC[];
|
||||
} struct_C0E0_2;
|
||||
|
||||
void bafalldamage_start(void);
|
||||
|
||||
/* .data */
|
||||
struct_C0E0_1 bafalldamage_lookup_table[]={
|
||||
{1000, 0, 0},
|
||||
{1500, 0, 0},
|
||||
{2000, 0, 0},
|
||||
{7000, 8, 2},
|
||||
{6000, 7, 1},
|
||||
{5000, 6, 1},
|
||||
{4000, 5, 1},
|
||||
{3000, 4, 1},
|
||||
{2000, 3, 1},
|
||||
{1000, 2, 1},
|
||||
{0, 1, 1},
|
||||
{-1, 0, 0}
|
||||
};
|
||||
|
||||
/* .bss */
|
||||
f32 bafalldamage_start_position[3];
|
||||
u8 bafalldamage_state;
|
||||
struct_C0E0 D_8037C1C0;
|
||||
|
||||
/* .code */
|
||||
s32 __bafalldamage_lookup(struct_C0E0 *arg0, s32 height, struct_C0E0_1 *arg2){
|
||||
struct_C0E0_1 *iPtr;
|
||||
for(iPtr = &arg2[3]; iPtr->height >= 0; iPtr++){
|
||||
if(iPtr->height + 1000 < height){
|
||||
arg0->damage = iPtr->damage;
|
||||
return iPtr->state;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 __bafalldamage_get_damage(struct_C0E0 *arg0, s32 height){
|
||||
arg0->damage = 0;
|
||||
if(height < 0)
|
||||
return 0;
|
||||
else{
|
||||
switch(bsStoredState_getTransformation()){
|
||||
case TRANSFORM_2_TERMITE: //L80293110
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
case TRANSFORM_3_PUMPKIN: //L80293124
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
case TRANSFORM_5_CROC: //L80293138
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
case TRANSFORM_4_WALRUS: //L8029314C
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
case TRANSFORM_6_BEE: //L80293160
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
default:
|
||||
return __bafalldamage_lookup(arg0, height, bafalldamage_lookup_table);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __bafalldamage_update(void){
|
||||
f32 player_position[3];
|
||||
s32 height;
|
||||
|
||||
player_getPosition(player_position);
|
||||
height = bafalldamage_start_position[1] - player_position[1];
|
||||
D_8037C1C0.state = __bafalldamage_get_damage(&D_8037C1C0, height);
|
||||
}
|
||||
|
||||
s32 bafalldamage_get_damage(s32 *damage){
|
||||
*damage = D_8037C1C0.damage;
|
||||
return D_8037C1C0.state;
|
||||
}
|
||||
|
||||
f32 bafalldamage_get_distance_fallen(void){
|
||||
f32 player_position[3];
|
||||
s32 temp_v0;
|
||||
|
||||
player_getPosition(player_position);
|
||||
temp_v0 = bafalldamage_start_position[1] - player_position[1];
|
||||
return temp_v0;
|
||||
}
|
||||
|
||||
s32 bafalldamage_get_state(void){
|
||||
return bafalldamage_state;
|
||||
}
|
||||
|
||||
void bafalldamage_set_state(s32 arg0){
|
||||
bafalldamage_state = arg0;
|
||||
if(bafalldamage_state == 2 || bafalldamage_state == 3)
|
||||
bafalldamage_start();
|
||||
}
|
||||
|
||||
void bafalldamage_set_start_position(f32 arg0[3]){
|
||||
ml_vec3f_copy(bafalldamage_start_position, arg0);
|
||||
}
|
||||
|
||||
void bafalldamage_init(void){
|
||||
_player_getPosition(bafalldamage_start_position);
|
||||
bafalldamage_state = 0;
|
||||
bafalldamage_set_state(1);
|
||||
D_8037C1C0.damage = 0;
|
||||
D_8037C1C0.state = 0;
|
||||
}
|
||||
|
||||
void bafalldamage_update(void){
|
||||
s32 player_position;
|
||||
player_position = func_8028ECAC();
|
||||
if(func_8028B2E8() || (func_8028EE84() != BSWATERGROUP_0_NONE) || player_position == BSGROUP_A_FLYING){
|
||||
bafalldamage_start();
|
||||
bafalldamage_set_state(1);
|
||||
}
|
||||
__bafalldamage_update();
|
||||
}
|
||||
|
||||
void bafalldamage_start(void){
|
||||
f32 player_position[3];
|
||||
|
||||
_player_getPosition(player_position);
|
||||
bafalldamage_set_start_position(player_position);
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
#include "core2/ba/physics.h"
|
||||
|
||||
#include "prop.h"
|
||||
#include "SnS.h"
|
||||
@@ -105,8 +106,8 @@ void __baMarker_8028B7F4(void){
|
||||
yaw_setIdeal(func_8029B41C());
|
||||
yaw_setUpdateState(1);
|
||||
func_8029957C(3);
|
||||
func_802978DC(2);
|
||||
func_80297970(0.0f);
|
||||
baphysics_set_type(BA_PHYSICS_NORMAL);
|
||||
baphysics_set_target_horizontal_velocity(0.0f);
|
||||
func_8029151C(0xC);
|
||||
}
|
||||
|
||||
@@ -686,7 +687,7 @@ void __baMarker_resolveCollision(Prop *other_prop){
|
||||
|
||||
case MARKER_6B_GLOOPBUBBLE: //L8028CD20
|
||||
if(func_8028EE84() == BSWATERGROUP_2_UNDERWATER){
|
||||
func_803463D4(ITEM_17_AIR, func_80301DBC(2));
|
||||
func_803463D4(ITEM_17_AIR, fxairscore_count_to_time(2));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -891,7 +892,7 @@ void baMarker_update(void){
|
||||
|
||||
if ((D_8037BF88 != 0)){
|
||||
temp_s0 = func_8024FEEC(func_8025ADD4(COMUSIC_30_5TH_JINJO_COLLECTED) & 0xFF);
|
||||
if((func_80259B8C() < 4 && temp_s0 >= 0xBB9) || !func_8025AD7C(COMUSIC_30_5TH_JINJO_COLLECTED)){
|
||||
if((comusic_active_track_count() < 4 && temp_s0 >= 0xBB9) || !func_8025AD7C(COMUSIC_30_5TH_JINJO_COLLECTED)){
|
||||
func_8028F918(0);
|
||||
D_8037BF88 = 0;
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#include "variables.h"
|
||||
|
||||
#include "core2/ba/model.h"
|
||||
#include "core2/ba/physics.h"
|
||||
|
||||
void func_80254008(void);
|
||||
extern void func_80256E24(f32[3], f32, f32, f32, f32, f32);
|
||||
@@ -317,7 +318,7 @@ void baModel_80292284(f32 arg0[3], s32 arg1){
|
||||
arg0[1] += sp44[1];
|
||||
arg0[2] += sp44[2];
|
||||
}
|
||||
func_802976C0(sp38);
|
||||
baphysics_get_position_change(sp38);
|
||||
arg0[0] = arg0[0] + sp38[0];
|
||||
arg0[1] = arg0[1] + sp38[1];
|
||||
arg0[2] = arg0[2] + sp38[2];
|
||||
|
432
src/core2/ba/physics.c
Normal file
432
src/core2/ba/physics.c
Normal file
@@ -0,0 +1,432 @@
|
||||
#include <ultra64.h>
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
#include "core2/ba/physics.h"
|
||||
|
||||
#define _SQ3v1(v) (v[0] * v[0] + v[1] * v[1] + v[2] * v[2])
|
||||
|
||||
extern f32 ml_sin_deg(f32);
|
||||
extern f32 ml_dotProduct_vec3f(f32[3], f32[3]);
|
||||
extern void func_80256D0C(f32, f32, f32, f32, f32, f32 *, f32 *, f32 *);
|
||||
extern void func_80256E24(f32[3], f32, f32, f32, f32, f32);
|
||||
extern f32 climbGetRadius(void);
|
||||
extern f32 func_8029CED0(void);
|
||||
|
||||
/* .data */
|
||||
f32 baphysics_default_gravity = -2700.0f; //defaultGravity
|
||||
f32 baphysics_default_terminal_velocity = -4000.0f;
|
||||
|
||||
/* .bss */
|
||||
s32 baphysics_type;
|
||||
f32 s_next_position[3];
|
||||
f32 s_player_velocity[3]; //velocity?
|
||||
f32 baphysics_target_velocity[3];
|
||||
f32 s_delta_position[3];
|
||||
f32 D_8037C4E4;
|
||||
f32 s_gravity; //gravity
|
||||
f32 s_terminal_velocity;
|
||||
f32 baphysics_target_horizontal_velocity;
|
||||
f32 baphysics_target_yaw; //angle
|
||||
f32 baphysics_acceleration;
|
||||
f32 D_8037C4FC;
|
||||
f32 D_8037C500;
|
||||
|
||||
struct {
|
||||
u8 state;
|
||||
//u8 pad1[0x3];
|
||||
f32 start_position[3];
|
||||
f32 end_position[3];
|
||||
f32 duration;
|
||||
f32 elapsed_time;
|
||||
} baphysics_goto;
|
||||
|
||||
/* .code */
|
||||
void __baphysics_update_normal(void){
|
||||
f32 sp84[3];
|
||||
f32 sp78[3];
|
||||
f32 sp6C[3];
|
||||
f32 sp60[3];
|
||||
f32 sp54[3];
|
||||
f32 sp48[3];
|
||||
f32 sp44;
|
||||
f32 sp40;
|
||||
|
||||
|
||||
func_80256D0C(0.0f, baphysics_target_yaw, 0.0f, 0.0f, baphysics_target_horizontal_velocity, &baphysics_target_velocity[0], &baphysics_target_velocity[1], &baphysics_target_velocity[2]);
|
||||
sp6C[0] = s_player_velocity[0];\
|
||||
sp6C[1] = 0.0f;\
|
||||
sp6C[2] = s_player_velocity[2];
|
||||
// sp6C[1] = s_player_velocity[1];
|
||||
|
||||
ml_vec3f_copy(sp60, baphysics_target_velocity);
|
||||
sp60[1] = 0.0f;
|
||||
if(func_80294548()){
|
||||
func_80294480(sp54);
|
||||
ml_vec3f_normalize_copy(sp48, sp60);
|
||||
sp44 = ml_dotProduct_vec3f(sp48, sp54);
|
||||
sp40 = get_slope_timer();
|
||||
if(sp44 != 0.0f){
|
||||
if(sp44 < 0){
|
||||
//sp44 = 0.0f;
|
||||
if(func_8028B3B4()){
|
||||
sp40 = ml_map_f(sp40, 0.0f, 1.0f, sp44*0.5, -1.0f);
|
||||
}
|
||||
else{//L80296E3C
|
||||
sp40 = 0.5*sp44;
|
||||
}//L80296E54
|
||||
ml_vec3f_scale(sp60, 1.0 + sp40);
|
||||
}
|
||||
else{//L80296E84
|
||||
sp40 = sp44*0.2;
|
||||
ml_vec3f_scale(sp60, sp40 + 1.0);
|
||||
}
|
||||
}//L80296EBC
|
||||
}//L80296EBC
|
||||
|
||||
ml_vec3f_scale_copy(sp84, sp60, func_8029CED0());
|
||||
ml_vec3f_scale_copy(sp78, sp6C, func_8029CED0());
|
||||
ml_vec3f_diff(sp84, sp78);
|
||||
ml_vec3f_scale(sp84, time_getDelta()/0.0333333);
|
||||
s_player_velocity[0] += sp84[0];\
|
||||
s_player_velocity[1] += sp84[1];\
|
||||
s_player_velocity[2] += sp84[2];
|
||||
|
||||
sp6C[0] = s_player_velocity[0];
|
||||
sp6C[2] = s_player_velocity[2];
|
||||
ml_vec3f_scale_copy(s_delta_position, sp6C, 1.0f);
|
||||
if(mlAbsF(s_player_velocity[0]) < 0.0001)
|
||||
s_player_velocity[0] = 0;
|
||||
|
||||
if(mlAbsF(s_player_velocity[2]) < 0.0001)
|
||||
s_player_velocity[2] = 0;
|
||||
|
||||
//update velocity for gravity
|
||||
s_player_velocity[1] = s_player_velocity[1] + time_getDelta()*s_gravity ;
|
||||
if(s_player_velocity[1] < s_terminal_velocity)
|
||||
s_player_velocity[1] = s_terminal_velocity;
|
||||
|
||||
//update position
|
||||
s_delta_position[1] = s_delta_position[1] + s_player_velocity[1];
|
||||
ml_vec3f_scale(s_delta_position, time_getDelta());
|
||||
s_next_position[0] += s_delta_position[0];\
|
||||
s_next_position[1] += s_delta_position[1];\
|
||||
s_next_position[2] += s_delta_position[2];
|
||||
}
|
||||
|
||||
void __baphysics_update_no_gravity(void){
|
||||
f32 sp24[3];
|
||||
//update velocity
|
||||
ml_vec3f_diff_copy(sp24, baphysics_target_velocity, s_player_velocity);
|
||||
ml_vec3f_scale(sp24, time_getDelta()*baphysics_acceleration);
|
||||
if(_SQ3v1(sp24) < 0.02){
|
||||
ml_vec3f_copy(s_player_velocity, baphysics_target_velocity);
|
||||
}
|
||||
else{
|
||||
s_player_velocity[0] += sp24[0];\
|
||||
s_player_velocity[1] += sp24[1];\
|
||||
s_player_velocity[2] += sp24[2];
|
||||
}
|
||||
//update position
|
||||
s_delta_position[0] = s_player_velocity[0];\
|
||||
s_delta_position[1] = s_player_velocity[1];\
|
||||
s_delta_position[2] = s_player_velocity[2];
|
||||
ml_vec3f_scale( s_delta_position, time_getDelta());
|
||||
|
||||
s_next_position[0] += s_delta_position[0];\
|
||||
s_next_position[1] += s_delta_position[1];\
|
||||
s_next_position[2] += s_delta_position[2];
|
||||
}
|
||||
|
||||
void func_802971DC(void){
|
||||
s_player_velocity[1] = s_player_velocity[1] + time_getDelta()*s_gravity;
|
||||
if(s_player_velocity[1] < s_terminal_velocity)
|
||||
s_player_velocity[1] = s_terminal_velocity;
|
||||
|
||||
s_delta_position[0] = s_player_velocity[0];\
|
||||
s_delta_position[1] = s_player_velocity[1];\
|
||||
s_delta_position[2] = s_player_velocity[2];
|
||||
ml_vec3f_scale(s_delta_position, time_getDelta());
|
||||
|
||||
s_next_position[0] += s_delta_position[0];\
|
||||
s_next_position[1] += s_delta_position[1];\
|
||||
s_next_position[2] += s_delta_position[2];
|
||||
}
|
||||
|
||||
void __baphysics_update_climb(void){
|
||||
f32 sp34[3];
|
||||
f32 sp28[3];
|
||||
|
||||
climbGetBottom(sp28);
|
||||
s_next_position[0] = sp28[0];
|
||||
s_next_position[2] = sp28[2];
|
||||
func_80256E24(sp34, 0.0f, yaw_get(), 0.0f, 0.0f, -climbGetRadius());
|
||||
|
||||
s_player_velocity[2] = 0.0f;
|
||||
s_next_position[0] += sp34[0];\
|
||||
s_next_position[1] += sp34[1];\
|
||||
s_next_position[2] += sp34[2];
|
||||
|
||||
|
||||
s_player_velocity[0] = baphysics_target_velocity[0] = baphysics_target_velocity[2] = s_player_velocity[2];
|
||||
__baphysics_update_no_gravity();
|
||||
}
|
||||
|
||||
void func_8029737C(void){
|
||||
s_delta_position[0] = s_player_velocity[0];
|
||||
s_delta_position[1] = s_player_velocity[1];
|
||||
s_delta_position[2] = s_player_velocity[2];
|
||||
ml_vec3f_scale(s_delta_position, time_getDelta());
|
||||
s_next_position[0] += s_delta_position[0];
|
||||
s_next_position[1] += s_delta_position[1];
|
||||
s_next_position[2] += s_delta_position[2];
|
||||
}
|
||||
|
||||
void func_8029740C(void){
|
||||
s_delta_position[0] = s_player_velocity[0];
|
||||
s_delta_position[1] = s_player_velocity[1];
|
||||
s_delta_position[2] = s_player_velocity[2];
|
||||
ml_vec3f_clear(s_player_velocity);
|
||||
ml_vec3f_scale(s_delta_position, time_getDelta());
|
||||
s_next_position[0] += s_delta_position[0];
|
||||
s_next_position[1] += s_delta_position[1];
|
||||
s_next_position[2] += s_delta_position[2];
|
||||
}
|
||||
|
||||
void __baphysics_update_goto(void){
|
||||
f32 sp2C;
|
||||
|
||||
switch(baphysics_goto.state){
|
||||
case 0: //L80297628
|
||||
break;
|
||||
case 1: //L802974E8
|
||||
baphysics_goto.state = 2;
|
||||
_player_getPosition(baphysics_goto.start_position);
|
||||
baphysics_goto.elapsed_time = 0.0f;
|
||||
baphysics_set_velocity(0);
|
||||
break;
|
||||
case 2: //L80297510
|
||||
baphysics_goto.elapsed_time += time_getDelta();
|
||||
sp2C = ml_map_f(baphysics_goto.elapsed_time, 0.0f, baphysics_goto.duration, 0.0f, 1.0f);
|
||||
ml_vec3f_copy(s_player_velocity, s_next_position);
|
||||
s_next_position[0] = ml_interpolate_f(sp2C, baphysics_goto.start_position[0], baphysics_goto.end_position[0]);
|
||||
s_next_position[1] = ml_interpolate_f(sp2C, baphysics_goto.start_position[1], baphysics_goto.end_position[1]);
|
||||
s_next_position[2] = ml_interpolate_f(sp2C, baphysics_goto.start_position[2], baphysics_goto.end_position[2]);
|
||||
ml_vec3f_diff_copy(s_player_velocity, s_next_position, s_player_velocity);
|
||||
ml_vec3f_scale(s_player_velocity, 1.0/time_getDelta());
|
||||
if(1.0 == sp2C){
|
||||
baphysics_set_velocity(0);
|
||||
baphysics_goto.state = 3;
|
||||
}
|
||||
break;
|
||||
case 3: //L80297628
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void __baphysics_update_transform(void){
|
||||
f32 temp_f0;
|
||||
|
||||
D_8037C500 += time_getDelta();
|
||||
temp_f0 = func_80257A44(D_8037C500, 1.2f);
|
||||
temp_f0 = ml_sin_deg(temp_f0*360.0f);
|
||||
s_next_position[1] = 5.0*temp_f0 + D_8037C4FC;
|
||||
}
|
||||
|
||||
void baphysics_get_position_change(f32 arg0[3]){
|
||||
ml_vec3f_copy(arg0, s_delta_position);
|
||||
}
|
||||
|
||||
void baphysics_init(void){
|
||||
baphysics_type = 0;
|
||||
ml_vec3f_clear(s_player_velocity);
|
||||
ml_vec3f_clear(baphysics_target_velocity);
|
||||
ml_vec3f_clear(s_delta_position);
|
||||
ml_vec3f_clear(s_next_position);
|
||||
D_8037C4E4 = 0.0f;
|
||||
baphysics_reset();
|
||||
}
|
||||
|
||||
void baphysics_update(void){
|
||||
_player_getPosition(s_next_position);
|
||||
switch(baphysics_type){
|
||||
case BA_PHYSICS_GOTO: //L80297780
|
||||
__baphysics_update_goto();
|
||||
break;
|
||||
case BA_PHYSICS_TRANSFORM: //L80297790
|
||||
__baphysics_update_transform();
|
||||
break;
|
||||
case BA_PHYSICS_UNK8: //L802977A0
|
||||
func_8029737C();
|
||||
break;
|
||||
case BA_PHYSICS_UNK1: //L802977B0
|
||||
func_802971DC();
|
||||
break;
|
||||
case BA_PHYSICS_NO_GRAVITY: //L802977C0
|
||||
__baphysics_update_no_gravity();
|
||||
break;
|
||||
case BA_PHYSICS_NORMAL: //L802977D0 //bear
|
||||
baphysics_set_target_yaw(yaw_getIdeal());
|
||||
__baphysics_update_normal();
|
||||
break;
|
||||
case BA_PHYSICS_INVERTED_YAW: //L802977F0 //bird
|
||||
baphysics_set_target_yaw(mlNormalizeAngle(yaw_getIdeal() + 180.0f));
|
||||
__baphysics_update_normal();
|
||||
break;
|
||||
case BA_PHYSICS_LOCKED_ROTATION: //L80297820
|
||||
__baphysics_update_normal();
|
||||
break;
|
||||
case BA_PHYSICS_UNK4: //L80297830
|
||||
func_8029740C();
|
||||
break;
|
||||
case BA_PHYSICS_AIRBORN: //L80297840
|
||||
if(0.0f < func_8029B2E8()){
|
||||
baphysics_set_target_yaw(func_8029B33C());
|
||||
}
|
||||
__baphysics_update_normal();
|
||||
break;
|
||||
case BA_PHYSICS_CLIMB: //L80297880
|
||||
__baphysics_update_climb();
|
||||
break;
|
||||
case BA_PHYSICS_NONE:
|
||||
case BA_PHYSICS_FREEZE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
player_setPosition(s_next_position);
|
||||
}
|
||||
|
||||
void baphysics_reset_horizontal_velocity(void){
|
||||
baphysics_set_target_horizontal_velocity(0.0f);
|
||||
s_player_velocity[0] = s_player_velocity[2] = 0.0f;
|
||||
}
|
||||
|
||||
void baphysics_set_type(BaPhysicsType arg0){
|
||||
if((arg0 == BA_PHYSICS_TRANSFORM) && (arg0 != baphysics_type)){
|
||||
D_8037C4FC = s_next_position[1];
|
||||
D_8037C500 = 0.0f;
|
||||
}
|
||||
if(arg0 == BA_PHYSICS_GOTO){
|
||||
baphysics_goto.state = 1;
|
||||
}
|
||||
baphysics_type = arg0;
|
||||
}
|
||||
|
||||
void baphysics_set_target_velocity(f32 src[3]){
|
||||
if(src)
|
||||
ml_vec3f_copy(baphysics_target_velocity, src);
|
||||
else
|
||||
ml_vec3f_clear(baphysics_target_velocity);
|
||||
}
|
||||
|
||||
void baphysics_set_target_horizontal_velocity(f32 arg0){
|
||||
baphysics_target_horizontal_velocity = arg0;
|
||||
}
|
||||
|
||||
void baphysics_set_target_yaw(f32 arg0){
|
||||
baphysics_target_yaw = mlNormalizeAngle(arg0);
|
||||
}
|
||||
|
||||
void baphysics_set_vertical_velocity(f32 arg0){
|
||||
s_player_velocity[1] = arg0;
|
||||
}
|
||||
|
||||
void baphysics_set_horizontal_velocity(f32 yaw, f32 magnitude) { \
|
||||
func_80256D0C(0.0f, yaw, 0.0f, 0.0f, magnitude, &s_player_velocity[0], &s_player_velocity[1], &s_player_velocity[2]);
|
||||
}
|
||||
|
||||
void baphysics_set_velocity(f32 src[3]){
|
||||
if(src)
|
||||
ml_vec3f_copy(s_player_velocity, src);
|
||||
else
|
||||
ml_vec3f_clear(s_player_velocity);
|
||||
}
|
||||
|
||||
f32 baphysics_get_gravity(void){
|
||||
return s_gravity;
|
||||
}
|
||||
|
||||
BaPhysicsType baphysics_get_type(void){
|
||||
return baphysics_type;
|
||||
}
|
||||
|
||||
f32 baphysics_get_target_horizontal_velocity(void){
|
||||
return baphysics_target_horizontal_velocity;
|
||||
}
|
||||
|
||||
f32 baphysics_get_target_vertical_velocity(void){
|
||||
return baphysics_target_velocity[1];
|
||||
}
|
||||
|
||||
f32 baphysics_get_target_yaw(void){
|
||||
return baphysics_target_yaw;
|
||||
}
|
||||
|
||||
void baphysics_get_velocity(f32 dst[3]){
|
||||
ml_vec3f_copy(dst, s_player_velocity);
|
||||
}
|
||||
|
||||
f32 baphysics_get_vertical_velocity(void){
|
||||
return s_player_velocity[1];
|
||||
}
|
||||
|
||||
f32 baphysics_get_horizontal_velocity(void){
|
||||
return gu_sqrtf(s_player_velocity[0]*s_player_velocity[0] + s_player_velocity[2]*s_player_velocity[2]);
|
||||
}
|
||||
|
||||
f32 baphysics_get_horizontal_velocity_percentage(void){
|
||||
f32 horz_vel;
|
||||
f32 target_vel;
|
||||
f32 temp_f12;
|
||||
|
||||
horz_vel = baphysics_get_horizontal_velocity();
|
||||
target_vel = baphysics_get_target_horizontal_velocity();
|
||||
|
||||
if(horz_vel < target_vel){
|
||||
temp_f12 = horz_vel/target_vel;
|
||||
}
|
||||
else{
|
||||
temp_f12 = 1.0f;
|
||||
}
|
||||
return temp_f12;
|
||||
}
|
||||
|
||||
void baphysics_reset(void){
|
||||
baphysics_reset_gravity();
|
||||
baphysics_reset_terminal_velocity();
|
||||
}
|
||||
|
||||
void baphysics_set_acceleration(f32 arg0){
|
||||
baphysics_acceleration = arg0;
|
||||
}
|
||||
|
||||
void baphysics_reset_gravity(void){
|
||||
baphysics_set_gravity(baphysics_default_gravity);
|
||||
}
|
||||
|
||||
void baphysics_reset_terminal_velocity(void){
|
||||
baphysics_set_terminal_velocity(baphysics_default_terminal_velocity);
|
||||
}
|
||||
|
||||
void baphysics_set_goto_duration(f32 arg0){
|
||||
baphysics_goto.duration = arg0;
|
||||
}
|
||||
|
||||
void baphysics_set_goto_position(f32 src[3]) { \
|
||||
ml_vec3f_copy(baphysics_goto.end_position, src);
|
||||
}
|
||||
|
||||
void baphysics_set_gravity(f32 arg0){
|
||||
s_gravity = arg0;
|
||||
}
|
||||
|
||||
void baphysics_set_terminal_velocity(f32 arg0){
|
||||
s_terminal_velocity = arg0;
|
||||
}
|
||||
|
||||
int baphysics_is_slower_than(f32 arg0){
|
||||
return s_player_velocity[0]*s_player_velocity[0] + s_player_velocity[2]*s_player_velocity[2] <= (arg0*arg0);
|
||||
}
|
||||
|
||||
int baphysics_goto_done(void){
|
||||
return baphysics_goto.state == 3;
|
||||
}
|
Reference in New Issue
Block a user