1

I feel this may be a bug can anyone reproduce or see some error in how I am doing things.

I am trying to add GKPolygonObstacle to a GKMeshGraph in a playground for iOS or macOS.

import Cocoa
import SceneKit
import GameplayKit

let points = [float2(1,1), float2(2,1), float2(2,2), float2(1, 2)]

let obstacle = GKPolygonObstacle(points: points)

let graph = GKMeshGraph<GKGraphNode2D>(
    bufferRadius: 0,
    minCoordinate: float2(0,0),
    maxCoordinate: float2(3,3))

graph.addObstacles([obstacle])
graph.obstacles // empty, should have 1 obstacle in it!
graph.triangulate()
graph.obstacles // still empty

This does add nodes to the graph however no matter what I do I can not populate obstacles.

The Apple API seems very straightforward. Am I missing something?

Thanks

Xcode: Version 8.0 (8A218a)

Swift: Apple Swift version 3.0 (swiftlang-800.0.46.2 clang-800.0.38)

Mr Flynn
  • 415
  • 2
  • 10

1 Answers1

1

You have to set triangulationMode before adding obstacles graph.triangulationMode = [.vertices,.centers]