public void Test() { var bounds = RecastBuilder.GetBoundsFromGameObject(gameObject); //bounds.Expand(2.0f); bounds = RecastBuilder.AlignBounds(bounds); bounds.Expand(new Vector3(0, 1.6f, 0)); voxel = RecastBuilder.Creat(bounds, Size); RecastBuilder.AddGameObject(voxel, gameObject); Vector3 min = voxel.Bounds.min; heightfield = RecastBuilder.VoxelToHeightfield(voxel); var bitMask = RecastBuilder.VoxelizationWalkableFilter(voxel); if (ValidPoint) { var pos = Vector3Int.CeilToInt((ValidPoint.position - min) / voxel.CellSize); Vector2Int pt = new Vector2Int(pos.x, pos.z); Vector2Int size = new Vector2Int(voxel.Size.x, voxel.Size.z); var validMask = RecastBuilder.CalcClosePoint(bitMask, size, pt); gridData = new RecastGridData { OriginPoint = new Vector3(min.x, min.z), Width = voxel.Size.x, Length = voxel.Size.z, Mask = new SerializBitArray(validMask) }; } else { gridData = RecastBuilder.VoxelizationToGrid(voxel); } }
public void Test() { var bounds = RecastBuilder.GetBoundsFromGameObject(gameObject); //bounds.Expand(2.0f); bounds = RecastBuilder.AlignBounds(bounds); bounds.Expand(new Vector3(0, 1.6f, 0)); voxel = RecastBuilder.Creat(bounds, Size); RecastBuilder.AddGameObject(voxel, gameObject); Vector3 min = voxel.Bounds.min; heightfield = RecastBuilder.VoxelToHeightfield(voxel); gridData = RecastBuilder.HeightfieldToPlaneGrid(heightfield, 0, 2); //var bitMask = RecastBuilder.VoxelizationWalkableFilter(voxel); if (ValidPoint) { var pos = Vector3Int.CeilToInt((ValidPoint.position - min) / voxel.CellSize); Vector2Int pt = new Vector2Int(pos.x, pos.z); Vector2Int size = new Vector2Int(voxel.Size.x, voxel.Size.z); gridData.Mask = RecastBuilder.CalcClosePoint(gridData.Mask, size, pt); } }
public void Clear() { voxel = null; }