diff --git a/Package.swift b/Package.swift new file mode 100644 index 00000000..1c6fa0ae --- /dev/null +++ b/Package.swift @@ -0,0 +1,13 @@ +// swift-tools-version:4.2 + +import PackageDescription + +let package = Package( + name: "CChipmunk2D", + products: [ + .library(name: "CChipmunk2D", type: .static, targets: ["CChipmunk2D"]) + ], + targets: [ + .target(name: "CChipmunk2D", path: ".", sources: ["src"], publicHeadersPath: "include") + ] +) \ No newline at end of file diff --git a/include/CChipmunk2D.h b/include/CChipmunk2D.h new file mode 100644 index 00000000..4f8cd129 --- /dev/null +++ b/include/CChipmunk2D.h @@ -0,0 +1,35 @@ +/* Copyright (c) 2018 Murat Yilmaz + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#ifndef CCHIPMUNK_2D_H +#define CCHIPMUNK_2D_H + +#include "chipmunk/chipmunk.h" +#include "chipmunk/chipmunk_ffi.h" +#include "chipmunk/chipmunk_private.h" +#include "chipmunk/chipmunk_structs.h" +#include "chipmunk/chipmunk_unsafe.h" +#include "chipmunk/cpHastySpace.h" +#include "chipmunk/cpMarch.h" +#include "chipmunk/cpPolyline.h" +#include "chipmunk/cpRobust.h" + +#endif \ No newline at end of file diff --git a/include/chipmunk/cpPolyline.h b/include/chipmunk/cpPolyline.h index 4e878f0c..78117670 100644 --- a/include/chipmunk/cpPolyline.h +++ b/include/chipmunk/cpPolyline.h @@ -30,6 +30,11 @@ CP_EXPORT cpPolyline *cpPolylineSimplifyVertexes(cpPolyline *line, cpFloat tol); /// Get the convex hull of a polyline as a looped polyline. CP_EXPORT cpPolyline *cpPolylineToConvexHull(cpPolyline *line, cpFloat tol); +/// Get vertex of polyline at given index. +CP_EXPORT cpVect cpPolylineGetVertex(cpPolyline* line, int index); + +/// Get pointer to vertices of polyline. +CP_EXPORT cpVect *cpPolylineGetVertices(cpPolyline* line); /// Polyline sets are collections of polylines, generally built by cpMarchSoft() or cpMarchHard(). typedef struct cpPolylineSet { diff --git a/include/module.modulemap b/include/module.modulemap new file mode 100644 index 00000000..6b73aefc --- /dev/null +++ b/include/module.modulemap @@ -0,0 +1,5 @@ +module CChipmunk2D { + umbrella header "CChipmunk2D.h" + link "CChipmunk2D" + export * +} diff --git a/src/cpPolyline.c b/src/cpPolyline.c index 5b375348..8b9e2b5a 100644 --- a/src/cpPolyline.c +++ b/src/cpPolyline.c @@ -385,6 +385,20 @@ cpPolylineToConvexHull(cpPolyline *line, cpFloat tol) return cpPolylineShrink(hull); } +//MARK: Member Access Functions + +cpVect +cpPolylineGetVertex(cpPolyline* line, int index) +{ + return line->verts[index]; +} + +cpVect * +cpPolylineGetVertices(cpPolyline* line) +{ + return &line->verts[0]; +} + //MARK: Approximate Concave Decompostition struct Notch {