Skip to content

Commit

Permalink
Add debugs for physics overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Dec 5, 2023
1 parent f3381aa commit 816cb1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
9 changes: 7 additions & 2 deletions physics/gjk.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
((null (test-simplex s0 s1 s2 s3 dir))
(setf dim 3))
(T
(return T)))))))
(return T)))
finally (trial::dbg "GJK Overflow")))))

;; FIXME: this does not work as intended
#++
Expand Down Expand Up @@ -311,6 +312,7 @@
(return)))
(unless edge-found-p
(when (<= EPA-MAX-LOOSE-EDGES num-loose-edges)
(trial::dbg "EPA Edges Overflow")
(return))
(p<- (e num-loose-edges 0) edge-a)
(p<- (e num-loose-edges 1) edge-b)
Expand All @@ -327,6 +329,7 @@
;; Expand the polytope with the search point added to the new loose edge faces
(dotimes (i num-loose-edges)
(when (<= EPA-MAX-FACES num-faces)
(trial::dbg "EPA Faces Overflow")
(return))
(p<- (v num-faces 0) (e i 0))
(p<- (v num-faces 1) (e i 1))
Expand All @@ -336,7 +339,9 @@
(when (< (+ (v. (v num-faces 0) (v num-faces 3)) 0.000001) 0)
(rotatef (v num-faces 0) (v num-faces 1))
(nv- (v num-faces 3)))
(incf num-faces))))
(incf num-faces)))
(when (= (1+ i) EPA-ITERATIONS)
(trial::dbg "EPA Overflow")))

;; Compute the actual intersection
;; If we did not converge, we just use the closest face we reached
Expand Down
10 changes: 7 additions & 3 deletions physics/resolution.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@
(!vc cross rotation-change loc)
(incf (contact-depth other)
(* sign (v. (nv+ cross velocity-change)
(contact-normal other)))))))
(contact-normal other))))))
finally (dbg "POSITION ADJUSTMENT OVERFLOW"))

;; Adjust Velocities
(loop repeat iterations
Expand All @@ -388,7 +389,8 @@
(ntransform-inverse (nv+ cross velocity-change) (contact-to-world other))
(nv+* (contact-velocity other) cross (- sign))
(setf (contact-desired-delta other)
(desired-delta-velocity other (contact-velocity other) dt))))))))
(desired-delta-velocity other (contact-velocity other) dt)))))
finally (dbg "VELOCITY ADJUSTMENT OVERFLOW"))))

(defclass accelerated-rigidbody-system (rigidbody-system)
((acceleration-structure :initform (org.shirakumo.fraf.trial.space.kd-tree:make-kd-tree) :accessor acceleration-structure)
Expand Down Expand Up @@ -424,7 +426,9 @@
(and (= 0.0 (inverse-mass entity1))
(= 0.0 (inverse-mass entity2))))
(setf start (prune-hits hits start (detect-hits a b hits start end)))
(when (<= end start) (return start))))))
(when (<= end start)
(dbg "HIT OVERFLOW")
(return start))))))

(defmethod start-frame :before ((system accelerated-rigidbody-system))
(let ((pending-inserts (pending-inserts system))
Expand Down

0 comments on commit 816cb1a

Please sign in to comment.