Merge more puppy2 changes

This commit is contained in:
AloXado320 2021-03-19 21:31:42 -05:00
parent 2ffc6bd121
commit 8b8892b5cf
6 changed files with 81 additions and 46 deletions

View file

@ -15,19 +15,6 @@
#include "make_const_nonconst.h"
#include "levels/castle_grounds/header.h"
#ifdef BETTERCAMERA
#include "extras/bettercamera.h"
const struct sPuppyAngles puppyAnglestest2 =
{
{PUPPY_NULL, PUPPY_NULL, PUPPY_NULL},
{-7408, 100, 10709},
{PUPPY_NULL},
{PUPPY_NULL},
{1000},
};
#endif
static const LevelScript script_func_local_1[] = {
WARP_NODE(/*id*/ 0x00, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x00, /*flags*/ WARP_NO_CHECKPOINT),
WARP_NODE(/*id*/ 0x01, /*destLevel*/ LEVEL_CASTLE, /*destArea*/ 0x01, /*destNode*/ 0x01, /*flags*/ WARP_NO_CHECKPOINT),
@ -140,9 +127,6 @@ const LevelScript level_castle_grounds_entry[] = {
MACRO_OBJECTS(/*objList*/ castle_grounds_seg7_macro_objs),
SET_BACKGROUND_MUSIC(/*settingsPreset*/ 0x0000, /*seq*/ SEQ_SOUND_PLAYER),
TERRAIN_TYPE(/*terrainType*/ TERRAIN_GRASS),
#ifdef BETTERCAMERA
PUPPYVOLUME(0, 0, 0, 500,2000,500,0, NULL, &puppyAnglestest2, NULL, NULL, PUPPYCAM_BEHAVIOUR_TEMPORARY, 1, PUPPYVOLUME_SHAPE_CYLINDER),
#endif
END_AREA(),
FREE_LEVEL_POOL(),

View file

@ -144,6 +144,18 @@ void puppycam_boot(void)
//puppycam_get_save();
}
//Called when an instant warp is done.
void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ)
{
gPuppyCam.pos[0] += displacementX;
gPuppyCam.pos[1] += displacementY;
gPuppyCam.pos[2] += displacementZ;
gPuppyCam.targetFloorHeight += displacementY;
gPuppyCam.lastTargetFloorHeight += displacementY;
gPuppyCam.floorY[0] += displacementY;
gPuppyCam.floorY[1] += displacementY;
}
///CUTSCENE
void puppycam_activate_cutscene(s32 *scene, s32 lockinput)
@ -154,7 +166,7 @@ void puppycam_activate_cutscene(s32 *scene, s32 lockinput)
gPuppyCam.sceneInput = lockinput;
}
static void newcam_process_cutscene(void)
static void puppycam_process_cutscene(void)
{
if (gPuppyCam.cutscene)
{
@ -205,7 +217,7 @@ void puppycam_init(void)
gPuppyCam.focus[1] = 0;
gPuppyCam.focus[2] = 0;
gPuppyCam.pan[0] = 0;
gPuppyCam.pan[1] = 0;//gMarioState->pos[1];
gPuppyCam.pan[1] = 0; //gMarioState->pos[1];
gPuppyCam.pan[2] = 0;
gPuppyCam.posHeight[0] = 0;
gPuppyCam.posHeight[1] = 0;
@ -1031,40 +1043,74 @@ static void puppycam_script(void)
}
}
void puppycam_script_clear(void)
{
s32 i = 0;
for (i = 0; i < gPuppyVolumeCount; i++)
{
mem_pool_free(gPuppyMemoryPool, sPuppyVolumeStack[i]);
}
gPuppyVolumeCount = 0;
}
//Handles collision detection using ray casting.
static void puppycam_collision(void)
{
struct Surface *surf;
Vec3f camdir;
Vec3f hitpos;
Vec3f target;
struct Surface *surf[2];
Vec3f camdir[2];
Vec3f hitpos[2];
Vec3f target[2];
s16 pitchTotal = CLAMP(gPuppyCam.pitch+(gPuppyCam.swimPitch*10), 800, 0x7800);
s32 dist[2];
if (gPuppyCam.targetObj == NULL)
return;
target[0] = gPuppyCam.targetObj->oPosX;
target[1] = gPuppyCam.targetObj->oPosY + gPuppyCam.povHeight;
target[2] = gPuppyCam.targetObj->oPosZ;
//The ray, starting from the top
target[0][0] = gPuppyCam.targetObj->oPosX;
target[0][1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight) - CLAMP(gPuppyCam.targetObj->oPosY - gPuppyCam.targetFloorHeight, 0, 300);
target[0][2] = gPuppyCam.targetObj->oPosZ;
//The ray, starting from the bottom
target[1][0] = gPuppyCam.targetObj->oPosX;
target[1][1] = gPuppyCam.targetObj->oPosY + (gPuppyCam.povHeight *0.4f);
target[1][2] = gPuppyCam.targetObj->oPosZ;
camdir[0] = LENSIN(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0];
camdir[1] = LENCOS(gPuppyCam.zoomTarget,pitchTotal) + gPuppyCam.shake[1] - gPuppyCam.floorY[1];// + gPuppyCam.posHeight[1];
camdir[2] = LENCOS(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2];
camdir[0][0] = LENSIN(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[0];
camdir[0][1] = LENCOS(gPuppyCam.zoomTarget,pitchTotal) + gPuppyCam.shake[1];// + gPuppyCam.posHeight[1];
camdir[0][2] = LENCOS(LENSIN(gPuppyCam.zoomTarget,pitchTotal),gPuppyCam.yaw) + gPuppyCam.shake[2];
find_surface_on_ray(target, camdir, &surf, hitpos);
gPuppyCam.collisionDistance = sqrtf((target[0] - hitpos[0]) * (target[0] - hitpos[0]) + (target[1] - hitpos[1]) * (target[1] - hitpos[1]) + (target[2] - hitpos[2]) * (target[2] - hitpos[2]));
camdir[1][0] = camdir[0][0];
camdir[1][1] = camdir[0][1];
camdir[1][2] = camdir[0][2];
if (surf)
find_surface_on_ray(target[0], camdir[0], &surf[0], &hitpos[0]);
find_surface_on_ray(target[1], camdir[1], &surf[1], &hitpos[1]);
dist[0] = ((target[0][0] - hitpos[0][0]) * (target[0][0] - hitpos[0][0]) + (target[0][1] - hitpos[0][1]) * (target[0][1] - hitpos[0][1]) + (target[0][2] - hitpos[0][2]) * (target[0][2] - hitpos[0][2]));
dist[1] = ((target[1][0] - hitpos[1][0]) * (target[1][0] - hitpos[1][0]) + (target[1][1] - hitpos[1][1]) * (target[1][1] - hitpos[1][1]) + (target[1][2] - hitpos[1][2]) * (target[1][2] - hitpos[1][2]));
gPuppyCam.collisionDistance = gPuppyCam.zoomTarget;
if (surf[0] && surf[1])
{
gPuppyCam.collisionDistance = sqrtf(MAX(dist[0], dist[1]));
if (gPuppyCam.zoom > gPuppyCam.collisionDistance)
{
gPuppyCam.zoom = gPuppyCam.collisionDistance;
if (gPuppyCam.zoom - gPuppyCam.zoomTarget < 5)
{
gPuppyCam.pos[0] = hitpos[0];
gPuppyCam.pos[1] = hitpos[1];
gPuppyCam.pos[2] = hitpos[2];
}
gPuppyCam.zoom = MIN(gPuppyCam.collisionDistance, gPuppyCam.zoomTarget);
if (gPuppyCam.zoom - gPuppyCam.zoomTarget < 5)
{
if (dist[0] >= dist[1])
{
gPuppyCam.pos[0] = hitpos[0][0];
gPuppyCam.pos[1] = hitpos[0][1];
gPuppyCam.pos[2] = hitpos[0][2];
}
else
{
gPuppyCam.pos[0] = hitpos[1][0];
gPuppyCam.pos[1] = hitpos[1][1] + (gPuppyCam.povHeight*0.6f);
gPuppyCam.pos[2] = hitpos[1][2];
}
}
}
}
@ -1161,7 +1207,7 @@ void puppycam_loop(void)
if (gPuppyCam.cutscene)
{
gPuppyCam.opacity = 255;
newcam_process_cutscene();
puppycam_process_cutscene();
}
puppycam_apply();

View file

@ -165,6 +165,8 @@ extern void puppycam_set_save(void);
extern void puppycam_check_pause_buttons(void);
extern void puppycam_activate_cutscene(s32 *scene, s32 lockinput);
extern void puppycam_render_option_text();
void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ);
void puppycam_script_clear(void);
extern void puppycam_hud(void);
#endif

View file

@ -24,10 +24,6 @@
#include "gfx_dimensions.h"
#ifdef BETTERCAMERA
#include "extras/bettercamera.h"
#endif
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *D_8033A160[0x100];
struct Area gAreaData[8];
@ -195,9 +191,6 @@ void clear_areas(void) {
gWarpTransition.isActive = FALSE;
gWarpTransition.pauseRendering = FALSE;
gMarioSpawnInfo->areaIndex = -1;
#ifdef BETTERCAMERA
gPuppyVolumeCount = 0;
#endif
for (i = 0; i < 8; i++) {
gAreaData[i].index = i;

View file

@ -5343,6 +5343,10 @@ void warp_camera(f32 displacementX, f32 displacementY, f32 displacementZ) {
vec3f_add(start->pos, displacement);
vec3f_add(end->focus, displacement);
vec3f_add(end->pos, displacement);
#ifdef BETTERCAMERA
puppycam_warp(displacementX, displacementY, displacementZ);
#endif
}
/**

View file

@ -657,6 +657,12 @@ void initiate_warp(s16 destLevel, s16 destArea, s16 destWarpNode, s32 arg3) {
sWarpDest.areaIdx = destArea;
sWarpDest.nodeId = destWarpNode;
sWarpDest.arg = arg3;
#ifdef BETTERCAMERA
if (sWarpDest.type != WARP_TYPE_SAME_AREA) {
puppycam_script_clear();
}
#endif
}
// From Surface 0xD3 to 0xFC