public float GetGroundHeight(Vector3 scene) { Vector3 voxSpace = FromSceneSpace(scene); int x = (int)voxSpace.x; int y = (int)voxSpace.y; int z = (int)voxSpace.z; for (int h = y; h >= 0; h--) { Voxel v = GetVoxel(x, h, z); if ((v.Active && v.Collider()) || v.Type == VoxelType.Water) { if (v.Type == VoxelType.Water) { for (int wh = h; wh < Chunk.Y_SIZE; wh++) { Voxel v2 = GetVoxel(x, wh, z); if (!v2.Active) { y = wh - 3; break; } } } else { y = h; } break; } } return(y * Voxel.SIZE); }