Some optimizations

This commit is contained in:
Arceveti committed 2021-09-26 16:43:55 -07:00
1 parent 419c88d615
commit be8a27f79f
8 files changed
+609 -932

No files matched your search

+88 -88
View File
@@ -49,42 +49,42 @@ enum RenderLayers
LAYER_COUNT,
};
#if SILHOUETTE
#define LAYER_ZB_LAST LAYER_OCCLUDE_SILHOUETTE_ALPHA
#define LAYER_ZB_LAST LAYER_OCCLUDE_SILHOUETTE_ALPHA
#define LAYER_SILHOUETTE_FIRST LAYER_SILHOUETTE_OPAQUE
#define LAYER_LAST_BEFORE_SILHOUETTE (LAYER_SILHOUETTE_FIRST - 1)
#define LAYER_SILHOUETTE_LAST LAYER_SILHOUETTE_ALPHA
#define LAYER_OCCLUDE_SILHOUETTE_FIRST LAYER_OCCLUDE_SILHOUETTE_OPAQUE
#define LAYER_OCCLUDE_SILHOUETTE_LAST LAYER_OCCLUDE_SILHOUETTE_ALPHA
#define LAYER_OPAQUE_ORIG LAYER_OPAQUE
#define LAYER_ALPHA_ORIG LAYER_ALPHA
#define LAYER_OPAQUE_ORIG LAYER_OPAQUE
#define LAYER_ALPHA_ORIG LAYER_ALPHA
#else
#define LAYER_ZB_LAST LAYER_ALPHA
#define LAYER_ALPHA_DECAL LAYER_ALPHA
#define LAYER_SILHOUETTE_OPAQUE LAYER_OPAQUE // is zbuffered
#define LAYER_SILHOUETTE_ALPHA LAYER_ALPHA // is zbuffered
#define LAYER_OCCLUDE_SILHOUETTE_OPAQUE LAYER_OPAQUE // is zbuffered
#define LAYER_OCCLUDE_SILHOUETTE_ALPHA LAYER_ALPHA // is zbuffered
#define LAYER_SILHOUETTE_OPAQUE LAYER_OPAQUE // is zbuffered
#define LAYER_SILHOUETTE_ALPHA LAYER_ALPHA // is zbuffered
#define LAYER_OCCLUDE_SILHOUETTE_OPAQUE LAYER_OPAQUE // is zbuffered
#define LAYER_OCCLUDE_SILHOUETTE_ALPHA LAYER_ALPHA // is zbuffered
#endif
#define LAYER_FIRST_NON_ZB (LAYER_ZB_LAST + 1)
#define INPUT_NONZERO_ANALOG /* 0x0001 */ (1 << 0)
#define INPUT_A_PRESSED /* 0x0002 */ (1 << 1)
#define INPUT_OFF_FLOOR /* 0x0004 */ (1 << 2)
#define INPUT_ABOVE_SLIDE /* 0x0008 */ (1 << 3)
#define INPUT_FIRST_PERSON /* 0x0010 */ (1 << 4)
#define INPUT_IDLE /* 0x0020 */ (1 << 5)
#define INPUT_SQUISHED /* 0x0040 */ (1 << 6)
#define INPUT_A_DOWN /* 0x0080 */ (1 << 7)
#define INPUT_IN_POISON_GAS /* 0x0100 */ (1 << 8)
#define INPUT_IN_WATER /* 0x0200 */ (1 << 9)
#define INPUT_STOMPED /* 0x0400 */ (1 << 10)
#define INPUT_INTERACT_OBJ_GRABBABLE /* 0x0800 */ (1 << 11)
#define INPUT_UNKNOWN_12 /* 0x1000 */ (1 << 12)
#define INPUT_B_PRESSED /* 0x2000 */ (1 << 13)
#define INPUT_Z_DOWN /* 0x4000 */ (1 << 14)
#define INPUT_Z_PRESSED /* 0x8000 */ (1 << 15)
#define INPUT_NONZERO_ANALOG /* 0x0001 */ (1 << 0)
#define INPUT_A_PRESSED /* 0x0002 */ (1 << 1)
#define INPUT_OFF_FLOOR /* 0x0004 */ (1 << 2)
#define INPUT_ABOVE_SLIDE /* 0x0008 */ (1 << 3)
#define INPUT_FIRST_PERSON /* 0x0010 */ (1 << 4)
#define INPUT_IDLE /* 0x0020 */ (1 << 5)
#define INPUT_SQUISHED /* 0x0040 */ (1 << 6)
#define INPUT_A_DOWN /* 0x0080 */ (1 << 7)
#define INPUT_IN_POISON_GAS /* 0x0100 */ (1 << 8)
#define INPUT_IN_WATER /* 0x0200 */ (1 << 9)
#define INPUT_STOMPED /* 0x0400 */ (1 << 10)
#define INPUT_INTERACT_OBJ_GRABBABLE /* 0x0800 */ (1 << 11)
#define INPUT_UNKNOWN_12 /* 0x1000 */ (1 << 12)
#define INPUT_B_PRESSED /* 0x2000 */ (1 << 13)
#define INPUT_Z_DOWN /* 0x4000 */ (1 << 14)
#define INPUT_Z_PRESSED /* 0x8000 */ (1 << 15)
#define GROUND_STEP_LEFT_GROUND 0
#define GROUND_STEP_NONE 1
@@ -92,43 +92,43 @@ enum RenderLayers
#define GROUND_STEP_HIT_WALL_STOP_QSTEPS 2
#define GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS 3
#define AIR_STEP_CHECK_LEDGE_GRAB 0x00000001
#define AIR_STEP_CHECK_HANG 0x00000002
#define AIR_STEP_CHECK_LEDGE_GRAB 0x1
#define AIR_STEP_CHECK_HANG 0x2
#define AIR_STEP_NONE 0
#define AIR_STEP_LANDED 1
#define AIR_STEP_HIT_WALL 2
#define AIR_STEP_GRABBED_LEDGE 3
#define AIR_STEP_GRABBED_CEILING 4
#define AIR_STEP_HIT_LAVA_WALL 6
#define AIR_STEP_HIT_CEILING 7
#define AIR_STEP_NONE 0x0
#define AIR_STEP_LANDED 0x1
#define AIR_STEP_HIT_WALL 0x2
#define AIR_STEP_GRABBED_LEDGE 0x3
#define AIR_STEP_GRABBED_CEILING 0x4
#define AIR_STEP_HIT_LAVA_WALL 0x6
#define AIR_STEP_HIT_CEILING 0x7
#define WATER_STEP_NONE 0
#define WATER_STEP_HIT_FLOOR 1
#define WATER_STEP_HIT_CEILING 2
#define WATER_STEP_CANCELLED 3
#define WATER_STEP_HIT_WALL 4
#define WATER_STEP_NONE 0x0
#define WATER_STEP_HIT_FLOOR 0x1
#define WATER_STEP_HIT_CEILING 0x2
#define WATER_STEP_CANCELLED 0x3
#define WATER_STEP_HIT_WALL 0x4
#define PARTICLE_DUST /* 0x00000001 */ (1 << 0)
#define PARTICLE_VERTICAL_STAR /* 0x00000002 */ (1 << 1)
#define PARTICLE_2 /* 0x00000004 */ (1 << 2)
#define PARTICLE_SPARKLES /* 0x00000008 */ (1 << 3)
#define PARTICLE_HORIZONTAL_STAR /* 0x00000010 */ (1 << 4)
#define PARTICLE_BUBBLE /* 0x00000020 */ (1 << 5)
#define PARTICLE_WATER_SPLASH /* 0x00000040 */ (1 << 6)
#define PARTICLE_IDLE_WATER_WAVE /* 0x00000080 */ (1 << 7)
#define PARTICLE_SHALLOW_WATER_WAVE /* 0x00000100 */ (1 << 8)
#define PARTICLE_PLUNGE_BUBBLE /* 0x00000200 */ (1 << 9)
#define PARTICLE_WAVE_TRAIL /* 0x00000400 */ (1 << 10)
#define PARTICLE_FIRE /* 0x00000800 */ (1 << 11)
#define PARTICLE_SHALLOW_WATER_SPLASH /* 0x00001000 */ (1 << 12)
#define PARTICLE_LEAF /* 0x00002000 */ (1 << 13)
#define PARTICLE_SNOW /* 0x00004000 */ (1 << 14)
#define PARTICLE_DIRT /* 0x00008000 */ (1 << 15)
#define PARTICLE_MIST_CIRCLE /* 0x00010000 */ (1 << 16)
#define PARTICLE_BREATH /* 0x00020000 */ (1 << 17)
#define PARTICLE_TRIANGLE /* 0x00040000 */ (1 << 18)
#define PARTICLE_19 /* 0x00080000 */ (1 << 19)
#define PARTICLE_DUST /* 0x00000001 */ (1 << 0)
#define PARTICLE_VERTICAL_STAR /* 0x00000002 */ (1 << 1)
#define PARTICLE_2 /* 0x00000004 */ (1 << 2)
#define PARTICLE_SPARKLES /* 0x00000008 */ (1 << 3)
#define PARTICLE_HORIZONTAL_STAR /* 0x00000010 */ (1 << 4)
#define PARTICLE_BUBBLE /* 0x00000020 */ (1 << 5)
#define PARTICLE_WATER_SPLASH /* 0x00000040 */ (1 << 6)
#define PARTICLE_IDLE_WATER_WAVE /* 0x00000080 */ (1 << 7)
#define PARTICLE_SHALLOW_WATER_WAVE /* 0x00000100 */ (1 << 8)
#define PARTICLE_PLUNGE_BUBBLE /* 0x00000200 */ (1 << 9)
#define PARTICLE_WAVE_TRAIL /* 0x00000400 */ (1 << 10)
#define PARTICLE_FIRE /* 0x00000800 */ (1 << 11)
#define PARTICLE_SHALLOW_WATER_SPLASH /* 0x00001000 */ (1 << 12)
#define PARTICLE_LEAF /* 0x00002000 */ (1 << 13)
#define PARTICLE_SNOW /* 0x00004000 */ (1 << 14)
#define PARTICLE_DIRT /* 0x00008000 */ (1 << 15)
#define PARTICLE_MIST_CIRCLE /* 0x00010000 */ (1 << 16)
#define PARTICLE_BREATH /* 0x00020000 */ (1 << 17)
#define PARTICLE_TRIANGLE /* 0x00040000 */ (1 << 18)
#define PARTICLE_19 /* 0x00080000 */ (1 << 19)
#define MODEL_STATE_ALPHA (1 << 8) // 0x100
#define MODEL_STATE_NOISE_ALPHA ((1 << 7) | MODEL_STATE_ALPHA) // (0x080 | MODEL_STATE_ALPHA)
@@ -159,39 +159,39 @@ enum RenderLayers
#define MARIO_SPECIAL_CAPS (MARIO_VANISH_CAP | MARIO_METAL_CAP | MARIO_WING_CAP)
#define MARIO_CAPS (MARIO_NORMAL_CAP | MARIO_SPECIAL_CAPS)
#define ACT_ID_MASK 0x000001FF
#define ACT_ID_MASK 0x000001FF
#define ACT_GROUP_MASK 0x000001C0
#define ACT_GROUP_STATIONARY /* 0x00000000 */ (0 << 6)
#define ACT_GROUP_MOVING /* 0x00000040 */ (1 << 6)
#define ACT_GROUP_AIRBORNE /* 0x00000080 */ (2 << 6)
#define ACT_GROUP_SUBMERGED /* 0x000000C0 */ (3 << 6)
#define ACT_GROUP_CUTSCENE /* 0x00000100 */ (4 << 6)
#define ACT_GROUP_AUTOMATIC /* 0x00000140 */ (5 << 6)
#define ACT_GROUP_OBJECT /* 0x00000180 */ (6 << 6)
#define ACT_GROUP_MASK 0x000001C0
#define ACT_GROUP_STATIONARY /* 0x00000000 */ (0 << 6)
#define ACT_GROUP_MOVING /* 0x00000040 */ (1 << 6)
#define ACT_GROUP_AIRBORNE /* 0x00000080 */ (2 << 6)
#define ACT_GROUP_SUBMERGED /* 0x000000C0 */ (3 << 6)
#define ACT_GROUP_CUTSCENE /* 0x00000100 */ (4 << 6)
#define ACT_GROUP_AUTOMATIC /* 0x00000140 */ (5 << 6)
#define ACT_GROUP_OBJECT /* 0x00000180 */ (6 << 6)
#define ACT_FLAG_STATIONARY /* 0x00000200 */ (1 << 9)
#define ACT_FLAG_MOVING /* 0x00000400 */ (1 << 10)
#define ACT_FLAG_AIR /* 0x00000800 */ (1 << 11)
#define ACT_FLAG_INTANGIBLE /* 0x00001000 */ (1 << 12)
#define ACT_FLAG_SWIMMING /* 0x00002000 */ (1 << 13)
#define ACT_FLAG_METAL_WATER /* 0x00004000 */ (1 << 14)
#define ACT_FLAG_SHORT_HITBOX /* 0x00008000 */ (1 << 15)
#define ACT_FLAG_RIDING_SHELL /* 0x00010000 */ (1 << 16)
#define ACT_FLAG_INVULNERABLE /* 0x00020000 */ (1 << 17)
#define ACT_FLAG_BUTT_OR_STOMACH_SLIDE /* 0x00040000 */ (1 << 18)
#define ACT_FLAG_DIVING /* 0x00080000 */ (1 << 19)
#define ACT_FLAG_ON_POLE /* 0x00100000 */ (1 << 20)
#define ACT_FLAG_HANGING /* 0x00200000 */ (1 << 21)
#define ACT_FLAG_IDLE /* 0x00400000 */ (1 << 22)
#define ACT_FLAG_ATTACKING /* 0x00800000 */ (1 << 23)
#define ACT_FLAG_ALLOW_VERTICAL_WIND_ACTION /* 0x01000000 */ (1 << 24)
#define ACT_FLAG_CONTROL_JUMP_HEIGHT /* 0x02000000 */ (1 << 25)
#define ACT_FLAG_ALLOW_FIRST_PERSON /* 0x04000000 */ (1 << 26)
#define ACT_FLAG_PAUSE_EXIT /* 0x08000000 */ (1 << 27)
#define ACT_FLAG_SWIMMING_OR_FLYING /* 0x10000000 */ (1 << 28)
#define ACT_FLAG_WATER_OR_TEXT /* 0x20000000 */ (1 << 29)
#define ACT_FLAG_THROWING /* 0x80000000 */ (1 << 31)
#define ACT_FLAG_STATIONARY /* 0x00000200 */ (1 << 9)
#define ACT_FLAG_MOVING /* 0x00000400 */ (1 << 10)
#define ACT_FLAG_AIR /* 0x00000800 */ (1 << 11)
#define ACT_FLAG_INTANGIBLE /* 0x00001000 */ (1 << 12)
#define ACT_FLAG_SWIMMING /* 0x00002000 */ (1 << 13)
#define ACT_FLAG_METAL_WATER /* 0x00004000 */ (1 << 14)
#define ACT_FLAG_SHORT_HITBOX /* 0x00008000 */ (1 << 15)
#define ACT_FLAG_RIDING_SHELL /* 0x00010000 */ (1 << 16)
#define ACT_FLAG_INVULNERABLE /* 0x00020000 */ (1 << 17)
#define ACT_FLAG_BUTT_OR_STOMACH_SLIDE /* 0x00040000 */ (1 << 18)
#define ACT_FLAG_DIVING /* 0x00080000 */ (1 << 19)
#define ACT_FLAG_ON_POLE /* 0x00100000 */ (1 << 20)
#define ACT_FLAG_HANGING /* 0x00200000 */ (1 << 21)
#define ACT_FLAG_IDLE /* 0x00400000 */ (1 << 22)
#define ACT_FLAG_ATTACKING /* 0x00800000 */ (1 << 23)
#define ACT_FLAG_ALLOW_VERTICAL_WIND_ACTION /* 0x01000000 */ (1 << 24)
#define ACT_FLAG_CONTROL_JUMP_HEIGHT /* 0x02000000 */ (1 << 25)
#define ACT_FLAG_ALLOW_FIRST_PERSON /* 0x04000000 */ (1 << 26)
#define ACT_FLAG_PAUSE_EXIT /* 0x08000000 */ (1 << 27)
#define ACT_FLAG_SWIMMING_OR_FLYING /* 0x10000000 */ (1 << 28)
#define ACT_FLAG_WATER_OR_TEXT /* 0x20000000 */ (1 << 29)
#define ACT_FLAG_THROWING /* 0x80000000 */ (1 << 31)
#define ACT_UNINITIALIZED 0x00000000 // (0x000)
+197 -36
View File
@@ -483,34 +483,31 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
void mtxf_to_mtx_scale(Mtx *dest, Mat4 src) {
Mat4 temp;
register s32 i, j;
for( i = 0; i < 4; i++ ) {
for( j = 0; j < 3; j++ ) {
temp[i][j] = src[i][j] / gWorldScale;
temp[i][j] = src[i][j] / gWorldScale;
}
temp[i][3] = src[i][3];
}
guMtxF2L( temp, dest );
}
void mtxf_to_mtx_constant(register s16 *dest, register f32 *src) {
s32 asFixedPoint;
s32 i;
for (i = 0; i < 16; i++)
{
asFixedPoint = src[i] * (1 << 16);
dest[i] = asFixedPoint >> 16;
dest[i + 16] = asFixedPoint & 0xFFFF;
for (i = 0; i < 16; i++) {
asFixedPoint = (src[i] * (1 << 16));
dest[i] = (asFixedPoint >> 16);
dest[i + 16] = (asFixedPoint & 0xFFFF);
}
}
void mtxf_to_mtx(void *dest, void *src)
{
if (gWorldScale > 2.0f)
void mtxf_to_mtx(void *dest, void *src) {
if (gWorldScale > 2.0f) {
mtxf_to_mtx_scale(dest, src);
else
} else {
mtxf_to_mtx_constant(dest, src);
}
}
/**
@@ -518,7 +515,6 @@ void mtxf_to_mtx(void *dest, void *src)
*/
void mtxf_rotate_xy(Mtx *mtx, s32 angle) {
Mat4 temp;
mtxf_identity(temp);
temp[0][0] = coss(angle);
temp[0][1] = sins(angle);
@@ -545,18 +541,123 @@ void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
dest[2] = objMtx[3][0] * camMtx[2][0] + objMtx[3][1] * camMtx[2][1] + objMtx[3][2] * camMtx[2][2] - camZ;
}
/**
* Take the vector starting at 'from' pointed at 'to' an retrieve the length
* of that vector, as well as the yaw and pitch angles.
* Basically it converts the direction to spherical coordinates.
*/
/// Finds the horizontal distance between two vectors.
void vec3f_get_lateral_dist(Vec3f from, Vec3f to, f32 *lateralDist) {
register f32 dx = (to[0] - from[0]);
register f32 dz = (to[2] - from[2]);
*lateralDist = sqrtf(sqr(dx) + sqr(dz));
}
/// Finds the squared horizontal distance between two vectors.
void vec3f_get_lateral_dist_squared(Vec3f from, Vec3f to, f32 *lateralDist) {
register f32 dx = (to[0] - from[0]);
register f32 dz = (to[2] - from[2]);
*lateralDist = (sqr(dx) + sqr(dz));
}
/// Finds the distance between two vectors.
void vec3f_get_dist(Vec3f from, Vec3f to, f32 *dist) {
register Vec3f d;
vec3_diff(d, to, from);
*dist = vec3_mag(d);
}
/// Finds the squared distance between two vectors.
void vec3f_get_dist_squared(Vec3f from, Vec3f to, f32 *dist) {
register Vec3f d;
vec3_diff(d, to, from);
*dist = vec3_sumsq(d);
}
/// Finds the distance and yaw etween two vectors.
void vec3f_get_dist_and_yaw(Vec3f from, Vec3f to, f32 *dist, s16 *yaw) {
register Vec3f d;
vec3_diff(d, to, from);
*dist = vec3_mag(d);
*yaw = atan2s(d[2], d[0]);
}
/// Finds the pitch between two vectors.
void vec3f_get_pitch(Vec3f from, Vec3f to, s16 *pitch) {
register Vec3f d;
vec3_diff(d, to, from);
*pitch = atan2s(sqrtf(sqr(d[0]) + sqr(d[2])), d[1]);
}
/// Finds the yaw between two vectors.
void vec3f_get_yaw(Vec3f from, Vec3f to, s16 *yaw) {
register f32 dx = (to[0] - from[0]);
register f32 dz = (to[2] - from[2]);
*yaw = atan2s(dz, dx);
}
/// Finds the pitch and yaw between two vectors.
void vec3f_get_angle(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw) {
register Vec3f d;
vec3_diff(d, to, from);
*pitch = atan2s(sqrtf(sqr(d[0]) + sqr(d[2])), d[1]);
*yaw = atan2s(d[2], d[0]);
}
/// Finds the horizontal distance and pitch between two vectors.
void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch) {
Vec3f d;
vec3_diff(d, to, from);
*lateralDist = sqrtf(sqr(d[0]) + sqr(d[2]));
*pitch = atan2s(*lateralDist, d[1]);
}
/// Finds the horizontal distance and yaw between two vectors.
void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw) {
register f32 dx = (to[0] - from[0]);
register f32 dz = (to[2] - from[2]);
*lateralDist = sqrtf(sqr(dx) + sqr(dz));
*yaw = atan2s(dz, dx);
}
/// Finds the horizontal distance and angles between two vectors.
void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw) {
Vec3f d;
vec3_diff(d, to, from);
*lateralDist = sqrtf(sqr(d[0]) + sqr(d[2]));
*pitch = atan2s(*lateralDist, d[1]);
*yaw = atan2s(d[2], d[0]);
}
/// Finds the distance and angles between two vectors.
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw) {
register f32 x = to[0] - from[0];
register f32 y = to[1] - from[1];
register f32 z = to[2] - from[2];
*dist = sqrtf(sqr(x) + sqr(y) + sqr(z));
*pitch = atan2s(sqrtf(sqr(x) + sqr(z)), y);
*yaw = atan2s(z, x);
register Vec3f d;
vec3_diff(d, to, from);
register f32 xz = sqr(d[0]) + sqr(d[2]);
*dist = sqrtf(xz + sqr(d[1]));
*pitch = atan2s(sqrtf(xz), d[1]);
*yaw = atan2s(d[2], d[0]);
}
void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw) {
Vec3s d;
vec3_diff(d, to, from);
register f32 xz = (sqr(d[0]) + sqr(d[2]));
*dist = sqrtf(xz + sqr(d[1]));
*pitch = atan2s(sqrtf(xz), d[1]);
*yaw = atan2s(d[2], d[0]);
}
/// Finds the distance, horizontal distance, and angles between two vectors.
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw) {
Vec3f d;
vec3_diff(d, to, from);
register f32 xz = (sqr(d[0]) + sqr(d[2]));
*dist = sqrtf(xz + sqr(d[1]));
*lateralDist = sqrtf(xz);
*pitch = atan2s(*lateralDist, d[1]);
*yaw = atan2s(d[2], d[0]);
}
/**
@@ -564,9 +665,16 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *
* and has the angles pitch and yaw.
*/
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s32 pitch, s32 yaw) {
to[0] = from[0] + dist * coss(pitch) * sins(yaw);
to[1] = from[1] + dist * sins(pitch);
to[2] = from[2] + dist * coss(pitch) * coss(yaw);
register f32 dcos = (dist * coss(pitch));
to[0] = (from[0] + (dcos * sins(yaw )));
to[1] = (from[1] + (dist * sins(pitch)));
to[2] = (from[2] + (dcos * coss(yaw )));
}
void vec3s_set_dist_and_angle(Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw) {
register f32 dcos = (dist * coss(pitch));
to[0] = (from[0] + (dcos * sins(yaw )));
to[1] = (from[1] + (dist * sins(pitch)));
to[2] = (from[2] + (dcos * coss(yaw )));
}
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec) {
@@ -646,18 +754,72 @@ s32 approach_angle(s32 current, s32 target, s32 inc) {
s32 dist = (s16)(target - current);
if (dist < 0) {
dist += inc;
if (dist > 0) {
dist = 0;
}
if (dist > 0) dist = 0;
} else if (dist > 0) {
dist -= inc;
if (dist < 0) {
dist = 0;
}
if (dist < 0) dist = 0;
}
return (target - dist);
}
/**
* Approaches an f32 value by taking the difference between the target and current value
* and adding a fraction of that to the current value.
* Edits the current value directly, returns TRUE if the target has been reached, FALSE otherwise.
*/
s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier) {
if (multiplier > 1.f) {
multiplier = 1.f;
}
*current = *current + (target - *current) * multiplier;
return (*current != target);
}
/**
* Nearly the same as the above function, returns new value instead.
*/
f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier) {
current = current + (target - current) * multiplier;
return current;
}
/**
* Approaches an s16 value in the same fashion as approach_f32_asymptotic_bool, returns TRUE if target
* is reached. Note: Since this function takes integers as parameters, the last argument is the
* reciprocal of what it would be in the previous two functions.
*/
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) {
s16 temp = *current;
if (divisor == 0) {
*current = target;
} else {
temp -= target;
temp -= temp / divisor;
temp += target;
*current = temp;
}
return (*current != target);
}
/**
* Approaches an s16 value in the same fashion as approach_f32_asymptotic, returns the new value.
* Note: last parameter is the reciprocal of what it would be in the f32 functions
*/
s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) {
s16 temp = current;
if (divisor == 0) {
current = target;
} else {
temp -= target;
temp -= temp / divisor;
temp += target;
current = temp;
}
return current;
}
/**
* Helper function for atan2s. Does a look up of the arctangent of y/x assuming
* the resulting angle is in range [0, 0x2000] (1/8 of a circle).
@@ -670,20 +832,19 @@ s32 approach_angle(s32 current, s32 target, s32 inc) {
*/
s16 atan2s(f32 y, f32 x) {
u16 ret;
if (x >= 0) {
if (y >= 0) {
if (y >= x) {
ret = atan2_lookup(x, y);
} else {
ret = 0x4000 - atan2_lookup(y, x);
ret = (0x4000 - atan2_lookup(y, x));
}
} else {
y = -y;
if (y < x) {
ret = 0x4000 + atan2_lookup(y, x);
ret = (0x4000 + atan2_lookup(y, x));
} else {
ret = 0x8000 - atan2_lookup(x, y);
ret = (0x8000 - atan2_lookup(x, y));
}
}
} else {
@@ -691,13 +852,13 @@ s16 atan2s(f32 y, f32 x) {
if (y < 0) {
y = -y;
if (y >= x) {
ret = 0x8000 + atan2_lookup(x, y);
ret = (0x8000 + atan2_lookup(x, y));
} else {
ret = 0xC000 - atan2_lookup(y, x);
ret = (0xC000 - atan2_lookup(y, x));
}
} else {
if (y < x) {
ret = 0xC000 + atan2_lookup(y, x);
ret = (0xC000 + atan2_lookup(y, x));
} else {
ret = -atan2_lookup(x, y);
}
@@ -710,7 +871,7 @@ s16 atan2s(f32 y, f32 x) {
* Compute the atan2 in radians by calling atan2s and converting the result.
*/
f32 atan2f(f32 y, f32 x) {
return (f32) atan2s(y, x) * M_PI / 0x8000;
return ((f32) atan2s(y, x) * M_PI / 0x8000);
}
#define CURVE_BEGIN_1 0x1
+22 -2
View File
@@ -372,8 +372,24 @@ void mtxf_to_mtx_constant(register s16 *dest, register f32 *src);
void mtxf_to_mtx_scale(Mtx *dest, Mat4 src);
void mtxf_rotate_xy(Mtx *mtx, s32 angle);
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s32 pitch, s32 yaw);
void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist );
void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist );
void vec3f_get_dist( Vec3f from, Vec3f to, f32 *dist );
void vec3f_get_dist_squared( Vec3f from, Vec3f to, f32 *dist );
void vec3f_get_dist_and_yaw( Vec3f from, Vec3f to, f32 *dist, Angle *yaw);
void vec3f_get_pitch( Vec3f from, Vec3f to, Angle *pitch );
void vec3f_get_yaw( Vec3f from, Vec3f to, Angle *yaw);
void vec3f_get_angle( Vec3f from, Vec3f to, Angle *pitch, Angle *yaw);
void vec3f_get_lateral_dist_and_pitch( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch );
void vec3f_get_lateral_dist_and_yaw( Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw);
void vec3f_get_lateral_dist_and_angle( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw);
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw);
void vec3s_get_dist_and_angle( Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw);
void vec3f_get_dist_and_angle( Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Angle *yaw);
void vec3s_set_dist_and_angle( Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw);
void vec3f_set_dist_and_angle( Vec3f from, Vec3f to, f32 dist, Angle32 pitch, Angle32 yaw);
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec);
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
@@ -388,6 +404,10 @@ Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec);
#define approach_f32_symmetric_bool(current, target, inc) approach_f32_bool((current), (target), (inc), (inc))
s32 approach_f32_signed(f32 *current, f32 target, f32 inc);
s32 approach_angle(s32 current, s32 target, s32 inc);
s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier);
f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor);
s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);
s16 atan2s(f32 y, f32 x);
f32 atan2f(f32 a, f32 b);
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
+268 -717
View File
File diff suppressed because it is too large. Load diff
+3 -6
View File
@@ -699,10 +699,6 @@ s32 collide_with_walls(Vec3f pos, f32 offsetY, f32 radius);
void clamp_pitch(Vec3f from, Vec3f to, s16 maxPitch, s16 minPitch);
s32 is_within_100_units_of_mario(f32 posX, f32 posY, f32 posZ);
s32 set_or_approach_f32_asymptotic(f32 *dst, f32 goal, f32 scale);
s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier);
f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor);
s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);
void approach_vec3f_asymptotic(Vec3f current, Vec3f target, f32 xMul, f32 yMul, f32 zMul);
void set_or_approach_vec3f_asymptotic(Vec3f dst, Vec3f goal, f32 xMul, f32 yMul, f32 zMul);
s32 camera_approach_s16_symmetric_bool(s16 *current, s16 target, s16 increment);
@@ -717,6 +713,7 @@ s16 calculate_pitch(Vec3f from, Vec3f to);
s16 calculate_yaw(Vec3f from, Vec3f to);
void calculate_angles(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw);
f32 calc_abs_dist(Vec3f a, Vec3f b);
f32 calc_abs_dist_squared(Vec3f a, Vec3f b);
f32 calc_hor_dist(Vec3f a, Vec3f b);
void rotate_in_xz(Vec3f dst, Vec3f src, s16 yaw);
void rotate_in_yz(Vec3f dst, Vec3f src, s16 pitch);
@@ -738,7 +735,7 @@ void play_sound_button_change_blocked(void);
void play_sound_rbutton_changed(void);
void play_sound_if_cam_switched_to_lakitu_or_mario(void);
void radial_camera_input(struct Camera *c);
s32 trigger_cutscene_dialog(s32 trigger);
void trigger_cutscene_dialog(s32 trigger);
void handle_c_button_movement(struct Camera *c);
void start_cutscene(struct Camera *c, u8 cutscene);
u8 get_cutscene_from_mario_status(struct Camera *c);
@@ -748,7 +745,7 @@ void offset_rotated(Vec3f dst, Vec3f from, Vec3f to, Vec3s rotation);
s16 next_lakitu_state(Vec3f newPos, Vec3f newFoc, Vec3f curPos, Vec3f curFoc, Vec3f oldPos, Vec3f oldFoc, s16 yaw);
void set_fixed_cam_axis_sa_lobby(UNUSED s16 preset);
s16 camera_course_processing(struct Camera *c);
void resolve_geometry_collisions(Vec3f pos, UNUSED Vec3f lastGood);
void resolve_geometry_collisions(Vec3f pos);
s32 rotate_camera_around_walls(struct Camera *c, Vec3f cPos, s16 *avoidYaw, s16 yawRange);
void find_mario_floor_and_ceil(struct PlayerGeometry *pg);
u8 start_object_cutscene_without_focus(u8 cutscene);
+9 -30
View File
@@ -869,11 +869,7 @@ void render_multi_text_string_lines(s8 multiTextId, s8 lineNum, s16 *linePos, s8
u32 ensure_nonnegative(s16 value) {
if (value < 0) {
value = 0;
}
return value;
return ((value < 0) ? 0 : value);
}
void handle_dialog_text_and_pages(s8 colorMode, struct DialogEntry *dialog, s8 lowerBound) {
@@ -1289,29 +1285,13 @@ void dl_rgba16_stop_cutscene_msg_fade(void) {
}
u8 ascii_to_credits_char(u8 c) {
if (c >= 'A' && c <= 'Z') {
return (c - ('A' - 0xA));
}
if (c >= 'a' && c <= 'z') { // remap lower to upper case
return (c - ('a' - 0xA));
}
if (c == ' ') {
return GLOBAL_CHAR_SPACE;
}
if (c == '.') {
return 0x24;
}
if (c == '3') {
return ASCII_TO_DIALOG('3');
}
if (c == '4') {
return ASCII_TO_DIALOG('4');
}
if (c == '6') {
return ASCII_TO_DIALOG('6');
}
if (c >= 'A' && c <= 'Z') return (c - ('A' - 0xA));
if (c >= 'a' && c <= 'z') return (c - ('a' - 0xA)); // remap lower to upper case
if (c == ' ') return GLOBAL_CHAR_SPACE;
if (c == '.') return 0x24;
if (c == '3') return ASCII_TO_DIALOG('3');
if (c == '4') return ASCII_TO_DIALOG('4');
if (c == '6') return ASCII_TO_DIALOG('6');
return GLOBAL_CHAR_SPACE;
}
@@ -1348,8 +1328,7 @@ void do_cutscene_handler(void) {
create_dl_ortho_matrix();
if (gMarioState->action == ACT_CREDITS_CUTSCENE || gMarioState->action == ACT_END_PEACH_CUTSCENE || gMarioState->action == ACT_END_WAVING_CUTSCENE)
{
if (gMarioState->action == ACT_CREDITS_CUTSCENE || gMarioState->action == ACT_END_PEACH_CUTSCENE || gMarioState->action == ACT_END_WAVING_CUTSCENE) {
gDPSetRenderMode(gDisplayListHead++, G_RM_OPA_SURF, G_RM_OPA_SURF2);
gDPSetCycleType(gDisplayListHead++, G_CYC_FILL);
+9 -9
View File
@@ -205,8 +205,8 @@ void reset_clipping(void)
static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
struct DisplayListNode *currList;
s32 startLayer, endLayer, currLayer = LAYER_FORCE;
s32 headsIndex = LIST_HEADS_REJ;
s32 renderPhase = RENDER_PHASE_REJ_ZB;
s32 headsIndex = LIST_HEADS_REJ;
s32 renderPhase = RENDER_PHASE_REJ_ZB;
s32 enableZBuffer = (node->node.flags & GRAPH_RENDER_Z_BUFFER) != 0;
struct RenderModeContainer *mode1List = &renderModeTable_1Cycle[enableZBuffer];
struct RenderModeContainer *mode2List = &renderModeTable_2Cycle[enableZBuffer];
@@ -217,9 +217,9 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
Mtx lMtx;
guLookAtReflect(&lMtx, &lookAt, 0, 0, 0, /* eye */ 0, 0, 1, /* at */ 1, 0, 0 /* up */);
#endif
//if (gPlayer1Controller->buttonPressed & L_TRIG)
// ucodeTestSwitch ^= 1;
//print_text_fmt_int(32,32,"%d",ucodeTestSwitch);
// if (gPlayer1Controller->buttonPressed & L_TRIG)
// ucodeTestSwitch ^= 1;
// print_text_fmt_int(32,32,"%d",ucodeTestSwitch);
#ifdef F3DZEX_GBI_2
loopBegin:
switch (renderPhase) {
@@ -229,12 +229,12 @@ static void geo_process_master_list_sub(struct GraphNodeMasterList *node) {
case RENDER_PHASE_REJ_SILHOUETTE: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_SILHOUETTE_FIRST; endLayer = LAYER_SILHOUETTE_LAST; break;
case RENDER_PHASE_REJ_NON_SILHOUETTE: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_SILHOUETTE_FIRST; endLayer = LAYER_SILHOUETTE_LAST; break;
case RENDER_PHASE_REJ_OCCLUDE_SILHOUETTE: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST; endLayer = LAYER_OCCLUDE_SILHOUETTE_LAST; break;
case RENDER_PHASE_ZEX_AFTER_SILHOUETTE: headsIndex = LIST_HEADS_ZEX; startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST; endLayer = LAYER_COUNT-1; break;
case RENDER_PHASE_REJ_NON_ZB: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_FIRST_NON_ZB; endLayer = LAYER_COUNT-1; break;
case RENDER_PHASE_ZEX_AFTER_SILHOUETTE: headsIndex = LIST_HEADS_ZEX; startLayer = LAYER_OCCLUDE_SILHOUETTE_FIRST; endLayer = (LAYER_COUNT - 1); break;
case RENDER_PHASE_REJ_NON_ZB: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_FIRST_NON_ZB; endLayer = (LAYER_COUNT - 1); break;
#else
case RENDER_PHASE_REJ_ZB: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_FORCE; endLayer = LAYER_ZB_LAST; break;
case RENDER_PHASE_ZEX_ALL: headsIndex = LIST_HEADS_ZEX; startLayer = LAYER_FORCE; endLayer = LAYER_COUNT-1; break;
case RENDER_PHASE_REJ_NON_ZB: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_FIRST_NON_ZB; endLayer = LAYER_COUNT-1; break;
case RENDER_PHASE_ZEX_ALL: headsIndex = LIST_HEADS_ZEX; startLayer = LAYER_FORCE; endLayer = (LAYER_COUNT - 1); break;
case RENDER_PHASE_REJ_NON_ZB: headsIndex = LIST_HEADS_REJ; startLayer = LAYER_FIRST_NON_ZB; endLayer = (LAYER_COUNT - 1); break;
#endif
}
// Load rejection on pass 2. ZEX is loaded afterwards.
+13 -44
View File
@@ -622,9 +622,7 @@ Gfx *create_shadow_player(f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 soli
}
switch (correct_shadow_solidity_for_animations(isLuigi, solidity, &shadow)) {
case SHADOW_SOLIDITY_NO_SHADOW:
return NULL;
break;
case SHADOW_SOLIDITY_NO_SHADOW: return NULL; break;
case SHADOW_SOILDITY_ALREADY_SET:
ret = init_shadow(&shadow, xPos, yPos, zPos, shadowScale, /* overwriteSolidity */ 0);
break;
@@ -804,17 +802,10 @@ Gfx *create_shadow_square(f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 soli
distFromShadow = yPos - shadowHeight;
switch (shadowType) {
case SHADOW_SQUARE_PERMANENT:
shadowRadius = shadowScale / 2;
break;
case SHADOW_SQUARE_SCALABLE:
shadowRadius = scale_shadow_with_distance(shadowScale, distFromShadow) / 2.0;
break;
case SHADOW_SQUARE_TOGGLABLE:
shadowRadius = disable_shadow_with_distance(shadowScale, distFromShadow) / 2.0;
break;
default:
return NULL;
case SHADOW_SQUARE_PERMANENT: shadowRadius = shadowScale / 2; break;
case SHADOW_SQUARE_SCALABLE: shadowRadius = scale_shadow_with_distance(shadowScale, distFromShadow) / 2.0; break;
case SHADOW_SQUARE_TOGGLABLE: shadowRadius = disable_shadow_with_distance(shadowScale, distFromShadow) / 2.0; break;
default: return NULL;
}
return create_shadow_rectangle(shadowRadius, shadowRadius, -distFromShadow, solidity);
@@ -875,36 +866,14 @@ Gfx *create_shadow_below_xyz(f32 xPos, f32 yPos, f32 zPos, s16 shadowScale, u8 s
sSurfaceTypeBelowShadow = pfloor->type;
}
switch (shadowType) {
case SHADOW_CIRCLE_9_VERTS:
displayList = create_shadow_circle_9_verts(xPos, yPos, zPos, shadowScale, shadowSolidity);
break;
case SHADOW_CIRCLE_4_VERTS:
displayList = create_shadow_circle_4_verts(xPos, yPos, zPos, shadowScale, shadowSolidity);
break;
case SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED: // unused shadow type
displayList = create_shadow_circle_assuming_flat_ground(xPos, yPos, zPos, shadowScale,
shadowSolidity);
break;
case SHADOW_SQUARE_PERMANENT:
displayList =
create_shadow_square(xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType);
break;
case SHADOW_SQUARE_SCALABLE:
displayList =
create_shadow_square(xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType);
break;
case SHADOW_SQUARE_TOGGLABLE:
displayList =
create_shadow_square(xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType);
break;
case SHADOW_CIRCLE_PLAYER:
displayList = create_shadow_player(xPos, yPos, zPos, shadowScale, shadowSolidity,
/* isLuigi */ FALSE);
break;
default:
displayList = create_shadow_hardcoded_rectangle(xPos, yPos, zPos, shadowScale,
shadowSolidity, shadowType);
break;
case SHADOW_CIRCLE_9_VERTS: displayList = create_shadow_circle_9_verts (xPos, yPos, zPos, shadowScale, shadowSolidity ); break;
case SHADOW_CIRCLE_4_VERTS: displayList = create_shadow_circle_4_verts (xPos, yPos, zPos, shadowScale, shadowSolidity ); break;
case SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED: displayList = create_shadow_circle_assuming_flat_ground(xPos, yPos, zPos, shadowScale, shadowSolidity ); break; // unused shadow type
case SHADOW_SQUARE_PERMANENT: displayList = create_shadow_square (xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType ); break;
case SHADOW_SQUARE_SCALABLE: displayList = create_shadow_square (xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType ); break;
case SHADOW_SQUARE_TOGGLABLE: displayList = create_shadow_square (xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType ); break;
case SHADOW_CIRCLE_PLAYER: displayList = create_shadow_player (xPos, yPos, zPos, shadowScale, shadowSolidity, /* isLuigi */ FALSE); break;
default: displayList = create_shadow_hardcoded_rectangle (xPos, yPos, zPos, shadowScale, shadowSolidity, shadowType ); break;
}
return displayList;
}