Skip to content

Commit eec94de

Browse files
committed
Continue enhancing functionality
1 parent 90ef083 commit eec94de

File tree

13 files changed

+390
-145
lines changed

13 files changed

+390
-145
lines changed

Sources/GameMath/2D Types (New)/Rect2n.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,18 @@ extension Rect2n {
102102

103103
extension Rect2n where Scalar: Comparable {
104104
/// `true` if `rhs` is inside `self`
105-
public func contains(_ rhs: Position2n<Scalar>, withThreshold threshold: Scalar = 0) -> Bool {
105+
public func contains(_ rhs: Position2n<Scalar>) -> Bool {
106+
let min = self.min
107+
guard rhs.x >= min.x && rhs.y >= min.y else {return false}
108+
109+
let max = self.max
110+
guard rhs.x < max.x && rhs.y < max.y else {return false}
111+
112+
return true
113+
}
114+
115+
/// `true` if `rhs` is inside `self`
116+
public func contains(_ rhs: Position2n<Scalar>, withThreshold threshold: Scalar) -> Bool {
106117
let min = self.min - threshold
107118
guard rhs.x >= min.x && rhs.y >= min.y else {return false}
108119

Sources/GameMath/2D Types (New)/Triangle2n.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public struct Triangle2n<Scalar: Vector2n.ScalarType & FloatingPoint> {
3030
}
3131

3232
public extension Triangle2n where Scalar: ExpressibleByFloatLiteral {
33+
@inlinable
3334
var center: Position2n<Scalar> {
3435
return Position2n<Scalar>(x: (p1.x + p2.x + p3.x) / 3.0, y: (p1.y + p2.y + p3.y) / 3.0)
3536
}
@@ -63,6 +64,7 @@ public extension Triangle2n {
6364
- parameter position: A point in space to use as an reference
6465
- returns: The point on the triangle's surface that is nearest to `p`
6566
*/
67+
@inlinable
6668
func nearestSurfacePosition(to position: Position2n<Scalar>) -> Position2n<Scalar> where Scalar: ExpressibleByFloatLiteral {
6769
let a = self.p1
6870
let b = self.p2

Sources/GateEngine/ECS/2D Specific/TileMap/TileMapSystem.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public final class TileMapSystem: System {
113113
if triangles.isEmpty {
114114
layer.geometry.rawGeometry = nil
115115
}else{
116-
layer.geometry.rawGeometry = RawGeometry(triangles: triangles)
116+
layer.geometry.rawGeometry = RawGeometry(triangles)
117117
}
118118
}
119119
}

Sources/GateEngine/Resources/Geometry/Geometry.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public extension Geometry {
3535
tangents: nil,
3636
colors: nil,
3737
indexes: indices
38-
).optimized()
38+
).cleaned()
3939
return Geometry(raw)
4040
}()
4141

@@ -64,7 +64,7 @@ public extension Geometry {
6464
tangents: nil,
6565
colors: nil,
6666
indexes: indices
67-
).optimized()
67+
).cleaned()
6868
return Geometry(raw)
6969
}()
7070
}

0 commit comments

Comments
 (0)