• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン4688cf2dd725ade5a3d37c2453d3385d792bb8b8 (tree)
日時2012-09-23 23:22:54
作者angeart <angeart@git....>
コミッターangeart

ログメッセージ

ジャンプに関する修正
(その場ジャンプに関するバグは一部残っている)

変更サマリ

差分

--- a/client/3d/PlayerCharacter.cpp
+++ b/client/3d/PlayerCharacter.cpp
@@ -34,6 +34,7 @@ public:
3434 prev_rot_(VGet(0, 0, 0)),
3535 move_vec_y_(0.0f),
3636 jump_flag_(false),
37+ jump_end_(false),
3738 flight_duration_ideal_(1.0f),
3839 model_height_(1.58f),
3940 jump_height_(sqrt(15.0f)*2.0f),
@@ -160,6 +161,7 @@ public:
160161 if(current_target_pos != prev_target_pos_ )
161162 {
162163 time_now = 0.0f;
164+ jump_end_ = false;
163165 }
164166
165167
@@ -191,8 +193,9 @@ public:
191193 //Logger::Debug("distance_to_target: %d %d", distance_to_target, current_speed_ * timer_->DeltaSec());
192194
193195 // TODO: Y下方向については重力加速度
194- if (distance_to_target > 2.0){
196+ if ((distance_to_target > 0.5 || (current_target_pos_ - current_pos_).y > 0 )&& !jump_end_){
195197 auto direction = current_target_pos_ - current_pos_;
198+ if(current_target_vec_y_ != 0)direction.y = 0;
196199 const auto diff_pos = VAdjustLength(direction, current_speed_ * timer_->DeltaSec());
197200 const float roty = atan2(-direction.x, -direction.z);
198201 const auto time_entire = VSize(direction) / (current_speed_ * (float)timer_->DeltaSec()); // ターゲットまでの移動完了時間
@@ -207,13 +210,12 @@ public:
207210 0.5f * -9.8f * (time_entire - time_now) * (time_entire - time_now) * (1.0f / flight_duration_ideal_) * (jump_height_ / 5.0f) * (jump_height_ / 5.0f); // 今からジャンプした際の最終的な位置
208211 */
209212 static auto st_acc = -9.8f;
210- auto acc = -6.5f;
213+ auto acc = -20.0f;
211214 auto prediction_vector = 0.0f;
212215
213- for(acc;acc < -11.0f;acc-=0.1f){
214- prediction_vector = jump_height_ * stage_->map_scale() + (acc) * (time_entire - time_now) * (jump_height_ / 5.0f) * (1.0f / flight_duration_ideal_ );
215- if( current_target_vec_y_ != 0 && jump_flag_ == false )
216- {
216+ if(jump_flag_ == false && current_target_vec_y_ != 0){
217+ for(acc;acc < -6.5f;acc+=0.1f){
218+ prediction_vector = jump_height_ * stage_->map_scale() + (acc) * (time_entire - time_now) * (jump_height_ / 5.0f) * (1.0f / flight_duration_ideal_ );
217219 // ターゲット座標ではジャンプを始めている
218220 if( prediction_vector > current_target_vec_y_ - 1 && prediction_vector < current_target_vec_y_ + 1)
219221 {
@@ -236,15 +238,8 @@ public:
236238 // 床へのめり込みを防止
237239 float floor_y;
238240 std::pair<bool, VECTOR> floor_coll;
239- if(!jump_flag_)
240- {
241- // 延長線上で接地検査
242- floor_coll = stage_->FloorExists(moved_pos,model_height_,8.0f);
243- }else if(jump_flag_ && current_pos_.y >= moved_pos.y)
244- {
245241 // 足で接地検査
246242 floor_coll = stage_->FloorExists(moved_pos,model_height_,0);
247- }
248243 //moved_pos.y = std::max(moved_pos.y, floor_y); // 床にあたっているときは床の方がyが高くなる
249244 if(!jump_flag_){
250245 // 登ったり下ったりできる段差の大きさの制限を求める
@@ -268,11 +263,11 @@ public:
268263 {
269264 moved_pos = current_pos_ + VSize(diff_pos) * VNorm(diff);
270265 }
271-
272266 }
273- if( floor_coll.first )
267+ auto floor_exists = stage_->FloorExists(moved_pos, model_height_, 50);
268+ if( floor_exists.first )
274269 {
275- if( floor_coll.second.y < moved_pos.y )
270+ if( floor_exists.second.y < moved_pos.y && current_target_pos.y < moved_pos.y)
276271 {
277272 jump_flag_ = true;
278273 }
@@ -285,6 +280,12 @@ public:
285280 {
286281 moved_pos = floor_coll.second;
287282 move_vec_y_ = 0;
283+ jump_flag_ = false;
284+ st_acc = -9.8;
285+ if( moved_pos.x > current_target_pos.x - 1 && moved_pos.x < current_target_pos.x + 1)
286+ {
287+ jump_end_ = true;
288+ }
288289 }
289290 }else{
290291 // 上昇している
@@ -305,7 +306,10 @@ public:
305306 }
306307
307308 data_provider_.set_position(moved_pos);
308- data_provider_.set_theta(current_rot_.y);
309+ if(distance_to_target > 2.0)
310+ {
311+ data_provider_.set_theta(current_rot_.y);
312+ }
309313
310314 MV1SetPosition(model_handle_, moved_pos);
311315 MV1SetRotationXYZ(model_handle_, current_rot_);
@@ -318,7 +322,7 @@ public:
318322 {
319323 current_motion_ = motion.walk_;
320324 }
321- }else{
325+ }else{
322326 current_motion_ = motion.stand_;
323327 }
324328
@@ -372,6 +376,7 @@ private:
372376 StagePtr stage_;
373377 int shadow_handle_;
374378 float shadow_size_;
379+ bool jump_end_;
375380
376381 struct {
377382 int stand_, walk_, run_;