1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-17 18:36:43 +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

@@ -601,23 +601,23 @@ vr::TrackedDevicePose_t tPose[vr::k_unMaxTrackedDeviceCount];
//eye textures(eventually) //eye textures(eventually)
//action handles //action handles
vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcInventory = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcInventory = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcStart = vr::k_ulInvalidActionHandle; vr::VRActionHandle_t VRcStart = vr::k_ulInvalidActionHandle;
vr::VRActionSetHandle_t m_actionsetDemo = vr::k_ulInvalidActionSetHandle; vr::VRActionSetHandle_t m_actionsetDemo = vr::k_ulInvalidActionSetHandle;
vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle; vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle;
vr::VRInputValueHandle_t m_rightHand = vr::k_ulInvalidInputValueHandle; vr::VRInputValueHandle_t m_rightHand = vr::k_ulInvalidInputValueHandle;
//only in select TR games //only in select TR games
@@ -644,33 +644,33 @@ void vrInit() {
return; return;
} }
//set manifest //set manifest
vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath
// get action handles // get action handles
vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft); vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft);
vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight); vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight);
vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp); vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp);
vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown); vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown);
vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump); vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump);
vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk); vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk);
vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction); vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction);
vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon); vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon);
vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll); vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll);
vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory); vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory);
vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart); vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart);
//get actionsethandle //get actionsethandle
vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo); vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo);
//get input source handles //get input source handles
vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand); vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand);
vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand); vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand);
// aren't using right now // aren't using right now
//vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic); //vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic);
//vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput); //vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput);
} }
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);
} }
@@ -696,71 +696,65 @@ mat4 convToMat4(const vr::HmdMatrix34_t &m) {
//utility function for reading digital state //utility function for reading digital state
bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr) bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr)
{ {
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;
{ if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) {
vr::InputOriginInfo_t originInfo; *pDevicePath = originInfo.devicePath;
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) }
{ }
*pDevicePath = originInfo.devicePath; }
} return actionData.bActive && actionData.bState;
}
}
return actionData.bActive && actionData.bState;
} }
void ProcessVREvent(const vr::VREvent_t &event) { void ProcessVREvent(const vr::VREvent_t &event) {
char buffer[1024] = "test"; char buffer[1024] = "test";
switch (event.eventType) { switch (event.eventType) {
case vr::VREvent_TrackedDeviceActivated: case vr::VREvent_TrackedDeviceActivated:
//SetupRenderModelForTrackedDevice( event.trackedDeviceIndex ); //SetupRenderModelForTrackedDevice( event.trackedDeviceIndex );
vr::RenderModel_t ** controllerRender; vr::RenderModel_t ** controllerRender;
hmd->GetStringTrackedDeviceProperty(event.trackedDeviceIndex, vr::ETrackedDeviceProperty::Prop_RenderModelName_String, buffer, 1024); // can be filled with an error,but I can't find the right type hmd->GetStringTrackedDeviceProperty(event.trackedDeviceIndex, vr::ETrackedDeviceProperty::Prop_RenderModelName_String, buffer, 1024); // can be filled with an error,but I can't find the right type
//rm->LoadRenderModel_Async(buffer, controllerRender); //rm->LoadRenderModel_Async(buffer, controllerRender);
// need to process render model? // need to process render model?
LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex); LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex);
break; break;
case vr::VREvent_TrackedDeviceDeactivated: case vr::VREvent_TrackedDeviceDeactivated:
LOG("Device %u detached.\n", event.trackedDeviceIndex); LOG("Device %u detached.\n", event.trackedDeviceIndex);
break; Input::reset();
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here break;
LOG("Device %u updated.\n", event.trackedDeviceIndex); case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
break; LOG("Device %u updated.\n", event.trackedDeviceIndex);
} break;
}
} }
//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;
} }