Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add swift package manager support for static chipmunk c library #173

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -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")
]
)
35 changes: 35 additions & 0 deletions include/CChipmunk2D.h
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions include/chipmunk/cpPolyline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions include/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module CChipmunk2D {
umbrella header "CChipmunk2D.h"
link "CChipmunk2D"
export *
}
14 changes: 14 additions & 0 deletions src/cpPolyline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down