mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Build navmesh files to game directory
And additional compiler improvements
This commit is contained in:
parent
3cf36b5d61
commit
7cd73893f4
@ -1,8 +0,0 @@
|
||||
// Pch.cpp : source file that includes just the standard includes
|
||||
// *.pch will be the pre-compiled header
|
||||
// Pch.obj will contain the pre-compiled type information
|
||||
|
||||
#include "Pch.h"
|
||||
|
||||
// TODO: reference any additional headers you need in PCH.H
|
||||
// and not in this file
|
@ -161,7 +161,7 @@ void Sample::collectSettings(BuildSettings& settings)
|
||||
void Sample::resetCommonSettings()
|
||||
{
|
||||
m_cellSize = 15.0f;
|
||||
m_cellHeight = 5.8f;
|
||||
m_cellHeight = 5.85f;
|
||||
m_agentHeight = 2.0f;
|
||||
m_agentRadius = 0.6f;
|
||||
m_agentMaxClimb = 0.9f;
|
||||
@ -429,82 +429,6 @@ void unpatch_tiletf2(dtMeshTile* t)
|
||||
coord_tf_unfix(t->offMeshCons[i].unk);
|
||||
}
|
||||
}
|
||||
dtNavMesh* Sample::loadAll(const char* path)
|
||||
{
|
||||
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%s_%s.nm", path, m_navmesh_name);
|
||||
|
||||
FILE* fp = fopen(buffer, "rb");
|
||||
if (!fp) return 0;
|
||||
|
||||
// Read header.
|
||||
NavMeshSetHeader header;
|
||||
size_t readLen = fread(&header, sizeof(NavMeshSetHeader), 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if (header.magic != NAVMESHSET_MAGIC)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if (header.version != NAVMESHSET_VERSION)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dtNavMesh* mesh = dtAllocNavMesh();
|
||||
if (!mesh)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if(*is_tf2) patch_headertf2(header);
|
||||
dtStatus status = mesh->init(&header.params);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read tiles.
|
||||
for (int i = 0; i < header.numTiles; ++i)
|
||||
{
|
||||
NavMeshTileHeader tileHeader;
|
||||
readLen = fread(&tileHeader, sizeof(tileHeader), 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tileHeader.tileRef || !tileHeader.dataSize)
|
||||
break;
|
||||
|
||||
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
|
||||
if (!data) break;
|
||||
memset(data, 0, tileHeader.dataSize);
|
||||
readLen = fread(data, tileHeader.dataSize, 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
dtFree(data);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
dtTileRef result;
|
||||
mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, &result);
|
||||
auto tile = const_cast<dtMeshTile*>(mesh->getTileByRef(result));
|
||||
if (*is_tf2) patch_tiletf2(tile);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
struct link_table_data
|
||||
{
|
||||
//disjoint set algo from some crappy site because i'm too lazy to think
|
||||
@ -623,15 +547,97 @@ void set_reachable(std::vector<int>& data,int count, int id1, int id2, bool valu
|
||||
else
|
||||
cell = (cell & value_mask) | (1 << (id2 & 0x1f));
|
||||
}
|
||||
void Sample::saveAll(const char* path,dtNavMesh* mesh)
|
||||
|
||||
dtNavMesh* Sample::loadAll(const char* path)
|
||||
{
|
||||
|
||||
printf("%s\n", path);
|
||||
if (!mesh) return;
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%s_%s.nm", path, m_navmesh_name);
|
||||
|
||||
printf("%s\n", buffer);
|
||||
FILE* fp = fopen(buffer, "rb");
|
||||
if (!fp) return 0;
|
||||
|
||||
// Read header.
|
||||
NavMeshSetHeader header;
|
||||
size_t readLen = fread(&header, sizeof(NavMeshSetHeader), 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if (header.magic != NAVMESHSET_MAGIC)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if (header.version != NAVMESHSET_VERSION)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dtNavMesh* mesh = dtAllocNavMesh();
|
||||
if (!mesh)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
if(*is_tf2) patch_headertf2(header);
|
||||
dtStatus status = mesh->init(&header.params);
|
||||
if (dtStatusFailed(status))
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read tiles.
|
||||
for (int i = 0; i < header.numTiles; ++i)
|
||||
{
|
||||
NavMeshTileHeader tileHeader;
|
||||
readLen = fread(&tileHeader, sizeof(tileHeader), 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!tileHeader.tileRef || !tileHeader.dataSize)
|
||||
break;
|
||||
|
||||
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
|
||||
if (!data) break;
|
||||
memset(data, 0, tileHeader.dataSize);
|
||||
readLen = fread(data, tileHeader.dataSize, 1, fp);
|
||||
if (readLen != 1)
|
||||
{
|
||||
dtFree(data);
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
dtTileRef result;
|
||||
mesh->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, &result);
|
||||
auto tile = const_cast<dtMeshTile*>(mesh->getTileByRef(result));
|
||||
if (*is_tf2) patch_tiletf2(tile);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return mesh;
|
||||
}
|
||||
|
||||
void Sample::saveAll(std::string path, dtNavMesh* mesh)
|
||||
{
|
||||
if (!mesh) return;
|
||||
|
||||
std::filesystem::path p = "..\\maps\\navmesh\\";
|
||||
|
||||
if (std::filesystem::is_directory(p))
|
||||
{
|
||||
path.insert(0, p.string());
|
||||
}
|
||||
|
||||
char buffer[256];
|
||||
sprintf(buffer, "%s_%s.nm", path.c_str(), m_navmesh_name);
|
||||
|
||||
FILE* fp = fopen(buffer, "wb");
|
||||
if (!fp)
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "NavEditor/Include/InputGeom.h"
|
||||
#include "NavEditor/Include/Sample.h"
|
||||
#include "NavEditor/Include/Sample_TempObstacles.h"
|
||||
#include "thirdparty/fastlz/fastlz.h"
|
||||
|
||||
|
||||
// This value specifies how many layers (or "floors") each navmesh tile is expected to have.
|
||||
|
@ -1,47 +0,0 @@
|
||||
#ifndef DTPCH_H
|
||||
#define DTPCH_H
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
#else // Linux, BSD, OSX
|
||||
# include <dirent.h>
|
||||
# include <cstring>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
#include "thirdparty/sdl/include/SDL.h"
|
||||
#include "thirdparty/sdl/include/SDL_syswm.h"
|
||||
#include "thirdparty/sdl/include/SDL_opengl.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <OpenGL/glu.h>
|
||||
#else
|
||||
# include <GL/glu.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include "NavEditor/Include/imgui.h"
|
||||
#include "NavEditor/Include/imguiRenderGL.h"
|
||||
|
||||
#endif // DTPCH_H
|
@ -144,7 +144,7 @@ protected:
|
||||
SampleDebugDraw m_dd;
|
||||
|
||||
dtNavMesh* loadAll(const char* path);
|
||||
void saveAll(const char* path,dtNavMesh* mesh);
|
||||
void saveAll(std::string path,dtNavMesh* mesh);
|
||||
|
||||
public:
|
||||
std::string m_model_name;
|
||||
|
@ -376,6 +376,10 @@ int not_main(int argc, char** argv)
|
||||
auto_load = argv[1];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeConsole();
|
||||
}
|
||||
|
||||
float t = 0.0f;
|
||||
float timeAcc = 0.0f;
|
||||
@ -412,8 +416,8 @@ int not_main(int argc, char** argv)
|
||||
string sampleName = "Choose Sample...";
|
||||
|
||||
vector<string> files;
|
||||
const string meshesFolder = "Meshes";
|
||||
string meshName = "Choose Mesh...";
|
||||
const string meshesFolder = "Levels";
|
||||
string meshName = "Choose Level...";
|
||||
|
||||
float markerPosition[3] = {0, 0, 0};
|
||||
bool markerPositionSet = false;
|
||||
@ -835,8 +839,8 @@ int not_main(int argc, char** argv)
|
||||
imguiSeparator();
|
||||
//if (imguiCheck("Import/Export TF2", tf2_transforms, true))
|
||||
// tf2_transforms = !tf2_transforms;
|
||||
imguiLabel("Input Mesh");
|
||||
if (imguiButton("Load mesh..."))
|
||||
imguiLabel("Input Level");
|
||||
if (imguiButton("Load Level..."))
|
||||
{
|
||||
char szFile[260];
|
||||
OPENFILENAMEA diag = { 0 };
|
||||
|
9
r5dev/thirdparty/recast/Pch.cpp
vendored
9
r5dev/thirdparty/recast/Pch.cpp
vendored
@ -1 +1,8 @@
|
||||
#include "NavEditor/Include/Pch.h"
|
||||
// Pch.cpp : source file that includes just the standard includes
|
||||
// *.pch will be the pre-compiled header
|
||||
// Pch.obj will contain the pre-compiled type information
|
||||
|
||||
#include "Pch.h"
|
||||
|
||||
// TODO: reference any additional headers you need in PCH.H
|
||||
// and not in this file
|
||||
|
9
r5dev/thirdparty/recast/Pch.h
vendored
9
r5dev/thirdparty/recast/Pch.h
vendored
@ -1,3 +1,5 @@
|
||||
#ifndef DTPCH_H
|
||||
#define DTPCH_H
|
||||
|
||||
#define _USE_MATH_DEFINES
|
||||
#include <math.h>
|
||||
@ -11,7 +13,7 @@
|
||||
|
||||
#ifdef WIN32
|
||||
# include <io.h>
|
||||
#else
|
||||
#else // Linux, BSD, OSX
|
||||
# include <dirent.h>
|
||||
# include <cstring>
|
||||
#endif
|
||||
@ -24,6 +26,9 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
#include "thirdparty/fastlz/fastlz.h"
|
||||
|
||||
#include "thirdparty/sdl/include/SDL.h"
|
||||
#include "thirdparty/sdl/include/SDL_syswm.h"
|
||||
@ -41,3 +46,5 @@
|
||||
|
||||
#include "NavEditor/Include/imgui.h"
|
||||
#include "NavEditor/Include/imguiRenderGL.h"
|
||||
|
||||
#endif // DTPCH_H
|
||||
|
@ -24,7 +24,6 @@
|
||||
<ClInclude Include="..\naveditor\include\NavMeshPruneTool.h" />
|
||||
<ClInclude Include="..\naveditor\include\NavMeshTesterTool.h" />
|
||||
<ClInclude Include="..\naveditor\include\OffMeshConnectionTool.h" />
|
||||
<ClInclude Include="..\naveditor\include\Pch.h" />
|
||||
<ClInclude Include="..\naveditor\include\PerfTimer.h" />
|
||||
<ClInclude Include="..\naveditor\include\Sample.h" />
|
||||
<ClInclude Include="..\naveditor\include\SampleInterfaces.h" />
|
||||
@ -35,6 +34,7 @@
|
||||
<ClInclude Include="..\naveditor\include\TestCase.h" />
|
||||
<ClInclude Include="..\naveditor\include\ValueHistory.h" />
|
||||
<ClInclude Include="..\thirdparty\fastlz\fastlz.h" />
|
||||
<ClInclude Include="..\thirdparty\recast\Pch.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\naveditor\ChunkyTriMesh.cpp" />
|
||||
@ -51,10 +51,6 @@
|
||||
<ClCompile Include="..\naveditor\NavMeshPruneTool.cpp" />
|
||||
<ClCompile Include="..\naveditor\NavMeshTesterTool.cpp" />
|
||||
<ClCompile Include="..\naveditor\OffMeshConnectionTool.cpp" />
|
||||
<ClCompile Include="..\naveditor\Pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\naveditor\PerfTimer.cpp" />
|
||||
<ClCompile Include="..\naveditor\Sample.cpp" />
|
||||
<ClCompile Include="..\naveditor\SampleInterfaces.cpp" />
|
||||
@ -68,6 +64,10 @@
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\thirdparty\recast\Pch.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
|
@ -39,9 +39,6 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\naveditor\include\Pch.h">
|
||||
<Filter>core\include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\naveditor\include\Sample.h">
|
||||
<Filter>core\include</Filter>
|
||||
</ClInclude>
|
||||
@ -111,6 +108,9 @@
|
||||
<ClInclude Include="..\thirdparty\fastlz\fastlz.h">
|
||||
<Filter>contrib\include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\thirdparty\recast\Pch.h">
|
||||
<Filter>core\include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\thirdparty\fastlz\fastlz.c">
|
||||
@ -119,9 +119,6 @@
|
||||
<ClCompile Include="..\naveditor\main.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\naveditor\Pch.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\naveditor\Sample.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
@ -188,5 +185,8 @@
|
||||
<ClCompile Include="..\naveditor\TestCase.cpp">
|
||||
<Filter>utils</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\thirdparty\recast\Pch.cpp">
|
||||
<Filter>core</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user