Skip to content

Commit

Permalink
rename _ComponentContentBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
carson-katri committed Jul 25, 2024
1 parent c0cd451 commit 579423d
Showing 1 changed file with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,19 @@ extension Entity {
}

if element.attributeBoolean(for: "generateCollisionShapes") {
self.generateCollisionShapes(
recursive: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "recursive")),
static: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "static"))
)
if element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "convex")) {
// convex mesh collision shapes
self.generateConvexCollisionShapes(
recursive: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "recursive")),
static: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "static"))
)
} else {
// simple box collision shapes
self.generateCollisionShapes(
recursive: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "recursive")),
static: element.attributeBoolean(for: .init(namespace: "generateCollisionShapes", name: "static"))
)
}
}
}

Expand Down Expand Up @@ -245,3 +254,19 @@ extension Entity {
}
}
}

extension Entity {
func generateConvexCollisionShapes(
recursive: Bool,
static isStatic: Bool
) {
if let mesh = self.components[ModelComponent.self]?.mesh {
self.components.set(CollisionComponent(shapes: [.generateConvex(from: mesh)], isStatic: isStatic))
}
if recursive {
for child in children {
child.generateConvexCollisionShapes(recursive: recursive, static: isStatic)
}
}
}
}

0 comments on commit 579423d

Please sign in to comment.