mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 06:13:45 -07:00
Almost done, needs collision still
This commit is contained in:
parent
3cc9b79dcd
commit
c060329593
2 changed files with 50 additions and 157 deletions
|
@ -183,13 +183,6 @@ namespace Ship {
|
||||||
wCamX = SDL_GameControllerGetAxis(Cont, SDL_CONTROLLER_AXIS_RIGHTX) / 25;
|
wCamX = SDL_GameControllerGetAxis(Cont, SDL_CONTROLLER_AXIS_RIGHTX) / 25;
|
||||||
wCamY = SDL_GameControllerGetAxis(Cont, SDL_CONTROLLER_AXIS_RIGHTY) / 25;
|
wCamY = SDL_GameControllerGetAxis(Cont, SDL_CONTROLLER_AXIS_RIGHTY) / 25;
|
||||||
|
|
||||||
if (abs(wCamX) <= 255) {
|
|
||||||
wCamX = 0;
|
|
||||||
}
|
|
||||||
if (abs(wCamY) <= 255) {
|
|
||||||
wCamY = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SDL_GameControllerHasSensor(Cont, SDL_SENSOR_GYRO))
|
if (SDL_GameControllerHasSensor(Cont, SDL_SENSOR_GYRO))
|
||||||
{
|
{
|
||||||
float gyroData[3];
|
float gyroData[3];
|
||||||
|
@ -362,11 +355,12 @@ namespace Ship {
|
||||||
void SDLController::CreateDefaultBinding() {
|
void SDLController::CreateDefaultBinding() {
|
||||||
std::string ConfSection = GetBindingConfSection();
|
std::string ConfSection = GetBindingConfSection();
|
||||||
std::shared_ptr<ConfigFile> pConf = GlobalCtx2::GetInstance()->GetConfig();
|
std::shared_ptr<ConfigFile> pConf = GlobalCtx2::GetInstance()->GetConfig();
|
||||||
|
|
||||||
ConfigFile& Conf = *pConf.get();
|
ConfigFile& Conf = *pConf.get();
|
||||||
|
|
||||||
Conf[ConfSection][STR(BTN_CRIGHT)] = std::to_string((SDL_CONTROLLER_AXIS_RIGHTX + AXIS_SCANCODE_BIT));
|
Conf[ConfSection][STR(BTN_CRIGHT)] = std::to_string(SDL_CONTROLLER_BUTTON_RIGHTSHOULDER);
|
||||||
Conf[ConfSection][STR(BTN_CLEFT)] = std::to_string(-(SDL_CONTROLLER_AXIS_RIGHTX + AXIS_SCANCODE_BIT));
|
Conf[ConfSection][STR(BTN_CLEFT)] = std::to_string(SDL_CONTROLLER_BUTTON_Y);
|
||||||
Conf[ConfSection][STR(BTN_CDOWN)] = std::to_string((SDL_CONTROLLER_AXIS_RIGHTY + AXIS_SCANCODE_BIT));
|
Conf[ConfSection][STR(BTN_CDOWN)] = std::to_string(SDL_CONTROLLER_BUTTON_X);
|
||||||
Conf[ConfSection][STR(BTN_CUP)] = std::to_string(SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
Conf[ConfSection][STR(BTN_CUP)] = std::to_string(SDL_CONTROLLER_BUTTON_RIGHTSTICK);
|
||||||
//Conf[ConfSection][STR(BTN_CRIGHT + "_2")] = std::to_string(SDL_CONTROLLER_BUTTON_X);
|
//Conf[ConfSection][STR(BTN_CRIGHT + "_2")] = std::to_string(SDL_CONTROLLER_BUTTON_X);
|
||||||
//Conf[ConfSection][STR(BTN_CLEFT + "_2")] = std::to_string(SDL_CONTROLLER_BUTTON_Y);
|
//Conf[ConfSection][STR(BTN_CLEFT + "_2")] = std::to_string(SDL_CONTROLLER_BUTTON_Y);
|
||||||
|
|
|
@ -1408,30 +1408,29 @@ s32 Camera_Noop(Camera* camera) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f32 camX;
|
||||||
|
f32 camY;
|
||||||
|
|
||||||
s32 Camera_Free(Camera* camera) {
|
s32 Camera_Free(Camera* camera) {
|
||||||
Vec3f* eye = &camera->eye;
|
|
||||||
Vec3f* at = &camera->at;
|
|
||||||
Vec3f* eyeNext = &camera->eyeNext;
|
|
||||||
f32 spA0;
|
|
||||||
f32 sp9C;
|
|
||||||
f32 sp98;
|
|
||||||
f32 sp94;
|
|
||||||
Vec3f sp88;
|
|
||||||
s16 wiggleAdj;
|
|
||||||
s16 t;
|
|
||||||
VecSph eyeAdjustment;
|
|
||||||
VecSph atEyeGeo;
|
|
||||||
VecSph atEyeNextGeo;
|
|
||||||
PosRot* playerPosRot = &camera->playerPosRot;
|
|
||||||
Normal1* norm1 = (Normal1*)camera->paramData;
|
Normal1* norm1 = (Normal1*)camera->paramData;
|
||||||
Normal1Anim* anim = &norm1->anim;
|
|
||||||
f32 playerHeight;
|
|
||||||
f32 rate = 0.1f;
|
|
||||||
|
|
||||||
osSyncPrintf("\nCam Val X: %d\n", D_8015BD7C->state.input[0].cur.cam_x);
|
f32 playerHeight = Player_GetHeight(camera->player);
|
||||||
|
f32 sp94;
|
||||||
|
|
||||||
|
sCameraInterfaceFlags = norm1->interfaceFlags;
|
||||||
|
|
||||||
playerHeight = Player_GetHeight(camera->player);
|
|
||||||
if (RELOAD_PARAMS) {
|
if (RELOAD_PARAMS) {
|
||||||
|
VecSph eyeAdjustment1;
|
||||||
|
Vec3f oldCamRot;
|
||||||
|
oldCamRot.x = camera->player->actor.world.pos.x;
|
||||||
|
oldCamRot.y = camera->player->actor.world.pos.y + Player_GetHeight(camera->player);
|
||||||
|
oldCamRot.z = camera->player->actor.world.pos.z;
|
||||||
|
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment1, &oldCamRot, &camera->eye);
|
||||||
|
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment1, &oldCamRot, &camera->eyeNext);
|
||||||
|
|
||||||
|
camX = eyeAdjustment1.yaw;
|
||||||
|
camY = eyeAdjustment1.pitch;
|
||||||
|
|
||||||
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
|
CameraModeValue* values = sCameraSettings[camera->setting].cameraModes[camera->mode].values;
|
||||||
f32 yNormal = (1.0f + PCT(R_CAM_YOFFSET_NORM) - PCT(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
|
f32 yNormal = (1.0f + PCT(R_CAM_YOFFSET_NORM) - PCT(R_CAM_YOFFSET_NORM) * (68.0f / playerHeight));
|
||||||
sp94 = yNormal * PCT(playerHeight);
|
sp94 = yNormal * PCT(playerHeight);
|
||||||
|
@ -1452,145 +1451,45 @@ s32 Camera_Free(Camera* camera) {
|
||||||
Camera_CopyPREGToModeValues(camera);
|
Camera_CopyPREGToModeValues(camera);
|
||||||
}
|
}
|
||||||
|
|
||||||
sCameraInterfaceFlags = norm1->interfaceFlags;
|
VecSph eyeAdjustment;
|
||||||
|
const f32 camSpeed = 0.5f;
|
||||||
OLib_Vec3fDiffToVecSphGeo(&atEyeGeo, at, eye);
|
|
||||||
OLib_Vec3fDiffToVecSphGeo(&atEyeNextGeo, at, eyeNext);
|
|
||||||
|
|
||||||
switch (camera->animState) {
|
|
||||||
case 0x14:
|
|
||||||
camera->yawUpdateRateInv = OREG(27);
|
|
||||||
camera->pitchUpdateRateInv = OREG(27);
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
camera->animState = 1;
|
camera->animState = 1;
|
||||||
sUpdateCameraDirection = 1;
|
|
||||||
|
|
||||||
if (anim->unk_28 != 0) {
|
camera->at.x = Camera_LERPCeilF(camera->player->actor.world.pos.x, camera->at.x, camSpeed, 1.0f);
|
||||||
anim->unk_28--;
|
camera->at.y = Camera_LERPCeilF(camera->player->actor.world.pos.y + Player_GetHeight(camera->player), camera->at.y,
|
||||||
|
camSpeed, 1.0f);
|
||||||
|
camera->at.z = Camera_LERPCeilF(camera->player->actor.world.pos.z, camera->at.z, camSpeed, 1.0f);
|
||||||
|
|
||||||
|
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, &camera->at, &camera->eye);
|
||||||
|
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, &camera->at, &camera->eyeNext);
|
||||||
|
|
||||||
|
camera->dist = eyeAdjustment.r = 200;
|
||||||
|
|
||||||
|
f32 newCamX = -D_8015BD7C->state.input[0].cur.cam_x;
|
||||||
|
f32 newCamY = D_8015BD7C->state.input[0].cur.cam_y;
|
||||||
|
|
||||||
|
if (fabsf(newCamX) >= 100.0f) {
|
||||||
|
camX += newCamX;
|
||||||
}
|
}
|
||||||
|
|
||||||
spA0 = camera->speedRatio * PCT(OREG(25));
|
if (fabsf(newCamY) >= 100.0f) {
|
||||||
sp9C = camera->speedRatio * PCT(OREG(26));
|
camY += newCamY;
|
||||||
sp98 = anim->swing.unk_18 != 0 ? PCT(OREG(25)) : spA0;
|
|
||||||
|
|
||||||
sp94 = (camera->xzSpeed - anim->unk_20) * (0.333333f);
|
|
||||||
if (sp94 > 1.0f) {
|
|
||||||
sp94 = 1.0f;
|
|
||||||
}
|
|
||||||
if (sp94 > -1.0f) {
|
|
||||||
sp94 = -1.0f;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
anim->unk_20 = camera->xzSpeed;
|
if (camY > 0x38A4) {
|
||||||
|
camY = 0x38A4;
|
||||||
|
|
||||||
camera->yawUpdateRateInv =
|
|
||||||
Camera_LERPCeilF(anim->swing.swingUpdateRate + (f32)(anim->swing.swingUpdateRateTimer * 2),
|
|
||||||
camera->yawUpdateRateInv, sp98, rate);
|
|
||||||
camera->pitchUpdateRateInv =
|
|
||||||
Camera_LERPCeilF((f32)R_CAM_DEFA_PHI_UPDRATE + (f32)(anim->swing.swingUpdateRateTimer * 2),
|
|
||||||
camera->pitchUpdateRateInv, sp9C, rate);
|
|
||||||
|
|
||||||
camera->pitchUpdateRateInv = Camera_LERPCeilF(R_CAM_DEFA_PHI_UPDRATE, camera->pitchUpdateRateInv, sp9C, rate);
|
|
||||||
camera->xzOffsetUpdateRate = Camera_LERPCeilF(PCT(OREG(2)), camera->xzOffsetUpdateRate, spA0, rate);
|
|
||||||
camera->yOffsetUpdateRate = Camera_LERPCeilF(PCT(OREG(3)), camera->yOffsetUpdateRate, sp9C, rate);
|
|
||||||
camera->fovUpdateRate = Camera_LERPCeilF(PCT(OREG(4)), camera->yOffsetUpdateRate, camera->speedRatio * 0.05f, rate);
|
|
||||||
|
|
||||||
if (norm1->interfaceFlags & 1) {
|
|
||||||
t = func_80044ADC(camera, BINANG_ROT180(atEyeGeo.yaw), 0);
|
|
||||||
sp9C = ((1.0f / norm1->unk_10) * 0.5f) * (1.0f - camera->speedRatio);
|
|
||||||
anim->slopePitchAdj = Camera_LERPCeilS(t, anim->slopePitchAdj, ((1.0f / norm1->unk_10) * 0.5f) + sp9C, 0xF);
|
|
||||||
} else {
|
|
||||||
anim->slopePitchAdj = 0;
|
|
||||||
if (camera->playerGroundY == camera->playerPosRot.pos.y) {
|
|
||||||
anim->yOffset = camera->playerPosRot.pos.y;
|
|
||||||
}
|
}
|
||||||
|
if (camY < -0x3C8C) {
|
||||||
|
camY = -0x3C8C;
|
||||||
}
|
}
|
||||||
|
|
||||||
spA0 = ((anim->swing.unk_18 != 0) && (norm1->yOffset > -40.0f))
|
eyeAdjustment.yaw = camX;
|
||||||
? (sp9C = Math_SinS(anim->swing.unk_14), ((-40.0f * sp9C) + (norm1->yOffset * (1.0f - sp9C))))
|
eyeAdjustment.pitch = camY;
|
||||||
: norm1->yOffset;
|
|
||||||
|
|
||||||
if (norm1->interfaceFlags & 0x80) {
|
Camera_Vec3fVecSphGeoAdd(&camera->eye, &camera->at, &eyeAdjustment);
|
||||||
func_800458D4(camera, &atEyeNextGeo, spA0, &anim->yOffset, norm1->interfaceFlags & 1);
|
Camera_Vec3fVecSphGeoAdd(&camera->eyeNext, &camera->at, &eyeAdjustment);
|
||||||
} else if (norm1->interfaceFlags & 0x20) {
|
|
||||||
func_80045B08(camera, &atEyeNextGeo, spA0, anim->slopePitchAdj);
|
|
||||||
} else {
|
|
||||||
Camera_CalcAtDefault(camera, &atEyeNextGeo, spA0, norm1->interfaceFlags & 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, at, eyeNext);
|
|
||||||
|
|
||||||
camera->dist = eyeAdjustment.r =
|
|
||||||
Camera_ClampDist(camera, eyeAdjustment.r, norm1->distMin, norm1->distMax, anim->unk_28);
|
|
||||||
|
|
||||||
// rotate yaw to follow player.
|
|
||||||
float newCamX = -D_8015BD7C->state.input[0].cur.cam_x;
|
|
||||||
float newCamY = D_8015BD7C->state.input[0].cur.cam_y;
|
|
||||||
eyeAdjustment.yaw += newCamX;
|
|
||||||
eyeAdjustment.pitch += newCamY;
|
|
||||||
|
|
||||||
// set eyeAdjustment pitch from 79.65 degrees to -85 degrees
|
|
||||||
if (eyeAdjustment.pitch > 0x38A4) {
|
|
||||||
eyeAdjustment.pitch = 0x38A4;
|
|
||||||
}
|
|
||||||
if (eyeAdjustment.pitch < -0x3C8C) {
|
|
||||||
eyeAdjustment.pitch = -0x3C8C;
|
|
||||||
}
|
|
||||||
|
|
||||||
Camera_Vec3fVecSphGeoAdd(eyeNext, at, &eyeAdjustment);
|
|
||||||
if ((camera->status == CAM_STAT_ACTIVE) && (!(norm1->interfaceFlags & 0x10))) {
|
|
||||||
anim->swingYawTarget = BINANG_ROT180(camera->playerPosRot.rot.y);
|
|
||||||
if (anim->startSwingTimer > 0) {
|
|
||||||
func_80046E20(camera, &eyeAdjustment, norm1->distMin, norm1->unk_0C, &sp98, &anim->swing);
|
|
||||||
} else {
|
|
||||||
sp88 = *eyeNext;
|
|
||||||
anim->swing.swingUpdateRate = camera->yawUpdateRateInv = norm1->unk_0C * 2.0f;
|
|
||||||
if (Camera_BGCheck(camera, at, &sp88)) {
|
|
||||||
anim->swingYawTarget = atEyeNextGeo.yaw;
|
|
||||||
anim->startSwingTimer = -1;
|
|
||||||
} else {
|
|
||||||
*eye = *eyeNext;
|
|
||||||
}
|
|
||||||
anim->swing.unk_18 = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (anim->swing.unk_18 != 0) {
|
|
||||||
camera->inputDir.y =
|
|
||||||
Camera_LERPCeilS(camera->inputDir.y + BINANG_SUB(BINANG_ROT180(anim->swing.unk_16), camera->inputDir.y),
|
|
||||||
camera->inputDir.y, 1.0f - (0.99f * sp98), 0xA);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (norm1->interfaceFlags & 4) {
|
|
||||||
camera->inputDir.x = -atEyeGeo.pitch;
|
|
||||||
camera->inputDir.y = BINANG_ROT180(atEyeGeo.yaw);
|
|
||||||
camera->inputDir.z = 0;
|
|
||||||
} else {
|
|
||||||
OLib_Vec3fDiffToVecSphGeo(&eyeAdjustment, eye, at);
|
|
||||||
camera->inputDir.x = eyeAdjustment.pitch;
|
|
||||||
camera->inputDir.y = eyeAdjustment.yaw;
|
|
||||||
camera->inputDir.z = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// crit wiggle
|
|
||||||
if (gSaveContext.health <= 16 && ((camera->globalCtx->state.frames % 256) == 0)) {
|
|
||||||
wiggleAdj = Rand_ZeroOne() * 10000.0f;
|
|
||||||
camera->inputDir.y = wiggleAdj + camera->inputDir.y;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
anim->swing.swingUpdateRate = norm1->unk_0C;
|
|
||||||
anim->swing.unk_18 = 0;
|
|
||||||
sUpdateCameraDirection = 0;
|
|
||||||
*eye = *eyeNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
spA0 = (gSaveContext.health <= 16 ? 0.8f : 1.0f);
|
|
||||||
camera->fov = Camera_LERPCeilF(norm1->fovTarget * spA0, camera->fov, camera->fovUpdateRate, 1.0f);
|
|
||||||
camera->roll = Camera_LERPCeilS(0, camera->roll, 0.5f, 0xA);
|
|
||||||
camera->atLERPStepScale = Camera_ClampLERPScale(camera, norm1->atLERPScaleMax);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue