Skip to content

Commit

Permalink
Initial checkin.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradWBeer committed Mar 20, 2017
0 parents commit 198d1b0
Show file tree
Hide file tree
Showing 20 changed files with 9,586 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# lisp junk
*.FASL
*.fasl
*.lisp-temp

# emacs junk
\#*
*~
.\#*

# system dependent junk
local/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Pavel Korolev

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.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cl-chipmunk

Thin Common Lisp wrapper around the chipmunk 2D physics engine.
20 changes: 20 additions & 0 deletions autowrap.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(in-package :cl-chipmunk)


(c-include "spec/chipmunk.h"
:spec-path "spec"
:definition-package :%chipmunk
;; :exclude-sources (".*.h")
;; :include-sources ("chipmunk/cpVect.h"
;; "chipmunk/cpBB.h"
;; "chipmunk/cpSpatialIndex.h"
;; "chipmunk/cpBody.h"
;; "chipmunk/cpShape.h"
;; "chipmunk/cpPolyShape.h"
;; "chipmunk/cpArbiter.h"
;; "chipmunk/constraints/cpConstraint.h"
;; "chipmunk/cpSpace.h")
;;:exclude-definitions ("dWorldSetStepThreadingImplementation")
:symbol-regex (("cp?[A-Z]\\w*" () (lambda (name matches regex)
(declare (ignore matches regex))
(subseq name 1)))))
22 changes: 22 additions & 0 deletions cl-chipmunk.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(in-package :cl-user)


(defpackage :cl-chipmunk.def
(:use :cl :asdf))

(in-package :cl-chipmunk.def)

(defsystem cl-chipmunk
:description "Thin wrapper around Open Dynamics Engine for cl-bodge system"
:version "0.0.1"
:author "Pavel Korolev"
:mailto "[email protected]"
:license "MIT"
:depends-on (alexandria cffi cl-autowrap cl-plus-c)
:serial t
:components ((:file "packages")
(:file "libchipmunk")
(:file "autowrap")))
;;(:file "ode")
;; (:module spec
;; :components ((:static-file "lib.h")))))
12 changes: 12 additions & 0 deletions libchipmunk.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(cl:in-package :%chipmunk)


(cffi:define-foreign-library libchipmunk
(:darwin (:or "libchipmunk.6.dylib" "libchipmunk.dylib"))
(:unix (:or "libchipmunk.so.0d3.0.0" ; debian/ubuntu convention for 0.14 version
"libchipmunk.so.0d3" "libchipmunk.so.0d3"))
(:windows "chipmunk.dll")
(t (:default "chipmunk")))


(cffi:use-foreign-library libchipmunk)
75 changes: 75 additions & 0 deletions ode.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
(in-package :cl-chipmunk)


;; (declaim (special *collision-input*))


;; (define-bitmask-from-constants (contact-flags)
;; %ode:+contact-mu2+
;; %ode:+contact-axis-dep+
;; %ode:+contact-f-dir1+
;; %ode:+contact-bounce+
;; %ode:+contact-soft-erp+
;; %ode:+contact-soft-cfm+
;; %ode:+contact-motion1+
;; %ode:+contact-motion2+
;; %ode:+contact-motion-n+
;; %ode:+contact-slip1+
;; %ode:+contact-slip2+
;; %ode:+contact-rolling+
;; %ode:+contact-approx0+
;; %ode:+contact-approx1-1+
;; %ode:+contact-approx1-2+
;; %ode:+contact-approx1-n+
;; %ode:+contact-approx1+)


;; (define-constant +double-precision-p+
;; (if (search "double_precision" (%ode:get-configuration)) t nil))


;; (define-constant +infinity+
;; (if +double-precision-p+
;; (progn
;; #+sbcl sb-ext:double-float-positive-infinity
;; #+clozure 1D++0
;; #+abcl ext:double-float-positive-infinity
;; #+allegro excl::*infinity-double*
;; #+cmu ext:double-float-positive-infinity
;; #+(and ecl (not infinity-not-available)) si:double-float-positive-infinity
;; #+lispworks #.(read-from-string "10E999")
;; #+scl ext:double-float-positive-infinity
;; #-(or sbcl clozure abcl allegro cmu ecl lispworks scl)
;; most-positive-double-float)
;; (progn
;; #+sbcl sb-ext:single-float-positive-infinity
;; #+clozure 1S++0
;; #+abcl ext:single-float-positive-infinity
;; #+allegro excl::*infinity-single*
;; #+cmu ext:single-float-positive-infinity
;; #+(and ecl (not infinity-not-available)) si:single-float-positive-infinity
;; #+lispworks (coerce infinity$$ 'single-float)
;; #+scl ext:single-float-positive-infinity
;; #-(or sbcl clozure abcl allegro cmu ecl lispworks scl)
;; most-positive-single-float))
;; :test 'eql)


;; (defmacro define-collision-callback (name (collision-input this-geom that-geom) &body body)
;; (with-gensyms (data-ptr g0 g1)
;; `(defcallback ,name :void ((,data-ptr :pointer) (,g0 %ode:geom-id) (,g1 %ode:geom-id))
;; (declare (ignore ,data-ptr))
;; (let ((,collision-input *collision-input*)
;; (,this-geom ,g0)
;; (,that-geom ,g1))
;; (declare (ignorable ,collision-input))
;; ,@body))))


;; (defmacro collision-callback (callback-name)
;; `(callback ',callback-name))


;; (defun space-collide (space collision-input collision-callback)
;; (let ((*collision-input* collision-input))
;; (%ode:space-collide space (cffi:null-pointer) collision-callback)))
11 changes: 11 additions & 0 deletions packages.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(in-package :cl-chipmunk.def)


(defpackage :%chipmunk
(:use))


(defpackage :cl-chipmunk
(:nicknames :chipmunk :chip)
(:use :cl :alexandria :autowrap :plus-c)
(:export ))
Loading

0 comments on commit 198d1b0

Please sign in to comment.