地形ok
This commit is contained in:
parent
3683a0a00d
commit
dc269b189a
@ -1418,9 +1418,9 @@ void Creature::CheckSpecObject(int new_poly_flags)
|
||||
if (!a8::SameBitFlag(poly_ext_flags_, new_poly_flags, i)) {
|
||||
if ((1 << i) == SAMPLE_POLYFLAGS_SWIM) {
|
||||
if (a8::HasBitFlag(poly_ext_flags_, i)) {
|
||||
TryAddBuff(this, kInWater1BuffId);
|
||||
} else {
|
||||
RemoveBuffByEffectId(kBET_InWater);
|
||||
} else {
|
||||
TryAddBuff(this, kInWater1BuffId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -669,12 +669,12 @@ bool MapInstance::RaycastEx(const glm::vec3& start, const glm::vec3& end,
|
||||
abort();
|
||||
}
|
||||
if (flags) {
|
||||
if (last_flags && last_flags != flags) {
|
||||
is_same_flags = false;
|
||||
}
|
||||
last_flags = flags;
|
||||
spec_polys.push_back(flags);
|
||||
spec_polys.push_back(polys_[i]);
|
||||
}
|
||||
if (last_flags && last_flags != flags) {
|
||||
is_same_flags = false;
|
||||
}
|
||||
last_flags = flags;
|
||||
}
|
||||
if (is_same_flags) {
|
||||
same_polys_flags = last_flags;
|
||||
@ -697,22 +697,27 @@ void MapInstance::CheckTerrain(Creature* c, int same_poly_flags, const std::vect
|
||||
c->CheckSpecObject(0);
|
||||
} else {
|
||||
float pos[3];
|
||||
pos[0] = c->GetPos().x;
|
||||
pos[0] = c->GetPos().x * GetMapMeta()->scale();
|
||||
pos[1] = c->GetPos().y;
|
||||
pos[2] = c->GetPos().z;
|
||||
pos[2] = c->GetPos().z * GetMapMeta()->scale();
|
||||
float closest[3];
|
||||
bool found = false;
|
||||
for (auto& poly_ref : spec_polys) {
|
||||
dtStatus status = navmesh_query_->closestPointOnPolyBoundary(poly_ref, pos, closest);
|
||||
if (dtStatusSucceed(status) &&
|
||||
std::fabs(closest[0] - c->GetPos().x) <= 0.3f &&
|
||||
std::fabs(closest[2] - c->GetPos().z) <= 0.3f) {
|
||||
std::fabs(closest[0] - c->GetPos().x * GetMapMeta()->scale()) <= 0.1f &&
|
||||
std::fabs(closest[2] - c->GetPos().z * GetMapMeta()->scale()) <= 0.1f) {
|
||||
unsigned short flags = 0;
|
||||
if (dtStatusSucceed(navmesh_->getPolyFlags(poly_ref, &flags))) {
|
||||
c->CheckSpecObject(flags);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
c->CheckSpecObject(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user