You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Optimize OBJ_OPACITY_BY_CAM_DIST + fix puppycam build warnings
This commit is contained in:
@@ -988,20 +988,20 @@ void cur_obj_update(void) {
|
||||
f32 dist;
|
||||
Vec3f d;
|
||||
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_BILLBOARD) {
|
||||
d[0] = gCurrentObject->oPosX - gCamera->pos[0];
|
||||
d[2] = gCurrentObject->oPosZ - gCamera->pos[2];
|
||||
dist = sqrtf(sqr(d[0]) + sqr(d[2]));
|
||||
d[0] = (gCurrentObject->oPosX - gCamera->pos[0]);
|
||||
d[2] = (gCurrentObject->oPosZ - gCamera->pos[2]);
|
||||
dist = (sqr(d[0]) + sqr(d[2]));
|
||||
} else {
|
||||
vec3_diff(d, &gCurrentObject->oPosVec, gCamera->pos);
|
||||
dist = sqrtf(sqr(d[0]) + sqr(d[1]) + sqr(d[2]));
|
||||
dist = (sqr(d[0]) + sqr(d[1]) + sqr(d[2]));
|
||||
}
|
||||
if (dist > 0.0f) {
|
||||
gCurrentObject->header.gfx.node.flags &= ~GRAPH_RENDER_UCODE_REJ;
|
||||
}
|
||||
#ifdef PUPPYCAM
|
||||
s32 opacityDist = ((gPuppyCam.zoom > 0) ? ((dist / gPuppyCam.zoom) * 255.0f) : 255);
|
||||
s32 opacityDist = ((gPuppyCam.zoom > 0) ? ((dist / sqr(gPuppyCam.zoom)) * 255.0f) : 255);
|
||||
#else
|
||||
s32 opacityDist = (dist * (255.0f / 1024.0f));
|
||||
s32 opacityDist = (dist * (255.0f / sqr(1024.0f)));
|
||||
#endif
|
||||
gCurrentObject->oOpacity = CLAMP(opacityDist, 0x00, 0xFF);
|
||||
}
|
||||
|
||||
@@ -68,12 +68,12 @@ static unsigned char gPCToggleStringsEN[][64] = {{NC_BUTTON_EN}, {NC_BUTTON2_EN
|
||||
|
||||
#define OPT 32 //Just a temp thing
|
||||
|
||||
static unsigned char (*gPCOptionStringsPtr)[OPT][64] = &gPCOptionStringsEN;
|
||||
static unsigned char (*gPCFlagStringsPtr)[OPT][64] = &gPCFlagStringsEN;
|
||||
static unsigned char (*gPCToggleStringsPtr)[OPT][64] = &gPCToggleStringsEN;
|
||||
static unsigned char (*gPCOptionStringsPtr)[OPT][64] = (unsigned char (*)[OPT][64])&gPCOptionStringsEN;
|
||||
static unsigned char (*gPCFlagStringsPtr )[OPT][64] = (unsigned char (*)[OPT][64])&gPCFlagStringsEN;
|
||||
static unsigned char (*gPCToggleStringsPtr)[OPT][64] = (unsigned char (*)[OPT][64])&gPCToggleStringsEN;
|
||||
|
||||
|
||||
static const struct gPCOptionStruct
|
||||
struct gPCOptionStruct
|
||||
{
|
||||
u8 gPCOptionName; //This is the position in the newcam_options text array. It doesn't have to directly correlate with its position in the struct
|
||||
s16 *gPCOptionVar; //This is the value that the option is going to directly affect.
|
||||
@@ -82,8 +82,7 @@ static const struct gPCOptionStruct
|
||||
s32 gPCOptionMax; //The maximum value of the option.
|
||||
};
|
||||
|
||||
static const struct gPCOptionStruct gPCOptions[]=
|
||||
{ //If the min and max are 0 and 1, then the value text is used, otherwise it's ignored.
|
||||
static const struct gPCOptionStruct gPCOptions[] = { //If the min and max are 0 and 1, then the value text is used, otherwise it's ignored.
|
||||
#ifdef WIDE
|
||||
{/*Option Name*/ 7, /*Option Variable*/ &gConfig.widescreen, /*Option Value Text Start*/ 0, /*Option Minimum*/ FALSE, /*Option Maximum*/ TRUE},
|
||||
#endif
|
||||
@@ -200,8 +199,7 @@ static void newcam_set_language(void)
|
||||
|
||||
///CUTSCENE
|
||||
|
||||
void puppycam_activate_cutscene(s32 *scene, s32 lockinput)
|
||||
{
|
||||
void puppycam_activate_cutscene(s32 (*scene)(), s32 lockinput) {
|
||||
gPuppyCam.cutscene = 1;
|
||||
gPuppyCam.sceneTimer = 0;
|
||||
gPuppyCam.sceneFunc = scene;
|
||||
@@ -211,8 +209,7 @@ void puppycam_activate_cutscene(s32 *scene, s32 lockinput)
|
||||
//If you've read camera.c this will look familiar.
|
||||
//It takes the next 4 spline points and extrapolates a curvature based positioning of the camera vector that's passed through.
|
||||
//It's a standard B spline
|
||||
static void puppycam_evaluate_spline(f32 progress, Vec3s cameraPos, Vec3f spline1, Vec3f spline2, Vec3f spline3, Vec3f spline4)
|
||||
{
|
||||
static void puppycam_evaluate_spline(f32 progress, Vec3s cameraPos, Vec3f spline1, Vec3f spline2, Vec3f spline3, Vec3f spline4) {
|
||||
f32 tempP[4];
|
||||
|
||||
if (progress > 1.0f) {
|
||||
@@ -367,8 +364,8 @@ void puppycam_display_options()
|
||||
unsigned char newstring[32];
|
||||
s32 scroll;
|
||||
s32 scrollpos;
|
||||
s16 var;
|
||||
s32 vr;
|
||||
u32 var; // should be s16, but gives a build warning otherwise?
|
||||
// s32 vr;
|
||||
s32 maxvar;
|
||||
s32 minvar;
|
||||
f32 newcam_sinpos;
|
||||
@@ -1112,7 +1109,7 @@ static s32 puppycam_check_volume_bounds(struct sPuppyVolume *volume, s32 index)
|
||||
else
|
||||
if (sPuppyVolumeStack[index]->shape == PUPPYVOLUME_SHAPE_CYLINDER)
|
||||
{
|
||||
s16 dir;
|
||||
// s16 dir;
|
||||
f32 dist;
|
||||
rel[0] = sPuppyVolumeStack[index]->pos[0] - gPuppyCam.targetObj->oPosX;
|
||||
rel[1] = sPuppyVolumeStack[index]->pos[1] - gPuppyCam.targetObj->oPosY;
|
||||
@@ -1285,7 +1282,7 @@ void puppycam_projection_behaviours(void)
|
||||
}
|
||||
}
|
||||
|
||||
void puppycam_shake(s16 x, s16 y, s16 z)
|
||||
void puppycam_shake(UNUSED s16 x, UNUSED s16 y, UNUSED s16 z)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1373,7 +1370,6 @@ static void puppycam_script(void)
|
||||
{
|
||||
u16 i = 0;
|
||||
struct sPuppyVolume volume;
|
||||
void (*func)();
|
||||
|
||||
if (gPuppyVolumeCount == 0 || !gPuppyCam.targetObj)
|
||||
return;
|
||||
@@ -1439,10 +1435,8 @@ static void puppycam_script(void)
|
||||
}
|
||||
|
||||
//Last and probably least, check if there's a function attached, and call it, if so.
|
||||
if (volume.func)
|
||||
{
|
||||
func = volume.func;
|
||||
(func)();
|
||||
if (volume.func) {
|
||||
(volume.func)();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ struct sPuppyVolume
|
||||
Vec3s pos; //The set position of the volume
|
||||
Vec3s radius; //Where it extends.
|
||||
s16 rot; //The rotational angle of the volume.
|
||||
s32 *func; //a pointer to a function. Optional.
|
||||
s32 (*func)(); //a pointer to a function. Optional.
|
||||
struct sPuppyAngles *angles; //A pointer to a gPuppyAngles struct. Optional
|
||||
s32 flagsAdd; //Adds behaviour flags.
|
||||
s32 flagsRemove; //Removes behaviour flags.
|
||||
@@ -188,7 +188,7 @@ extern s16 LENSIN(s16 length, s16 direction);
|
||||
extern void puppycam_display_options(void);
|
||||
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_activate_cutscene(s32 (*scene)(), s32 lockinput);
|
||||
extern void puppycam_render_option_text();
|
||||
extern void puppycam_warp(f32 displacementX, f32 displacementY, f32 displacementZ);
|
||||
extern s32 puppycam_move_spline(struct sPuppySpline splinePos[], struct sPuppySpline splineFocus[], s32 mode, s32 index);
|
||||
|
||||
Reference in New Issue
Block a user