Puppycam Freeview improvements

This commit is contained in:
Fazana
2021-09-17 20:10:01 +01:00
parent f190671ade
commit 55017da993
3 changed files with 65 additions and 19 deletions

View File

@@ -1418,7 +1418,7 @@ void update_mario_inputs(struct MarioState *m) {
m->flags &= 0xFFFFFF;
#ifdef PUPPYCAM
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ENTER_FIRST_PERSON)
if (gPuppyCam.mode3Flags & PUPPYCAM_MODE3_ENTER_FIRST_PERSON || (gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE && gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS))
{
m->input = INPUT_FIRST_PERSON;
return;
@@ -1752,6 +1752,9 @@ s32 execute_mario_action(UNUSED struct Object *o) {
gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE;
mario_reset_bodystate(gMarioState);
update_mario_inputs(gMarioState);
#ifdef PUPPYCAM
if (!(gPuppyCam.flags & PUPPYCAM_BEHAVIOUR_FREE))
#endif
mario_handle_special_floors(gMarioState);
mario_process_interactions(gMarioState);

View File

@@ -575,6 +575,7 @@ void puppycam_init(void)
gPuppyCam.framesSinceC[0] = 10; //This just exists to stop input type B being stupid.
gPuppyCam.framesSinceC[1] = 10; //This just exists to stop input type B being stupid.
gPuppyCam.mode3Flags = PUPPYCAM_MODE3_ZOOMED_MED;
gPuppyCam.debugFlags = PUPPYDEBUG_LOCK_CONTROLS;
puppycam_reset_values();
}
@@ -900,25 +901,63 @@ static void puppycam_input_press(void)
void puppycam_debug_view(void)
{
if (ABS(gPlayer1Controller->rawStickX) > DEADZONE)
if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)
{
gPuppyCam.pos[0] += (gPlayer1Controller->rawStickX/4) * -sins(gPuppyCam.yawTarget);
gPuppyCam.pos[2] += (gPlayer1Controller->rawStickX/4) * coss(gPuppyCam.yawTarget);
}
if (ABS(gPlayer1Controller->rawStickY) > DEADZONE)
{
gPuppyCam.pos[0] += (gPlayer1Controller->rawStickY/4) * coss(gPuppyCam.yawTarget);
gPuppyCam.pos[1] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.pitchTarget);
gPuppyCam.pos[2] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.yawTarget);
}
if (gPlayer1Controller->buttonDown & Z_TRIG || gPlayer1Controller->buttonDown & L_TRIG)
gPuppyCam.pos[1] -= 20;
if (gPlayer1Controller->buttonDown & R_TRIG)
gPuppyCam.pos[1] += 20;
if (ABS(gPlayer1Controller->rawStickX) > DEADZONE)
{
gPuppyCam.pos[0] += (gPlayer1Controller->rawStickX/4) * -sins(gPuppyCam.yawTarget);
gPuppyCam.pos[2] += (gPlayer1Controller->rawStickX/4) * coss(gPuppyCam.yawTarget);
}
if (ABS(gPlayer1Controller->rawStickY) > DEADZONE)
{
gPuppyCam.pos[0] += (gPlayer1Controller->rawStickY/4) * coss(gPuppyCam.yawTarget);
gPuppyCam.pos[1] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.pitchTarget);
gPuppyCam.pos[2] += (gPlayer1Controller->rawStickY/4) * sins(gPuppyCam.yawTarget);
}
if (gPlayer1Controller->buttonDown & Z_TRIG || gPlayer1Controller->buttonDown & L_TRIG)
gPuppyCam.pos[1] -= 20;
if (gPlayer1Controller->buttonDown & R_TRIG)
gPuppyCam.pos[1] += 20;
gPuppyCam.focus[0] = gPuppyCam.pos[0] + (100 *coss(gPuppyCam.yawTarget));
gPuppyCam.focus[1] = gPuppyCam.pos[1] + (100 *sins(gPuppyCam.pitchTarget));
gPuppyCam.focus[2] = gPuppyCam.pos[2] + (100 *sins(gPuppyCam.yawTarget));
gPuppyCam.focus[0] = gPuppyCam.pos[0] + (100 *coss(gPuppyCam.yawTarget));
gPuppyCam.focus[1] = gPuppyCam.pos[1] + (100 *sins(gPuppyCam.pitchTarget));
gPuppyCam.focus[2] = gPuppyCam.pos[2] + (100 *sins(gPuppyCam.yawTarget));
}
else
{
if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO)
{
gPuppyCam.focus[0] = gPuppyCam.targetObj->oPosX;
gPuppyCam.focus[1] = gPuppyCam.targetObj->oPosY;
gPuppyCam.focus[2] = gPuppyCam.targetObj->oPosZ;
}
gPuppyCam.yawTarget = atan2s(gPuppyCam.pos[2] - gPuppyCam.focus[2], gPuppyCam.pos[0] - gPuppyCam.focus[0]);
gPuppyCam.pitchTarget = atan2s(gPuppyCam.pos[1] - gPuppyCam.focus[1], 100);
}
gPuppyCam.yaw = gPuppyCam.yawTarget;
gPuppyCam.pitch = gPuppyCam.pitchTarget;
if (gPlayer1Controller->buttonPressed & A_BUTTON && gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)
{
vec3f_set(gMarioState->pos, gPuppyCam.pos[0], gPuppyCam.pos[1], gPuppyCam.pos[2]);
}
if (gPlayer1Controller->buttonPressed & B_BUTTON)
{
if (gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS)
gPuppyCam.debugFlags &= ~PUPPYDEBUG_LOCK_CONTROLS;
else
gPuppyCam.debugFlags |= PUPPYDEBUG_LOCK_CONTROLS;
}
if (gPlayer1Controller->buttonPressed & R_TRIG && !(gPuppyCam.debugFlags & PUPPYDEBUG_LOCK_CONTROLS))
{
if (gPuppyCam.debugFlags & PUPPYDEBUG_TRACK_MARIO)
gPuppyCam.debugFlags &= ~PUPPYDEBUG_TRACK_MARIO;
else
gPuppyCam.debugFlags |= PUPPYDEBUG_TRACK_MARIO;
}
}
static void puppycam_view_panning(void)

View File

@@ -28,6 +28,9 @@
#define PUPPYSPLINE_NONE 1 //Will not write to focus at all.
#define PUPPYSPLINE_FOLLOW 2 //Focus will follow a separate spline, but will mirror the speed and progress of the pos.
#define PUPPYDEBUG_LOCK_CONTROLS 0x1
#define PUPPYDEBUG_TRACK_MARIO 0x2
#include "include/command_macros_base.h"
#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape) \
@@ -90,6 +93,7 @@ struct gPuppyStruct
s16 targetDist[2]; //Used with secondary view targets to smooth out the between status.
s16 intendedTerrainPitch; //The pitch that the game wants the game to tilt towards, following the terrain.
s16 terrainPitch; //The pitch the game tilts towards, when following terrain inclines.
u8 debugFlags; //Behaviour flags during free view.
u8 cutscene; //A boolean that decides whether a cutscene is active
s32 (*sceneFunc)();
@@ -164,7 +168,7 @@ enum gPuppyCamBeh
PUPPYCAM_BEHAVIOUR_DEFAULT = PUPPYCAM_BEHAVIOUR_X_MOVEMENT | PUPPYCAM_BEHAVIOUR_Y_MOVEMENT | PUPPYCAM_BEHAVIOUR_Z_MOVEMENT |
PUPPYCAM_BEHAVIOUR_YAW_ROTATION | PUPPYCAM_BEHAVIOUR_PITCH_ROTATION | PUPPYCAM_BEHAVIOUR_ZOOM_CHANGE |
PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER | PUPPYCAM_BEHAVIOUR_TURN_HELPER | PUPPYCAM_BEHAVIOUR_INPUT_NORMAL | PUPPYCAM_BEHAVIOUR_PANSHIFT | PUPPYCAM_BEHAVIOUR_COLLISION
PUPPYCAM_BEHAVIOUR_HEIGHT_HELPER | PUPPYCAM_BEHAVIOUR_TURN_HELPER | PUPPYCAM_BEHAVIOUR_INPUT_NORMAL | PUPPYCAM_BEHAVIOUR_PANSHIFT | PUPPYCAM_BEHAVIOUR_COLLISION | PUPPYCAM_BEHAVIOUR_FREE
};
extern const struct sPuppyAngles puppyAnglesNull;