mirror of
https://github.com/open-goal/jak-project.git
synced 2024-11-23 06:09:57 +00:00
jak3: shadow culling hack + finish region debugging tools + fix bigmap crashes (#3532)
This commit is contained in:
parent
dd765b41cb
commit
645e649a9c
@ -13110,7 +13110,7 @@
|
||||
|
||||
(deftype drawable-tree-region-prim (drawable-tree)
|
||||
"Top-level container for all regions of a level."
|
||||
((name basic :offset 8)
|
||||
((name symbol :offset 8)
|
||||
(data2 drawable-inline-array :dynamic :offset 32 :score 1))
|
||||
:method-count-assert 19
|
||||
:size-assert #x20
|
||||
|
@ -405,7 +405,7 @@
|
||||
(let ((s5-3 (-> this draw shadow-ctrl)))
|
||||
(when (!= *nav-enemy-dummy-shadow-control* s5-3)
|
||||
(let ((f0-7 (vector-vector-distance (camera-pos) (-> this root trans))))
|
||||
(#when PC_PORT
|
||||
(#when PC_PORT ;; og:preserve-this shadow cull toggle
|
||||
(if (not (-> *pc-settings* ps2-shadow?))
|
||||
(set! f0-7 0.0)))
|
||||
(cond
|
||||
|
@ -706,7 +706,7 @@
|
||||
(let ((s5-0 (-> this draw shadow-ctrl)))
|
||||
(when (!= *vehicle-shadow-control-disabled* s5-0)
|
||||
(let ((f30-0 (vector-vector-xz-distance (camera-pos) (-> this root trans))))
|
||||
;; og:preserve-this Shadow fix of some sort
|
||||
;; og:preserve-this shadow cull toggle
|
||||
(#when PC_PORT
|
||||
(if (not (-> *pc-settings* ps2-shadow?))
|
||||
(set! f30-0 0.0)))
|
||||
|
@ -4058,7 +4058,7 @@
|
||||
:virtual #t
|
||||
:trans (behavior ()
|
||||
(set! (-> self task-counter) (-> *game-info* task-counter))
|
||||
(if (and *bigmap* (nonzero? *bigmap*))
|
||||
(if *bigmap*
|
||||
(bigmap-method-16 *bigmap*)
|
||||
)
|
||||
(let ((gp-0 (res-lump-struct (-> self entity) 'on-running structure)))
|
||||
|
@ -1960,7 +1960,7 @@
|
||||
(true! draw?)
|
||||
)
|
||||
(when draw?
|
||||
(set! *debug-region-color-alt* (= tree-name 'camera))
|
||||
(set! *debug-region-tree-name* tree-name)
|
||||
(debug-draw-region region 0)))
|
||||
(set! i (+ i 1))
|
||||
(set! region (-> (the-as drawable-inline-array-region-prim (-> region-tree data2 (+ (-> region-tree length) -1))) data i))
|
||||
@ -1976,6 +1976,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(set! *debug-region-tree-name* #f)
|
||||
)
|
||||
(if *debug-track-skill*
|
||||
(debug-track-skill))
|
||||
|
@ -1577,6 +1577,11 @@
|
||||
(s1-4 (-> s4-8 bsp region-trees s2-4))
|
||||
)
|
||||
(while (< s2-4 s3-6)
|
||||
;; og:preserve-this pc port note: added this name and water check
|
||||
(let ((tree-name (-> s1-4 name)))
|
||||
(when (or (!= tree-name 'water) (not *debug-region-hide-water*))
|
||||
(set! *debug-region-tree-name* tree-name)
|
||||
|
||||
(let ((s0-4 (-> s1-4 data2 (+ (-> s1-4 length) -1) length)))
|
||||
(set! sv-128 0)
|
||||
(let ((a0-128 (the-as object (+ (+ (* sv-128 32) 32) (the-as int (-> s1-4 data2 (+ (-> s1-4 length) -1)))))))
|
||||
@ -1587,6 +1592,7 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
))
|
||||
(+! s2-4 1)
|
||||
(set! s1-4 (-> s4-8 bsp region-trees s2-4))
|
||||
)
|
||||
|
@ -587,7 +587,7 @@
|
||||
(dotimes (v1-96 (-> this game-score length))
|
||||
(set! (-> this game-score v1-96) 0.0)
|
||||
)
|
||||
(when (nonzero? *bigmap*) ;; og:preserve-this not-yet-implemented check
|
||||
(when *bigmap* ;; og:preserve-this not-yet-implemented check
|
||||
(format 0 "skipping bigmap init in game-info~%")
|
||||
((method-of-object *bigmap* bigmap-method-9))
|
||||
)
|
||||
|
@ -852,6 +852,9 @@
|
||||
)
|
||||
)
|
||||
)
|
||||
(#when PC_PORT ;; og:preserve-this
|
||||
(if (not (-> *pc-settings* ps2-shadow?))
|
||||
(set! t0-0 0.0)))
|
||||
(let ((t1-5 (-> a3-3 flags)))
|
||||
(-> arg0 cur-lod)
|
||||
(when (not (logtest? t1-5 (shadow-flags disable-fade)))
|
||||
|
@ -50,7 +50,7 @@ Note that all child classes of this must be 32-bytes."
|
||||
|
||||
(deftype drawable-tree-region-prim (drawable-tree)
|
||||
"Top-level container for all regions of a level."
|
||||
((name basic :offset 8)
|
||||
((name symbol :offset 8)
|
||||
(data2 drawable-inline-array :dynamic :offset 32)
|
||||
)
|
||||
(:methods
|
||||
|
@ -77,7 +77,7 @@
|
||||
(local-vars (sv-32 vector2h) (sv-36 vector))
|
||||
(set! sv-32 (new 'stack 'vector2h))
|
||||
(set! sv-36 (-> this bsphere))
|
||||
(add-debug-x #t (bucket-id debug-no-zbuf1) sv-36 (new 'static 'rgba :r #xff :g #xff :a #x80))
|
||||
(add-debug-x #t (bucket-id debug-no-zbuf1) sv-36 (#if PC_PORT (region-enter-color #x80) (new 'static 'rgba :r #xff :g #xff :a #x80)))
|
||||
(when (nonzero? (-> this region))
|
||||
(let ((s5-0 add-debug-text-3d)
|
||||
(s4-0 #t)
|
||||
@ -202,11 +202,15 @@
|
||||
)
|
||||
|
||||
(defmethod debug-draw-region ((this drawable-region-sphere) (arg0 int))
|
||||
(#when PC_PORT
|
||||
(when (and *debug-region-hide-empty* (not (or (-> this region on-enter) (-> this region on-exit) (-> this region on-inside))))
|
||||
;; no scripts to run means the region is "empty" so do not render (unless enabled)
|
||||
(return 0)))
|
||||
(let ((t9-0 (method-of-type drawable-region-prim debug-draw-region)))
|
||||
(t9-0 this arg0)
|
||||
)
|
||||
(let ((a2-0 (-> this bsphere)))
|
||||
(add-debug-sphere #t (bucket-id debug) a2-0 (-> this bsphere w) (new 'static 'rgba :r #xff :a #x80))
|
||||
(add-debug-sphere #t (bucket-id debug) a2-0 (-> this bsphere w) (#if PC_PORT (region-enter-color #x80) (new 'static 'rgba :r #xff :a #x80)))
|
||||
)
|
||||
0
|
||||
(none)
|
||||
@ -237,6 +241,10 @@
|
||||
)
|
||||
|
||||
(defmethod debug-draw-region ((this drawable-region-face) (arg0 int))
|
||||
(#when PC_PORT
|
||||
(when (and *debug-region-hide-empty* (not (or (-> this region on-enter) (-> this region on-exit) (-> this region on-inside))))
|
||||
;; no scripts to run means the region is "empty" so do not render (unless enabled)
|
||||
(return 0)))
|
||||
(when (zero? arg0)
|
||||
(let ((t9-0 (method-of-type drawable-region-prim debug-draw-region)))
|
||||
(t9-0 this arg0)
|
||||
@ -246,39 +254,19 @@
|
||||
(PC_PORT
|
||||
(when *debug-region-show-bsphere*
|
||||
(let ((s5-0 (-> this bsphere)))
|
||||
(add-debug-vector
|
||||
#t
|
||||
(bucket-id debug-no-zbuf1)
|
||||
s5-0
|
||||
(-> this data normal)
|
||||
(meters 2)
|
||||
(new 'static 'rgba :r #xff :g #xff :a #x80)
|
||||
)
|
||||
(add-debug-sphere #t (bucket-id debug) s5-0 (-> this bsphere w) (new 'static 'rgba :r #xff :a #x30))
|
||||
(add-debug-vector #t (bucket-id debug-no-zbuf1) s5-0 (-> this data normal) (meters 2) (region-enter-color #x80))
|
||||
(add-debug-sphere #t (bucket-id debug) s5-0 (-> this bsphere w) (region-exit-color #x30))
|
||||
)
|
||||
)
|
||||
(add-debug-bound (bucket-id debug) (-> this data points) (the-as int (-> this data num-points)) (region-enter-color #x40) (region-exit-color #x40) 0)
|
||||
)
|
||||
(#t
|
||||
(let ((s5-0 (-> this bsphere)))
|
||||
(add-debug-vector
|
||||
#t
|
||||
(bucket-id debug-no-zbuf1)
|
||||
s5-0
|
||||
(-> this data normal)
|
||||
(meters 2)
|
||||
(new 'static 'rgba :r #xff :g #xff :a #x80)
|
||||
)
|
||||
(add-debug-vector #t (bucket-id debug-no-zbuf1) s5-0 (-> this data normal) (meters 2) (new 'static 'rgba :r #xff :g #xff :a #x80))
|
||||
(add-debug-sphere #t (bucket-id debug) s5-0 (-> this bsphere w) (new 'static 'rgba :r #xff :a #x30))
|
||||
)
|
||||
(add-debug-bound (bucket-id debug) (-> this data points) (the-as int (-> this data num-points)) (new 'static 'rgba :r #x80 :g #x80 :a #x40) (new 'static 'rgba :r #x80 :a #x40) 0)
|
||||
))
|
||||
(add-debug-bound
|
||||
(bucket-id debug)
|
||||
(-> this data points)
|
||||
(the-as int (-> this data num-points))
|
||||
(new 'static 'rgba :r #x80 :g #x80 :a #x40)
|
||||
(new 'static 'rgba :r #x80 :a #x40)
|
||||
0
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
@ -7,3 +7,9 @@
|
||||
|
||||
;; DECOMP BEGINS
|
||||
|
||||
(kmemopen global "bigmap")
|
||||
|
||||
;; og:preserve-this
|
||||
(define-perm *bigmap* bigmap #f)
|
||||
|
||||
(kmemclose)
|
@ -1885,7 +1885,7 @@
|
||||
(while s3-0
|
||||
(let ((s4-0 (-> s3-0 next)))
|
||||
;; og:preserve-this not-yet-implemented check
|
||||
(when (or (and (nonzero? *bigmap*) (bigmap-method-11 *bigmap*)) (not (paused?)))
|
||||
(when (or (and *bigmap* (bigmap-method-11 *bigmap*)) (not (paused?)))
|
||||
(cond
|
||||
((logtest? (-> s3-0 flags) (minimap-flag fade-out))
|
||||
(logclear! (-> s3-0 flags) (minimap-flag fade-in))
|
||||
|
@ -453,7 +453,7 @@
|
||||
(process-spawn hud-ring-cell 11 (* -1.0 f30-0) 9 :name "hud-ring-cell" :to self)
|
||||
)
|
||||
(clear *stdcon1*)
|
||||
(if (nonzero? *bigmap*)
|
||||
(if *bigmap*
|
||||
(enable-drawing *bigmap*)
|
||||
)
|
||||
(set-setting! 'scanlines 'abs 0.0 0)
|
||||
@ -505,7 +505,7 @@
|
||||
(set! (-> *progress-work* hero-mode-save) #f)
|
||||
(remove-setting-by-arg0 *setting-control* 'extra-bank)
|
||||
;; og:preserve-this not-yet-implemented check
|
||||
(if (nonzero? *bigmap*) (disable-drawing *bigmap*))
|
||||
(if *bigmap* (disable-drawing *bigmap*))
|
||||
(set-menu-mode *blit-displays-work* #f)
|
||||
(set! *progress-process* (the-as (pointer progress) #f))
|
||||
(enable-level-text-file-loading)
|
||||
@ -1863,7 +1863,7 @@
|
||||
:virtual #t
|
||||
:code (behavior ()
|
||||
;; og:preserve-this not-yet-implemented check
|
||||
(if (nonzero? *bigmap*) (disable-drawing *bigmap*))
|
||||
(if *bigmap* (disable-drawing *bigmap*))
|
||||
(set-menu-mode *blit-displays-work* #f)
|
||||
(while (or (-> *blit-displays-work* screen-copied) (nonzero? (-> *blit-displays-work* count-down)))
|
||||
(suspend)
|
||||
|
@ -561,6 +561,9 @@
|
||||
(let ((s5-6 (-> this draw shadow-ctrl)))
|
||||
(when (!= *nav-enemy-dummy-shadow-control* s5-6)
|
||||
(let ((f0-10 (vector-vector-distance (camera-pos) (-> this root trans))))
|
||||
(#when PC_PORT ;; og:preserve-this shadow cull toggle
|
||||
(if (not (-> *pc-settings* ps2-shadow?))
|
||||
(set! f0-10 0.0)))
|
||||
(cond
|
||||
((< 163840.0 f0-10)
|
||||
(logior! (-> s5-6 settings flags) (shadow-flags disable-draw))
|
||||
|
@ -223,6 +223,10 @@
|
||||
(when (!= *vehicle-shadow-control-disabled* s5-0)
|
||||
(let ((s4-0 (new 'stack-no-clear 'inline-array 'vector 2)))
|
||||
(set! (-> s4-0 0 y) (vector-vector-xz-distance-squared (camera-pos) (-> this root trans)))
|
||||
;; og:preserve-this shadow cull toggle
|
||||
(#when PC_PORT
|
||||
(if (not (-> *pc-settings* ps2-shadow?))
|
||||
(set! (-> s4-0 0 y) 0.0)))
|
||||
(let ((f0-1 245760.0))
|
||||
(cond
|
||||
((< (* f0-1 f0-1) (-> s4-0 0 y))
|
||||
|
@ -126,7 +126,7 @@
|
||||
(set! (-> this minimap-temple) #f)
|
||||
)
|
||||
;; og:preserve-this not-yet-implemented check
|
||||
(if (nonzero? *bigmap*) (bigmap-method-16 *bigmap*))
|
||||
(if *bigmap* (bigmap-method-16 *bigmap*))
|
||||
(when (and (not (-> this rod-of-god))
|
||||
; (!= (-> *bigmap* load-index) 18)
|
||||
; (!= (-> *bigmap* load-index) 19)
|
||||
|
@ -179,6 +179,61 @@
|
||||
0)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; region debugging
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
|
||||
(define *debug-region-tree-name* #f)
|
||||
(define *debug-region-show-bsphere* #f)
|
||||
(define *debug-region-hide-water* #t)
|
||||
(define *debug-region-hide-empty* #t)
|
||||
|
||||
(deftype debug-region-color (structure)
|
||||
((enter rgba)
|
||||
(exit rgba))
|
||||
)
|
||||
|
||||
(define *debug-region-color-table* (new 'static 'inline-array debug-region-color 3
|
||||
(new 'static 'debug-region-color :enter (static-rgba #xff #xff #x00 #x80) :exit (static-rgba #xff #x00 #x00 #x80))
|
||||
(new 'static 'debug-region-color :enter (static-rgba #x00 #xff #x00 #x80) :exit (static-rgba #xff #x00 #xff #x80))
|
||||
(new 'static 'debug-region-color :enter (static-rgba #x00 #xff #xff #x80) :exit (static-rgba #x00 #x00 #xff #x80))
|
||||
))
|
||||
|
||||
|
||||
(defmacro rgba-with-a (color a)
|
||||
"return a color but with alpha set to a"
|
||||
`(begin
|
||||
(let ((newcol ,color))
|
||||
(set! (-> newcol a) ,a)
|
||||
newcol)))
|
||||
|
||||
(defun-debug get-region-enter-color ((name symbol) (alpha int))
|
||||
(rgba-with-a (case name
|
||||
(('target) (-> *debug-region-color-table* 0 enter))
|
||||
(('camera) (-> *debug-region-color-table* 1 enter))
|
||||
(('water) (-> *debug-region-color-table* 2 enter))
|
||||
(else (-> *debug-region-color-table* 0 enter)))
|
||||
alpha))
|
||||
|
||||
(defun-debug get-region-exit-color ((name symbol) (alpha int))
|
||||
(rgba-with-a (case name
|
||||
(('target) (-> *debug-region-color-table* 0 exit))
|
||||
(('camera) (-> *debug-region-color-table* 1 exit))
|
||||
(('water) (-> *debug-region-color-table* 2 exit))
|
||||
(else (-> *debug-region-color-table* 0 exit)))
|
||||
alpha))
|
||||
|
||||
(defmacro region-enter-color (alpha)
|
||||
"return color for the enter side of this region"
|
||||
`(get-region-enter-color *debug-region-tree-name* ,alpha))
|
||||
(defmacro region-exit-color (alpha)
|
||||
"return color for the exit side of this region"
|
||||
`(get-region-exit-color *debug-region-tree-name* ,alpha))
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; other
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
@ -186,10 +241,6 @@
|
||||
|
||||
|
||||
(define *hires-sky* #t)
|
||||
(define *debug-region-color-alt* #t)
|
||||
(define *debug-region-show-bsphere* #f)
|
||||
(define *debug-region-hide-water* #t)
|
||||
(define *debug-region-hide-empty* #t)
|
||||
(define *fallback-text-lookup?* #t)
|
||||
|
||||
|
||||
|
6
test/decompiler/reference/jak3/engine/level/region-h_REF.gc
generated
vendored
6
test/decompiler/reference/jak3/engine/level/region-h_REF.gc
generated
vendored
@ -86,7 +86,7 @@ Note that all child classes of this must be 32-bytes."
|
||||
;; definition of type drawable-tree-region-prim
|
||||
(deftype drawable-tree-region-prim (drawable-tree)
|
||||
"Top-level container for all regions of a level."
|
||||
((name basic :offset 8)
|
||||
((name symbol :offset 8)
|
||||
(data2 drawable-inline-array :dynamic :offset 32)
|
||||
)
|
||||
(:methods
|
||||
@ -260,7 +260,3 @@ exactly the same size as the parent, so it's okay."
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user