From 67cbf7ffd15512e913a0769ae5fbb5bb236c7546 Mon Sep 17 00:00:00 2001 From: ikpil Date: Sat, 29 Apr 2023 19:32:20 +0900 Subject: [PATCH] copy -> operator= --- .../Tools/CrowdProfilingTool.cs | 2 +- src/DotRecast.Recast/RecastBuilderConfig.cs | 4 ++-- src/DotRecast.Recast/RecastCompact.cs | 4 ++-- src/DotRecast.Recast/RecastContour.cs | 4 ++-- src/DotRecast.Recast/RecastLayers.cs | 10 ++++----- src/DotRecast.Recast/RecastMesh.cs | 12 +++++----- src/DotRecast.Recast/RecastVectors.cs | 22 ------------------- .../TestTiledNavMeshBuilder.cs | 2 +- .../AbstractTileCacheTest.cs | 2 +- 9 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs index a5f66ec..8adaade 100644 --- a/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs +++ b/src/DotRecast.Recast.Demo/Tools/CrowdProfilingTool.cs @@ -426,7 +426,7 @@ public class CrowdProfilingTool public AgentData(AgentType type, Vector3f home) { this.type = type; - RecastVectors.copy(ref this.home, home); + this.home = home; } } diff --git a/src/DotRecast.Recast/RecastBuilderConfig.cs b/src/DotRecast.Recast/RecastBuilderConfig.cs index 9470382..58949ec 100644 --- a/src/DotRecast.Recast/RecastBuilderConfig.cs +++ b/src/DotRecast.Recast/RecastBuilderConfig.cs @@ -52,8 +52,8 @@ namespace DotRecast.Recast this.tileX = tileX; this.tileZ = tileZ; this.cfg = cfg; - copy(ref this.bmin, bmin); - copy(ref this.bmax, bmax); + this.bmin = bmin; + this.bmax = bmax; if (cfg.useTiles) { float tsx = cfg.tileSizeX * cfg.cs; diff --git a/src/DotRecast.Recast/RecastCompact.cs b/src/DotRecast.Recast/RecastCompact.cs index cd46f80..d41587f 100644 --- a/src/DotRecast.Recast/RecastCompact.cs +++ b/src/DotRecast.Recast/RecastCompact.cs @@ -56,8 +56,8 @@ namespace DotRecast.Recast chf.walkableHeight = walkableHeight; chf.walkableClimb = walkableClimb; chf.maxRegions = 0; - copy(ref chf.bmin, hf.bmin); - copy(ref chf.bmax, hf.bmax); + chf.bmin = hf.bmin; + chf.bmax = hf.bmax; chf.bmax.y += walkableHeight * hf.ch; chf.cs = hf.cs; chf.ch = hf.ch; diff --git a/src/DotRecast.Recast/RecastContour.cs b/src/DotRecast.Recast/RecastContour.cs index 2f2e298..e89ec3a 100644 --- a/src/DotRecast.Recast/RecastContour.cs +++ b/src/DotRecast.Recast/RecastContour.cs @@ -780,8 +780,8 @@ namespace DotRecast.Recast ContourSet cset = new ContourSet(); ctx.startTimer("CONTOURS"); - RecastVectors.copy(ref cset.bmin, chf.bmin, 0); - RecastVectors.copy(ref cset.bmax, chf.bmax, 0); + cset.bmin = chf.bmin; + cset.bmax = chf.bmax; if (borderSize > 0) { // If the heightfield was build with bordersize, remove the offset. diff --git a/src/DotRecast.Recast/RecastLayers.cs b/src/DotRecast.Recast/RecastLayers.cs index 863ae95..08ce79e 100644 --- a/src/DotRecast.Recast/RecastLayers.cs +++ b/src/DotRecast.Recast/RecastLayers.cs @@ -428,10 +428,8 @@ namespace DotRecast.Recast int lh = h - borderSize * 2; // Build contracted bbox for layers. - Vector3f bmin = new Vector3f(); - Vector3f bmax = new Vector3f(); - copy(ref bmin, chf.bmin); - copy(ref bmax, chf.bmax); + Vector3f bmin = chf.bmin; + Vector3f bmax = chf.bmax; bmin.x += borderSize * chf.cs; bmin.z += borderSize * chf.cs; bmax.x -= borderSize * chf.cs; @@ -475,8 +473,8 @@ namespace DotRecast.Recast layer.ch = chf.ch; // Adjust the bbox to fit the heightfield. - copy(ref layer.bmin, bmin); - copy(ref layer.bmax, bmax); + layer.bmin = bmin; + layer.bmax = bmax; layer.bmin.y = bmin.y + hmin * chf.ch; layer.bmax.y = bmin.y + hmax * chf.ch; layer.hmin = hmin; diff --git a/src/DotRecast.Recast/RecastMesh.cs b/src/DotRecast.Recast/RecastMesh.cs index ef5bff8..59345f6 100644 --- a/src/DotRecast.Recast/RecastMesh.cs +++ b/src/DotRecast.Recast/RecastMesh.cs @@ -976,8 +976,8 @@ namespace DotRecast.Recast { ctx.startTimer("POLYMESH"); PolyMesh mesh = new PolyMesh(); - RecastVectors.copy(ref mesh.bmin, cset.bmin, 0); - RecastVectors.copy(ref mesh.bmax, cset.bmax, 0); + mesh.bmin = cset.bmin; + mesh.bmax = cset.bmax; mesh.cs = cset.cs; mesh.ch = cset.ch; mesh.borderSize = cset.borderSize; @@ -1231,8 +1231,8 @@ namespace DotRecast.Recast mesh.nvp = meshes[0].nvp; mesh.cs = meshes[0].cs; mesh.ch = meshes[0].ch; - RecastVectors.copy(ref mesh.bmin, meshes[0].bmin, 0); - RecastVectors.copy(ref mesh.bmax, meshes[0].bmax, 0); + mesh.bmin = meshes[0].bmin; + mesh.bmax = meshes[0].bmax; int maxVerts = 0; int maxPolys = 0; @@ -1361,8 +1361,8 @@ namespace DotRecast.Recast dst.npolys = src.npolys; dst.maxpolys = src.npolys; dst.nvp = src.nvp; - RecastVectors.copy(ref dst.bmin, src.bmin, 0); - RecastVectors.copy(ref dst.bmax, src.bmax, 0); + dst.bmin = src.bmin; + dst.bmax = src.bmax; dst.cs = src.cs; dst.ch = src.ch; dst.borderSize = src.borderSize; diff --git a/src/DotRecast.Recast/RecastVectors.cs b/src/DotRecast.Recast/RecastVectors.cs index 1f714bb..d0f1302 100644 --- a/src/DotRecast.Recast/RecastVectors.cs +++ b/src/DotRecast.Recast/RecastVectors.cs @@ -58,18 +58,6 @@ namespace DotRecast.Recast copy(ref @out, 0, @in, i); } - public static void copy(ref Vector3f @out, Vector3f @in, int i) - { - copy(ref @out, 0, @in, i); - } - - - public static void copy(ref Vector3f @out, Vector3f @in) - { - @out = @in; - } - - public static void copy(float[] @out, int n, float[] @in, int m) { @out[n] = @in[m]; @@ -84,8 +72,6 @@ namespace DotRecast.Recast @out[n + 2] = @in[m + 2]; } - - public static void copy(ref Vector3f @out, int n, float[] @in, int m) { @out[n] = @in[m]; @@ -93,14 +79,6 @@ namespace DotRecast.Recast @out[n + 2] = @in[m + 2]; } - public static void copy(ref Vector3f @out, int n, Vector3f @in, int m) - { - @out[n] = @in[m]; - @out[n + 1] = @in[m + 1]; - @out[n + 2] = @in[m + 2]; - } - - public static void add(ref Vector3f e0, Vector3f a, float[] verts, int i) { e0.x = a.x + verts[i]; diff --git a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs index 9cd8b45..3e0b983 100644 --- a/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs +++ b/test/DotRecast.Detour.Test/TestTiledNavMeshBuilder.cs @@ -59,7 +59,7 @@ public class TestTiledNavMeshBuilder { // Create empty nav mesh NavMeshParams navMeshParams = new NavMeshParams(); - copy(ref navMeshParams.orig, m_geom.getMeshBoundsMin()); + navMeshParams.orig = m_geom.getMeshBoundsMin(); navMeshParams.tileWidth = m_tileSize * m_cellSize; navMeshParams.tileHeight = m_tileSize * m_cellSize; navMeshParams.maxTiles = 128; diff --git a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs index 19694c2..2d12edb 100644 --- a/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs +++ b/test/DotRecast.Detour.TileCache.Test/AbstractTileCacheTest.cs @@ -66,7 +66,7 @@ public class AbstractTileCacheTest option.maxTiles = twh[0] * twh[1] * EXPECTED_LAYERS_PER_TILE; option.maxObstacles = 128; NavMeshParams navMeshParams = new NavMeshParams(); - copy(ref navMeshParams.orig, geom.getMeshBoundsMin()); + navMeshParams.orig = geom.getMeshBoundsMin(); navMeshParams.tileWidth = m_tileSize * m_cellSize; navMeshParams.tileHeight = m_tileSize * m_cellSize; navMeshParams.maxTiles = 256;