2022-06-30 01:22:51 -04:00
|
|
|
;;-*-Lisp-*-
|
|
|
|
(in-package goal)
|
|
|
|
|
|
|
|
;; name: vol.gc
|
|
|
|
;; name in dgo: vol
|
|
|
|
;; dgos: ENGINE, GAME
|
|
|
|
|
2022-08-05 16:12:54 -04:00
|
|
|
;; DECOMP BEGINS
|
|
|
|
|
2022-09-11 13:42:46 -04:00
|
|
|
(defun plane-volume-intersect-dist ((arg0 vector) (arg1 vector) (arg2 vector))
|
|
|
|
(let ((f0-1 (vector-dot arg1 arg0))
|
|
|
|
(f1-1 (vector-dot arg2 arg0))
|
|
|
|
)
|
|
|
|
(if (< 0.00001 (fabs f1-1))
|
|
|
|
(/ (- (-> arg0 w) f0-1) f1-1)
|
|
|
|
409600000.0
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-10-29 23:20:02 -04:00
|
|
|
(defmethod plane-volume-method-9 ((this plane-volume) (arg0 symbol) (arg1 vector-array) (arg2 vector-array))
|
2022-09-11 13:42:46 -04:00
|
|
|
(local-vars
|
|
|
|
(sv-144 vector)
|
|
|
|
(sv-148 number)
|
|
|
|
(sv-152 int)
|
|
|
|
(sv-160 vector)
|
|
|
|
(sv-176 vector)
|
|
|
|
(sv-192 vector)
|
|
|
|
(sv-208 vector)
|
|
|
|
(sv-224 vector)
|
|
|
|
(sv-240 int)
|
|
|
|
(sv-256 int)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(set! (-> this volume-type) arg0)
|
|
|
|
(set! (-> this point-count) 0)
|
|
|
|
(set! (-> this first-point) (the-as (pointer vector) (-> arg1 data (-> arg1 length))))
|
|
|
|
(set! (-> this normal-count) 0)
|
|
|
|
(set! (-> this first-normal) (the-as (pointer vector) (-> arg2 data (-> arg2 length))))
|
|
|
|
(dotimes (s3-0 (-> this num-planes))
|
2022-09-26 20:57:44 -04:00
|
|
|
(set! sv-176 (new 'stack-no-clear 'vector))
|
|
|
|
(set! (-> sv-176 quad) (the-as uint128 0))
|
|
|
|
(set! sv-192 (new 'stack-no-clear 'vector))
|
|
|
|
(set! (-> sv-192 quad) (the-as uint128 0))
|
|
|
|
(set! sv-208 (new 'stack-no-clear 'vector))
|
|
|
|
(set! (-> sv-208 quad) (the-as uint128 0))
|
|
|
|
(set! sv-224 (new 'stack-no-clear 'vector))
|
|
|
|
(set! (-> sv-224 quad) (the-as uint128 0))
|
|
|
|
0.0
|
|
|
|
0.0
|
|
|
|
0.0
|
|
|
|
(set! (-> (new 'stack-no-clear 'vector) quad) (the-as uint128 0))
|
|
|
|
(let ((s1-0 (new-stack-vector0))
|
|
|
|
(s0-0 0)
|
2023-09-26 10:17:00 -04:00
|
|
|
(s2-0 (-> this plane))
|
2022-09-26 20:57:44 -04:00
|
|
|
)
|
|
|
|
(set! sv-240 0)
|
2023-09-26 10:17:00 -04:00
|
|
|
(while (< sv-240 (-> this num-planes))
|
2022-09-26 20:57:44 -04:00
|
|
|
(when (!= s3-0 sv-240)
|
|
|
|
(vector-float*! sv-176 (the-as vector (-> s2-0 sv-240)) (-> s2-0 sv-240 w))
|
|
|
|
(vector-cross! sv-192 (the-as vector (-> s2-0 sv-240)) (the-as vector (-> s2-0 s3-0)))
|
|
|
|
(vector-normalize! sv-192 1.0)
|
|
|
|
(vector-cross! sv-208 sv-192 (the-as vector (-> s2-0 sv-240)))
|
|
|
|
(vector-normalize! sv-208 1.0)
|
|
|
|
(let ((f0-4 (plane-volume-intersect-dist (-> s2-0 s3-0) sv-176 sv-208)))
|
|
|
|
(when (!= f0-4 409600000.0)
|
|
|
|
(vector+float*! sv-224 sv-176 sv-208 f0-4)
|
|
|
|
(set! sv-144 (new-stack-vector0))
|
|
|
|
(set! sv-148 0.0)
|
|
|
|
(set! sv-152 0)
|
|
|
|
(set! sv-160 (new-stack-vector0))
|
|
|
|
(set! (-> sv-144 quad) (-> sv-224 quad))
|
|
|
|
(set! sv-256 0)
|
2023-09-26 10:17:00 -04:00
|
|
|
(while (< sv-256 (-> this num-planes))
|
2022-09-26 20:57:44 -04:00
|
|
|
(when (and (!= sv-256 s3-0) (!= sv-256 sv-240))
|
|
|
|
(let ((f0-6 (plane-volume-intersect-dist (-> s2-0 sv-256) sv-144 sv-192)))
|
|
|
|
(cond
|
|
|
|
((= f0-6 409600000.0)
|
|
|
|
)
|
|
|
|
((zero? sv-152)
|
|
|
|
(vector+float*! sv-144 sv-144 sv-192 f0-6)
|
|
|
|
(set! (-> sv-160 quad) (-> s2-0 sv-256 quad))
|
|
|
|
(set! sv-148 8192000.0)
|
|
|
|
(set! sv-152 1)
|
|
|
|
)
|
|
|
|
((begin (vector-float*! sv-224 sv-192 f0-6) (>= (vector-dot sv-224 sv-160) 0.0))
|
|
|
|
)
|
|
|
|
((>= (vector-dot sv-224 (the-as vector (-> s2-0 sv-256))) 0.0)
|
|
|
|
(when (< (fabs f0-6) (fabs (the-as float sv-148)))
|
|
|
|
(set! sv-148 f0-6)
|
|
|
|
(set! sv-152 (+ sv-152 1))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2022-09-26 20:57:44 -04:00
|
|
|
)
|
|
|
|
(else
|
|
|
|
(vector+float*! sv-144 sv-144 sv-192 f0-6)
|
|
|
|
(set! (-> sv-160 quad) (-> s2-0 sv-256 quad))
|
|
|
|
(set! sv-152 (+ sv-152 1))
|
|
|
|
(if (< (fabs f0-6) (fabs (the-as float sv-148)))
|
|
|
|
(set! sv-148 (- (the-as float sv-148) f0-6))
|
|
|
|
(set! sv-148 0.0)
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2022-09-26 20:57:44 -04:00
|
|
|
(set! sv-256 (+ sv-256 1))
|
|
|
|
)
|
|
|
|
(cond
|
|
|
|
((zero? sv-152)
|
|
|
|
)
|
|
|
|
((= (the-as float sv-148) 0.0)
|
|
|
|
)
|
|
|
|
(else
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (v1-79 (-> this num-planes))
|
2022-09-26 20:57:44 -04:00
|
|
|
(when (and (!= v1-79 s3-0) (!= v1-79 sv-240))
|
|
|
|
(if (< 4096.0 (- (vector-dot sv-144 (the-as vector (-> s2-0 v1-79))) (-> s2-0 v1-79 w)))
|
|
|
|
(goto cfg-42)
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
2022-09-26 20:57:44 -04:00
|
|
|
)
|
|
|
|
(vector+float*! sv-224 sv-144 sv-192 (the-as float sv-148))
|
|
|
|
(cond
|
|
|
|
((< (-> arg1 allocated-length) (+ (-> arg1 length) 2))
|
2023-09-26 10:17:00 -04:00
|
|
|
(format 0 "ERROR <AG>: vol-control #x~X out of volume points~%" this)
|
2022-09-26 20:57:44 -04:00
|
|
|
)
|
|
|
|
(else
|
|
|
|
(set! (-> arg1 data (-> arg1 length) quad) (-> sv-144 quad))
|
|
|
|
(set! (-> arg1 data (+ (-> arg1 length) 1) quad) (-> sv-224 quad))
|
|
|
|
(+! (-> arg1 length) 2)
|
2023-09-26 10:17:00 -04:00
|
|
|
(+! (-> this point-count) 2)
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
2022-09-26 20:57:44 -04:00
|
|
|
(vector+! s1-0 s1-0 sv-144)
|
|
|
|
(vector+! s1-0 s1-0 sv-224)
|
|
|
|
(+! s0-0 2)
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2022-09-26 20:57:44 -04:00
|
|
|
(label cfg-42)
|
|
|
|
(set! sv-240 (+ sv-240 1))
|
|
|
|
)
|
|
|
|
(when (nonzero? s0-0)
|
|
|
|
(vector-float*! s1-0 s1-0 (/ 1.0 (the float s0-0)))
|
|
|
|
(cond
|
|
|
|
((< (-> arg2 allocated-length) (+ (-> arg2 length) 2))
|
2023-09-26 10:17:00 -04:00
|
|
|
(format 0 "ERROR <AG>: vol-control #x~X out of volume normals~%" this)
|
2022-09-26 20:57:44 -04:00
|
|
|
)
|
|
|
|
(else
|
|
|
|
(set! (-> arg2 data (-> arg2 length) quad) (-> s1-0 quad))
|
|
|
|
(set! (-> arg2 data (+ (-> arg2 length) 1) quad) (-> s2-0 s3-0 quad))
|
|
|
|
(+! (-> arg2 length) 2)
|
2023-09-26 10:17:00 -04:00
|
|
|
(set! (-> this normal-count) (+ (-> this normal-count) 2))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
this
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
|
2023-10-29 23:20:02 -04:00
|
|
|
(defmethod debug-draw ((this plane-volume))
|
2023-09-26 10:17:00 -04:00
|
|
|
(let* ((v1-0 (-> this volume-type))
|
2022-09-11 13:42:46 -04:00
|
|
|
(s5-0 (cond
|
|
|
|
((= v1-0 'vol)
|
|
|
|
(the-as uint #x8000c000)
|
|
|
|
)
|
|
|
|
((= v1-0 'pvol)
|
|
|
|
(the-as uint #x80808080)
|
|
|
|
)
|
|
|
|
(else
|
|
|
|
(the-as uint #x800000c0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(s4-0 (-> this first-point))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s3-0 (/ (-> this point-count) 2))
|
2022-09-11 13:42:46 -04:00
|
|
|
(add-debug-line
|
|
|
|
#t
|
2022-09-16 20:42:33 -04:00
|
|
|
(bucket-id debug-no-zbuf1)
|
2022-09-11 13:42:46 -04:00
|
|
|
(the-as vector s4-0)
|
|
|
|
(the-as vector (&-> s4-0 4))
|
|
|
|
(the-as rgba s5-0)
|
|
|
|
#f
|
|
|
|
(the-as rgba -1)
|
|
|
|
)
|
|
|
|
(set! s4-0 (&-> s4-0 8))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
0
|
|
|
|
(none)
|
|
|
|
)
|
|
|
|
|
2023-10-29 23:20:02 -04:00
|
|
|
(defmethod point-in-vol? ((this plane-volume) (arg0 vector) (arg1 float))
|
2022-09-11 13:42:46 -04:00
|
|
|
"TODO - Checks if the given [[vector]] point is inside the volume defined by 6 [[plane]]s by atleast the padding value provided"
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (v1-0 (-> this num-planes))
|
|
|
|
(if (< arg1 (- (vector-dot arg0 (the-as vector (-> this plane v1-0))) (-> this plane v1-0 w)))
|
2022-09-11 13:42:46 -04:00
|
|
|
(return #f)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#t
|
|
|
|
)
|
|
|
|
|
2023-10-29 23:20:02 -04:00
|
|
|
(defmethod debug-draw ((this vol-control))
|
2022-09-11 13:42:46 -04:00
|
|
|
(with-pp
|
2023-09-26 10:17:00 -04:00
|
|
|
(let ((a0-1 this))
|
2022-09-11 13:42:46 -04:00
|
|
|
(when (and (and *display-vol-marks* (logtest? (-> a0-1 flags) (vol-flags display?)))
|
2023-09-26 10:17:00 -04:00
|
|
|
(logtest? (-> this flags) (vol-flags vol-flags-1))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(when (zero? (-> this debug-point))
|
2022-09-11 13:42:46 -04:00
|
|
|
(let ((s5-0 pp))
|
2023-09-26 10:17:00 -04:00
|
|
|
(set! pp (-> this process))
|
2022-09-11 13:42:46 -04:00
|
|
|
(let ((s4-0 0))
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (v1-8 (-> this pos-vol-count))
|
|
|
|
(+! s4-0 (-> this pos-vol v1-8 num-planes))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (v1-11 (-> this neg-vol-count))
|
|
|
|
(+! s4-0 (-> this neg-vol v1-11 num-planes))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(set! (-> this debug-point) (new 'debug 'vector-array (* 10 s4-0)))
|
|
|
|
(set! (-> this debug-normal) (new 'debug 'vector-array (* 10 s4-0)))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
(set! pp s5-0)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(set! (-> this debug-point length) 0)
|
|
|
|
(set! (-> this debug-normal length) 0)
|
|
|
|
(dotimes (s5-1 (-> this pos-vol-count))
|
|
|
|
(plane-volume-method-9 (-> this pos-vol s5-1) 'vol (-> this debug-point) (-> this debug-normal))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s5-2 (-> this neg-vol-count))
|
|
|
|
(plane-volume-method-9 (-> this neg-vol s5-2) 'vol (-> this debug-point) (-> this debug-normal))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s5-3 (-> this pos-vol-count))
|
|
|
|
(debug-draw (-> this pos-vol s5-3))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s5-4 (-> this neg-vol-count))
|
|
|
|
(debug-draw (-> this neg-vol s5-4))
|
2022-09-11 13:42:46 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
0
|
|
|
|
(none)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-10-29 23:20:02 -04:00
|
|
|
(defmethod vol-control-method-10 ((this vol-control) (arg0 plane))
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s4-0 (-> this neg-vol-count))
|
|
|
|
(if (point-in-vol? (-> this neg-vol s4-0) arg0 0.0)
|
2022-09-11 13:42:46 -04:00
|
|
|
(return #f)
|
|
|
|
)
|
|
|
|
)
|
2023-09-26 10:17:00 -04:00
|
|
|
(dotimes (s4-1 (-> this pos-vol-count))
|
|
|
|
(if (point-in-vol? (-> this pos-vol s4-1) arg0 0.0)
|
2022-09-11 13:42:46 -04:00
|
|
|
(return #t)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
#f
|
|
|
|
)
|