1
This commit is contained in:
parent
518a037c8b
commit
fb338ea6d6
@ -1015,6 +1015,7 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig,
|
|||||||
bary_position,
|
bary_position,
|
||||||
distance
|
distance
|
||||||
);
|
);
|
||||||
|
#if 0
|
||||||
a8::XPrintf("rayname:%s hit:%d distance:%f orig:%f,%f,%f %f,%f,%f %f,%f,%f %f,%f,%fn\n",
|
a8::XPrintf("rayname:%s hit:%d distance:%f orig:%f,%f,%f %f,%f,%f %f,%f,%f %f,%f,%fn\n",
|
||||||
{node->tri->node->name, hit, distance, orig.x, orig.y, orig.z,
|
{node->tri->node->name, hit, distance, orig.x, orig.y, orig.z,
|
||||||
|
|
||||||
@ -1031,6 +1032,7 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig,
|
|||||||
node->tri->vert2.z,
|
node->tri->vert2.z,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
node->tri->check_flag = raycast_index;
|
node->tri->check_flag = raycast_index;
|
||||||
++tri_count;
|
++tri_count;
|
||||||
if (hit && distance > 0.00001f) {
|
if (hit && distance > 0.00001f) {
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
|
||||||
|
#include <glm/gtx/intersect.hpp>
|
||||||
|
|
||||||
#include "DetourCommon.h"
|
#include "DetourCommon.h"
|
||||||
|
|
||||||
#include "mapservice.h"
|
#include "mapservice.h"
|
||||||
@ -159,11 +161,44 @@ void MapService::AddTriangle(mc::Triangle* tri)
|
|||||||
aabb_verts[10] = 0;
|
aabb_verts[10] = 0;
|
||||||
aabb_verts[11] = world_y + cell_width_;
|
aabb_verts[11] = world_y + cell_width_;
|
||||||
}
|
}
|
||||||
#if 1
|
{
|
||||||
if (true) {
|
glm::vec3 a[3 * 2];
|
||||||
#else
|
a[0] = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
glm::vec2 bary_position;
|
||||||
|
float distance;
|
||||||
|
|
||||||
|
glm::vec3 v1;
|
||||||
|
glm::vec3 v2;
|
||||||
|
glm::vec3 orig = v1;
|
||||||
|
glm::vec3 dir = v2 - v1;
|
||||||
|
GlmHelper::Normalize(dir);
|
||||||
|
float max_distance = GlmHelper::Norm(v2 - v1);
|
||||||
|
for (int i = 0; i < 2; ++i){
|
||||||
|
bool hit = glm::intersectRayTriangle
|
||||||
|
(orig,
|
||||||
|
dir,
|
||||||
|
a[i * 3 + 0],
|
||||||
|
a[i * 3 + 1],
|
||||||
|
a[i * 3 + 2],
|
||||||
|
bary_position,
|
||||||
|
distance
|
||||||
|
);
|
||||||
|
if (hit && distance > 0.00001f) {
|
||||||
|
if (distance < max_distance + 1) {
|
||||||
|
found = true;
|
||||||
|
int grid_id = x + y * map_width_;
|
||||||
|
list_head* head = &map_cells_[grid_id];
|
||||||
|
CellNode* node = new CellNode();
|
||||||
|
node->tri = tri;
|
||||||
|
list_add_tail(&node->entry, head);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if 0
|
||||||
if (dtOverlapPolyPoly2D(tri_verts, 3, aabb_verts, 4)) {
|
if (dtOverlapPolyPoly2D(tri_verts, 3, aabb_verts, 4)) {
|
||||||
#endif
|
|
||||||
int grid_id = x + y * map_width_;
|
int grid_id = x + y * map_width_;
|
||||||
list_head* head = &map_cells_[grid_id];
|
list_head* head = &map_cells_[grid_id];
|
||||||
CellNode* node = new CellNode();
|
CellNode* node = new CellNode();
|
||||||
@ -171,6 +206,7 @@ void MapService::AddTriangle(mc::Triangle* tri)
|
|||||||
list_add_tail(&node->entry, head);
|
list_add_tail(&node->entry, head);
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user