File tree 4 files changed +37
-39
lines changed
4 files changed +37
-39
lines changed Original file line number Diff line number Diff line change @@ -622,3 +622,36 @@ v3s16 LocalPlayer::getStandingNodePos()
622
622
return floatToInt (getPosition () - v3f (0 , BS, 0 ), BS);
623
623
}
624
624
625
+ // Horizontal acceleration (X and Z), Y direction is ignored
626
+ void LocalPlayer::accelerateHorizontal (const v3f &target_speed, const f32 max_increase)
627
+ {
628
+ if (max_increase == 0 )
629
+ return ;
630
+
631
+ v3f d_wanted = target_speed - m_speed;
632
+ d_wanted.Y = 0 ;
633
+ f32 dl = d_wanted.getLength ();
634
+ if (dl > max_increase)
635
+ dl = max_increase;
636
+
637
+ v3f d = d_wanted.normalize () * dl;
638
+
639
+ m_speed.X += d.X ;
640
+ m_speed.Z += d.Z ;
641
+ }
642
+
643
+ // Vertical acceleration (Y), X and Z directions are ignored
644
+ void LocalPlayer::accelerateVertical (const v3f &target_speed, const f32 max_increase)
645
+ {
646
+ if (max_increase == 0 )
647
+ return ;
648
+
649
+ f32 d_wanted = target_speed.Y - m_speed.Y ;
650
+ if (d_wanted > max_increase)
651
+ d_wanted = max_increase;
652
+ else if (d_wanted < -max_increase)
653
+ d_wanted = -max_increase;
654
+
655
+ m_speed.Y += d_wanted;
656
+ }
657
+
Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ class LocalPlayer : public Player
45
45
bool isAttached;
46
46
47
47
v3f overridePosition;
48
-
48
+
49
49
void move (f32 dtime, Environment *env, f32 pos_max_d);
50
50
void move (f32 dtime, Environment *env, f32 pos_max_d,
51
51
std::vector<CollisionInfo> *collision_info);
@@ -81,6 +81,9 @@ class LocalPlayer : public Player
81
81
}
82
82
83
83
private:
84
+ void accelerateHorizontal (const v3f &target_speed, const f32 max_increase);
85
+ void accelerateVertical (const v3f &target_speed, const f32 max_increase);
86
+
84
87
// This is used for determining the sneaking range
85
88
v3s16 m_sneak_node;
86
89
// Whether the player is allowed to sneak
Original file line number Diff line number Diff line change @@ -111,41 +111,6 @@ Player::~Player()
111
111
clearHud ();
112
112
}
113
113
114
- // Horizontal acceleration (X and Z), Y direction is ignored
115
- void Player::accelerateHorizontal (v3f target_speed, f32 max_increase)
116
- {
117
- if (max_increase == 0 )
118
- return ;
119
-
120
- v3f d_wanted = target_speed - m_speed;
121
- d_wanted.Y = 0 ;
122
- f32 dl = d_wanted.getLength ();
123
- if (dl > max_increase)
124
- dl = max_increase;
125
-
126
- v3f d = d_wanted.normalize () * dl;
127
-
128
- m_speed.X += d.X ;
129
- m_speed.Z += d.Z ;
130
-
131
- }
132
-
133
- // Vertical acceleration (Y), X and Z directions are ignored
134
- void Player::accelerateVertical (v3f target_speed, f32 max_increase)
135
- {
136
- if (max_increase == 0 )
137
- return ;
138
-
139
- f32 d_wanted = target_speed.Y - m_speed.Y ;
140
- if (d_wanted > max_increase)
141
- d_wanted = max_increase;
142
- else if (d_wanted < -max_increase)
143
- d_wanted = -max_increase;
144
-
145
- m_speed.Y += d_wanted;
146
-
147
- }
148
-
149
114
v3s16 Player::getLightPosition () const
150
115
{
151
116
return floatToInt (m_position + v3f (0 ,BS+BS/2 ,0 ), BS);
Original file line number Diff line number Diff line change @@ -119,9 +119,6 @@ class Player
119
119
m_speed = speed;
120
120
}
121
121
122
- void accelerateHorizontal (v3f target_speed, f32 max_increase);
123
- void accelerateVertical (v3f target_speed, f32 max_increase);
124
-
125
122
v3f getPosition ()
126
123
{
127
124
return m_position;
You can’t perform that action at this time.
0 commit comments