1
This commit is contained in:
parent
ad13535f00
commit
f2f67c28c2
@ -296,6 +296,7 @@ int MapInstance::FindStraightPath(
|
||||
MAX_POLYS);
|
||||
glm::vec3 last_pos = start;
|
||||
UnScale(last_pos);
|
||||
int last_poly_pos = 0;
|
||||
for(int i = 0; i < nstraightPath * 3; ) {
|
||||
glm::vec3 pos;
|
||||
pos.x = straightPath[i++];
|
||||
@ -303,12 +304,6 @@ int MapInstance::FindStraightPath(
|
||||
pos.z = straightPath[i++];
|
||||
UnScale(pos);
|
||||
if (!GlmHelper::IsEqual2D(pos, last_pos)) {
|
||||
dtPolyRef poly_ref = straightPathPolys[i];
|
||||
if (i == 0) {
|
||||
if (poly_ref != polys_[0]) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
glm::vec3 dir = pos - last_pos;
|
||||
GlmHelper::Normalize(dir);
|
||||
MovePathPoint point;
|
||||
@ -319,14 +314,46 @@ int MapInstance::FindStraightPath(
|
||||
point.dir.z = dir.z;
|
||||
point.distance = GlmHelper::Norm2D(pos - last_pos);
|
||||
point.tar_pos.FromGlmVec3(pos);
|
||||
dtPolyRef poly_ref = straightPathPolys[i];
|
||||
if (i > 0 && last_poly_pos < npolys) {
|
||||
int found_pos = -1;
|
||||
bool is_same_flags = true;
|
||||
unsigned short last_flags = 0;
|
||||
for (int ii = last_poly_pos; ii < npolys; ++ii) {
|
||||
dtPolyRef curr_poly_ref = polys_[ii];
|
||||
if (curr_poly_ref != poly_ref) {
|
||||
unsigned short flags = 0;
|
||||
auto status = navmesh_->getPolyFlags(curr_poly_ref, &flags);
|
||||
if (!dtStatusSucceed(status)) {
|
||||
abort();
|
||||
}
|
||||
if (flags) {
|
||||
point.spec_polys.push_back(curr_poly_ref);
|
||||
}
|
||||
if (last_flags && last_flags != flags) {
|
||||
is_same_flags = false;
|
||||
}
|
||||
last_flags = flags;
|
||||
} else {
|
||||
found_pos = ii;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found_pos > -1) {
|
||||
last_poly_pos = found_pos;
|
||||
} else {
|
||||
#ifdef MYDEBUG
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
if (is_same_flags) {
|
||||
point.same_polys_flags = last_flags;
|
||||
}
|
||||
}
|
||||
paths.push_back(point);
|
||||
|
||||
last_pos = pos;
|
||||
}
|
||||
#if 0
|
||||
paths.push_back(currpos);
|
||||
pos++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user