1
This commit is contained in:
parent
ea39a9387b
commit
359c59f350
@ -444,10 +444,6 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
|
|||||||
const float* va = &tile->verts[poly->verts[ii] * 3];
|
const float* va = &tile->verts[poly->verts[ii] * 3];
|
||||||
dbg_data += a8::Format(" v:%d %f,%f,%f ", {ii, va[0], va[1], va[2]});
|
dbg_data += a8::Format(" v:%d %f,%f,%f ", {ii, va[0], va[1], va[2]});
|
||||||
}
|
}
|
||||||
{
|
|
||||||
const unsigned int ip = (unsigned int)(poly - tile->polys);
|
|
||||||
const dtPolyDetail* pd = &tile->detailMeshes[ip];
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
abort();
|
abort();
|
||||||
@ -465,66 +461,63 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
|
|||||||
hit_result = false;
|
hit_result = false;
|
||||||
} else {
|
} else {
|
||||||
// Hit
|
// Hit
|
||||||
/*hit_pos_[0] = spos[0] + (epos[0] - spos[0]) * t;
|
|
||||||
hit_pos_[1] = spos[1] + (epos[1] - spos[1]) * t;
|
|
||||||
hit_pos_[2] = spos[2] + (epos[2] - spos[2]) * t;*/
|
|
||||||
dtVlerp(hit_pos_, spos, epos, t);
|
dtVlerp(hit_pos_, spos, epos, t);
|
||||||
if (npolys > 0) {
|
if (npolys > 0) {
|
||||||
dtVlerp(hit_pos_, spos, epos, t - 0.01f);
|
a8::Vec2 dir(epos[0] - spos[0], epos[2] - spos[2]);
|
||||||
|
dir.Normalize();
|
||||||
float h = 0;
|
|
||||||
bool ok = false;
|
|
||||||
float hit_pos_copy[3];
|
float hit_pos_copy[3];
|
||||||
dtVcopy(hit_pos_copy, hit_pos_);
|
dtVcopy(hit_pos_copy, hit_pos_);
|
||||||
|
|
||||||
#if 0
|
float h = 0;
|
||||||
{
|
bool ok = false;
|
||||||
bool over_poly = false;
|
dir = dir / 10;
|
||||||
auto ret = navmesh_query_->closestPointOnPoly(polys_[npolys-1], hit_pos_, hit_pos_copy, &over_poly);
|
|
||||||
assert(ret == DT_SUCCESS);
|
for (int ii = npolys - 1; ii >= 0; --ii) {
|
||||||
}
|
auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h);
|
||||||
{
|
|
||||||
auto ret = navmesh_query_->getPolyHeight(polys_[npolys-1], hit_pos_copy, &h);
|
|
||||||
assert(ret == DT_SUCCESS);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
for (int i = 0; i < npolys; ++i) {
|
|
||||||
auto ret = navmesh_query_->getPolyHeight(polys_[i], hit_pos_copy, &h);
|
|
||||||
if (ret == DT_SUCCESS){
|
if (ret == DT_SUCCESS){
|
||||||
ok = true;
|
ok = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert(ok);
|
if (!ok){
|
||||||
#endif
|
ok = true;
|
||||||
hit_pos_[1] = h;
|
} else {
|
||||||
#if 0
|
for (int i = 0; i < 3; ++i) {
|
||||||
#if 1
|
hit_pos_copy[0] -= dir.x;
|
||||||
float h;
|
hit_pos_copy[2] -= dir.y;
|
||||||
Position tmp_pos;
|
for (int ii = npolys - 1; ii >= 0; --ii) {
|
||||||
tmp_pos.x = hit_pos_[0] / GetMapMeta()->pb->scale();
|
auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h);
|
||||||
tmp_pos.y = hit_pos_[1];
|
if (ret == DT_SUCCESS){
|
||||||
tmp_pos.z = hit_pos_[2] / GetMapMeta()->pb->scale();
|
ok = true;
|
||||||
GetPosHeight(tmp_pos, h);
|
break;
|
||||||
hit_pos_[1] = h;
|
}
|
||||||
#else
|
}
|
||||||
float h = 0;
|
if (ok) {
|
||||||
{
|
break;
|
||||||
float hit_pos_copy[3];
|
}
|
||||||
|
}
|
||||||
dtVcopy(hit_pos_copy, hit_pos_);
|
dtVcopy(hit_pos_copy, hit_pos_);
|
||||||
{
|
for (int i = 0; i < 3; ++i) {
|
||||||
bool over_poly = false;
|
hit_pos_copy[0] += dir.x;
|
||||||
auto ret = navmesh_query_->closestPointOnPoly(polys_[npolys-1], hit_pos_, hit_pos_copy, &over_poly);
|
hit_pos_copy[2] += dir.y;
|
||||||
assert(ret == DT_SUCCESS);
|
for (int ii = npolys - 1; ii >= 0; --ii) {
|
||||||
}
|
auto ret = navmesh_query_->getPolyHeight(polys_[ii], hit_pos_copy, &h);
|
||||||
{
|
if (ret == DT_SUCCESS){
|
||||||
auto ret = navmesh_query_->getPolyHeight(polys_[npolys-1], hit_pos_copy, &h);
|
ok = true;
|
||||||
assert(ret == DT_SUCCESS);
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ok) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assert(ok);
|
||||||
|
hit_pos_[0] = hit_pos_copy[0];
|
||||||
hit_pos_[1] = h;
|
hit_pos_[1] = h;
|
||||||
#endif
|
hit_pos_[2] = hit_pos_copy[2];
|
||||||
#endif
|
} else {
|
||||||
|
abort();
|
||||||
}
|
}
|
||||||
hit_result = true;
|
hit_result = true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user