1
This commit is contained in:
parent
3afdaf0f2f
commit
ff3e213d1b
@ -495,7 +495,8 @@ void AndroidAI::UpdatePursuit()
|
||||
paths
|
||||
);
|
||||
if (ret > 0) {
|
||||
|
||||
myself->GetMoveHelper()->ClearPath();
|
||||
myself->GetMoveHelper()->AddPaths(center, paths);
|
||||
}
|
||||
}
|
||||
#else
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "precompile.h"
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
#include "movehelper.h"
|
||||
#include "moveableentity.h"
|
||||
#include "room.h"
|
||||
@ -13,7 +15,6 @@ struct MovePathPoint
|
||||
glm::vec3 tar_pos;
|
||||
glm::vec3 curr_pos;
|
||||
glm::vec3 dir;
|
||||
long long frameno = 0;
|
||||
float distance = 0.0f;
|
||||
};
|
||||
|
||||
@ -53,7 +54,6 @@ bool MoveHelper::GetMovePosition(glm::vec3& out_pos)
|
||||
++path_index_;
|
||||
if (path_index_ < paths_.size()) {
|
||||
auto& next_point = paths_[path_index_];
|
||||
next_point->frameno = owner_->room->GetFrameNo();
|
||||
|
||||
a8::Vec2 v2;
|
||||
v2.x = next_point->tar_pos.x;
|
||||
@ -125,7 +125,6 @@ void MoveHelper::CalcTargetPos(float distance)
|
||||
point->src_pos.z = owner_->GetPos().y;
|
||||
point->curr_pos.x = owner_->GetPos().x;
|
||||
point->curr_pos.z = owner_->GetPos().y;
|
||||
point->frameno = owner_->room->GetFrameNo() - 1;
|
||||
|
||||
if (point->tar_pos.x < 0 ||
|
||||
point->tar_pos.z < 0) {
|
||||
@ -170,3 +169,41 @@ void MoveHelper::ClearPath()
|
||||
}
|
||||
paths_.clear();
|
||||
}
|
||||
|
||||
void MoveHelper::AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths)
|
||||
{
|
||||
glm::vec3 last_pos;
|
||||
last_pos.x = start.x;
|
||||
last_pos.y = start.y;
|
||||
last_pos.z = start.z;
|
||||
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
MovePathPoint* p = new MovePathPoint();
|
||||
p->src_pos = last_pos;
|
||||
|
||||
p->tar_pos.x = paths[i].x;
|
||||
p->tar_pos.y = paths[i].y;
|
||||
p->tar_pos.z = paths[i].z;
|
||||
|
||||
p->curr_pos = p->src_pos;
|
||||
|
||||
glm::vec2 src_pos;
|
||||
glm::vec2 tar_pos;
|
||||
|
||||
src_pos.x = p->src_pos.x;
|
||||
src_pos.y = p->src_pos.y;
|
||||
|
||||
tar_pos.x = p->tar_pos.x;
|
||||
tar_pos.y = p->tar_pos.y;
|
||||
|
||||
//p->distance = glm::norm(tar_pos - src_pos);
|
||||
glm::vec2 dir = tar_pos - src_pos;
|
||||
glm::normalize(dir);
|
||||
|
||||
p->dir.x = dir.x;
|
||||
p->dir.y = 0;
|
||||
p->dir.z = dir.y;
|
||||
|
||||
paths_.push_back(p);
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ class MoveHelper
|
||||
bool GetMovePosition(glm::vec3& out_pos);
|
||||
void CalcTargetPos(float distance);
|
||||
void ClearPath();
|
||||
void AddPaths(const a8::Vec3& start, std::vector<a8::Vec3>& paths);
|
||||
|
||||
private:
|
||||
std::vector<MovePathPoint*> paths_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user