Files
jak-project/goal_src/jak2/engine/collide/collide-mesh.gc
T
Tyler Wilding 6f093f98ff gsrc: Add convenience macros for masking VF operations (#3824)
Migrates all code, there should be no change in the compilation output
(linter should check this)

At first i was considering making these builtins, which short of a bunch
of code generation, would require some sort of dynamic definition in
`Atoms.cpp`. This isn't hard but, i figured it would be better to keep
it simple and just generate the OG macros.

Fixes https://github.com/open-goal/jak-project/issues/233
2025-01-11 12:16:05 -05:00

656 lines
21 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.
|#
;; DECOMP BEGINS
(defmethod asize-of ((this collide-mesh))
(the-as int (+ (-> collide-mesh size) (* (+ (-> this num-tris) -1) 8)))
)
(defmethod mem-usage ((this 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 this)))
(+! (-> 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 (* (-> this 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 ((this 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 (-> this tris)))
(s4-0 (-> arg0 node-list data arg1 bone transform))
)
(countdown (s3-0 (-> this 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 quad 0))
(.lvf vf5 (&-> s4-0 quad 1))
(.lvf vf6 (&-> s4-0 quad 2))
(.lvf vf7 (&-> s4-0 trans quad))
(.lvf vf1 (&-> (-> this vertex-data (-> (the-as collide-mesh-tri s5-0) vertex-index 0)) quad))
(.lvf vf2 (&-> (-> this vertex-data (-> (the-as collide-mesh-tri s5-0) vertex-index 1)) quad))
(.lvf vf3 (&-> (-> this 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)
(sphere-bbox4w bounding-box4w :inline)
)
)
(defmethod-mips2c "(method 12 collide-mesh)" 12 collide-mesh)
;;;;;;;;;;;;;;;;;;;;;
;; should push away
;;;;;;;;;;;;;;;;;;;;;
(deftype spat-work (structure)
((intersect vector :inline)
(sphere-bbox4w bounding-box4w :inline)
)
)
(defmethod should-push-away-test ((this 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) ;; og:preserve-this 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 (-> this 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.w vf1 vf0)
(.lvf vf9 (&-> s3-0 vertex 2 quad))
(.add.x.vf.y vf5 vf5 vf5)
(&+! s3-0 96)
(.add.y.vf.x vf6 vf6 vf6)
(set! f3-0 arg3)
(.add.z.vf.y vf5 vf5 vf5)
(.add.z.vf.x vf6 vf6 vf6)
(.sqrt.vf Q vf6 :ftf #b0)
(.mov a2-4 vf5)
(set! f0-0 0.0)
(.wait.vf)
(let ((f1-0 (-> arg2 w)))
(.add.vf.x vf6 vf0 Q)
(.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.x vf5 vf5 vf5)
(.add.z.vf.x vf5 vf5 vf5)
(.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 ((this 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) (-> this id)) ;; check id first
;; this weird pxor stuff is checking the transform for equality
(let ((v1-6 (-> s5-0 quad 0))
(a0-4 (-> s4-0 mat quad 0))
)
(.pxor v1-7 v1-6 a0-4)
)
(let ((a0-5 (-> s5-0 quad 1))
(a1-1 (-> s4-0 mat quad 1))
)
(.pxor a0-6 a0-5 a1-1)
)
(.por v1-8 v1-7 a0-6)
(let ((a0-7 (-> s5-0 quad 2))
(a1-2 (-> s4-0 mat quad 2))
)
(.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 quad 0) (-> s5-0 quad 0))
(set! (-> s4-0 mat quad 1) (-> s5-0 quad 1))
(set! (-> s4-0 mat quad 2) (-> s5-0 quad 2))
(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! this (+ (* 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) (-> this id))
(set! (-> s4-0 mat quad 0) (-> s5-0 quad 0))
(set! (-> s4-0 mat quad 1) (-> s5-0 quad 1))
(set! (-> s4-0 mat quad 2) (-> s5-0 quad 2))
(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! ((this 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 (-> this used-size))
(v1-1 (/ v1-0 16))
(a3-0 (-> this data))
(a2-0 (-> this 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 (-> this 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 (-> this data))
(set! (-> this id) (the-as uint a2-2))
(label cfg-5)
(set! (-> this 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! ((this 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 (-> this num-verts))
)
(nop!)
(let ((a3-0 (the-as object (-> this vertex-data))))
(b! (zero? v1-0) cfg-3 :delay (.lvf vf1 (&-> arg1 quad 0)))
(nop!)
(.lvf vf2 (&-> arg1 quad 1))
;; this first loop does the transformation.
(let ((t0-1 (the-as object (+ t0-0 -64))))
(.lvf vf3 (&-> arg1 quad 2))
(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 (-> this tris))))
(nop!)
(let ((a2-1 (scratchpad-object int))
(a0-1 (-> this 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.w acc vf0 vf7)
(let ((t3-0 (* t0-5 16)))
(.add.mul.y.vf.w acc vf0 vf7 acc)
(set! t0-4 (+ t1-3 a2-1))
(.add.mul.z.vf.w vf7 vf0 vf7 acc)
(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.xyz vf6 vf6 Q)
(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)
(sphere-bbox4w bounding-box4w :inline)
)
)
(defmethod overlap-test ((this 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 (-> this 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.w vf4 vf2 vf2)
(.mul.vf vf3 vf3 vf3)
(.mul.x.vf.w acc vf0 vf3)
(.add.mul.y.vf.w acc vf0 vf3 acc)
(.add.mul.z.vf.w vf3 vf0 vf3 acc)
(.sub.w.vf.w vf3 vf3 vf4)
(.add.w.vf.y vf3 vf0 vf3)
(.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
)
)