1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-16 01:54:38 +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 {
float eye;
Texture* eyeTex[2];
Texture *eyeTex[2];
Viewport viewport, viewportDef;
mat4 mModel, mView, mProj, mViewProj, mViewInv;
mat4 mLightProj;

View File

@@ -2237,11 +2237,7 @@ struct GiantMutant : Enemy {
}
virtual void updatePosition() {
float angleY = 0.0f;
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);
turn(false, GIANT_MUTANT_TURN_SLOW);
Enemy::updatePosition();
//setOverrides(true, jointChest, jointHead);

View File

@@ -40,7 +40,7 @@ namespace Input {
mat4 controllers[2];
vec3 zero;
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) {
proj[0] = pL;
@@ -213,7 +213,7 @@ namespace Input {
Core::Settings::Controls &ctrl = Core::settings.controls[j];
for (int i = 0; i < cMAX; 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
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());
angle.y = ang.y;
if (stand == STAND_UNDERWATER) {
@@ -3075,10 +3080,6 @@ struct Lara : Character {
|| state == STATE_ROLL_END
|| state == STATE_MIDAS_USE
|| 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_3
|| animation.index == ANIM_CLIMB_JUMP;

View File

@@ -2696,7 +2696,7 @@ struct Level : IGame {
}
Core::pass = Core::passCompose;
if (view == 0 && Input::hmd.ready) {
Core::settings.detail.stereo = Core::Settings::STEREO_VR;
@@ -2704,14 +2704,14 @@ struct Level : IGame {
Viewport vp = Core::viewportDef;
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::eye = -1.0f;
setup();
renderView(camera->getRoomIndex(), true);
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::eye = 1.0f;
setup();
@@ -2723,7 +2723,7 @@ struct Level : IGame {
Core::setTarget(NULL, Core::defaultTarget, 0);
Core::viewportDef = vp;
}
if (Core::settings.detail.stereo == Core::Settings::STEREO_ON) { // left/right SBS stereo
float oldEye = Core::eye;

View File

@@ -507,7 +507,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
break;
// keyboard
case WM_CHAR :
case WM_SYSCHAR :
case WM_SYSCHAR :
#ifdef _NAPI_SOCKET
if (wParam == VK_RETURN) {
parseCommand(command);
@@ -533,7 +533,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
if (style & WS_OVERLAPPEDWINDOW) {
MONITORINFO mInfo = { sizeof(mInfo) };
if (GetWindowPlacement(hWnd, &pLast) && GetMonitorInfo(MonitorFromWindow(hWnd, MONITOR_DEFAULTTOPRIMARY), &mInfo)) {
RECT &r = mInfo.rcMonitor;
RECT &r = mInfo.rcMonitor;
SetWindowLong(hWnd, GWL_STYLE, style & ~WS_OVERLAPPEDWINDOW);
MoveWindow(hWnd, r.left, r.top, r.right - r.left, r.bottom - r.top, FALSE);
}
@@ -601,23 +601,23 @@ vr::TrackedDevicePose_t tPose[vr::k_unMaxTrackedDeviceCount];
//eye textures(eventually)
//action handles
vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcLeft = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRight = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcUp = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcDown = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcLook = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcJump = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWalk = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcAction = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcWeapon = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcRoll = vr::k_ulInvalidActionHandle;
vr::VRActionHandle_t VRcLook = 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::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle;
vr::VRInputValueHandle_t m_leftHand = vr::k_ulInvalidInputValueHandle;
vr::VRInputValueHandle_t m_rightHand = vr::k_ulInvalidInputValueHandle;
//only in select TR games
@@ -644,33 +644,33 @@ void vrInit() {
return;
}
//set manifest
vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath
//set manifest
vr::VRInput()->SetActionManifestPath("C:/Users/Austin/Desktop/OpenLaraGitTest2/OpenLara/bin/TombRaidervr_actions.json"); // needs absolutepath
// get action handles
vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft);
vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight);
vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp);
vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown);
vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump);
vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk);
vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction);
vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon);
vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll);
vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory);
vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart);
//get actionsethandle
vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo);
//get input source handles
vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand);
vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand);
// aren't using right now
//vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic);
//vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput);
vr::VRInput()->GetActionHandle("/actions/demo/in/Left", &VRcLeft);
vr::VRInput()->GetActionHandle("/actions/demo/in/Right", &VRcRight);
vr::VRInput()->GetActionHandle("/actions/demo/in/Up", &VRcUp);
vr::VRInput()->GetActionHandle("/actions/demo/in/Down", &VRcDown);
vr::VRInput()->GetActionHandle("/actions/demo/in/Jump", &VRcJump);
vr::VRInput()->GetActionHandle("/actions/demo/in/Walk", &VRcWalk);
vr::VRInput()->GetActionHandle("/actions/demo/in/Action", &VRcAction);
vr::VRInput()->GetActionHandle("/actions/demo/in/Weapon", &VRcWeapon);
vr::VRInput()->GetActionHandle("/actions/demo/in/Roll", &VRcRoll);
vr::VRInput()->GetActionHandle("/actions/demo/in/Inventory", &VRcInventory);
vr::VRInput()->GetActionHandle("/actions/demo/in/Start", &VRcStart);
//get actionsethandle
vr::VRInput()->GetActionSetHandle("/actions/demo", &m_actionsetDemo);
//get input source handles
vr::VRInput()->GetInputSourceHandle("/user/hand/left", &m_leftHand);
vr::VRInput()->GetInputSourceHandle("/user/hand/right", &m_rightHand);
// aren't using right now
//vr::VRInput()->GetActionHandle("/actions/demo/in/TriggerHaptic", &m_actionTriggerHaptic);
//vr::VRInput()->GetActionHandle("/actions/demo/in/AnalogInput", &m_actionAnalongInput);
}
void vrInitTargets() {
uint32_t width, height;
hmd->GetRecommendedRenderTargetSize( &width, &height);
hmd->GetRecommendedRenderTargetSize(&width, &height);
Core::eyeTex[0] = new Texture(width, height, TexFormat::FMT_RGBA);
Core::eyeTex[1] = new Texture(width, height, TexFormat::FMT_RGBA);
}
@@ -682,13 +682,13 @@ void vrFree() {
mat4 convToMat4(const vr::HmdMatrix44_t &m) {
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], m.m[3][0],
m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1],
m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2],
m.m[0][1], m.m[1][1], m.m[2][1], m.m[3][1],
m.m[0][2], m.m[1][2], m.m[2][2], m.m[3][2],
m.m[0][3], m.m[1][3], m.m[2][3], m.m[3][3]);
}
mat4 convToMat4(const vr::HmdMatrix34_t &m) {
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f,
return mat4(m.m[0][0], m.m[1][0], m.m[2][0], 0.0f,
m.m[0][1], m.m[1][1], m.m[2][1], 0.0f,
m.m[0][2], m.m[1][2], m.m[2][2], 0.0f,
m.m[0][3], m.m[1][3], m.m[2][3], 1.0f);
@@ -696,71 +696,65 @@ mat4 convToMat4(const vr::HmdMatrix34_t &m) {
//utility function for reading digital state
bool GetDigitalActionState(vr::VRActionHandle_t action, vr::VRInputValueHandle_t *pDevicePath = nullptr)
{
vr::InputDigitalActionData_t actionData;
vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
if (pDevicePath)
{
*pDevicePath = vr::k_ulInvalidInputValueHandle;
if (actionData.bActive)
{
vr::InputOriginInfo_t originInfo;
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo)))
{
*pDevicePath = originInfo.devicePath;
}
}
}
return actionData.bActive && actionData.bState;
vr::InputDigitalActionData_t actionData;
vr::VRInput()->GetDigitalActionData(action, &actionData, sizeof(actionData), vr::k_ulInvalidInputValueHandle);
if (pDevicePath) {
*pDevicePath = vr::k_ulInvalidInputValueHandle;
if (actionData.bActive) {
vr::InputOriginInfo_t originInfo;
if (vr::VRInputError_None == vr::VRInput()->GetOriginTrackedDeviceInfo(actionData.activeOrigin, &originInfo, sizeof(originInfo))) {
*pDevicePath = originInfo.devicePath;
}
}
}
return actionData.bActive && actionData.bState;
}
void ProcessVREvent(const vr::VREvent_t &event) {
char buffer[1024] = "test";
switch (event.eventType) {
case vr::VREvent_TrackedDeviceActivated:
//SetupRenderModelForTrackedDevice( event.trackedDeviceIndex );
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
//rm->LoadRenderModel_Async(buffer, controllerRender);
// need to process render model?
LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex);
break;
case vr::VREvent_TrackedDeviceDeactivated:
LOG("Device %u detached.\n", event.trackedDeviceIndex);
break;
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
LOG("Device %u updated.\n", event.trackedDeviceIndex);
break;
}
char buffer[1024] = "test";
switch (event.eventType) {
case vr::VREvent_TrackedDeviceActivated:
//SetupRenderModelForTrackedDevice( event.trackedDeviceIndex );
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
//rm->LoadRenderModel_Async(buffer, controllerRender);
// need to process render model?
LOG("Device %u attached. Setting up render model\n", event.trackedDeviceIndex);
break;
case vr::VREvent_TrackedDeviceDeactivated:
LOG("Device %u detached.\n", event.trackedDeviceIndex);
Input::reset();
break;
case vr::VREvent_TrackedDeviceUpdated: //not sure what to do here
LOG("Device %u updated.\n", event.trackedDeviceIndex);
break;
}
}
//taken from openvrsimpleexamples
void vrUpdateInput() { // going to use action manifest and ivr:input(Steam Vr Input) // broken
void vrUpdateInput() {
if (!hmd) return;
vr::VREvent_t 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 };
actionSet.ulActionSet = m_actionsetDemo;
vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1);
vr::VRActiveActionSet_t actionSet = { 0 };
actionSet.ulActionSet = m_actionsetDemo;
vr::VRInput()->UpdateActionState(&actionSet, sizeof(actionSet), 1);
Input::hmd.down[cUp] = GetDigitalActionState(VRcUp);
Input::hmd.down[cDown] = GetDigitalActionState(VRcDown);
Input::hmd.down[cRight] = GetDigitalActionState(VRcRight);
Input::hmd.down[cLeft] = GetDigitalActionState(VRcLeft);
Input::hmd.down[cJump] = GetDigitalActionState(VRcJump);
Input::hmd.down[cWalk] = GetDigitalActionState(VRcWalk);
Input::hmd.down[cAction] = GetDigitalActionState(VRcAction);
Input::hmd.down[cWeapon] = GetDigitalActionState(VRcWeapon);
Input::hmd.down[cRoll] = GetDigitalActionState(VRcRoll);
Input::hmd.down[cStart] = GetDigitalActionState(VRcStart);
Input::hmd.down[cInventory] = GetDigitalActionState(VRcInventory);
Input::hmd.state[cUp] = GetDigitalActionState(VRcUp);
Input::hmd.state[cDown] = GetDigitalActionState(VRcDown);
Input::hmd.state[cRight] = GetDigitalActionState(VRcRight);
Input::hmd.state[cLeft] = GetDigitalActionState(VRcLeft);
Input::hmd.state[cJump] = GetDigitalActionState(VRcJump);
Input::hmd.state[cWalk] = GetDigitalActionState(VRcWalk);
Input::hmd.state[cAction] = GetDigitalActionState(VRcAction);
Input::hmd.state[cWeapon] = GetDigitalActionState(VRcWeapon);
Input::hmd.state[cRoll] = GetDigitalActionState(VRcRoll);
Input::hmd.state[cStart] = GetDigitalActionState(VRcStart);
Input::hmd.state[cInventory] = GetDigitalActionState(VRcInventory);
}
void vrUpdateView() {
@@ -777,14 +771,14 @@ void vrUpdateView() {
if (Input::hmd.zero.x == INF)
Input::hmd.zero = head.getPos();
head.setPos(head.getPos() - Input::hmd.zero);
mat4 vL = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Left));
mat4 vR = head * convToMat4(hmd->GetEyeToHeadTransform(vr::Eye_Right));
vL.setPos(vL.getPos() * ONE_METER);
vR.setPos(vR.getPos() * ONE_METER);
Input::hmd.setView(pL, pR, vL, vR);
// pass this to Lara's rotation value
Input::hmd.head = head;
}