1
This commit is contained in:
parent
82a6b4ef01
commit
d77f09f2f0
@ -468,14 +468,14 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
|
|||||||
// Hit
|
// Hit
|
||||||
dtVlerp(hit_pos_, spos, epos, t);
|
dtVlerp(hit_pos_, spos, epos, t);
|
||||||
if (npolys > 0) {
|
if (npolys > 0) {
|
||||||
a8::Vec2 dir(epos[0] - spos[0], epos[2] - spos[2]);
|
glm::vec3 dir(epos[0] - spos[0], epos[1] - spos[1], epos[2] - spos[2]);
|
||||||
dir.Normalize();
|
GlmHelper::Normalize(dir);
|
||||||
float hit_pos_copy[3];
|
float hit_pos_copy[3];
|
||||||
dtVcopy(hit_pos_copy, hit_pos_);
|
dtVcopy(hit_pos_copy, hit_pos_);
|
||||||
|
|
||||||
float h = 0;
|
float h = 0;
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
dir = dir / 10;
|
Scale(dir);
|
||||||
|
|
||||||
for (int ii = npolys - 1; ii >= 0; --ii) {
|
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_[ii], hit_pos_copy, &h);
|
||||||
@ -489,7 +489,7 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
|
|||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
hit_pos_copy[0] -= dir.x;
|
hit_pos_copy[0] -= dir.x;
|
||||||
hit_pos_copy[2] -= dir.y;
|
hit_pos_copy[2] -= dir.z;
|
||||||
for (int ii = npolys - 1; ii >= 0; --ii) {
|
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_[ii], hit_pos_copy, &h);
|
||||||
if (ret == DT_SUCCESS){
|
if (ret == DT_SUCCESS){
|
||||||
@ -504,7 +504,7 @@ bool MapInstance::Raycast(int layer, const glm::vec3& start, const glm::vec3& en
|
|||||||
dtVcopy(hit_pos_copy, hit_pos_);
|
dtVcopy(hit_pos_copy, hit_pos_);
|
||||||
for (int i = 0; i < 3; ++i) {
|
for (int i = 0; i < 3; ++i) {
|
||||||
hit_pos_copy[0] += dir.x;
|
hit_pos_copy[0] += dir.x;
|
||||||
hit_pos_copy[2] += dir.y;
|
hit_pos_copy[2] += dir.z;
|
||||||
for (int ii = npolys - 1; ii >= 0; --ii) {
|
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_[ii], hit_pos_copy, &h);
|
||||||
if (ret == DT_SUCCESS){
|
if (ret == DT_SUCCESS){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user