This commit is contained in:
aozhiwei 2023-03-27 18:58:17 +08:00
parent dd2da45e78
commit 7aaa8ece0e
2 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,8 @@
#include "mt/MapCollider.h"
#include "mt/MetaMgr.h"
#include "navmesh.pb.h"
std::vector<mt::MapCollider*> mt::MapCollider::raw_list;
std::map<std::string, mt::MapCollider*> mt::MapCollider::name_hash;
@ -30,6 +32,7 @@ namespace mt
for (auto& filename : files) {
MapCollider* p = new MapCollider();
p->Load(filename);
p->LoadTerrain("map4_terrain.bin");
raw_list.push_back(p);
name_hash[filename] = p;
}
@ -51,6 +54,21 @@ namespace mt
}
}
void MapCollider::LoadTerrain(const std::string& filename)
{
FILE *fp = fopen((mt::MetaMgr::Instance()->GetResDir() + filename).c_str(), "rb");
if (fp) {
fseek(fp, 0, SEEK_END);
int file_size = ftell(fp);
if (file_size > 0) {
char* data = (char*)malloc(file_size);
size_t read_len = fread(data, file_size, 1, fp);
free(data);
}
fclose(fp);
}
}
mc::ColliderNode* MapCollider::GetNode(const std::string& name)
{
auto itr = nodes_.find(name);

View File

@ -21,6 +21,7 @@ namespace mt
public:
void Load(const std::string& filename);
void LoadTerrain(const std::string& filename);
mc::ColliderNode* GetNode(const std::string& name);
std::map<std::string, mc::ColliderNode*>& GetNodes() { return nodes_; };