1
This commit is contained in:
parent
145caa62ee
commit
18d3b78ba6
@ -87,7 +87,7 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
if (owner_->HasBuffEffect(kBET_ThroughWall) ||
|
||||
owner_->HasBuffEffect(kBET_Fly) ||
|
||||
owner_->HasBuffEffect(kBET_Jump)) {
|
||||
point.tar_pos = end;
|
||||
point.tar_pos.FromGlmVec3(end);
|
||||
if (point.tar_pos.x > owner_->room->GetMapMeta()->pb->map_width() + 10) {
|
||||
point.tar_pos.x = owner_->room->GetMapMeta()->pb->map_width() - 10;
|
||||
}
|
||||
@ -107,15 +107,12 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
int ret = owner_->room->map_instance->Raycast(0, start, end, hit_point);
|
||||
if (ret > 0) {
|
||||
is_hit = true;
|
||||
point.tar_pos = hit_point / owner_->room->GetMapMeta()->pb->scale();
|
||||
point.tar_pos.FromGlmVec3(hit_point / owner_->room->GetMapMeta()->pb->scale());
|
||||
} else {
|
||||
point.tar_pos = end / owner_->room->GetMapMeta()->pb->scale();
|
||||
point.tar_pos.FromGlmVec3(end / owner_->room->GetMapMeta()->pb->scale());
|
||||
}
|
||||
}
|
||||
a8::Vec2 v2;
|
||||
v2.x = point.tar_pos.x;
|
||||
v2.y = point.tar_pos.z;
|
||||
point.distance = owner_->GetPos().Distance2D(v2);
|
||||
point.distance = owner_->GetPos().Distance2D2(point.tar_pos);
|
||||
point.src_pos.x = owner_->GetPos().x;
|
||||
point.src_pos.z = owner_->GetPos().y;
|
||||
point.curr_pos.x = owner_->GetPos().x;
|
||||
@ -149,17 +146,10 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
return;
|
||||
}
|
||||
|
||||
#if 1
|
||||
a8::Vec2 dir = owner_->GetPos().CalcDir2DEx(v2);
|
||||
a8::Vec2 dir = owner_->GetPos().CalcDir2D(point.tar_pos);
|
||||
dir.Normalize();
|
||||
point.dir.x = dir.x;
|
||||
point.dir.z = dir.y;
|
||||
#else
|
||||
a8::Vec2 dir = (v2 - owner_->GetPos());
|
||||
dir.Normalize();
|
||||
point.dir.x = dir.x;
|
||||
point.dir.z = dir.y;
|
||||
#endif
|
||||
|
||||
paths_.push_back(point);
|
||||
}
|
||||
@ -172,6 +162,7 @@ void MoveHelper::ClearPath()
|
||||
|
||||
void MoveHelper::AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths)
|
||||
{
|
||||
#if 0
|
||||
if (paths.empty()) {
|
||||
abort();
|
||||
return;
|
||||
@ -251,6 +242,7 @@ void MoveHelper::AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths)
|
||||
#endif
|
||||
paths_.push_back(p);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t MoveHelper::GetPathSize()
|
||||
|
@ -2,11 +2,14 @@
|
||||
|
||||
struct MovePathPoint
|
||||
{
|
||||
glm::vec3 src_pos;
|
||||
glm::vec3 tar_pos;
|
||||
glm::vec3 curr_pos;
|
||||
private:
|
||||
Position src_pos;
|
||||
Position tar_pos;
|
||||
Position curr_pos;
|
||||
glm::vec3 dir;
|
||||
float distance = 0.0f;
|
||||
|
||||
friend class MoveHelper;
|
||||
};
|
||||
|
||||
class Creature;
|
||||
|
@ -22,7 +22,7 @@ float Position::ManhattanDistance2D(const Position& target_pos)
|
||||
|
||||
a8::Vec2 Position::CalcDir2D(const Position& target_pos)
|
||||
{
|
||||
return target_pos.ToVec2() - ToVec2();
|
||||
return a8::Vec2(target_pos.x, target_pos.z) - a8::Vec2(x, z);
|
||||
}
|
||||
|
||||
a8::Vec2 Position::CalcDir2DEx(const a8::Vec2& target_pos)
|
||||
|
Loading…
x
Reference in New Issue
Block a user