game2006/server/gameserver/mapservice.h
aozhiwei 3d9d01a0f1 1
2023-11-04 21:40:27 +08:00

42 lines
794 B
C++

#pragma once
class Human;
namespace mc
{
struct Triangle;
}
struct CellNode
{
list_head entry;
mc::Triangle* tri = nullptr;
std::shared_ptr<CellNode> holder;
};
class Room;
class MapService
{
public:
MapService();
~MapService();
void Init(int width, int height, int cell_width);
void UnInit();
bool CanAdd(const glm::vec3& pos, int rad);
void AddTriangle(mc::Triangle* tri);
int GetGridId(float world_x, float world_y);
void GetGridList(int grid_id, list_head* grid_list[9], int& grid_count);
bool TriIntersect(glm::vec3 t1[3], glm::vec3 t2[3]);
private:
std::vector<list_head> map_cells_;
int map_width_ = 0;
int map_height_ = 0;
int cell_width_ = 0;
int max_grid_id_ = 0;
int grid_offset_arr_[9] = {0};
};