Skip to content

Commit

Permalink
Quake VR v0.0.2 (#7)
Browse files Browse the repository at this point in the history
* WIP implementation of SteamVR input API (for bindings

* Implement menu controls

* Add input manifest

* Code cleanup and config

* Code cleanup

* Fix run speed

* GitIgnore

* More cleanup

* Cleanup, TODOs, WIP roomscale jump

* Implement roomscale jump

* Implement menu distance CVar

* Improve hand collision detection/resolution, fix offhand lighting bug

* Add melee damage and range multiplier settings

* Add CVar and setting to control item pickup with body

* Add speed modified button and binding

* Hide unused menu options

* v0.0.2 release
  • Loading branch information
vittorioromeo authored Mar 2, 2020
1 parent 207bc82 commit 0984388
Show file tree
Hide file tree
Showing 36 changed files with 1,752 additions and 3,127 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Windows/build
id1
Id1
Debug/id1
Debug/Id1
Linux/CodeBlocks/id1
Linux/CodeBlocks/Id1
Build-qu*
*.so
*.dbg
Expand Down
Binary file modified QC/pak3.pak
Binary file not shown.
Binary file modified QC/progs.dat
Binary file not shown.
28 changes: 20 additions & 8 deletions QC/weapons.qc
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,22 @@ vector() vrProjectileVelocity =
return VEC_ORIGIN;
};

float(float v) VRMeleeDmg =
{
return (v * self.handvelmag) * cvar("vr_melee_dmg_multiplier");
}

float(float v) VRMeleeOffHandDmg =
{
return (v * self.offhandvelmag) * cvar("vr_melee_dmg_multiplier");
}


float(float v) VRMeleeRange =
{
return v * cvar("vr_melee_range_multiplier");
}

/*
================
W_FireAxe
Expand All @@ -70,8 +84,7 @@ void() W_FireAxe =
local string s;
local float playedsound;

// TODO VR: add damage multiplier cvar
xdmg = 0.73 * self.handvelmag;
xdmg = VRMeleeDmg(0.73);

// s = ftos(xdmg);
// sprint (self, "DMG: ");
Expand All @@ -80,8 +93,7 @@ void() W_FireAxe =

makevectors (self.v_angle);
source = self.handpos + '0 0 0';
// TODO VR: add range multiplier cvar
traceline (source - v_forward*24, source + v_forward*28, FALSE, self);
traceline (source - v_forward*24, source + v_forward * VRMeleeRange(28), FALSE, self);
if (trace_fraction == 1.0)
return;

Expand Down Expand Up @@ -137,7 +149,7 @@ void() W_GunMelee =
local string s;
local float playedsound;

xdmg = 0.43 * self.handvelmag;
xdmg = VRMeleeDmg(0.43);

// s = ftos(xdmg);
// sprint (self, "DMG: ");
Expand All @@ -146,7 +158,7 @@ void() W_GunMelee =

makevectors (self.v_angle);
source = self.handpos + '0 0 0';
traceline (source - v_forward*24, source + v_forward*26, FALSE, self);
traceline (source - v_forward*24, source + v_forward * VRMeleeRange(26), FALSE, self);
if (trace_fraction == 1.0)
return;

Expand Down Expand Up @@ -203,7 +215,7 @@ void() W_FistMelee =
local string s;
local float playedsound;

xdmg = 0.53 * self.offhandvelmag;
xdmg = VRMeleeOffHandDmg(0.53);

// s = ftos(xdmg);
// sprint (self, "OFFHANDDMG: ");
Expand All @@ -212,7 +224,7 @@ void() W_FistMelee =

makevectors (self.v_angle);
source = self.offhandpos + '0 0 0';
traceline (source - v_forward*24, source + v_forward*24, FALSE, self);
traceline (source - v_forward*24, source + v_forward * VRMeleeRange(24), FALSE, self);
if (trace_fraction == 1.0)
return;

Expand Down
2 changes: 1 addition & 1 deletion Quake/cl_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ cvar_t cl_forwardspeed = {"cl_forwardspeed", "200", CVAR_ARCHIVE};
cvar_t cl_backspeed = {"cl_backspeed", "200", CVAR_ARCHIVE};
cvar_t cl_sidespeed = {"cl_sidespeed", "350", CVAR_NONE};

cvar_t cl_movespeedkey = {"cl_movespeedkey", "2.0", CVAR_NONE};
cvar_t cl_movespeedkey = {"cl_movespeedkey", "0.5", CVAR_ARCHIVE};

cvar_t cl_yawspeed = {"cl_yawspeed", "140", CVAR_NONE};
cvar_t cl_pitchspeed = {"cl_pitchspeed", "150", CVAR_NONE};
Expand Down
10 changes: 1 addition & 9 deletions Quake/cl_tent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,19 +347,11 @@ void CL_UpdateTEnts()
{
if(vr_enabled.value)
{
// TODO VR: deal with offset in non-vr mode ?
//
// vec3_t adj;
// VectorCopy(cl.handpos[1], adj);
// adj[2] += vr_projectilespawn_z_offset.value;
// VectorCopy(adj, b->start);

// TODO VR: hardcoded lightning gun muzzle position for beam
// effect
vec3_t forward;

vec3_t forward;
vec3_t right;

vec3_t up;
AngleVectors(cl.handrot[1], forward, right, up);

Expand Down
35 changes: 16 additions & 19 deletions Quake/gl_rmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,28 +981,25 @@ void R_ShowTris()
}
}

const auto doViewmodel =
[&](entity_t* ent) {
currententity = ent;
if (r_drawviewmodel.value && !chase_active.value &&
cl.stats[STAT_HEALTH] > 0 &&
!(cl.items & IT_INVISIBILITY) && currententity->model &&
currententity->model->type == mod_alias)
{
glDepthRange(0, 0.3);
R_DrawAliasModel_ShowTris(currententity);
glDepthRange(0, 1);
}
};

// viewmodel
currententity = &cl.viewent;
if(r_drawviewmodel.value && !chase_active.value &&
cl.stats[STAT_HEALTH] > 0 && !(cl.items & IT_INVISIBILITY) &&
currententity->model && currententity->model->type == mod_alias)
{
glDepthRange(0, 0.3);
R_DrawAliasModel_ShowTris(currententity);
glDepthRange(0, 1);
}
doViewmodel(&cl.viewent);

// TODO VR: not needed?
// offhand viewmodel
/* currententity = &cl.offhand_viewent;
if(r_drawviewmodel.value && !chase_active.value &&
cl.stats[STAT_HEALTH] > 0 && !(cl.items & IT_INVISIBILITY) &&
currententity->model && currententity->model->type == mod_alias)
{
glDepthRange(0, 0.3);
R_DrawAliasModel_ShowTris(currententity);
glDepthRange(0, 1);
} */
doViewmodel(&cl.offhand_viewent);
}

if(r_particles.value)
Expand Down
13 changes: 13 additions & 0 deletions Quake/main_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <cassert>
#include <string>

#include "quakedef.hpp"
#if defined(SDL_FRAMEWORK) || defined(NO_SDL_CONFIG)
#if defined(USE_SDL2)
Expand Down Expand Up @@ -104,8 +107,17 @@ static quakeparms_t parms;
#define main SDL_main
#endif

// TODO VR:
extern std::string vr_working_directory;

int main(int argc, char* argv[])
{
// TODO VR: more portable/reliable way of doing this
assert(argc >= 1);
vr_working_directory = argv[0];
vr_working_directory = vr_working_directory.substr(0, vr_working_directory.find_last_of("\\"));
Sys_Printf("Working directory: '%s'\n", vr_working_directory.c_str());

int t;
double time;

Expand Down Expand Up @@ -152,6 +164,7 @@ int main(int argc, char* argv[])
Sys_Printf("FitzQuake SDL port (c) SleepwalkR, Baker\n");
Sys_Printf("QuakeSpasm " QUAKESPASM_VER_STRING
" (c) Ozkan Sezer, Eric Wasylishen & others\n");
Sys_Printf("Quake VR " QUAKEVR_VERSION " by Vittorio Romeo & others\n");

Sys_Printf("Host_Init\n");
Host_Init();
Expand Down
54 changes: 26 additions & 28 deletions Quake/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1066,9 +1066,10 @@ void M_Net_Key(int k)

enum
{
OPT_CUSTOMIZE = 0,
OPT_CONSOLE, // 1
OPT_DEFAULTS, // 2
// TODO VR:
// OPT_CUSTOMIZE = 0,
OPT_CONSOLE = 0,
OPT_DEFAULTS,
OPT_SCALE,
OPT_SCRSIZE,
OPT_GAMMA,
Expand Down Expand Up @@ -1101,7 +1102,7 @@ enum
{
ALWAYSRUN_OFF = 0,
ALWAYSRUN_VANILLA,
ALWAYSRUN_QUAKESPASM,
// ALWAYSRUN_QUAKESPASM,
ALWAYSRUN_ITEMS
};

Expand All @@ -1120,7 +1121,8 @@ void M_Menu_Options_f()

void M_AdjustSliders(int dir)
{
int curr_alwaysrun;
// TODO VR:
// int curr_alwaysrun;

int target_alwaysrun;
float f;
Expand Down Expand Up @@ -1235,39 +1237,36 @@ void M_AdjustSliders(int dir)
break;

case OPT_ALWAYRUN: // always run
if(cl_alwaysrun.value)
// TODO VR:
/*if(cl_alwaysrun.value)
{
curr_alwaysrun = ALWAYSRUN_QUAKESPASM;
}
else if(cl_forwardspeed.value > 200)
else */
/*if(cl_forwardspeed.value > 200)
{
curr_alwaysrun = ALWAYSRUN_VANILLA;
}
else
{
curr_alwaysrun = ALWAYSRUN_OFF;
}
}*/

target_alwaysrun =
(ALWAYSRUN_ITEMS + curr_alwaysrun + dir) % ALWAYSRUN_ITEMS;
(ALWAYSRUN_ITEMS + (int)cl_alwaysrun.value + dir) %
ALWAYSRUN_ITEMS;

if(target_alwaysrun == ALWAYSRUN_VANILLA)
{
Cvar_SetValue("cl_alwaysrun", 0);
Cvar_SetValue("cl_forwardspeed", 400);
Cvar_SetValue("cl_backspeed", 400);
}
else if(target_alwaysrun == ALWAYSRUN_QUAKESPASM)
{
Cvar_SetValue("cl_alwaysrun", 1);
Cvar_SetValue("cl_forwardspeed", 200);
Cvar_SetValue("cl_backspeed", 200);
}
// TODO VR:
// else if(target_alwaysrun == ALWAYSRUN_QUAKESPASM)
// {
// }
else // ALWAYSRUN_OFF
{
Cvar_SetValue("cl_alwaysrun", 0);
Cvar_SetValue("cl_forwardspeed", 200);
Cvar_SetValue("cl_backspeed", 200);
}
break;

Expand Down Expand Up @@ -1348,8 +1347,9 @@ void M_Options_Draw()
M_DrawPic((320 - p->width) / 2, 4, p);

// Draw the items in the order of the enum defined above:
// TODO VR:
// OPT_CUSTOMIZE:
M_Print(16, 32, " Controls");
// M_Print(16, 32, " Controls");
// OPT_CONSOLE:
M_Print(16, 32 + 8 * OPT_CONSOLE, " Goto console");
// OPT_DEFAULTS:
Expand Down Expand Up @@ -1404,11 +1404,7 @@ void M_Options_Draw()
M_Print(16, 32 + 8 * OPT_ALWAYRUN, " Always Run");
if(cl_alwaysrun.value)
{
M_Print(220, 32 + 8 * OPT_ALWAYRUN, "quakespasm");
}
else if(cl_forwardspeed.value > 200.0)
{
M_Print(220, 32 + 8 * OPT_ALWAYRUN, "vanilla");
M_Print(220, 32 + 8 * OPT_ALWAYRUN, "on");
}
else
{
Expand Down Expand Up @@ -1465,7 +1461,8 @@ void M_Options_Key(int k)
m_entersound = true;
switch(options_cursor)
{
case OPT_CUSTOMIZE: M_Menu_Keys_f(); break;
// TODO VR:
// case OPT_CUSTOMIZE: M_Menu_Keys_f(); break;
case OPT_CONSOLE:
m_state = m_none;
Con_ToggleConsole_f();
Expand Down Expand Up @@ -1896,8 +1893,9 @@ bool M_Quit_TextEntry()
void M_Quit_Draw() // johnfitz -- modified for new quit message
{
char msg1[40];
char msg2[] = "by Ozkan Sezer, Eric Wasylishen, others"; /* msg2/msg3 are
mostly [40] */
char msg2[] =
"by Vittorio Romeo, Ozkan Sezer, Eric Wasylishen, others"; /* msg2/msg3
are mostly [40] */
char msg3[] = "Press y to quit";
int boxlen;

Expand Down
4 changes: 3 additions & 1 deletion Quake/quakedef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#define FITZQUAKE_VERSION 0.85 // johnfitz
#define QUAKESPASM_VERSION 0.93
#define QUAKEVR_VERSION "0.0.2"
#define QUAKESPASM_VER_PATCH 2 // helper to print a string like 0.93.2
#ifndef QUAKESPASM_VER_SUFFIX
#define QUAKESPASM_VER_SUFFIX // optional version suffix string literal like
Expand All @@ -49,7 +50,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// combined version string like "0.92.1-beta1"
#define QUAKESPASM_VER_STRING \
QS_STRINGIFY(QUAKESPASM_VERSION) \
"." QS_STRINGIFY(QUAKESPASM_VER_PATCH) QUAKESPASM_VER_SUFFIX
"." QS_STRINGIFY(QUAKESPASM_VER_PATCH) QUAKESPASM_VER_SUFFIX \
" | Quake VR " QUAKEVR_VERSION

// define PARANOID // speed sapping error checking

Expand Down
2 changes: 1 addition & 1 deletion Quake/r_alias.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void R_SetupAliasLighting(entity_t* e)
}

// minimum light value on gun (24)
if(e == &cl.viewent)
if(e == &cl.viewent || e == &cl.offhand_viewent)
{
add = 72.0f - (lightcolor[0] + lightcolor[1] + lightcolor[2]);
if(add > 0.0f)
Expand Down
7 changes: 4 additions & 3 deletions Quake/sv_phys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ int SV_FlyMove(edict_t* ent, float time, trace_t* steptrace)
//
SV_Impact(ent, trace.ent, &entvars_t::touch);

if(!vr_enabled.value)
if(!vr_enabled.value || vr_body_interactions.value)
{
SV_Impact(ent, trace.ent, &entvars_t::handtouch);
}
Expand Down Expand Up @@ -507,7 +507,7 @@ trace_t SV_PushEntity(edict_t* ent, vec3_t push)
{
SV_Impact(ent, trace.ent, &entvars_t::touch);

if(!vr_enabled.value)
if(!vr_enabled.value || vr_body_interactions.value)
{
SV_Impact(ent, trace.ent, &entvars_t::handtouch);
}
Expand Down Expand Up @@ -1064,7 +1064,8 @@ Trigger hand-touching actions (e.g. pick up an item, press a button)
*/
void SV_Handtouch(edict_t* ent)
{
// TODO VR: this is still fucking broken, buttons don't work sometimes
// TODO VR: cleanup, too much unnecessary tracing and work


using namespace quake::util;

Expand Down
5 changes: 4 additions & 1 deletion Quake/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ namespace quake::util
template <typename... Ts>
[[nodiscard]] constexpr auto makeAdjustedMenuLabels(const Ts&... labels)
{
return std::array{(std::string(24 - strlen(labels), ' ') + labels)...};
constexpr auto maxLen = 25;

assert(((strlen(labels) <= maxLen) && ...));
return std::array{(std::string(maxLen - strlen(labels), ' ') + labels)...};
}

[[nodiscard]] constexpr bool boxIntersection(const vec3_t& aMin,
Expand Down
Loading

0 comments on commit 0984388

Please sign in to comment.