int resolution; //to determine if it's changed and avoid writing public void Read(Terrain terrain, Lock lk) { TerrainData terrainData = terrain.terrainData; resolution = terrainData.heightmapResolution; circle = new CoordCircle(terrain, resolution, lk.worldPos, lk.worldRadius, lk.worldTransition); heightsArr = terrainData.GetHeights(circle.rect.offset.x, circle.rect.offset.z, circle.rect.size.x, circle.rect.size.z); }
int resolution; //to determine if it's changed and avoid writing public void Read(Terrain terrain, Lock lk) { TerrainData terrainData = terrain.terrainData; if (terrainData.terrainLayers == null || terrainData.terrainLayers.Length == 0) { lockSplats = null; lockPrototypes = null; return; } // Don't perform lock resolution = terrain.terrainData.alphamapResolution; circle = new CoordCircle(terrain, resolution, lk.worldPos, lk.worldRadius, lk.worldTransition); lockSplats = terrainData.GetAlphamaps(circle.rect.offset.x, circle.rect.offset.z, circle.rect.size.x, circle.rect.size.z); lockPrototypes = terrainData.terrainLayers; }
int resolution; //to determine if it's changed and avoid writing public void Read(Terrain terrain, Lock lk) { TerrainData terrainData = terrain.terrainData; if (terrainData.detailPrototypes == null || terrainData.detailPrototypes.Length == 0) { lockLayers = null; lockPrototypes = null; return; } // Don't perform lock if no grass prototypes resolution = terrain.terrainData.detailResolution; circle = new CoordCircle(terrain, resolution, lk.worldPos, lk.worldRadius, lk.worldTransition); lockPrototypes = terrainData.detailPrototypes; lockLayers = new int[lockPrototypes.Length][, ]; for (int i = 0; i < lockPrototypes.Length; i++) { int[,] layer = terrainData.GetDetailLayer(circle.rect.offset.x, circle.rect.offset.z, circle.rect.size.x, circle.rect.size.z, i); lockLayers[i] = layer; } patchResolution = terrainData.detailResolutionPerPatch; }