Skip to content

Commit 6f88c7b

Browse files
committed
Update Euclid to 0.5.14
1 parent 1cef121 commit 6f88c7b

12 files changed

Lines changed: 93 additions & 20 deletions

File tree

Euclid/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [0.5.14](https://github.com/nicklockwood/Euclid/releases/tag/0.5.14) (2021-11-01)
2+
3+
- Added support for `triangeStrip` and `polygon` primitives when creating a `Mesh` from `SCNGeometry`
4+
- Creating a `Mesh` from an `SCNGeometry` now returns nil if the mesh can't be loaded
5+
6+
## [0.5.13](https://github.com/nicklockwood/Euclid/releases/tag/0.5.13) (2021-10-15)
7+
8+
- Fixed support for Mac Catalyst
9+
110
## [0.5.12](https://github.com/nicklockwood/Euclid/releases/tag/0.5.12) (2021-09-12)
211

312
- Added `Quaternion` type as an alternative representation for rotations

Euclid/Euclid.podspec.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Euclid",
3-
"version": "0.5.12",
3+
"version": "0.5.14",
44
"license": {
55
"type": "MIT",
66
"file": "LICENSE.md"
@@ -10,7 +10,7 @@
1010
"authors": "Nick Lockwood",
1111
"source": {
1212
"git": "https://github.com/nicklockwood/Euclid.git",
13-
"tag": "0.5.12"
13+
"tag": "0.5.14"
1414
},
1515
"source_files": "Sources",
1616
"requires_arc": true,

Euclid/Euclid.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
isa = PBXProject;
350350
attributes = {
351351
LastSwiftUpdateCheck = 1010;
352-
LastUpgradeCheck = 1300;
352+
LastUpgradeCheck = 1310;
353353
ORGANIZATIONNAME = "Nick Lockwood";
354354
TargetAttributes = {
355355
016FAB2821BFE78100AF60DC = {
@@ -604,7 +604,7 @@
604604
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
605605
GCC_WARN_UNUSED_FUNCTION = YES;
606606
GCC_WARN_UNUSED_VARIABLE = YES;
607-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
607+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
608608
MACOSX_DEPLOYMENT_TARGET = 10.12;
609609
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
610610
MTL_FAST_MATH = YES;
@@ -664,7 +664,7 @@
664664
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
665665
GCC_WARN_UNUSED_FUNCTION = YES;
666666
GCC_WARN_UNUSED_VARIABLE = YES;
667-
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
667+
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
668668
MACOSX_DEPLOYMENT_TARGET = 10.12;
669669
MTL_ENABLE_DEBUG_INFO = NO;
670670
MTL_FAST_MATH = YES;
@@ -696,7 +696,7 @@
696696
"@executable_path/../Frameworks",
697697
"@loader_path/Frameworks",
698698
);
699-
MARKETING_VERSION = 0.5.12;
699+
MARKETING_VERSION = 0.5.14;
700700
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
701701
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.Euclid;
702702
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";
@@ -728,7 +728,7 @@
728728
"@executable_path/../Frameworks",
729729
"@loader_path/Frameworks",
730730
);
731-
MARKETING_VERSION = 0.5.12;
731+
MARKETING_VERSION = 0.5.14;
732732
OTHER_SWIFT_FLAGS = "-Xfrontend -warn-long-expression-type-checking=75";
733733
PRODUCT_BUNDLE_IDENTIFIER = com.charcoaldesign.Euclid;
734734
PRODUCT_MODULE_NAME = "$(PRODUCT_NAME:c99extidentifier)";

Euclid/Euclid.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Euclid/Euclid.xcodeproj/xcshareddata/xcschemes/Euclid.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Euclid/Euclid.xcodeproj/xcshareddata/xcschemes/Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1300"
3+
LastUpgradeVersion = "1310"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Euclid/Sources/Euclid+AppKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// Copyright © 2021 Nick Lockwood. All rights reserved.
77
//
88

9-
#if canImport(AppKit)
9+
#if canImport(AppKit) && !targetEnvironment(macCatalyst)
1010

1111
import AppKit
1212

Euclid/Sources/Euclid+SceneKit.swift

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -580,14 +580,14 @@ public extension Mesh {
580580
let materials = scnGeometry.materials.map(materialLookup)
581581
for (index, element) in scnGeometry.elements.enumerated() {
582582
let material = materials.isEmpty ? nil : materials[index % materials.count]
583+
let indexData = element.data
584+
let indexSize = element.bytesPerIndex
585+
func vertex(at i: Int) -> Vertex {
586+
let index = indexData.index(at: i, bytes: indexSize)
587+
return vertices[Int(index)]
588+
}
583589
switch element.primitiveType {
584590
case .triangles:
585-
let indexData = element.data
586-
let indexSize = element.bytesPerIndex
587-
func vertex(at i: Int) -> Vertex {
588-
let index = indexData.index(at: i, bytes: indexSize)
589-
return vertices[Int(index)]
590-
}
591591
for i in 0 ..< element.primitiveCount {
592592
Polygon([
593593
vertex(at: i * 3),
@@ -597,8 +597,40 @@ public extension Mesh {
597597
polygons.append($0)
598598
}
599599
}
600+
case .triangleStrip:
601+
for i in stride(from: 0, to: element.primitiveCount - 1, by: 2) {
602+
Polygon([
603+
vertex(at: i),
604+
vertex(at: i + 1),
605+
vertex(at: i + 2),
606+
], material: material).map {
607+
polygons.append($0)
608+
}
609+
Polygon([
610+
vertex(at: i + 3),
611+
vertex(at: i + 2),
612+
vertex(at: i + 1),
613+
], material: material).map {
614+
polygons.append($0)
615+
}
616+
}
617+
case let type where type.rawValue == 4: // polygon
618+
let polyCount = element.primitiveCount
619+
var index = polyCount
620+
for i in 0 ..< polyCount {
621+
let vertexCount = indexData.index(at: i, bytes: indexSize)
622+
var vertices = [Vertex]()
623+
for _ in 0 ..< vertexCount {
624+
vertices.append(vertex(at: index))
625+
index += 1
626+
}
627+
Polygon(vertices, material: material).map {
628+
polygons.append($0)
629+
}
630+
}
600631
default:
601-
break // TODO:
632+
// TODO: throw detailed error message instead
633+
return nil
602634
}
603635
}
604636
let isConvex: Bool

Euclid/Sources/Plane.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ extension Plane: Codable {
6565
self.w = try container.decode(Double.self)
6666
} else {
6767
let container = try decoder.container(keyedBy: CodingKeys.self)
68-
normal = try container.decode(Vector.self, forKey: .normal).normalized()
69-
w = try container.decode(Double.self, forKey: .w)
68+
self.normal = try container.decode(Vector.self, forKey: .normal).normalized()
69+
self.w = try container.decode(Double.self, forKey: .w)
7070
}
7171
}
7272

0 commit comments

Comments
 (0)