1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-17 10:30:47 +02:00

code formatting and minor fixes

This commit is contained in:
XProger
2019-01-31 11:00:21 +03:00
parent f5213e31f6
commit 417a2cd3be
6 changed files with 101 additions and 110 deletions

View File

@@ -494,7 +494,7 @@ struct Viewport {
namespace Core { namespace Core {
float eye; float eye;
Texture* eyeTex[2]; Texture *eyeTex[2];
Viewport viewport, viewportDef; Viewport viewport, viewportDef;
mat4 mModel, mView, mProj, mViewProj, mViewInv; mat4 mModel, mView, mProj, mViewProj, mViewInv;
mat4 mLightProj; mat4 mLightProj;

View File

@@ -2237,11 +2237,7 @@ struct GiantMutant : Enemy {
} }
virtual void updatePosition() { virtual void updatePosition() {
float angleY = 0.0f; turn(false, GIANT_MUTANT_TURN_SLOW);
if (target && target->health > 0.0f && fabsf(targetAngle) > GIANT_MUTANT_MIN_ANGLE)
if (state == STATE_TURN_LEFT || state == STATE_TURN_RIGHT || state == STATE_WALK || state == STATE_STOP)
angleY = targetAngle;
turn(angleY, GIANT_MUTANT_TURN_SLOW);
Enemy::updatePosition(); Enemy::updatePosition();
//setOverrides(true, jointChest, jointHead); //setOverrides(true, jointChest, jointHead);

View File

@@ -40,7 +40,7 @@ namespace Input {
mat4 controllers[2]; mat4 controllers[2];
vec3 zero; vec3 zero;
bool ready; bool ready;
bool down[cMAX]; // internal state for VR controllers( based on actions not buttons) bool state[cMAX];
void setView(const mat4 &pL, const mat4 &pR, const mat4 &vL, const mat4 &vR) { void setView(const mat4 &pL, const mat4 &pR, const mat4 &vL, const mat4 &vR) {
proj[0] = pL; proj[0] = pL;
@@ -213,7 +213,7 @@ namespace Input {
Core::Settings::Controls &ctrl = Core::settings.controls[j]; Core::Settings::Controls &ctrl = Core::settings.controls[j];
for (int i = 0; i < cMAX; i++) { for (int i = 0; i < cMAX; i++) {
KeySet &c = ctrl.keys[i]; KeySet &c = ctrl.keys[i];
newState[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]) || hmd.down[i]; //adding vr check with hmd[down] newState[j][i] = (c.key != ikNone && down[c.key]) || (c.joy != jkNone && joy[ctrl.joyIndex].down[c.joy]) || hmd.state[i];
} }
} }

View File

@@ -3040,6 +3040,11 @@ struct Lara : Character {
// VR control // VR control
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR && camera->firstPerson && canFreeRotate()) { if (Core::settings.detail.stereo == Core::Settings::STEREO_VR && camera->firstPerson && canFreeRotate()) {
if (!(input & WALK)) {
input &= ~(LEFT | RIGHT);
}
vec3 ang = getAngleAbs(Input::hmd.head.dir().xyz()); vec3 ang = getAngleAbs(Input::hmd.head.dir().xyz());
angle.y = ang.y; angle.y = ang.y;
if (stand == STAND_UNDERWATER) { if (stand == STAND_UNDERWATER) {
@@ -3075,10 +3080,6 @@ struct Lara : Character {
|| state == STATE_ROLL_END || state == STATE_ROLL_END
|| state == STATE_MIDAS_USE || state == STATE_MIDAS_USE
|| state == STATE_MIDAS_DEATH || state == STATE_MIDAS_DEATH
// make me sick!
//|| state == STATE_BACK_JUMP
//|| state == STATE_LEFT_JUMP
//|| state == STATE_RIGHT_JUMP
|| animation.index == ANIM_CLIMB_2 || animation.index == ANIM_CLIMB_2
|| animation.index == ANIM_CLIMB_3 || animation.index == ANIM_CLIMB_3
|| animation.index == ANIM_CLIMB_JUMP; || animation.index == ANIM_CLIMB_JUMP;

View File

@@ -2704,14 +2704,14 @@ struct Level : IGame {
Viewport vp = Core::viewportDef; Viewport vp = Core::viewportDef;
Core::defaultTarget = Core::eyeTex[0]; Core::defaultTarget = Core::eyeTex[0];
Core::viewportDef = Viewport(0, 0, float(Core::defaultTarget->width), float(Core::defaultTarget->height)); Core::viewportDef = Viewport(0, 0, Core::defaultTarget->width, Core::defaultTarget->height);
Core::setTarget(NULL,Core::defaultTarget, 0); // changing to 0 and adding defaultTarget parameter Core::setTarget(NULL,Core::defaultTarget, 0); // changing to 0 and adding defaultTarget parameter
Core::eye = -1.0f; Core::eye = -1.0f;
setup(); setup();
renderView(camera->getRoomIndex(), true); renderView(camera->getRoomIndex(), true);
Core::defaultTarget = Core::eyeTex[1]; Core::defaultTarget = Core::eyeTex[1];
Core::viewportDef = Viewport(0, 0, float(Core::defaultTarget->width), float(Core::defaultTarget->height)); Core::viewportDef = Viewport(0, 0, Core::defaultTarget->width, Core::defaultTarget->height);
Core::setTarget(NULL, Core::defaultTarget, 0); Core::setTarget(NULL, Core::defaultTarget, 0);
Core::eye = 1.0f; Core::eye = 1.0f;
setup(); setup();

View File

@@ -670,7 +670,7 @@ void vrInit() {
void vrInitTargets() { void vrInitTargets() {
uint32_t width, height; uint32_t width, height;
hmd->GetRecommendedRenderTargetSize( &width, &height); hmd->GetRecommendedRenderTargetSize(&width, &height);
Core::eyeTex[0] = new Texture(width, height, TexFormat::FMT_RGBA); Core::eyeTex[0] = new Texture(width, height, TexFormat::FMT_RGBA);
Core::eyeTex[1] = new Texture(width, height, TexFormat::FMT_RGBA); Core::eyeTex[1] = new Texture(width, height, TexFormat::FMT_RGBA);
} }
@@ -698,14 +698,11 @@ bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t
{ {
vr::InputDigitalActionData_t actionData; vr::InputDigitalActionData_t actionData;
vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle); vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
if (pDevicePath) if (pDevicePath) {
{
*pDevicePath = vr::k_ulInvalidInputValueHandle; *pDevicePath = vr::k_ulInvalidInputValueHandle;
if (actionData.bActive) if (actionData.bActive) {
{
vr::InputOriginInfo_t originInfo; vr::InputOriginInfo_t originInfo;
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) {
{
*pDevicePath = originInfo.devicePath; *pDevicePath = originInfo.devicePath;
} }
} }
@@ -727,6 +724,7 @@ void ProcessVREvent(const vr::VREvent_t &event) {
break; break;
case vr::VREvent_TrackedDeviceDeactivated: case vr::VREvent_TrackedDeviceDeactivated:
LOG("Device %u detached.\n", event.trackedDeviceIndex); LOG("Device %u detached.\n", event.trackedDeviceIndex);
Input::reset();
break; break;
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
LOG("Device %u updated.\n", event.trackedDeviceIndex); LOG("Device %u updated.\n", event.trackedDeviceIndex);
@@ -734,33 +732,29 @@ void ProcessVREvent(const vr::VREvent_t &event) {
} }
} }
//taken from openvrsimpleexamples void vrUpdateInput() {
void vrUpdateInput() { // going to use action manifest and ivr:input(Steam Vr Input) // broken
if (!hmd) return; if (!hmd) return;
vr::VREvent_t event; vr::VREvent_t event;
while (hmd->PollNextEvent(&event, sizeof(event))) { while (hmd->PollNextEvent(&event, sizeof(event))) {
ProcessVREvent( event ); // eventually going to be the function for this while loop ProcessVREvent(event);
} }
//process actions( set hmd down)
vr::VRActiveActionSet_t actionSet = { 0 }; vr::VRActiveActionSet_t actionSet = { 0 };
actionSet.ulActionSet = m_actionsetDemo; actionSet.ulActionSet = m_actionsetDemo;
vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1); vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1);
Input::hmd.down[cUp] = GetDigitalActionState(VRcUp); Input::hmd.state[cUp] = GetDigitalActionState(VRcUp);
Input::hmd.down[cDown] = GetDigitalActionState(VRcDown); Input::hmd.state[cDown] = GetDigitalActionState(VRcDown);
Input::hmd.down[cRight] = GetDigitalActionState(VRcRight); Input::hmd.state[cRight] = GetDigitalActionState(VRcRight);
Input::hmd.down[cLeft] = GetDigitalActionState(VRcLeft); Input::hmd.state[cLeft] = GetDigitalActionState(VRcLeft);
Input::hmd.down[cJump] = GetDigitalActionState(VRcJump); Input::hmd.state[cJump] = GetDigitalActionState(VRcJump);
Input::hmd.down[cWalk] = GetDigitalActionState(VRcWalk); Input::hmd.state[cWalk] = GetDigitalActionState(VRcWalk);
Input::hmd.down[cAction] = GetDigitalActionState(VRcAction); Input::hmd.state[cAction] = GetDigitalActionState(VRcAction);
Input::hmd.down[cWeapon] = GetDigitalActionState(VRcWeapon); Input::hmd.state[cWeapon] = GetDigitalActionState(VRcWeapon);
Input::hmd.down[cRoll] = GetDigitalActionState(VRcRoll); Input::hmd.state[cRoll] = GetDigitalActionState(VRcRoll);
Input::hmd.down[cStart] = GetDigitalActionState(VRcStart); Input::hmd.state[cStart] = GetDigitalActionState(VRcStart);
Input::hmd.down[cInventory] = GetDigitalActionState(VRcInventory); Input::hmd.state[cInventory] = GetDigitalActionState(VRcInventory);
} }
void vrUpdateView() { void vrUpdateView() {
@@ -784,7 +778,7 @@ void vrUpdateView() {
vL.setPos(vL.getPos() * ONE_METER); vL.setPos(vL.getPos() * ONE_METER);
vR.setPos(vR.getPos() * ONE_METER); vR.setPos(vR.getPos() * ONE_METER);
Input::hmd.setView(pL, pR, vL, vR); Input::hmd.setView(pL, pR, vL, vR);
// pass this to Lara's rotation value
Input::hmd.head = head; Input::hmd.head = head;
} }