Local view weapon no longer disturbing while aiming
This commit is contained in:
parent
a8451adb17
commit
0824bffd19
@ -595,6 +595,24 @@ namespace spades {
|
||||
if(dt > 0.f)
|
||||
viewWeaponOffset *= powf(.02f, dt);
|
||||
|
||||
if(player->GetTool() == Player::ToolWeapon &&
|
||||
player->GetWeaponInput().secondary) {
|
||||
|
||||
if(dt > 0.f)
|
||||
viewWeaponOffset *= powf(.01f, dt);
|
||||
|
||||
const float limitX = .01f;
|
||||
const float limitY = .01f;
|
||||
if(viewWeaponOffset.x < -limitX)
|
||||
viewWeaponOffset.x = Mix(viewWeaponOffset.x, -limitX, .5f);
|
||||
if(viewWeaponOffset.x > limitX)
|
||||
viewWeaponOffset.x = Mix(viewWeaponOffset.x, limitX, .5f);
|
||||
if(viewWeaponOffset.z < 0.f)
|
||||
viewWeaponOffset.z = Mix(viewWeaponOffset.z, 0.f, .5f);
|
||||
if(viewWeaponOffset.z > limitY)
|
||||
viewWeaponOffset.z = Mix(viewWeaponOffset.z, limitY, .5f);
|
||||
}
|
||||
|
||||
}else{
|
||||
viewWeaponOffset = MakeVector3(0,0,0);
|
||||
}
|
||||
|
@ -473,6 +473,12 @@ namespace spades {
|
||||
return v * v * (3.f - 2.f * v);
|
||||
}
|
||||
|
||||
float Mix(float a, float b, float frac) {
|
||||
return a + (b - a) * frac;
|
||||
}
|
||||
Vector2 Mix(Vector2 a, Vector2 b, float frac) {
|
||||
return a + (b - a) * frac;
|
||||
}
|
||||
Vector3 Mix(Vector3 a, Vector3 b, float frac) {
|
||||
return a + (b - a) * frac;
|
||||
}
|
||||
|
@ -665,6 +665,8 @@ namespace spades {
|
||||
vec.resize(vec.size() - 1);
|
||||
}
|
||||
|
||||
float Mix(float a, float b, float frac);
|
||||
Vector2 Mix(Vector2 a, Vector2 b, float frac);
|
||||
Vector3 Mix(Vector3 a, Vector3 b, float frac);
|
||||
|
||||
/** @return true if any portion of the box is in the positive side of plane. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user