mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 21:27:52 -04:00
664 lines
22 KiB
Common Lisp
664 lines
22 KiB
Common Lisp
;;-*-Lisp-*-
|
|
(in-package goal)
|
|
|
|
;; name: collide-mesh.gc
|
|
;; name in dgo: collide-mesh
|
|
;; dgos: ENGINE, GAME
|
|
|
|
#|@file
|
|
note: this file has patched functions
|
|
|
|
this file has functions for foreground mesh collision functions. This is for stuff like jak being on a platform, or a
|
|
platform pushing jak away.
|
|
|
|
The "collide-mesh" is the foreground collision mesh type. These can be used as part of a collide-shape.
|
|
|
|
These can be added to the normal "collide-cache" and work with the most common collision queries.
|
|
|
|
However, there are a few special case collision queries that use a separate collide-mesh-cache.
|
|
The intented use is something like this:
|
|
- a mesh is unpacked to the collide-mesh-cache
|
|
- primitive vs. mesh tests are done using the unpacked data, reusing the data.
|
|
|
|
This collide-mesh-cache is limited compared to the real collide cache - this can only hold
|
|
a single mesh, so it's limited to tests like single foreground mesh vs. sphere.
|
|
Another limitation is that triangles don't have per-tri pat info.
|
|
|#
|
|
|
|
;; og:update-with-merge
|
|
|
|
;; DECOMP BEGINS
|
|
|
|
|
|
(defmethod asize-of collide-mesh ((obj collide-mesh))
|
|
(the-as int (+ (-> collide-mesh size) (* (+ (-> obj num-tris) -1) 8)))
|
|
)
|
|
|
|
(defmethod mem-usage collide-mesh ((obj collide-mesh) (arg0 memory-usage-block) (arg1 int))
|
|
(set! (-> arg0 length) (max 82 (-> arg0 length)))
|
|
(set! (-> arg0 data 81 name) "collide-mesh")
|
|
(+! (-> arg0 data 81 count) 1)
|
|
(let ((v1-6 (asize-of obj)))
|
|
(+! (-> arg0 data 81 used) v1-6)
|
|
(+! (-> arg0 data 81 total) (logand -16 (+ v1-6 15)))
|
|
)
|
|
(set! (-> arg0 length) (max 82 (-> arg0 length)))
|
|
(set! (-> arg0 data 81 name) "collide-mesh")
|
|
(+! (-> arg0 data 81 count) 1)
|
|
(let ((v1-16 (* (-> obj num-verts) 16)))
|
|
(+! (-> arg0 data 81 used) v1-16)
|
|
(+! (-> arg0 data 81 total) (logand -16 (+ v1-16 15)))
|
|
)
|
|
(the-as collide-mesh 0)
|
|
)
|
|
|
|
(defmethod debug-draw-tris collide-mesh ((obj collide-mesh) (arg0 process-drawable) (arg1 int))
|
|
(rlet ((acc :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
(vf6 :class vf)
|
|
(vf7 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(let ((s5-0 (the-as object (-> obj tris)))
|
|
(s4-0 (-> arg0 node-list data arg1 bone transform))
|
|
)
|
|
(countdown (s3-0 (-> obj num-tris))
|
|
(let ((a2-1 (new 'stack-no-clear 'vector))
|
|
(a3-0 (new 'stack-no-clear 'vector))
|
|
(t0-0 (new 'stack-no-clear 'vector))
|
|
)
|
|
(.lvf vf4 (&-> s4-0 vector 0 quad))
|
|
(.lvf vf5 (&-> s4-0 vector 1 quad))
|
|
(.lvf vf6 (&-> s4-0 vector 2 quad))
|
|
(.lvf vf7 (&-> s4-0 trans quad))
|
|
(.lvf vf1 (&-> (-> obj vertex-data (-> (the-as collide-mesh-tri s5-0) vertex-index 0)) quad))
|
|
(.lvf vf2 (&-> (-> obj vertex-data (-> (the-as collide-mesh-tri s5-0) vertex-index 1)) quad))
|
|
(.lvf vf3 (&-> (-> obj vertex-data (-> (the-as collide-mesh-tri s5-0) vertex-index 2)) quad))
|
|
(let ((t1-0 (copy-and-set-field (-> *pat-mode-info* (-> (the-as collide-mesh-tri s5-0) pat mode) color) a 16)))
|
|
(.mul.w.vf acc vf7 vf0)
|
|
(.add.mul.x.vf acc vf4 vf1 acc)
|
|
(.add.mul.y.vf acc vf5 vf1 acc)
|
|
(.add.mul.z.vf vf1 vf6 vf1 acc)
|
|
(.mul.w.vf acc vf7 vf0)
|
|
(.add.mul.x.vf acc vf4 vf2 acc)
|
|
(.add.mul.y.vf acc vf5 vf2 acc)
|
|
(.add.mul.z.vf vf2 vf6 vf2 acc)
|
|
(.mul.w.vf acc vf7 vf0)
|
|
(.add.mul.x.vf acc vf4 vf3 acc)
|
|
(.add.mul.y.vf acc vf5 vf3 acc)
|
|
(.add.mul.z.vf vf3 vf6 vf3 acc)
|
|
(.svf (&-> a2-1 quad) vf1)
|
|
(.svf (&-> a3-0 quad) vf2)
|
|
(.svf (&-> t0-0 quad) vf3)
|
|
(add-debug-flat-triangle #t (bucket-id debug-no-zbuf1) a2-1 a3-0 t0-0 t1-0)
|
|
)
|
|
)
|
|
(set! s5-0 (&+ (the-as collide-mesh-tri s5-0) 8))
|
|
)
|
|
)
|
|
0
|
|
(none)
|
|
)
|
|
)
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; sphere on platform
|
|
;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(deftype sopt-work (structure)
|
|
((intersect vector :inline :offset-assert 0)
|
|
(sphere-bbox4w bounding-box4w :inline :offset-assert 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x30
|
|
:flag-assert #x900000030
|
|
)
|
|
|
|
(defmethod-mips2c "(method 12 collide-mesh)" 12 collide-mesh)
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;
|
|
;; should push away
|
|
;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(deftype spat-work (structure)
|
|
((intersect vector :inline :offset-assert 0)
|
|
(sphere-bbox4w bounding-box4w :inline :offset-assert 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x30
|
|
:flag-assert #x900000030
|
|
)
|
|
|
|
(defmethod should-push-away-test collide-mesh ((obj collide-mesh) (arg0 collide-mesh-cache-tri) (arg1 collide-tri-result) (arg2 vector) (arg3 float))
|
|
(local-vars
|
|
(v1-0 uint128)
|
|
(a0-1 uint128)
|
|
(a1-2 uint128)
|
|
(a1-3 uint128)
|
|
(a1-4 uint128)
|
|
(a1-7 pat-surface)
|
|
(a2-1 uint128)
|
|
(a2-2 uint128)
|
|
(a2-4 int) ;; changed
|
|
(a2-5 float)
|
|
(a2-7 float)
|
|
(f0-0 float)
|
|
(f2-1 float)
|
|
(f3-0 float)
|
|
(f4-0 float)
|
|
)
|
|
(rlet ((Q :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf10 :class vf)
|
|
(vf11 :class vf)
|
|
(vf12 :class vf)
|
|
(vf13 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
(vf6 :class vf)
|
|
(vf7 :class vf)
|
|
(vf8 :class vf)
|
|
(vf9 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(let ((s4-0 (new 'stack-no-clear 'spat-work)))
|
|
(nop!)
|
|
(let ((s3-0 arg0))
|
|
(.lvf vf3 (&-> arg2 quad))
|
|
(nop!)
|
|
(let ((s2-0 (-> obj num-tris)))
|
|
(.sub.w.vf vf12 vf3 vf3)
|
|
(nop!)
|
|
(.add.w.vf vf13 vf3 vf3)
|
|
(nop!)
|
|
(.ftoi.vf vf12 vf12)
|
|
(nop!)
|
|
(.ftoi.vf vf13 vf13)
|
|
(nop!)
|
|
(.mov v1-0 vf12)
|
|
(.svf (&-> s4-0 sphere-bbox4w min quad) vf12)
|
|
(.mov a0-1 vf13)
|
|
(.svf (&-> s4-0 sphere-bbox4w max quad) vf13)
|
|
(until (>= a2-7 f4-0)
|
|
(until (> f0-0 f2-1)
|
|
(until (>= f3-0 f2-1)
|
|
(label cfg-1)
|
|
(b! (zero? s2-0) cfg-10 :delay (set! a2-1 (-> s3-0 bbox4w min quad)))
|
|
(+! s2-0 -1)
|
|
(let ((a1-1 (-> s3-0 bbox4w max quad)))
|
|
(.pcgtw a2-2 a2-1 a0-1)
|
|
(nop!)
|
|
(.pcgtw a1-2 v1-0 a1-1)
|
|
)
|
|
(nop!)
|
|
(.por a1-3 a2-2 a1-2)
|
|
(nop!)
|
|
(.ppach a1-4 (the-as uint128 0) a1-3)
|
|
(nop!)
|
|
(let ((a1-5 (shl (the-as int a1-4) 16)))
|
|
(nop!)
|
|
(b! (nonzero? a1-5) cfg-1 :likely-delay (set! s3-0 (&+ s3-0 96)))
|
|
)
|
|
(closest-pt-in-triangle (-> s4-0 intersect) arg2 (the-as matrix (-> s3-0 vertex)) (-> s3-0 normal))
|
|
(.lvf vf2 (&-> s4-0 intersect quad))
|
|
(.lvf vf3 (&-> arg2 quad))
|
|
(.lvf vf1 (&-> s3-0 normal quad))
|
|
(set! v1-0 (-> s4-0 sphere-bbox4w min quad))
|
|
(set! a0-1 (-> s4-0 sphere-bbox4w max quad))
|
|
(.sub.vf vf4 vf3 vf2)
|
|
(set! a1-7 (-> s3-0 pat))
|
|
(.mul.vf vf5 vf4 vf1)
|
|
(.lvf vf7 (&-> s3-0 vertex 0 quad))
|
|
(.mul.vf vf6 vf4 vf4)
|
|
(.lvf vf8 (&-> s3-0 vertex 1 quad))
|
|
(.mov.vf vf1 vf0 :mask #b1000)
|
|
(.lvf vf9 (&-> s3-0 vertex 2 quad))
|
|
(.add.x.vf vf5 vf5 vf5 :mask #b10)
|
|
(&+! s3-0 96)
|
|
(.add.y.vf vf6 vf6 vf6 :mask #b1)
|
|
(set! f3-0 arg3)
|
|
(.add.z.vf vf5 vf5 vf5 :mask #b10)
|
|
(.add.z.vf vf6 vf6 vf6 :mask #b1)
|
|
(.sqrt.vf Q vf6 :ftf #b0)
|
|
(.mov a2-4 vf5)
|
|
(set! f0-0 0.0)
|
|
(.wait.vf)
|
|
(let ((f1-0 (-> arg2 w)))
|
|
(.add.vf vf6 vf0 Q :mask #b1)
|
|
(.mov.vf vf10 vf6)
|
|
(b! (< (the-as int a2-4) 0) cfg-6 :likely-delay (.sub.vf vf10 vf0 vf10))
|
|
(label cfg-6)
|
|
(.mov a2-5 vf10)
|
|
(set! f2-1 (- a2-5 f1-0))
|
|
)
|
|
(.div.vf Q vf0 vf6 :fsf #b11 :ftf #b0)
|
|
)
|
|
)
|
|
(.wait.vf)
|
|
(nop!)
|
|
(.mul.vf vf11 vf4 Q)
|
|
(set! f4-0 0.707)
|
|
(.mul.vf vf5 vf11 vf1)
|
|
(.add.y.vf vf5 vf5 vf5 :mask #b1)
|
|
(.add.z.vf vf5 vf5 vf5 :mask #b1)
|
|
(.mov a2-7 vf5)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(set! arg3 f2-1)
|
|
(.svf (&-> arg1 vertex 0 quad) vf7)
|
|
(.svf (&-> arg1 vertex 1 quad) vf8)
|
|
(.svf (&-> arg1 vertex 2 quad) vf9)
|
|
(.svf (&-> arg1 intersect quad) vf2)
|
|
(.svf (&-> arg1 normal quad) vf1)
|
|
(b! #t cfg-1 :delay (set! (-> arg1 pat) a1-7))
|
|
(label cfg-10)
|
|
arg3
|
|
)
|
|
)
|
|
|
|
|
|
;; these two are unknown.
|
|
(defmethod-mips2c "(method 14 collide-mesh)" 14 collide-mesh)
|
|
(defmethod-mips2c "(method 15 collide-mesh)" 15 collide-mesh)
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Collide Mesh Cache
|
|
;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
(defmethod populate-for-prim-mesh collide-mesh-cache ((obj collide-mesh-cache) (arg0 collide-shape-prim-mesh))
|
|
"Populate the mesh cache for the given prim-mesh.
|
|
Will reuse existing data only if the transform and object are the same."
|
|
(local-vars
|
|
(v1-7 uint128)
|
|
(v1-8 uint128)
|
|
(v1-9 uint128)
|
|
(v1-11 uint128)
|
|
(a0-6 uint128)
|
|
(a0-8 uint128)
|
|
(a0-10 uint128)
|
|
(a0-11 uint128)
|
|
(a0-12 uint128)
|
|
)
|
|
(let ((s5-0 (-> arg0 cshape process node-list data (-> arg0 transform-index) bone transform))
|
|
(s4-0 (-> arg0 mesh-cache-entry))
|
|
)
|
|
(cond
|
|
((= (-> arg0 mesh-cache-id) (-> obj id)) ;; check id first
|
|
;; this weird pxor stuff is checking the transform for equality
|
|
(let ((v1-6 (-> s5-0 vector 0 quad))
|
|
(a0-4 (-> s4-0 mat vector 0 quad))
|
|
)
|
|
(.pxor v1-7 v1-6 a0-4)
|
|
)
|
|
(let ((a0-5 (-> s5-0 vector 1 quad))
|
|
(a1-1 (-> s4-0 mat vector 1 quad))
|
|
)
|
|
(.pxor a0-6 a0-5 a1-1)
|
|
)
|
|
(.por v1-8 v1-7 a0-6)
|
|
(let ((a0-7 (-> s5-0 vector 2 quad))
|
|
(a1-2 (-> s4-0 mat vector 2 quad))
|
|
)
|
|
(.pxor a0-8 a0-7 a1-2)
|
|
)
|
|
(.por v1-9 v1-8 a0-8)
|
|
(let ((a0-9 (-> s5-0 trans quad))
|
|
(a1-3 (-> s4-0 mat trans quad))
|
|
)
|
|
(.pxor a0-10 a0-9 a1-3)
|
|
)
|
|
(.por a0-11 v1-9 a0-10)
|
|
(let ((v1-10 a0-11))
|
|
(.pcpyud a0-12 a0-11 (the uint128 0))
|
|
(.por v1-11 a0-12 v1-10)
|
|
)
|
|
(when (nonzero? v1-11)
|
|
;; the id is equal, but the transform isn't. update transform
|
|
(set! (-> s4-0 mat vector 0 quad) (-> s5-0 vector 0 quad))
|
|
(set! (-> s4-0 mat vector 1 quad) (-> s5-0 vector 1 quad))
|
|
(set! (-> s4-0 mat vector 2 quad) (-> s5-0 vector 2 quad))
|
|
(set! (-> s4-0 mat trans quad) (-> s5-0 trans quad))
|
|
;; and unpack to cache again.
|
|
(unpack-mesh-to-cache! (-> arg0 mesh) (-> s4-0 tris) s5-0)
|
|
)
|
|
;; otherwise, reuse.
|
|
)
|
|
(else
|
|
;; id doesn't match.
|
|
(let ((v1-19 (-> arg0 mesh)))
|
|
(when v1-19
|
|
;; allocate new mesh.
|
|
(set! s4-0 (allocate! obj (+ (* 96 (-> v1-19 num-tris)) 64)))
|
|
(set! (-> arg0 mesh-cache-entry) s4-0)
|
|
(cond
|
|
(s4-0
|
|
;; if allocation succeeds, set up:
|
|
(set! (-> arg0 mesh-cache-id) (-> obj id))
|
|
(set! (-> s4-0 mat vector 0 quad) (-> s5-0 vector 0 quad))
|
|
(set! (-> s4-0 mat vector 1 quad) (-> s5-0 vector 1 quad))
|
|
(set! (-> s4-0 mat vector 2 quad) (-> s5-0 vector 2 quad))
|
|
(set! (-> s4-0 mat trans quad) (-> s5-0 trans quad))
|
|
;; and unpack.
|
|
(unpack-mesh-to-cache! (-> arg0 mesh) (-> s4-0 tris) s5-0)
|
|
)
|
|
(else
|
|
(set! (-> arg0 mesh-cache-id) (the-as uint 0))
|
|
0
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
s4-0
|
|
)
|
|
)
|
|
|
|
(defmethod allocate! collide-mesh-cache ((obj collide-mesh-cache) (arg0 int))
|
|
"Allocate room in the collide-mesh-cache for an unpacked mesh with arg0 tris."
|
|
(local-vars (a1-2 int) (a2-2 int))
|
|
(let* ((v1-0 (+ arg0 15))
|
|
(a1-1 (-> obj used-size))
|
|
(v1-1 (/ v1-0 16))
|
|
(a3-0 (-> obj data))
|
|
(a2-0 (-> obj max-size))
|
|
(v1-2 (* v1-1 16))
|
|
(a3-1 (&+ a3-0 a1-1))
|
|
)
|
|
(let ((t1-0 (- a2-0 (the-as uint v1-2)))
|
|
(t0-0 (-> obj id))
|
|
)
|
|
(b! (< (the-as int t1-0) 0) cfg-6 :delay (set! a1-2 (the-as int (+ a1-1 v1-2))))
|
|
(b! (>= (the-as int (- a2-0 (the-as uint a1-2))) 0) cfg-5 :delay (set! a2-2 (the-as int (+ t0-0 1))))
|
|
)
|
|
(b! (zero? (the-as uint a2-2)) cfg-4 :likely-delay (set! a2-2 1))
|
|
(label cfg-4)
|
|
(set! a1-2 v1-2)
|
|
(set! a3-1 (-> obj data))
|
|
(set! (-> obj id) (the-as uint a2-2))
|
|
(label cfg-5)
|
|
(set! (-> obj used-size) (the-as uint a1-2))
|
|
(let ((v0-0 a3-1))
|
|
(b! #t cfg-7 :delay (nop!))
|
|
(label cfg-6)
|
|
(format 0 "ERROR: Attempted to allocate something bigger than the entire mesh cache!~%")
|
|
(set! v0-0 (the-as (pointer uint8) #f))
|
|
(label cfg-7)
|
|
(the-as collide-mesh-cache-entry v0-0)
|
|
)
|
|
)
|
|
)
|
|
|
|
(defmethod unpack-mesh-to-cache! collide-mesh ((obj collide-mesh) (arg0 (inline-array collide-mesh-cache-tri)) (arg1 matrix))
|
|
"Unpack mesh and store in cache.
|
|
Transform triangles, computes normals and bbox."
|
|
(local-vars (t0-2 uint))
|
|
(rlet ((acc :class vf)
|
|
(Q :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf10 :class vf)
|
|
(vf11 :class vf)
|
|
(vf12 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
(vf6 :class vf)
|
|
(vf7 :class vf)
|
|
(vf8 :class vf)
|
|
(vf9 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(nop!)
|
|
(let ((t0-0 (scratchpad-object int))
|
|
(v1-0 (-> obj num-verts))
|
|
)
|
|
(nop!)
|
|
(let ((a3-0 (the-as object (-> obj vertex-data))))
|
|
(b! (zero? v1-0) cfg-3 :delay (.lvf vf1 (&-> arg1 vector 0 quad)))
|
|
(nop!)
|
|
(.lvf vf2 (&-> arg1 vector 1 quad))
|
|
;; this first loop does the transformation.
|
|
(let ((t0-1 (the-as object (+ t0-0 -64))))
|
|
(.lvf vf3 (&-> arg1 vector 2 quad))
|
|
(nop!)
|
|
(.lvf vf4 (&-> arg1 trans quad))
|
|
(nop!)
|
|
(.lvf vf5 (&-> (the-as (inline-array vector) a3-0) 0 quad))
|
|
(nop!)
|
|
(.lvf vf6 (&-> (the-as (inline-array vector) a3-0) 1 quad))
|
|
(nop!)
|
|
(.lvf vf7 (&-> (the-as (inline-array vector) a3-0) 2 quad))
|
|
(nop!)
|
|
(.lvf vf8 (&-> (the-as (inline-array vector) a3-0) 3 quad))
|
|
(label cfg-2)
|
|
(.mul.w.vf acc vf4 vf0)
|
|
(set! a3-0 (-> (the-as (inline-array vector) a3-0) 4))
|
|
(.add.mul.x.vf acc vf1 vf5 acc)
|
|
(set! t0-1 (-> (the-as (inline-array vector) t0-1) 4))
|
|
(.add.mul.y.vf acc vf2 vf5 acc)
|
|
(nop!)
|
|
(.add.mul.z.vf vf9 vf3 vf5 acc)
|
|
(nop!)
|
|
(.mul.w.vf acc vf4 vf0)
|
|
(.lvf vf5 (&-> (the-as vector a3-0) quad))
|
|
(.add.mul.x.vf acc vf1 vf6 acc)
|
|
(nop!)
|
|
(.add.mul.y.vf acc vf2 vf6 acc)
|
|
(nop!)
|
|
(.add.mul.z.vf vf10 vf3 vf6 acc)
|
|
(nop!)
|
|
(.mul.w.vf acc vf4 vf0)
|
|
(.lvf vf6 (&+ (the-as vector a3-0) 16))
|
|
(.add.mul.x.vf acc vf1 vf7 acc)
|
|
(nop!)
|
|
(.add.mul.y.vf acc vf2 vf7 acc)
|
|
(nop!)
|
|
(.add.mul.z.vf vf11 vf3 vf7 acc)
|
|
(nop!)
|
|
(.mul.w.vf acc vf4 vf0)
|
|
(.lvf vf7 (&+ (the-as vector a3-0) 32))
|
|
(.add.mul.x.vf acc vf1 vf8 acc)
|
|
(nop!)
|
|
(.add.mul.y.vf acc vf2 vf8 acc)
|
|
(nop!)
|
|
(.add.mul.z.vf vf12 vf3 vf8 acc)
|
|
(nop!)
|
|
(nop!)
|
|
(.lvf vf8 (&+ (the-as vector a3-0) 48))
|
|
(+! v1-0 -4)
|
|
(.svf (&-> (the-as (inline-array vector) t0-1) 0 quad) vf9)
|
|
(nop!)
|
|
(.svf (&-> (the-as (inline-array vector) t0-1) 1 quad) vf10)
|
|
(nop!)
|
|
(.svf (&-> (the-as (inline-array vector) t0-1) 2 quad) vf11)
|
|
(b! (> (the-as int v1-0) 0) cfg-2 :delay (.svf (&-> (the-as (inline-array vector) t0-1) 3 quad) vf12))
|
|
)
|
|
)
|
|
)
|
|
(label cfg-3)
|
|
(let ((v1-1 (the-as object (-> obj tris))))
|
|
(nop!)
|
|
(let ((a2-1 (scratchpad-object int))
|
|
(a0-1 (-> obj num-tris))
|
|
)
|
|
(b! (zero? a0-1) cfg-6 :delay (set! t0-2 (-> (the-as (inline-array collide-mesh-tri) v1-1) 0 vertex-index 0)))
|
|
(let* ((a1-1 (-> arg0 -1))
|
|
(a3-1 (-> (the-as (inline-array collide-mesh-tri) v1-1) 0 vertex-index 1))
|
|
(t0-3 (* t0-2 16))
|
|
(t2-0 (-> (the-as (inline-array collide-mesh-tri) v1-1) 0 vertex-index 2))
|
|
(t1-0 (* a3-1 16))
|
|
(a3-2 (the-as uint (-> (the-as (inline-array collide-mesh-tri) v1-1) 0 pat)))
|
|
)
|
|
(let* ((t2-1 (* t2-0 16))
|
|
(t0-4 (+ t0-3 a2-1))
|
|
(t1-1 (+ t1-0 a2-1))
|
|
(t2-2 (+ t2-1 a2-1))
|
|
)
|
|
;; this second loop does min/max for the bbox, and computes the normal.
|
|
(label cfg-5)
|
|
(+! a0-1 -1)
|
|
(.lvf vf1 t0-4)
|
|
(set! v1-1 (&+ (the-as collide-mesh-tri v1-1) 8))
|
|
(.lvf vf2 t1-1)
|
|
(&+! a1-1 96)
|
|
(.lvf vf3 t2-2)
|
|
(.sub.vf vf4 vf2 vf1)
|
|
(.svf (&-> a1-1 vertex 0 quad) vf1)
|
|
(.min.vf vf8 vf1 vf2)
|
|
(.svf (&-> a1-1 vertex 1 quad) vf2)
|
|
(.sub.vf vf5 vf3 vf1)
|
|
(.svf (&-> a1-1 vertex 2 quad) vf3)
|
|
(.max.vf vf9 vf1 vf2)
|
|
(let ((t1-2 (-> (the-as collide-mesh-tri v1-1) vertex-index 0)))
|
|
(.outer.product.a.vf acc vf4 vf5)
|
|
(let ((t2-3 (-> (the-as collide-mesh-tri v1-1) vertex-index 1)))
|
|
(.outer.product.b.vf vf6 vf5 vf4 acc)
|
|
(let ((t0-5 (-> (the-as collide-mesh-tri v1-1) vertex-index 2)))
|
|
(.mul.vf vf7 vf6 vf6)
|
|
(nop!)
|
|
(.min.vf vf8 vf8 vf3)
|
|
(let ((t1-3 (* t1-2 16)))
|
|
(.max.vf vf9 vf9 vf3)
|
|
(let ((t2-4 (* t2-3 16)))
|
|
(.mul.x.vf acc vf0 vf7 :mask #b1000)
|
|
(let ((t3-0 (* t0-5 16)))
|
|
(.add.mul.y.vf acc vf0 vf7 acc :mask #b1000)
|
|
(set! t0-4 (+ t1-3 a2-1))
|
|
(.add.mul.z.vf vf7 vf0 vf7 acc :mask #b1000)
|
|
(set! t1-1 (+ t2-4 a2-1))
|
|
(.isqrt.vf Q vf0 vf7 :fsf #b11 :ftf #b11)
|
|
(set! t2-2 (+ t3-0 a2-1))
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
)
|
|
(.ftoi.vf vf8 vf8)
|
|
(nop!)
|
|
(.ftoi.vf vf9 vf9)
|
|
(nop!)
|
|
(nop!)
|
|
(.svf (&-> a1-1 bbox4w min quad) vf8)
|
|
(.wait.vf)
|
|
(.svf (&-> a1-1 bbox4w max quad) vf9)
|
|
(.mul.vf vf6 vf6 Q :mask #b111)
|
|
(nop!)
|
|
(nop!)
|
|
(.svf (&-> a1-1 normal quad) vf6)
|
|
(nop!)
|
|
(set! (-> a1-1 pat) (the-as pat-surface a3-2))
|
|
(b! (nonzero? a0-1) cfg-5 :delay (set! a3-2 (the-as uint (-> (the-as collide-mesh-tri v1-1) pat))))
|
|
)
|
|
)
|
|
)
|
|
(label cfg-6)
|
|
0
|
|
(none)
|
|
)
|
|
)
|
|
|
|
;;;;;;;;;;;;;;;;;;;;
|
|
;; overlaps others
|
|
;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; this checks to see if a point is inside the mesh or not.
|
|
|
|
(deftype oot-work (structure)
|
|
((intersect vector :inline :offset-assert 0)
|
|
(sphere-bbox4w bounding-box4w :inline :offset-assert 16)
|
|
)
|
|
:method-count-assert 9
|
|
:size-assert #x30
|
|
:flag-assert #x900000030
|
|
)
|
|
|
|
(defmethod overlap-test collide-mesh ((obj collide-mesh) (arg0 collide-mesh-cache-tri) (arg1 vector))
|
|
(local-vars
|
|
(v1-0 uint128)
|
|
(a0-1 uint128)
|
|
(a1-2 uint128)
|
|
(a1-3 uint128)
|
|
(a1-4 uint128)
|
|
(a1-7 int)
|
|
(a2-1 uint128)
|
|
(a2-2 uint128)
|
|
)
|
|
(rlet ((acc :class vf)
|
|
(vf0 :class vf)
|
|
(vf1 :class vf)
|
|
(vf2 :class vf)
|
|
(vf3 :class vf)
|
|
(vf4 :class vf)
|
|
(vf5 :class vf)
|
|
(vf6 :class vf)
|
|
)
|
|
(init-vf0-vector)
|
|
(let ((s5-0 (new 'stack-no-clear 'oot-work))
|
|
(s4-0 arg0)
|
|
)
|
|
(.lvf vf2 (&-> arg1 quad))
|
|
(let ((s3-0 (-> obj num-tris)))
|
|
(.sub.w.vf vf5 vf2 vf2)
|
|
(.add.w.vf vf6 vf2 vf2)
|
|
(.ftoi.vf vf5 vf5)
|
|
(.ftoi.vf vf6 vf6)
|
|
(.mov v1-0 vf5)
|
|
(.svf (&-> s5-0 sphere-bbox4w min quad) vf5)
|
|
(.mov a0-1 vf6)
|
|
(.svf (&-> s5-0 sphere-bbox4w max quad) vf6)
|
|
(label cfg-1)
|
|
(b! (zero? s3-0) cfg-7 :delay (set! a2-1 (-> s4-0 bbox4w min quad)))
|
|
(+! s3-0 -1)
|
|
)
|
|
(let ((a1-1 (-> s4-0 bbox4w max quad)))
|
|
(.pcgtw a2-2 a2-1 a0-1)
|
|
(nop!)
|
|
(.pcgtw a1-2 v1-0 a1-1)
|
|
)
|
|
(nop!)
|
|
(.por a1-3 a2-2 a1-2)
|
|
(nop!)
|
|
(.ppach a1-4 (the-as uint128 0) a1-3)
|
|
(nop!)
|
|
(let ((a1-5 (shl (the-as int a1-4) 16)))
|
|
(nop!)
|
|
(b! (nonzero? a1-5) cfg-1 :likely-delay (set! s4-0 (&+ s4-0 96)))
|
|
)
|
|
(closest-pt-in-triangle (-> s5-0 intersect) arg1 (the-as matrix (-> s4-0 vertex)) (-> s4-0 normal))
|
|
(.lvf vf1 (&-> s5-0 intersect quad))
|
|
(.lvf vf2 (&-> arg1 quad))
|
|
(set! v1-0 (-> s5-0 sphere-bbox4w min quad))
|
|
(set! a0-1 (-> s5-0 sphere-bbox4w max quad))
|
|
(.sub.vf vf3 vf2 vf1)
|
|
(.mul.w.vf vf4 vf2 vf2 :mask #b1000)
|
|
(.mul.vf vf3 vf3 vf3)
|
|
(.mul.x.vf acc vf0 vf3 :mask #b1000)
|
|
(.add.mul.y.vf acc vf0 vf3 acc :mask #b1000)
|
|
(.add.mul.z.vf vf3 vf0 vf3 acc :mask #b1000)
|
|
(.sub.w.vf vf3 vf3 vf4 :mask #b1000)
|
|
(.add.w.vf vf3 vf0 vf3 :mask #b10)
|
|
(.mov a1-7 vf3)
|
|
(b! (>= (the-as int a1-7) 0) cfg-1 :delay (set! s4-0 (&+ s4-0 96)))
|
|
)
|
|
(return #t)
|
|
(label cfg-7)
|
|
#f
|
|
)
|
|
)
|