Skip to content

Commit

Permalink
Use single floats for physics
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Oct 13, 2019
1 parent cc9d5c9 commit 5d12a46
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions physics/2d/body.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
;;; MASS
;;;
(defstruct mass
(value 0d0 :type double-float :read-only t)
(inertia 0d0 :type double-float :read-only t))
(value 0f0 :type single-float :read-only t)
(inertia 0f0 :type single-float :read-only t))


(defmethod simulation-engine-make-mass-for-circle ((engine chipmunk-engine) (mass number)
Expand Down Expand Up @@ -60,7 +60,7 @@

(defmethod simulation-engine-make-rigid-body ((engine chipmunk-engine) (universe universe)
&key mass kinematic)
(let ((body (make-instance 'rigid-body :mass (or mass (and (not kinematic) (make-mass :value 1d0 :inertia 1d0)))
(let ((body (make-instance 'rigid-body :mass (or mass (and (not kinematic) (make-mass :value 1f0 :inertia 1f0)))
:universe universe
:kinematic kinematic)))
(%cp:space-add-body (handle-value-of universe) (handle-value-of body))
Expand Down
2 changes: 1 addition & 1 deletion physics/2d/utils.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


(definline cp-float (val)
(float val 0d0))
(float val 0f0))


(definline init-cp-vect (vect bodge-vec)
Expand Down
6 changes: 3 additions & 3 deletions physics/3d/ode/contacts.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

(defstruct (contact-surface
(:constructor make-contact-surface))
(friction 0.05d0)
(bounciness 0.4d0)
(velocity 0d0))
(friction 0.05f0)
(bounciness 0.4f0)
(velocity 0f0))


(defstruct (contact
Expand Down
2 changes: 1 addition & 1 deletion physics/3d/ode/ode.lisp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(cl:in-package :cl-bodge.physics.ode)


(define-constant +precision+ 0d0)
(define-constant +precision+ 0f0)


(defclass ode-object (foreign-object) ())
Expand Down
6 changes: 3 additions & 3 deletions physics/3d/ode/universe.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

(defparameter *world-quick-step-iterations* 40)
(defparameter *auto-disable-bodies-p* t)
(defparameter *error-reduction-parameter* 0.1) ;; 0.1 ~ 0.8 recommended
(defparameter *constant-force-mixing* 0d000001) ;; 10e-9 ~ 1.0 recommended
(defparameter *error-reduction-parameter* 0.1f0) ;; 0.1 ~ 0.8 recommended
(defparameter *constant-force-mixing* 0.00001f0) ;; 10e-9 ~ 1.0 recommended
(defparameter *contact-points-per-collision* 3)
;; https://en.wikipedia.org/wiki/Successive_over-relaxation
(defparameter *world-over-relaxation* 1.3d0)
(defparameter *world-over-relaxation* 1.3f0)


(defclass universe ()
Expand Down

0 comments on commit 5d12a46

Please sign in to comment.