2023-03-14 08:02:43 +03:00
|
|
|
/*
|
|
|
|
Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
|
|
|
|
recast4j copyright (c) 2015-2019 Piotr Piastucki piotr@jtilia.org
|
2024-05-25 16:42:57 +03:00
|
|
|
DotRecast Copyright (c) 2023-2024 Choi Ikpil ikpil@naver.com
|
2023-03-14 08:02:43 +03:00
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any damages
|
|
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
|
|
including commercial applications, and to alter it and redistribute it
|
|
|
|
freely, subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not
|
|
|
|
claim that you wrote the original software. If you use this software
|
|
|
|
in a product, an acknowledgment in the product documentation would be
|
|
|
|
appreciated but is not required.
|
|
|
|
2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
misrepresented as being the original software.
|
|
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
|
|
*/
|
|
|
|
|
|
|
|
using DotRecast.Core;
|
|
|
|
using DotRecast.Detour.TileCache.Io.Compress;
|
2023-08-19 06:48:02 +03:00
|
|
|
using DotRecast.Recast;
|
2023-03-14 08:02:43 +03:00
|
|
|
using DotRecast.Recast.Geom;
|
2023-04-25 17:22:44 +03:00
|
|
|
using NUnit.Framework;
|
2023-09-23 01:30:47 +03:00
|
|
|
|
2023-05-26 15:34:29 +03:00
|
|
|
|
2023-03-14 08:02:43 +03:00
|
|
|
namespace DotRecast.Detour.TileCache.Test;
|
|
|
|
|
2024-01-21 13:27:58 +03:00
|
|
|
|
2023-03-16 19:48:49 +03:00
|
|
|
public class AbstractTileCacheTest
|
|
|
|
{
|
2023-03-14 08:02:43 +03:00
|
|
|
private const int EXPECTED_LAYERS_PER_TILE = 4;
|
2023-10-16 17:55:34 +03:00
|
|
|
|
2023-03-14 08:02:43 +03:00
|
|
|
private readonly float m_cellSize = 0.3f;
|
|
|
|
private readonly float m_cellHeight = 0.2f;
|
|
|
|
private readonly float m_agentHeight = 2.0f;
|
|
|
|
private readonly float m_agentRadius = 0.6f;
|
|
|
|
private readonly float m_agentMaxClimb = 0.9f;
|
|
|
|
private readonly float m_edgeMaxError = 1.3f;
|
|
|
|
private readonly int m_tileSize = 48;
|
|
|
|
|
|
|
|
|
2023-06-08 16:24:34 +03:00
|
|
|
public DtTileCache GetTileCache(IInputGeomProvider geom, RcByteOrder order, bool cCompatibility)
|
2023-03-16 19:48:49 +03:00
|
|
|
{
|
2023-06-08 16:24:34 +03:00
|
|
|
DtTileCacheParams option = new DtTileCacheParams();
|
2024-05-11 19:11:03 +03:00
|
|
|
RcRecast.CalcTileCount(geom.GetMeshBoundsMin(), geom.GetMeshBoundsMax(), m_cellSize, m_tileSize, m_tileSize, out var tw, out var th);
|
2023-03-14 08:02:43 +03:00
|
|
|
option.ch = m_cellHeight;
|
|
|
|
option.cs = m_cellSize;
|
2023-05-05 02:44:48 +03:00
|
|
|
option.orig = geom.GetMeshBoundsMin();
|
2023-03-14 08:02:43 +03:00
|
|
|
option.height = m_tileSize;
|
|
|
|
option.width = m_tileSize;
|
|
|
|
option.walkableHeight = m_agentHeight;
|
|
|
|
option.walkableRadius = m_agentRadius;
|
|
|
|
option.walkableClimb = m_agentMaxClimb;
|
|
|
|
option.maxSimplificationError = m_edgeMaxError;
|
2023-06-01 16:25:15 +03:00
|
|
|
option.maxTiles = tw * th * EXPECTED_LAYERS_PER_TILE;
|
2023-03-14 08:02:43 +03:00
|
|
|
option.maxObstacles = 128;
|
2023-08-19 08:55:15 +03:00
|
|
|
|
2023-06-08 15:38:02 +03:00
|
|
|
DtNavMeshParams navMeshParams = new DtNavMeshParams();
|
2023-05-05 02:44:48 +03:00
|
|
|
navMeshParams.orig = geom.GetMeshBoundsMin();
|
2023-03-14 08:02:43 +03:00
|
|
|
navMeshParams.tileWidth = m_tileSize * m_cellSize;
|
|
|
|
navMeshParams.tileHeight = m_tileSize * m_cellSize;
|
|
|
|
navMeshParams.maxTiles = 256;
|
|
|
|
navMeshParams.maxPolys = 16384;
|
2023-08-19 08:55:15 +03:00
|
|
|
|
2024-05-12 16:05:19 +03:00
|
|
|
var navMesh = new DtNavMesh();
|
|
|
|
navMesh.Init(navMeshParams, 6);
|
2023-08-19 09:31:51 +03:00
|
|
|
var comp = DtTileCacheCompressorFactory.Shared.Create(cCompatibility ? 0 : 1);
|
2023-08-19 07:16:29 +03:00
|
|
|
var storageParams = new DtTileCacheStorageParams(order, cCompatibility);
|
2023-08-19 06:48:02 +03:00
|
|
|
var process = new TestTileCacheMeshProcess();
|
|
|
|
DtTileCache tc = new DtTileCache(option, storageParams, navMesh, comp, process);
|
2023-03-14 08:02:43 +03:00
|
|
|
return tc;
|
|
|
|
}
|
2023-06-01 16:25:15 +03:00
|
|
|
}
|