Skip to content

Commit

Permalink
Fix this crap
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Dec 5, 2023
1 parent a4ca873 commit f3381aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
5 changes: 3 additions & 2 deletions global-bounds-cache.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@
(defclass global-bounds-cached-entity (entity)
((global-bounds-cache :accessor global-bounds-cache)))

(defmethod initialize-instance :after ((entity global-bounds-cached-entity) &key)
(setf (global-bounds-cache entity) (make-global-bounds-cache entity)))
(defmethod shared-initialize :after ((entity global-bounds-cached-entity) slots &key)
(unless (slot-boundp entity 'global-bounds-cache)
(setf (global-bounds-cache entity) (make-global-bounds-cache entity))))

(defmethod global-location ((entity global-bounds-cached-entity) &optional target)
(global-location (global-bounds-cache entity) target))
Expand Down
16 changes: 4 additions & 12 deletions physics/rigidbody.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@

(defmethod bsize ((entity rigidbody))
(let ((vmin (vec3)) (vmax (vec3))
(bsize (bsize entity)))
(bsize (vec3)))
(declare (dynamic-extent vmin vmax))
(loop for primitive across (physics-primitives entity)
do (let ((bsize (global-bsize primitive))
(location (location primitive)))
Expand Down Expand Up @@ -97,17 +98,8 @@
(setf (inertia-tensor entity) primitive)))

(defmethod (setf physics-primitives) :before ((primitives vector) (entity rigidbody))
(let ((vmin (vec3)) (vmax (vec3))
(bsize (bsize entity)))
(loop for primitive across primitives
do (setf (primitive-entity primitive) entity)
(let ((bsize (global-bsize primitive))
(location (location primitive)))
(vmin vmin (v- location bsize))
(vmax vmax (v+ location bsize))))
(!v- bsize vmax vmin)
(nv* bsize 0.5)
(setf (bradius entity) (vlength bsize))))
(loop for primitive across primitives
do (setf (primitive-entity primitive) entity)))

(defmethod (setf physics-primitives) :after ((primitives vector) (entity rigidbody))
(%update-rigidbody-cache entity))
Expand Down

0 comments on commit f3381aa

Please sign in to comment.