/// <summary> /// Builds the entire NavMesh from the Data gathered by BuildGeometry through the Detail Mesh /// Then it creates a GameObject that has the RecastNavMesh. /// </summary> /// <returns></returns> public long BuildAllTiles(Config config, Geometry geom, int tileWidth, int tileHeight, int maxPolysPerTile, int maxTiles) { NavMesh = new Detour.NavMesh(); NavMeshParams param = new NavMeshParams() { Orig = geom.MinBounds.ToArray(), MaxPolys = maxPolysPerTile, MaxTiles = maxTiles, TileWidth = config.TileSize * config.CellSize, TileHeight = config.TileSize * config.CellSize }; NavMesh.Init(param); TileWidth = tileWidth; TileHeight = tileHeight; Config = config; Geometry = geom; Progress = 0; IsBuilding = true; Stopwatch timer = new Stopwatch(); timer.Start(); RecastVertex bmin = geom.MinBounds; RecastVertex bmax = geom.MaxBounds; float tcs = config.TileSize * config.CellSize; Total = TileWidth * TileHeight; bool canceled = false; for (int y = 0; y < TileHeight; y++) { YLoop(y, tcs, bmin, bmax); } if (!canceled) { while (Progress != Total) { canceled = EditorUtility.DisplayCancelableProgressBar("Generating...", "Generating Tile " + Progress + " of " + Total, Progress / (float)Total); if (canceled) { tokenSource.Cancel(); break; } } } Task.WaitAll(tasks.ToArray()); timer.Stop(); EditorUtility.ClearProgressBar(); IsBuilding = false; BuildGeometry(); return(timer.ElapsedMilliseconds); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void write(java.io.OutputStream stream, org.recast4j.detour.NavMeshParams params, java.nio.ByteOrder order) throws java.io.IOException public virtual void write(System.IO.Stream stream, NavMeshParams @params, ByteOrder order) { write(stream, @params.orig[0], order); write(stream, @params.orig[1], order); write(stream, @params.orig[2], order); write(stream, @params.tileWidth, order); write(stream, @params.tileHeight, order); write(stream, @params.maxTiles, order); write(stream, @params.maxPolys, order); }
public virtual NavMeshParams read(ByteBuffer bb) { NavMeshParams @params = new NavMeshParams(); @params.orig[0] = bb.Float; @params.orig[1] = bb.Float; @params.orig[2] = bb.Float; @params.tileWidth = bb.Float; @params.tileHeight = bb.Float; @params.maxTiles = bb.Int; @params.maxPolys = bb.Int; return(@params); }
private long convert32BitRef(int @ref, NavMeshParams @params) { int m_tileBits = ilog2(nextPow2(@params.maxTiles)); int m_polyBits = ilog2(nextPow2(@params.maxPolys)); // Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow. int m_saltBits = Math.Min(31, 32 - m_tileBits - m_polyBits); int saltMask = (1 << m_saltBits) - 1; int tileMask = (1 << m_tileBits) - 1; int polyMask = (1 << m_polyBits) - 1; int salt = ((@ref >> (m_polyBits + m_tileBits)) & saltMask); int it = ((@ref >> m_polyBits) & tileMask); int ip = @ref & polyMask; return(NavMesh.encodePolyId(salt, it, ip)); }
public override void Read(AssetReader reader) { base.Read(reader); NavMeshTiles = reader.ReadAssetArray <NavMeshTileData>(); if (HasNavMeshParams(reader.Version)) { NavMeshParams.Read(reader); } else { NavMeshBuildSettings.Read(reader); } Heightmaps = reader.ReadAssetArray <HeightmapData>(); HeightMeshes = reader.ReadAssetArray <HeightMeshData>(); OffMeshLinks = reader.ReadAssetArray <AutoOffMeshLinkData>(); if (HasSourceBounds(reader.Version)) { SourceBounds.Read(reader); Rotation.Read(reader); Position.Read(reader); AgentTypeID = reader.ReadInt32(); } }
public override void Read(AssetStream stream) { base.Read(stream); m_navMeshTiles = stream.ReadArray <NavMeshTileData>(); if (IsReadNavMeshParams(stream.Version)) { NavMeshParams.Read(stream); } else { NavMeshBuildSettings.Read(stream); } m_heightmaps = stream.ReadArray <HeightmapData>(); m_heightMeshes = stream.ReadArray <HeightMeshData>(); m_offMeshLinks = stream.ReadArray <AutoOffMeshLinkData>(); if (IsReadSourceBounds(stream.Version)) { SourceBounds.Read(stream); Rotation.Read(stream); Position.Read(stream); AgentTypeID = stream.ReadInt32(); } }
/// <summary> /// Builds the entire NavMesh from the Data gathered by BuildGeometry through the Detail Mesh /// Then it creates a GameObject that has the RecastNavMesh. /// </summary> /// <returns></returns> public long BuildAllTiles(Config config, Geometry geom, int tileWidth, int tileHeight, int maxPolysPerTile, int maxTiles) { NavMesh = new Detour.NavMesh(); NavMeshParams param = new NavMeshParams() { Orig = geom.MinBounds.ToArray(), MaxPolys = maxPolysPerTile, MaxTiles = maxTiles, TileWidth = config.TileSize*config.CellSize, TileHeight = config.TileSize*config.CellSize }; NavMesh.Init(param); TileWidth = tileWidth; TileHeight = tileHeight; Config = config; Geometry = geom; Progress = 0; IsBuilding = true; Stopwatch timer = new Stopwatch(); timer.Start(); RecastVertex bmin = geom.MinBounds; RecastVertex bmax = geom.MaxBounds; float tcs = config.TileSize * config.CellSize; Total = TileWidth * TileHeight; bool canceled = false; for (int y = 0; y < TileHeight; y++) { YLoop(y, tcs, bmin, bmax); } #if UNITY_EDITOR if (!canceled) { while (Progress != Total) { canceled = EditorUtility.DisplayCancelableProgressBar("Generating...", "Generating Tile " + Progress + " of " + Total, Progress/(float) Total); if (canceled) { tokenSource.Cancel(); break; } } } Task.WaitAll(tasks.ToArray()); timer.Stop(); EditorUtility.ClearProgressBar(); #endif IsBuilding = false; BuildGeometry(); return timer.ElapsedMilliseconds; }