Files
jak-project/goal_src/engine/gfx/tie/tie-methods.gc
T
water111 a8342aef31 [graphics] TIE extractor (#1026)
* temp

* temp

* wip

* more progress on the instance asm

* first half of tie extraction, up to dma lists

* more tie extraction

* first part figured out maybe

* bp1 loop seems to work, bp2 loop does not

* bp1 and bp2 appear working. sadly ip is needed

* ip1 outline, not working ip2

* just kidding, ip2 seems to work

* extraction seems to work

* basic rendering working

* tie fixes

* performance optimization of tie renderer

* hook up tie to engine

* fix more bugs

* cleanup and perf improvements

* fix tests

* ref tests

* mm256i for gcc

* CLANG

* windows

* more compile fixes

* fix fast time of day

* small fixes

* fix after merge

* clang
2021-12-26 12:33:51 -05:00

736 lines
31 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: tie-methods.gc
;; name in dgo: tie-methods
;; dgos: GAME, ENGINE
(defun tie-init-buffers ((arg0 dma-buffer))
"Initialize the TIE buckets.
Note: the buffer passed in here is _not_ used.
this function should be called _after_ all TIE drawing is done.
It will skip setup if there is nothing drawn."
;; the TIE buckets are only used by TIE - so we can safely splice things at the beginning/end without
;; messing things up.
(let ((gp-0 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-0))))
;; only if we have something in the bucket.
(when (!= gp-0 (-> gp-0 last))
(let* ((s5-0 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-1 (-> s5-0 base))
)
;; add initialization data
(tie-init-engine
s5-0
(new 'static 'gs-test :atst (gs-atest not-equal) :zte #x1 :ztst (gs-ztest greater-equal))
0
)
;; patch to the start
(let ((v1-8 (the-as object (-> s5-0 base))))
(set! (-> (the-as dma-packet v1-8) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-0 next)))
(set! (-> (the-as dma-packet v1-8) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-8) vif1) (new 'static 'vif-tag))
(set! (-> s5-0 base) (&+ (the-as pointer v1-8) 16))
)
(set! (-> gp-0 next) (the-as uint s4-1))
)
)
)
(let ((gp-1 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-0))))
;; only if we have something in teh bucket
(when (!= gp-1 (-> gp-1 last))
(let* ((s4-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s5-1 (-> s4-2 base))
)
;; add the end data at the end.
(tie-end-buffer s4-2)
(let ((v1-19 (-> s4-2 base)))
(let ((a0-17 (the-as object (-> s4-2 base))))
(set! (-> (the-as dma-packet a0-17) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet a0-17) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-17) vif1) (new 'static 'vif-tag))
(set! (-> s4-2 base) (&+ (the-as pointer a0-17) 16))
)
(set! (-> (the-as (pointer uint32) (-> gp-1 last)) 1) (the-as uint s5-1))
(set! (-> gp-1 last) (the-as (pointer dma-tag) v1-19))
)
)
)
)
;; same as above, but for level 1's tie.
(let ((gp-2 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-1))))
(when (!= gp-2 (-> gp-2 last))
(let* ((s5-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-4 (-> s5-2 base))
)
(tie-init-engine
s5-2
(new 'static 'gs-test :atst (gs-atest not-equal) :zte #x1 :ztst (gs-ztest greater-equal))
0
)
(let ((v1-28 (the-as object (-> s5-2 base))))
(set! (-> (the-as dma-packet v1-28) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-2 next)))
(set! (-> (the-as dma-packet v1-28) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-28) vif1) (new 'static 'vif-tag))
(set! (-> s5-2 base) (&+ (the-as pointer v1-28) 16))
)
(set! (-> gp-2 next) (the-as uint s4-4))
)
)
)
(let ((gp-3 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-1))))
(when (!= gp-3 (-> gp-3 last))
(let* ((s4-5 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s5-3 (-> s4-5 base))
)
(tie-end-buffer s4-5)
(let ((v1-39 (-> s4-5 base)))
(let ((a0-36 (the-as object (-> s4-5 base))))
(set! (-> (the-as dma-packet a0-36) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet a0-36) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-36) vif1) (new 'static 'vif-tag))
(set! (-> s4-5 base) (&+ (the-as pointer a0-36) 16))
)
(set! (-> (the-as (pointer uint32) (-> gp-3 last)) 1) (the-as uint s5-3))
(set! (-> gp-3 last) (the-as (pointer dma-tag) v1-39))
)
)
)
)
#|
;; level 0's tie near
(let ((gp-4 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-near-0))))
(when (!= gp-4 (-> gp-4 last))
(let* ((s5-4 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-7 (-> s5-4 base))
)
(tie-near-init-engine
s5-4
(new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
0
)
(let ((v1-48 (the-as object (-> s5-4 base))))
(set! (-> (the-as dma-packet v1-48) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-4 next)))
(set! (-> (the-as dma-packet v1-48) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-48) vif1) (new 'static 'vif-tag))
(set! (-> s5-4 base) (&+ (the-as pointer v1-48) 16))
)
(set! (-> gp-4 next) (the-as uint s4-7))
)
)
)
(let ((gp-5 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-near-0))))
(when (!= gp-5 (-> gp-5 last))
(let* ((s4-8 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s5-5 (-> s4-8 base))
)
(tie-near-end-buffer s4-8)
(let ((v1-59 (-> s4-8 base)))
(let ((a0-55 (the-as object (-> s4-8 base))))
(set! (-> (the-as dma-packet a0-55) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet a0-55) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-55) vif1) (new 'static 'vif-tag))
(set! (-> s4-8 base) (&+ (the-as pointer a0-55) 16))
)
(set! (-> (the-as (pointer uint32) (-> gp-5 last)) 1) (the-as uint s5-5))
(set! (-> gp-5 last) (the-as (pointer dma-tag) v1-59))
)
)
)
)
;; level 1's tie near
(let ((gp-6 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-near-1))))
(when (!= gp-6 (-> gp-6 last))
(let* ((s5-6 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s4-10 (-> s5-6 base))
)
(tie-near-init-engine
s5-6
(new 'static 'gs-test
:ate #x1
:atst (gs-atest greater-equal)
:aref #x26
:zte #x1
:ztst (gs-ztest greater-equal)
)
0
)
(let ((v1-68 (the-as object (-> s5-6 base))))
(set! (-> (the-as dma-packet v1-68) dma) (new 'static 'dma-tag :id (dma-tag-id next) :addr (-> gp-6 next)))
(set! (-> (the-as dma-packet v1-68) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-68) vif1) (new 'static 'vif-tag))
(set! (-> s5-6 base) (&+ (the-as pointer v1-68) 16))
)
(set! (-> gp-6 next) (the-as uint s4-10))
)
)
)
(let ((gp-7 (-> *display* frames (-> *display* on-screen) frame bucket-group (bucket-id tie-near-1))))
(when (!= gp-7 (-> gp-7 last))
(let* ((s4-11 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s5-7 (-> s4-11 base))
)
(tie-near-end-buffer s4-11)
(let ((v1-79 (-> s4-11 base)))
(let ((a0-74 (the-as object (-> s4-11 base))))
(set! (-> (the-as dma-packet a0-74) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet a0-74) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet a0-74) vif1) (new 'static 'vif-tag))
(set! (-> s4-11 base) (&+ (the-as pointer a0-74) 16))
)
(set! (-> (the-as (pointer uint32) (-> gp-7 last)) 1) (the-as uint s5-7))
(set! (-> gp-7 last) (the-as (pointer dma-tag) v1-79))
)
)
)
)
|#
0
(none)
)
;;;;;;;;;;;;;;;;;
;; TIE debug
;;;;;;;;;;;;;;;;;
;; most of this doesn't really do anything.
;; a ranges of instances to debug
(deftype tie-instance-debug (structure)
((max-instance uint32 :offset-assert 0)
(min-instance uint32 :offset-assert 4)
)
:method-count-assert 9
:size-assert #x8
:flag-assert #x900000008
)
;; unused
(define *tie* (new 'global 'tie-instance-debug))
(defun tie-debug-between ((arg0 uint) (arg1 uint))
(set! (-> *instance-tie-work* test-id) arg1)
(set! (-> *instance-tie-work* test-id2) arg0)
arg0
)
(defun tie-debug-one ((arg0 uint) (arg1 uint))
(set! (-> *instance-tie-work* test-id) (+ arg1 -1 arg0))
(set! (-> *instance-tie-work* test-id2) arg0)
arg0
)
(defun walk-tie-generic-prototypes ()
(none)
)
;; unused
(define *pke-hack* (new 'global 'vector))
;; draw-inline-array-instance-tie
;; draw-inline-array-prototype-tie-generic-asm
;; draw-inline-array-prototype-tie-asm
;; draw-inline-array-prototype-tie-near-asm
(defmethod login drawable-tree-instance-tie ((obj drawable-tree-instance-tie))
(if (nonzero? (-> obj prototypes prototype-array-tie))
(login (-> obj prototypes prototype-array-tie))
)
(dotimes (s5-0 (-> obj length))
(login (-> obj data s5-0))
)
obj
)
(defun draw-drawable-tree-instance-tie ((arg0 drawable-tree-instance-tie) (arg1 level))
"Actually draw TIE instances.
Will draw TIE, TIE-NEAR, and GENERIC"
;; todo kill
(local-vars
(r0-0 none)
(a0-31 int)
(a0-33 int)
(a0-46 int)
(a0-48 int)
(a0-62 int)
(a0-64 int)
(a0-82 int)
(a0-84 int)
(sv-16 int)
)
;; only if one of our renderers is enabled.
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near tie generic))
;; setup work (TODO, what uses TIE wind?)
(set! (-> *instance-tie-work* first-generic-prototype) (the-as uint 0))
(set! (-> *instance-tie-work* wind-vectors) (-> arg0 prototypes wind-vectors))
;;
(let ((s4-0 (+ (-> arg0 length) -1))) ;; number of arrays of draw-nodes (depth of the BVH tree, not counting instance leaves)
;; perform draw node culling. TODO
#|
(when (nonzero? s4-0)
(dotimes (s3-0 s4-0)
(let* ((v1-10 (-> arg0 data s3-0))
(a0-5 (-> arg0 data (+ s3-0 1)))
(a1-2 (/ (-> (the-as drawable-inline-array-node v1-10) data 0 id) 8))
(a0-7 (/ (-> (the-as drawable-inline-array-node a0-5) data 0 id) 8))
(a1-4 (+ a1-2 #x38b0 #x70000000))
(a0-9 (+ a0-7 #x38b0 #x70000000))
)
(draw-node-cull
(the-as pointer a0-9)
(the-as pointer a1-4)
(-> (the-as drawable-inline-array-node v1-10) data)
(-> (the-as drawable-inline-array-node v1-10) length)
)
)
)
)
|#
(let* ((v1-16 (-> arg0 data s4-0)) ;; leaves
(s4-1 (-> arg0 prototypes prototype-array-tie)) ;; prototypes
(s5-1 (-> s4-1 length)) ;; number of prototypes
)
(dotimes (a0-11 s5-1) ;; loop over prototypes, zero stuff??
(let ((a1-7 (-> s4-1 array-data a0-11)))
(set! (-> a1-7 next-clear) (the-as uint128 0))
(set! (-> a1-7 generic-count-clear) (the-as uint128 0))
(set! (-> a1-7 generic-next-clear) (the-as uint128 0))
)
0
)
(let* ((s1-0 (-> (the-as drawable-inline-array-instance-tie v1-16) data)) ;; the inline array of instances
(s0-0 (&-> (scratchpad-object terrain-context) work background vis-list (/ (-> s1-0 0 id) 8))) ;; vis for first.
(s3-1 (-> *display* frames (-> *display* on-screen) frame global-buf)) ;; dma buf to write to
)
(set! sv-16 (-> (the-as drawable-inline-array-node v1-16) length)) ;; number of instances
;; if we actually have things to draw
(when (nonzero? sv-16)
;; this is some buffer for the generic renderer
(let* ((v1-21 (logand (the-as int *gsf-buffer*) 8191))
(v1-23 (logand (the-as int (&- (logand (the-as int (&-> (-> s4-1 data) -512)) 8191) (the-as uint v1-21))) 8191))
)
;; not sure why, but we'll use some gsf-buffer space to store an instance-tie-work
;; all the external stuff will dump into *instance-tie-work*, and we'll make a copy that's used
;; in the actual DMA generation code.
(set! *instance-tie-work-copy* (the-as instance-tie-work (+ (the-as int *gsf-buffer*) v1-23)))
)
;;; TIE instance Drawing
;; we do the instances first so the prototypes that aren't drawn can be skipped.
(let ((s2-0 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
;; actually copy the work
(quad-copy! (the-as pointer *instance-tie-work-copy*) (the-as pointer *instance-tie-work*) 28)
;; clear perf counting stuff
(set! (-> *instance-tie-work-copy* wait-to-spr) (the-as uint 0))
(set! (-> *instance-tie-work-copy* wait-from-spr) (the-as uint 0))
(reset! (-> *perf-stats* data 9))
;; DRAW!
;;(draw-inline-array-instance-tie s0-0 s1-0 sv-16 s3-1)
;; finish perf stats
(read! (-> *perf-stats* data 9))
(update-wait-stats (-> *perf-stats* data 9) (the-as uint 0)
(-> *instance-tie-work-copy* wait-to-spr)
(-> *instance-tie-work-copy* wait-from-spr))
;; copy out things from instance tie work
(let ((v1-42 (-> *instance-tie-work-copy* min-dist quad)))
(set! (-> *instance-tie-work* min-dist quad) v1-42)
)
(set! (-> *instance-tie-work* flags) (-> *instance-tie-work-copy* flags))
;; update memory usage
(let ((a0-38 *dma-mem-usage*))
(when (nonzero? a0-38)
(set! (-> a0-38 length) (max 10 (-> a0-38 length)))
(set! (-> a0-38 data 9 name) "tie-fragment")
(+! (-> a0-38 data 9 count) 1)
(+! (-> a0-38 data 9 used)
(&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s2-0))
)
(set! (-> a0-38 data 9 total) (-> a0-38 data 9 used))
)
)
)
;; Generic TIE prototype drawing
(when (logtest? *vu1-enable-user* (vu1-renderer-mask generic))
(when (logtest? (-> *instance-tie-work* flags) 2)
(let ((s2-1 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
(set! (-> *prototype-tie-work* generic-wait-to-spr) (the-as uint 0))
(set! (-> *prototype-tie-work* generic-wait-from-spr) (the-as uint 0))
(set! (-> *instance-tie-work* first-generic-prototype) (the-as uint (-> s3-1 base)))
(reset! (-> *perf-stats* data 10))
;;(draw-inline-array-prototype-tie-generic-asm s3-1 s5-1 s4-1)
(read! (-> *perf-stats* data 10))
(update-wait-stats (-> *perf-stats* data 10) (the-as uint 0)
(-> *prototype-tie-work* generic-wait-to-spr)
(-> *prototype-tie-work* generic-wait-from-spr)
)
;; Note: we don't add to a bucket. This lives in some buffer somewhere and generic will take care of actually adding it.
(let ((a0-51 *dma-mem-usage*))
(when (nonzero? a0-51)
(set! (-> a0-51 length) (max 18 (-> a0-51 length)))
(set! (-> a0-51 data 17 name) "tie-generic")
(+! (-> a0-51 data 17 count) 1)
(+! (-> a0-51 data 17 used)
(&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s2-1))
)
(set! (-> a0-51 data 17 total) (-> a0-51 data 17 used))
)
)
)
)
)
;; Normal TIE prototype drawing
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
(let ((s3-2 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
(let* ((s1-1 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s2-2 (-> s1-1 base))
)
(set! (-> *prototype-tie-work* wait-to-spr) (the-as uint 0))
(set! (-> *prototype-tie-work* wait-from-spr) (the-as uint 0))
(reset! (-> *perf-stats* data 11))
;;(draw-inline-array-prototype-tie-asm s1-1 s5-1 s4-1)
(add-pc-tfrag3-data s1-1 (-> *level* data (-> (scratchpad-object terrain-context) bsp lev-index)))
(read! (-> *perf-stats* data 11))
(update-wait-stats (-> *perf-stats* data 11) (the-as uint 0)
(-> *prototype-tie-work* wait-to-spr)
(-> *prototype-tie-work* wait-from-spr)
)
;; this actually generates real drawing DMA, so add it to the appropriate bucket.
(let ((a3-11 (-> s1-1 base)))
(let ((v1-94 (the-as object (-> s1-1 base))))
(set! (-> (the-as dma-packet v1-94) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet v1-94) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-94) vif1) (new 'static 'vif-tag))
(set! (-> s1-1 base) (&+ (the-as pointer v1-94) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
(the-as bucket-id (if (zero? (-> arg1 index))
(bucket-id tie-0)
(bucket-id tie-1)
)
)
s2-2
(the-as (pointer dma-tag) a3-11)
)
)
)
)
(let ((v1-100 *dma-mem-usage*))
(when (nonzero? v1-100)
(set! (-> v1-100 length) (max 10 (-> v1-100 length)))
(set! (-> v1-100 data 9 name) "tie-fragment")
(+! (-> v1-100 data 9 count) 1)
(+! (-> v1-100 data 9 used)
(&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s3-2))
)
(set! (-> v1-100 data 9 total) (-> v1-100 data 9 used))
)
)
)
)
#|
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near))
(let ((s3-3 (-> *display* frames (-> *display* on-screen) frame global-buf base)))
(let* ((s1-2 (-> *display* frames (-> *display* on-screen) frame global-buf))
(s2-3 (-> s1-2 base))
)
(set! (-> *prototype-tie-work* near-wait-to-spr) (the-as uint 0))
(set! (-> *prototype-tie-work* near-wait-from-spr) (the-as uint 0))
(reset! (-> *perf-stats* data 12))
;;(draw-inline-array-prototype-tie-near-asm s1-2 s5-1 s4-1)
(read! (-> *perf-stats* data 12))
(update-wait-stats (-> *perf-stats* data 12) (the-as uint 0)
(-> *prototype-tie-work* near-wait-to-spr)
(-> *prototype-tie-work* near-wait-from-spr)
)
(let ((a3-16 (-> s1-2 base)))
(let ((v1-123 (the-as object (-> s1-2 base))))
(set! (-> (the-as dma-packet v1-123) dma) (new 'static 'dma-tag :id (dma-tag-id next)))
(set! (-> (the-as dma-packet v1-123) vif0) (new 'static 'vif-tag))
(set! (-> (the-as dma-packet v1-123) vif1) (new 'static 'vif-tag))
(set! (-> s1-2 base) (&+ (the-as pointer v1-123) 16))
)
(dma-bucket-insert-tag
(-> *display* frames (-> *display* on-screen) frame bucket-group)
(the-as bucket-id (if (zero? (-> arg1 index))
(bucket-id tie-near-0)
(bucket-id tie-near-1)
)
)
s2-3
(the-as (pointer dma-tag) a3-16)
)
)
)
(let ((a0-92 *dma-mem-usage*))
(when (nonzero? a0-92)
(set! (-> a0-92 length) (max 16 (-> a0-92 length)))
(set! (-> a0-92 data 15 name) "tie-near")
(+! (-> a0-92 data 15 count) 1)
(+! (-> a0-92 data 15 used)
(&- (-> *display* frames (-> *display* on-screen) frame global-buf base) (the-as uint s3-3))
)
(set! (-> a0-92 data 15 total) (-> a0-92 data 15 used))
)
)
)
)|#
)
)
)
)
0
)
(set! (-> arg1 closest-object 5) (-> *instance-tie-work* min-dist x))
0
(none)
)
(defmethod draw drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 drawable-tree-instance-tie) (arg1 display-frame))
"Add the tree to the background work list."
(let* ((v1-1 (-> *background-work* tie-tree-count))
(a1-2 (-> (scratchpad-object terrain-context) bsp lev-index))
(a1-5 (-> *level* level a1-2))
)
(set! (-> *background-work* tie-trees v1-1) obj)
(set! (-> *background-work* tie-levels v1-1) a1-5)
)
(+! (-> *background-work* tie-tree-count) 1)
(none)
)
(defmethod collect-stats drawable-tree-instance-tie ((obj drawable-tree-instance-tie))
"Collect statistics on TIE drawing."
;; only if tie/generic ran
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near tie generic))
;; unused?
(-> obj data (+ (-> obj length) -1))
;; loop over all prototypes.
;; the drawing process will write to the prototypes to say how many of each it draws
(let ((v1-8 (-> obj prototypes prototype-array-tie)))
(dotimes (a0-1 (-> v1-8 length))
;; grap the prototype
(let ((a1-2 (-> v1-8 array-data a0-1)))
;; GENERIC
(when (logtest? *vu1-enable-user* (vu1-renderer-mask generic))
;; there are 4 arrays of fragments per prototype. Looks like we check them all for generic.
(let ((a2-3 0)
(a3-0 3)
)
(while (>= a3-0 a2-3)
(let ((t0-2 (-> a1-2 generic-count a2-3)) ;; number of times this geom was drawn with generic
(t2-0 (-> a1-2 geometry-override a2-3)) ;; the geom that was drawn
)
(when (nonzero? t0-2) ;; were we drawn?
(let ((t1-3 (the-as object (-> t2-0 data))) ;; tie fragment array
(t2-1 (-> t2-0 length)) ;; number of tie fragments
)
(+! (-> *terrain-stats* tie-generic groups) 1) ;; number of geometries drawn (unique)
(+! (-> *terrain-stats* tie-generic fragments) t2-1) ;; number of frags drawn (unique)
(+! (-> *terrain-stats* tie-generic instances) t0-2) ;; number of instances drawn (not unique)
;; now, collect stats per fragment
(dotimes (t3-9 t2-1)
(let ((t5-0 (* (-> (the-as tie-fragment t1-3) num-tris) t0-2)) ;; multiply by number of instances
(t4-5 (* (-> (the-as tie-fragment t1-3) num-dverts) t0-2))
)
(+! (-> *terrain-stats* tie-generic tris) t5-0)
(+! (-> *terrain-stats* tie-generic dverts) t4-5)
)
(set! t1-3 (&+ (the-as tie-fragment t1-3) 64))
)
)
)
)
(+! a2-3 1)
)
)
)
;; normal tie
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie))
(let ((a2-9 1) ;; looks like we never draw geom 0's with normal tie?
(a3-1 3)
)
(while (>= a3-1 a2-9)
(let ((t0-6 (-> a1-2 count a2-9))
(t2-2 (-> a1-2 geometry-override a2-9))
)
(when (nonzero? t0-6)
(let ((t1-8 (the-as object (-> t2-2 data)))
(t2-3 (-> t2-2 length))
)
(+! (-> *terrain-stats* tie groups) 1)
(+! (-> *terrain-stats* tie fragments) t2-3)
(+! (-> *terrain-stats* tie instances) t0-6)
(dotimes (t3-19 t2-3)
(let ((t5-5 (* (-> (the-as tie-fragment t1-8) num-tris) t0-6))
(t4-12 (* (-> (the-as tie-fragment t1-8) num-dverts) t0-6))
)
(+! (-> *terrain-stats* tie tris) t5-5)
(+! (-> *terrain-stats* tie dverts) t4-12)
)
(set! t1-8 (&+ (the-as tie-fragment t1-8) 64))
)
)
)
)
(+! a2-9 1)
)
)
)
;; near tie
(when (logtest? *vu1-enable-user* (vu1-renderer-mask tie-near))
(let ((a2-14 (-> a1-2 count 0)) ;; always geom 0.
(a3-2 (-> a1-2 geometry-override 0))
)
(when (nonzero? a2-14)
(let ((a1-3 (the-as object (-> a3-2 data)))
(a3-3 (-> a3-2 length))
)
(+! (-> *terrain-stats* tie-near groups) 1)
(+! (-> *terrain-stats* tie-near fragments) a3-3)
(+! (-> *terrain-stats* tie-near instances) a2-14)
(dotimes (t0-19 a3-3)
(let ((t2-4 (* (-> (the-as tie-fragment a1-3) num-tris) a2-14))
(t1-15 (* (-> (the-as tie-fragment a1-3) num-dverts) a2-14))
)
(+! (-> *terrain-stats* tie-near tris) t2-4)
(+! (-> *terrain-stats* tie-near dverts) t1-15)
)
(set! a1-3 (&+ (the-as tie-fragment a1-3) 64))
)
)
)
)
)
)
)
)
)
(none)
)
(defmethod debug-draw drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 drawable) (arg1 display-frame))
(-> obj data (+ (-> obj length) -1))
(let* ((s5-0 (-> obj prototypes prototype-array-tie))
(s4-0 (-> s5-0 length))
)
(dotimes (s3-0 s4-0)
(let ((a1-1 (-> s5-0 array-data s3-0 geometry 0)))
(debug-draw a1-1 a1-1 arg1)
)
)
)
(none)
)
;;;;;;;;;;;;;;;;;
;; TIE collision
;;;;;;;;;;;;;;;;;
;; note: the first three methods appear twice in the original code.
(defmethod collide-with-box drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
(collide-with-box (-> obj data 0) (-> obj length) arg1)
0
(none)
)
(defmethod collide-y-probe drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
(collide-y-probe (-> obj data 0) (-> obj length) arg1)
0
(none)
)
(defmethod collide-ray drawable-tree-instance-tie ((obj drawable-tree-instance-tie) (arg0 int) (arg1 collide-list))
(collide-ray (-> obj data 0) (-> obj length) arg1)
0
(none)
)
(defmethod collide-with-box drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
(collide-with-box (the-as instance-tie (-> obj data)) (-> obj length) arg1)
0
(none)
)
(defmethod collide-y-probe drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
(collide-y-probe (the-as instance-tie (-> obj data)) (-> obj length) arg1)
0
(none)
)
(defmethod collide-ray drawable-inline-array-instance-tie ((obj drawable-inline-array-instance-tie) (arg0 int) (arg1 collide-list))
(collide-ray (the-as instance-tie (-> obj data)) (-> obj length) arg1)
0
(none)
)
(defun tie-test-cam-restore ()
(let ((a0-0 (new-stack-vector0))
(a1-0 (new-stack-matrix0))
)
(set! (-> a0-0 x) 1246582.6)
(set! (-> a0-0 y) 57026.02)
(set! (-> a0-0 z) -490734.78)
(set! (-> a0-0 w) 1.0)
(set! (-> a1-0 vector 0 x) -0.9873)
(set! (-> a1-0 vector 0 y) 0.0)
(set! (-> a1-0 vector 0 z) -0.1587)
(set! (-> a1-0 vector 0 w) 0.0)
(set! (-> a1-0 vector 1 x) 0.0014)
(set! (-> a1-0 vector 1 y) 0.9999)
(set! (-> a1-0 vector 1 z) -0.0092)
(set! (-> a1-0 vector 1 w) 0.0)
(set! (-> a1-0 vector 2 x) 0.1587)
(set! (-> a1-0 vector 2 y) -0.0093)
(set! (-> a1-0 vector 2 z) -0.9872)
(set! (-> a1-0 vector 2 w) 0.0)
(set! (-> a1-0 vector 3 x) 0.0)
(set! (-> a1-0 vector 3 y) 0.0)
(set! (-> a1-0 vector 3 z) 0.0)
(set! (-> a1-0 vector 3 w) 1.0)
(debug-set-camera-pos-rot! a0-0 a1-0)
)
(send-event *camera* 'set-fov 11650.845)
(none)
)