Skip to content

Commit

Permalink
Physics: less default bounciness, body autodisabling enabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
borodust committed Feb 8, 2017
1 parent 2ab72e8 commit 8c110d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion graphics/shaders/lighting.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

vec4 computeLight(vec4 base, vec3 normal, DirectionalLight lightSource) {
float f = max(-dot(lightSource.direction, normal), 0);
return lightSource.ambient * base + lightSource.diffuse * f;
return (lightSource.ambient + lightSource.diffuse * f) * base;
}
2 changes: 1 addition & 1 deletion physics/contacts.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
(defun fill-contact (contact info)
(setf (%ode:contact.surface.mode contact) (mask 'contact-flags :approx0 :bounce)
(%ode:contact.surface.mu contact) +infinity+
(%ode:contact.surface.bounce contact) (ode-real 1.0))
(%ode:contact.surface.bounce contact) (ode-real 0.1))
(fill-contact-geom (%ode:contact.geom contact) info)
contact)
10 changes: 8 additions & 2 deletions physics/universe.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


(defvar *contact-points-per-collision* 4)
(defvar *world-quick-step-iterations* 20)
(defvar *auto-disable-bodies-p* t)
(defvar *error-reduction-parameter* 0.5) ;; 0.1 ~ 0.8 recommended
(defvar *constant-force-mixing* 0.0001) ;; 10e-9 ~ 1.0 recommended


(defclass universe ()
Expand All @@ -18,8 +22,10 @@

(defmethod initialize-instance :after ((this universe) &key)
(with-slots (world) this
(%ode:world-set-erp world (ode-real 0.8))
(%ode:world-set-cfm world (ode-real 0.01))))
(%ode:world-set-quick-step-num-iterations world *world-quick-step-iterations*)
(%ode:world-set-auto-disable-flag world (if *auto-disable-bodies-p* 1 0))
(%ode:world-set-erp world (ode-real *error-reduction-parameter*))
(%ode:world-set-cfm world (ode-real *constant-force-mixing*))))


(defun make-universe ()
Expand Down

0 comments on commit 8c110d8

Please sign in to comment.