public ObiHeightFieldHandle GetOrCreateHeightField(TerrainData source) { ObiHeightFieldHandle handle; if (!handles.TryGetValue(source, out handle)) { // Get the heighfield into a 1d array: int width = source.heightmapResolution; int height = source.heightmapResolution; float[,] heights = source.GetHeights(0, 0, width, height); float[] buffer = new float[width * height]; for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { buffer[y * width + x] = heights[y, x]; } } handle = new ObiHeightFieldHandle(source, headers.count); handles.Add(source, handle); headers.Add(new HeightFieldHeader(samples.count, buffer.Length)); samples.AddRange(buffer); } return(handle); }
public void AddConstraint(int[] indices, bool isExplicit) { RegisterConstraint(); firstIndex.Add((int)particleIndices.count); numIndices.Add((int)indices.Length); explicitGroup.Add(isExplicit ? 1 : 0); particleIndices.AddRange(indices); materialParameters.AddRange(new float[] { 1, 1, 1, 1, 1 }); }