Skip to content

Commit d923d67

Browse files
Merge pull request #437 from knallpsi/body-first-person
First Person Body
1 parent 1583921 commit d923d67

11 files changed

Lines changed: 454 additions & 90 deletions

src/xrGame/Actor.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,11 +2129,16 @@ bool CActor::AllowActorShadow()
21292129
void CActor::renderable_Render()
21302130
{
21312131
VERIFY(_valid(XFORM()));
2132-
2132+
21332133
if (cam_active == eacFirstEye)
21342134
{
21352135
if (::Render->active_phase() == 0) // can render first person body here
21362136
{
2137+
if (g_player_hud && psHUD_Flags.test(HUD_DRAW) && !m_holder)
2138+
{
2139+
g_player_hud->render_legs();
2140+
}
2141+
21372142
//if (fpBody)
21382143
// inherited::renderable_Render();
21392144
}
@@ -2146,7 +2151,7 @@ void CActor::renderable_Render()
21462151
}
21472152
}
21482153

2149-
// Third Person Body and Weapon/Item
2154+
// Third Person Body and Weapon/Item
21502155
else
21512156
{
21522157
inherited::renderable_Render();

src/xrGame/ActorAnimation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ void CActor::g_SetAnimation(u32 mstate_rl)
407407
else if (mstate_rl & mcLStrafe) M_legs = AS->legs_ls;
408408
else if (mstate_rl & mcRStrafe) M_legs = AS->legs_rs;
409409
else is_standing = true;
410+
if (g_player_hud && is_standing && IsFocused() && g_player_hud->m_legs_controller.is_active()) {
411+
is_standing = false;
412+
}
410413

411414
if (mstate_rl & mcSprint)
412415
{

src/xrGame/Actor_Movement.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,13 @@ void CActor::g_Orientate(u32 mstate_rl, float dt)
410410
}
411411

412412
// lerp angle for "effect" and capture torso data from camera
413-
angle_lerp(r_model_yaw_delta, calc_yaw, PI_MUL_4, dt);
413+
float scale_yaw_offset = 1.0f;
414+
415+
if (cam_active == eacFirstEye && g_player_hud && g_player_hud->m_legs_controller.is_active()) {
416+
scale_yaw_offset = 0.15f;
417+
}
418+
419+
angle_lerp(r_model_yaw_delta, calc_yaw * scale_yaw_offset, PI_MUL_4 * scale_yaw_offset, dt);
414420

415421
// build matrix
416422
Fmatrix mXFORM;

src/xrGame/IKLimbsController.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ float CIKLimbsController::LegLengthShiftLimit(float current_shift, const SCalcul
9898
if (shift_down < s_down)
9999
shift_down = s_down;
100100
}
101+
102+
if (Actor() == m_object) {
103+
if (Actor()->active_cam() == EActorCameras::eacFirstEye) {
104+
clamp(shift_down, -0.1f, 0.1f);
105+
}
106+
}
107+
101108
return shift_down;
102109
}
103110

@@ -193,6 +200,13 @@ bool CIKLimbsController::PredictObjectShift(const SCalculateData cd[max_size])
193200

194201
if (predict_time_shift < EPS_S)
195202
predict_time_shift = Device.fTimeDelta;
203+
204+
if (Actor() == m_object) {
205+
if (Actor()->active_cam() == EActorCameras::eacFirstEye) {
206+
clamp(predict_shift, -0.1f, 0.1f);
207+
}
208+
}
209+
196210
_object_shift.set_taget(predict_shift, predict_time_shift);
197211
return true;
198212
}

src/xrGame/console_commands.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ extern BOOL g_allow_silencer_hide_tracer;
134134

135135
//demonized: new console vars
136136
extern BOOL firstPersonDeath;
137+
extern BOOL g_legs_enabled;
137138
extern BOOL pseudogiantCanDamageObjects;
138139
extern BOOL use_english_text_for_missing_translations;
139140
namespace crash_saving {
@@ -2969,6 +2970,10 @@ void CCC_RegisterCommands()
29692970
CMD4(CCC_Integer, "first_person_death_direction_smoothing", &firstPersonDeathDirectionSmoothing, 1, 60);
29702971
CMD4(CCC_Float, "first_person_death_near_plane_offset", &viewportNearOffset, -.1f, .5f);
29712972

2973+
//legs
2974+
2975+
CMD4(CCC_Integer, "g_legs", &g_legs_enabled, 0, 1);
2976+
29722977
// PDA commands
29732978
CMD4(CCC_Integer, "pda_map_zoom_in_to_mouse", &pda_map_zoom_in_to_mouse, 0, 1);
29742979
CMD4(CCC_Integer, "pda_map_zoom_out_to_mouse", &pda_map_zoom_out_to_mouse, 0, 1);

0 commit comments

Comments
 (0)