This commit is contained in:
aozhiwei 2023-03-27 19:13:07 +08:00
parent 7aaa8ece0e
commit 2182706b3a

View File

@ -2,6 +2,8 @@
#include <a8/xobject.h>
#include <f8/udplog.h>
#include "mt/MapCollider.h"
#include "mt/MetaMgr.h"
@ -56,17 +58,32 @@ namespace mt
void MapCollider::LoadTerrain(const std::string& filename)
{
navmesh::vertex verts_pb;
long long begin_tick = a8::XGetTickCount();
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) {
fseek(fp, 0, SEEK_SET);
char* data = (char*)malloc(file_size);
size_t read_len = fread(data, file_size, 1, fp);
bool ok = verts_pb.ParseFromArray(data, file_size);
if (!ok) {
abort();
}
free(data);
}
fclose(fp);
}
long long end_tick = a8::XGetTickCount();
f8::UdpLog::Instance()->Info("load terrain file_name:%s triangles:%d vectors:%d cost_time:%d",
{
filename,
verts_pb.triangles().size(),
verts_pb.vectors().size(),
end_tick - begin_tick
});
}
mc::ColliderNode* MapCollider::GetNode(const std::string& name)