Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev into main #45

Merged
merged 17 commits into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
* Fix speed and direction in legacy ladder climbing
  • Loading branch information
maxvollmer committed Feb 11, 2023
commit 0d547de866d3fc7ba44956228d90c5d065f722d3
9 changes: 9 additions & 0 deletions src/cl_dll/VRHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,15 @@ void VRGetMaxClimbSpeed(float& updown, float& sideways)
sideways = CVAR_GET_FLOAT("vr_ladder_legacy_sideways_speed");
}

// for pm_shared.cpp
void VRGetCVARSpeeds(float& forwardSpeed, float& backSpeed, float& sideSpeed, float& upSpeed)
{
forwardSpeed = CVAR_GET_FLOAT("vr_forwardspeed");
backSpeed = CVAR_GET_FLOAT("vr_backspeed");
sideSpeed = CVAR_GET_FLOAT("vr_sidespeed");
upSpeed = CVAR_GET_FLOAT("vr_upspeed");
}

// for pm_shared.cpp
int VRGetLadderMode()
{
Expand Down
2 changes: 1 addition & 1 deletion src/cl_dll/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ void DLLEXPORT CL_CreateMove(float frametime, struct usercmd_s* cmd, int active)
if (g_vrInput.analogforward < -EPSILON)
cmd->buttons |= IN_BACK;
if (g_vrInput.analogsidemove > EPSILON)
cmd->buttons |= IN_MOVELEFT;
cmd->buttons |= IN_MOVERIGHT;
if (g_vrInput.analogsidemove < -EPSILON)
cmd->buttons |= IN_MOVELEFT;
if (g_vrInput.analogupmove > EPSILON)
Expand Down
8 changes: 8 additions & 0 deletions src/dlls/VRCommons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ void VRGetMaxClimbSpeed(float& updown, float& sideways)
sideways = CVAR_GET_FLOAT("vr_ladder_legacy_sideways_speed");
}

void VRGetCVARSpeeds(float& forwardSpeed, float& backSpeed, float& sideSpeed, float& upSpeed)
{
forwardSpeed = CVAR_GET_FLOAT("vr_forwardspeed");
backSpeed = CVAR_GET_FLOAT("vr_backspeed");
sideSpeed = CVAR_GET_FLOAT("vr_sidespeed");
upSpeed = CVAR_GET_FLOAT("vr_upspeed");
}

int VRGetLadderMode()
{
return (int)CVAR_GET_FLOAT("vr_ladder_mode");
Expand Down
46 changes: 29 additions & 17 deletions src/pm_shared/pm_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ extern bool VRGlobalGetNoclipMode();
extern bool VRNotifyStuckEnt(int player, int ent);
extern bool VRGlobalIsPointInsideEnt(const float* point, int ent);
extern void VRGetMaxClimbSpeed(float& updown, float& sideways);
extern void VRGetCVARSpeeds(float& forwardSpeed, float& backSpeed, float& sideSpeed, float& upSpeed);
extern int VRGetLadderMode();
extern int VRGetGrabbedLadder(int player); // For client or server to use to identify (index into edicts or cl_entities)
inline bool VRIsGrabbingLadder() { return VRGetGrabbedLadder(pmove->player_index) > 0; }
Expand Down Expand Up @@ -74,6 +75,7 @@ float vJumpAngles[3];

//typedef enum {mod_brush, mod_sprite, mod_alias, mod_studio} modtype_t;

#define DEFAULT_MOVEMENT_SPEED 270
#define DEFAULT_MAX_CLIMB_SPEED 200
#define DEFAULT_MAX_SIDEWAYS_SPEED 50

Expand Down Expand Up @@ -2155,23 +2157,33 @@ void PM_LadderMove(physent_t* pLadder)
}
else
{
float maxClimbSpeed = 0.f;
float maxSidewaysSpeed = 0.f;
float forwardSpeed = DEFAULT_MOVEMENT_SPEED;
float backSpeed = DEFAULT_MOVEMENT_SPEED;
float sideSpeed = DEFAULT_MOVEMENT_SPEED;
float upSpeed = DEFAULT_MOVEMENT_SPEED;
float maxClimbSpeed = DEFAULT_MAX_CLIMB_SPEED;
float maxSidewaysSpeed = DEFAULT_MAX_SIDEWAYS_SPEED;
VRGetCVARSpeeds(forwardSpeed, backSpeed, sideSpeed, upSpeed);
VRGetMaxClimbSpeed(maxClimbSpeed, maxSidewaysSpeed);
if (forwardSpeed <= 1.f) forwardSpeed = DEFAULT_MOVEMENT_SPEED;
if (backSpeed <= 1.f) backSpeed = DEFAULT_MOVEMENT_SPEED;
if (sideSpeed <= 1.f) sideSpeed = DEFAULT_MOVEMENT_SPEED;
if (upSpeed <= 1.f) upSpeed = DEFAULT_MOVEMENT_SPEED;
if (maxClimbSpeed <= 1.f) maxClimbSpeed = DEFAULT_MAX_CLIMB_SPEED;
if (maxSidewaysSpeed <= 1.f) maxSidewaysSpeed = DEFAULT_MAX_SIDEWAYS_SPEED;

float up = 0.f;
if (pmove->cmd.buttons & IN_FORWARD || pmove->cmd.buttons_ex & X_IN_UP)
up += maxClimbSpeed;
if (pmove->cmd.buttons & IN_BACK || pmove->cmd.buttons_ex & X_IN_DOWN)
up -= maxClimbSpeed;
float up;
if (pmove->cmd.forwardmove > 0.f)
{
up = (pmove->cmd.forwardmove / forwardSpeed) * maxClimbSpeed;
}
else
{
up = (pmove->cmd.forwardmove / backSpeed) * maxClimbSpeed;
}
up += (pmove->cmd.upmove / upSpeed) * maxClimbSpeed;

float right = 0.f;
if (pmove->cmd.buttons & IN_MOVERIGHT)
right += maxSidewaysSpeed;
if (pmove->cmd.buttons & IN_MOVELEFT)
right -= maxSidewaysSpeed;
float right = (pmove->cmd.sidemove / sideSpeed) * maxSidewaysSpeed;

if (up != 0.f || right != 0.f)
{
Expand All @@ -2183,25 +2195,25 @@ void PM_LadderMove(physent_t* pLadder)
vec3_t v_right{ 0.f, 0.f, 0.f };

// ladder is horizontal
if (trace.plane.normal[2] > 0.995f)
if (fabs(trace.plane.normal[2]) > 0.995f)
{
// guesstimate vectors in horizontal ladder plane
if (ladderSize[0] > ladderSize[1])
{
v_up[0] = 1.f;
v_right[1] = 1.f;
v_right[1] = -1.f;
}
else
{
v_up[1] = 1.f;
v_right[0] = -1.f;
v_right[0] = 1.f;
}
}
else
{
// calculate vectors in vertical ladder plane
CrossProduct(trace.plane.normal, vec3_t{ 0.f, 0.f, 1.f }, v_right);
CrossProduct(v_right, trace.plane.normal, v_up);
CrossProduct(vec3_t{ 0.f, 0.f, 1.f }, trace.plane.normal, v_right);
CrossProduct(trace.plane.normal, v_right, v_up);
}

// Calculate velocity
Expand Down