1
This commit is contained in:
parent
79279cc2fb
commit
b4fd0bb29c
@ -83,7 +83,7 @@ bool Movement::UpdatePosition()
|
||||
void Movement::CalcTargetPos(float distance)
|
||||
{
|
||||
ClearPath();
|
||||
#ifdef MYDEBUG1
|
||||
#ifdef MYDEBUG
|
||||
if (owner_->IsPlayer()) {
|
||||
a8::XPrintf("CalcTaretPos old_size:%d distance:%f\n", {paths_.size(), distance});
|
||||
}
|
||||
@ -294,7 +294,7 @@ void Movement::AdjustLastPath(float distance)
|
||||
bool Movement::MoveToPos(const glm::vec3& target_pos)
|
||||
{
|
||||
ClearPath();
|
||||
#ifdef MYDEBUG
|
||||
#ifdef MYDEBUG1
|
||||
a8::XPrintf("MoveToTarget curr_pos:%f %f %f target_pos:%f %f %f\n",
|
||||
{
|
||||
owner_->GetPos().GetX(),
|
||||
@ -368,7 +368,7 @@ bool Movement::MoveToPos(const glm::vec3& target_pos)
|
||||
point.tar_pos.GetZ() < 0) {
|
||||
abort();
|
||||
}
|
||||
#ifdef MYDEBUG
|
||||
#ifdef MYDEBUG1
|
||||
{
|
||||
a8::XPrintf("MoveTotarget src_pos:%f,%f,%f tar_pos:%f,%f,%f is_hit:%d start:%f,%f,%f end:%f,%f,%f distance:%f \n",
|
||||
{
|
||||
@ -393,18 +393,47 @@ bool Movement::MoveToPos(const glm::vec3& target_pos)
|
||||
#endif
|
||||
|
||||
const float safe_distance = 2.0f;
|
||||
#if 1
|
||||
if (point.distance < safe_distance + 1.0f / owner_->room->GetMapMeta()->scale()) {
|
||||
}
|
||||
#else
|
||||
if (point.distance < safe_distance + 1.0f / owner_->room->GetMapMeta()->scale()) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
glm::vec3 dir = point.tar_pos.ToGlmVec3() - owner_->GetPos().ToGlmVec3();
|
||||
GlmHelper::Normalize(dir);
|
||||
point.dir.x = dir.x;
|
||||
point.dir.y = dir.y;
|
||||
point.dir.z = dir.z;
|
||||
point.distance -= safe_distance;
|
||||
//point.distance -= safe_distance;
|
||||
point.tar_pos.FromGlmVec3(owner_->GetPos().ToGlmVec3() + point.dir * point.distance);
|
||||
|
||||
#ifdef MYDEBUG1
|
||||
{
|
||||
a8::XPrintf("MoveTotarget2 src_pos:%f,%f,%f tar_pos:%f,%f,%f is_hit:%d start:%f,%f,%f end:%f,%f,%f distance:%f \n",
|
||||
{
|
||||
point.src_pos.GetX(),
|
||||
point.src_pos.GetY(),
|
||||
point.src_pos.GetZ(),
|
||||
point.tar_pos.GetX(),
|
||||
point.tar_pos.GetY(),
|
||||
point.tar_pos.GetZ(),
|
||||
hit_result ? 1 : 0,
|
||||
|
||||
start.x,
|
||||
start.y,
|
||||
start.z,
|
||||
|
||||
end.x,
|
||||
end.y,
|
||||
end.z,
|
||||
point.distance,
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
||||
paths_.push_back(point);
|
||||
return true;
|
||||
}
|
||||
|
@ -229,15 +229,17 @@ void Player::InternalUpdate(int delta_time)
|
||||
moving = false;
|
||||
}
|
||||
}
|
||||
#if 1
|
||||
if (GetMovement()->GetPathSize() > 0) {
|
||||
moving = true;
|
||||
if (is_client_move) {
|
||||
if (GetMovement()->GetPathSize() > 0) {
|
||||
moving = true;
|
||||
} else {
|
||||
moving = false;
|
||||
}
|
||||
} else {
|
||||
if (GetMovement()->IsFindPath()) {
|
||||
moving = true;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (GetMovement()->IsFindPath()) {
|
||||
moving = true;
|
||||
}
|
||||
#endif
|
||||
#if 1
|
||||
if (moving) {
|
||||
UpdateMoving();
|
||||
@ -1026,11 +1028,14 @@ void Player::_CMMove(f8::MsgHdr* hdr, const cs::CMMove& msg)
|
||||
if (GetPos().Distance2D2(tmp_pos) < 200) {
|
||||
if (!GetMovement()->MoveToPos(tmp_pos)) {
|
||||
#ifdef MYDEBUG
|
||||
a8::XPrintf("pullback target_pos:%f,%f,%f\n",
|
||||
a8::XPrintf("pullback target_pos:%f,%f,%f last_target_pos:%f,%f,%f\n",
|
||||
{
|
||||
tmp_pos.x,
|
||||
tmp_pos.y,
|
||||
tmp_pos.z
|
||||
tmp_pos.z,
|
||||
move_target_pos_.x,
|
||||
move_target_pos_.y,
|
||||
move_target_pos_.z,
|
||||
});
|
||||
#endif
|
||||
SyncServerPos(0);
|
||||
@ -1039,11 +1044,14 @@ void Player::_CMMove(f8::MsgHdr* hdr, const cs::CMMove& msg)
|
||||
}
|
||||
} else {
|
||||
#ifdef MYDEBUG
|
||||
a8::XPrintf("pullback target_pos:%f,%f,%f\n",
|
||||
a8::XPrintf("pullback target_pos:%f,%f,%f last_target_pos:%f,%f,%f\n",
|
||||
{
|
||||
tmp_pos.x,
|
||||
tmp_pos.y,
|
||||
tmp_pos.z
|
||||
tmp_pos.z,
|
||||
move_target_pos_.x,
|
||||
move_target_pos_.y,
|
||||
move_target_pos_.z,
|
||||
});
|
||||
#endif
|
||||
SyncServerPos(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user