diff --git a/server/gameserver/mapcollider.cc b/server/gameserver/mapcollider.cc index c50be614..d9b24012 100644 --- a/server/gameserver/mapcollider.cc +++ b/server/gameserver/mapcollider.cc @@ -155,8 +155,19 @@ namespace mc dirs.push_back(glm::vec3(-extends.x, -extends.y, -extends.z)); dirs.push_back(glm::vec3(-extends.x, -extends.y, extends.z)); for (const glm::vec3& dir : dirs) { - points.push_back(center + dir); + points.push_back(center + quat * dir); } } + std::string ColliderNode::GetPath() + { + std::string path = name; + ColliderNode* node = this; + while (node && node->parent) { + path = node->parent->name + "/" + path; + node = node->parent; + } + return path; + } + } diff --git a/server/gameserver/mapcollider.h b/server/gameserver/mapcollider.h index 699c8862..45b93c2b 100644 --- a/server/gameserver/mapcollider.h +++ b/server/gameserver/mapcollider.h @@ -104,6 +104,7 @@ namespace mc std::map childs; void Read(std::shared_ptr xobj); + std::string GetPath(); }; void RotateBounds(const glm::vec3& center, diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 824fdabf..9d13d4e6 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -1079,10 +1079,10 @@ bool MapInstance::SceneRaycast(const glm::vec3& orig, } while (!end); if (result) { -#ifdef DEBUG1 +#ifdef DEBUG if (DebugCmd::Enable()) { a8::XPrintf("nearest_node:%s tri_count:%d nearest_distance:%f\n", - {nearest_node->tri->node->name, + {nearest_node->tri->node->GetPath(), tri_count, nearest_distance}); } diff --git a/server/gameserver/mapservice.cc b/server/gameserver/mapservice.cc index 4caf99a7..78f94abe 100644 --- a/server/gameserver/mapservice.cc +++ b/server/gameserver/mapservice.cc @@ -83,6 +83,11 @@ bool MapService::CanAdd(const glm::vec3& pos, int rad) void MapService::AddTriangle(mc::Triangle* tri) { + #if 0 + if (tri->node->name == "water03") { + return; + } + #endif glm::vec3* verts[3] = {&tri->vert0, &tri->vert1, &tri->vert2}; float min_x = verts[0]->x; float max_x = verts[0]->x; @@ -107,6 +112,9 @@ void MapService::AddTriangle(mc::Triangle* tri) max_x += 1.0f; min_y -= 1.0f; max_y += 1.0f; + + min_x = std::max(min_x, 0.0f); + min_y = std::max(min_y, 0.0f); } { @@ -114,22 +122,81 @@ void MapService::AddTriangle(mc::Triangle* tri) int min_grid_y = floor(min_y / cell_width_); int max_grid_x = ceil(max_x / cell_width_); int max_grid_y = ceil(max_y / cell_width_); + #if 1 if (min_grid_x < 0) { + a8::XPrintf("error1 name:%s tri:%f,%f,%f %f,%f,%f\n", + { + tri->node->GetPath(), + tri->vert0.x, + tri->vert0.y, + tri->vert0.z, + + tri->vert1.x, + tri->vert1.y, + tri->vert1.z, + + tri->vert2.x, + tri->vert2.y, + tri->vert2.z, + } + ); + return; min_grid_x = 0; } + #endif if (min_grid_x < 0) { A8_ABORT(); } if (max_grid_x >= map_width_) { + #if 1 + a8::XPrintf("error4 name:%s tri:%f,%f,%f %f,%f,%f\n", + { + tri->node->GetPath(), + tri->vert0.x, + tri->vert0.y, + tri->vert0.z, + + tri->vert1.x, + tri->vert1.y, + tri->vert1.z, + + tri->vert2.x, + tri->vert2.y, + tri->vert2.z, + } + ); + #endif + return; + A8_ABORT(); max_grid_x = map_width_ - 1; } + #if 1 if (min_grid_y < 0) { + a8::XPrintf("error2 name:%s tri:%f,%f,%f %f,%f,%f\n", + { + tri->node->GetPath(), + tri->vert0.x, + tri->vert0.y, + tri->vert0.z, + + tri->vert1.x, + tri->vert1.y, + tri->vert1.z, + + tri->vert2.x, + tri->vert2.y, + tri->vert2.z, + } + ); + return; min_grid_y = 0; } + #endif if (min_grid_y < 0) { - A8_ABORT(); + //A8_ABORT(); } if (max_grid_y >= map_height_) { + A8_ABORT(); max_grid_y = map_height_ - 1; } float tri_verts[3 * 3]; @@ -190,7 +257,7 @@ void MapService::AddTriangle(mc::Triangle* tri) found = true; } } -#if 0 +#if 1 if (dtOverlapPolyPoly2D(tri_verts, 3, aabb_verts, 4)) { int grid_id = x + y * map_width_; list_head* head = &map_cells_[grid_id]; @@ -202,9 +269,28 @@ void MapService::AddTriangle(mc::Triangle* tri) #endif } } - #if 0 + #if 1 if (!found) { + a8::XPrintf("error3 name:%s tri:%f,%f,%f %f,%f,%f\n", + { + tri->node->GetPath(), + tri->vert0.x, + tri->vert0.y, + tri->vert0.z, + + tri->vert1.x, + tri->vert1.y, + tri->vert1.z, + + tri->vert2.x, + tri->vert2.y, + tri->vert2.z, + } + ); + #if 0 + AddTriangle(tri); abort(); + #endif } #endif }