diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 7e52a48b3..656f88a0d 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -610,6 +610,9 @@ :bitfield #t :type uint32 (display 0) + (draw-line 1) ;; TODO - only seen it used to control debug drawing so far + (draw-point 2) ;; TODO - only seen it used to control debug drawing so far + (draw-text 3) ;; TODO - only seen it used to control debug drawing so far (not-found 4) ) @@ -14121,35 +14124,34 @@ (deftype path-control (basic) ((flags path-control-flag :offset-assert 4) - (name basic :offset-assert 8) - (process basic :offset-assert 12) + (name symbol :offset-assert 8) + (process process-drawable :offset-assert 12) (curve curve :inline :offset-assert 16) (num-cverts int32 :offset 20) - (cverts pointer :offset 16) + (cverts (inline-array vector) :score 100 :offset 16) ) :method-count-assert 21 :size-assert #x24 :flag-assert #x1500000024 (:methods (new (symbol type process symbol float) _type_) - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) - (dummy-14 () none 14) + (dummy-9 (_type_) none 9) + (eval-path-curve-div! (_type_ vector float symbol) vector 10) + (get-random-point (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ vector float) vector 12) + (eval-path-curve! (_type_ vector float symbol) vector 13) + (TODO-RENAME-14 (_type_ vector float) vector 14) (length-as-float (_type_) float 15) - (dummy-16 () none 16) + (path-distance (_type_) float 16) (get-num-verts (_type_) int 17) (should-display? (_type_) symbol 18) - (dummy-19 () none 19) - (dummy-20 () none 20) + (TODO-RENAME-19 (_type_) float 19) + (TODO-RENAME-20 (_type_) float 20) ) ) (deftype curve-control (path-control) () - (:methods (new (symbol type process symbol float) _type_) ) @@ -15088,7 +15090,7 @@ (define-extern add-debug-rot-matrix (function symbol bucket-id matrix vector matrix)) (define-extern add-debug-yrot-vector (function symbol bucket-id vector float float rgba symbol)) (define-extern add-debug-arc (function symbol bucket-id vector float float float rgba matrix symbol)) -(define-extern add-debug-curve2 (function symbol bucket-id curve rgba symbol)) +(define-extern add-debug-curve2 (function symbol bucket-id curve rgba symbol symbol)) (define-extern add-debug-points (function symbol bucket-id (inline-array vector) int rgba float int symbol)) ;; unused (define-extern debug-percent-bar (function symbol bucket-id int int float rgba symbol)) (define-extern debug-pad-display (function cpad-info symbol)) ;; unused diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 0c313ea2b..b9f31659f 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1166,6 +1166,14 @@ "memory-usage": [ ["L15", "_lambda_", true] ], + + "path": [ + ["L47", "float", true], + ["L49", "float", true], + ["L78", "rgba", true], + ["L79", "rgba", true] + ], + // please do not add things after this entry! git is dumb. "object-file-that-doesnt-actually-exist-and-i-just-put-this-here-to-prevent-merge-conflicts-with-this-file": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index bb1130a4e..82a5c0ad2 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -529,5 +529,16 @@ [16, "sphere"] ], + "(method 14 curve-control)": [ + [16, "vector"] + ], + + "(method 19 path-control)": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [64, "vector"] + ], + "placeholder-do-not-add-below!": [] } diff --git a/goal_src/engine/debug/debug.gc b/goal_src/engine/debug/debug.gc index 83ac3ff0e..c1b0567f0 100644 --- a/goal_src/engine/debug/debug.gc +++ b/goal_src/engine/debug/debug.gc @@ -1332,7 +1332,7 @@ #f ) -(defun-debug add-debug-curve2 ((arg0 symbol) (arg1 bucket-id) (arg2 curve) (arg3 rgba)) +(defun-debug add-debug-curve2 ((arg0 symbol) (arg1 bucket-id) (arg2 curve) (arg3 rgba) (arg4 symbol)) (if arg0 (add-debug-curve #t diff --git a/goal_src/engine/nav/path-h.gc b/goal_src/engine/nav/path-h.gc index e40c1b346..3f979d207 100644 --- a/goal_src/engine/nav/path-h.gc +++ b/goal_src/engine/nav/path-h.gc @@ -6,39 +6,42 @@ ;; dgos: GAME, ENGINE (defenum path-control-flag - :bitfield #t - :type uint32 - (display 0) - (not-found 4) - ) + :bitfield #t + :type uint32 + (display 0) + (draw-line 1) ;; TODO - only seen it used to control debug drawing so far + (draw-point 2) ;; TODO - only seen it used to control debug drawing so far + (draw-text 3) ;; TODO - only seen it used to control debug drawing so far + (not-found 4) + ) ;; A path-control is a curve that can be loaded from res-lump/entities. (deftype path-control (basic) - ((flags path-control-flag :offset-assert 4) - (name basic :offset-assert 8) - (process basic :offset-assert 12) - (curve curve :inline :offset-assert 16) - (num-cverts int32 :offset 20) - (cverts pointer :offset 16) + ((flags path-control-flag :offset-assert 4) + (name symbol :offset-assert 8) + (process process-drawable :offset-assert 12) + (curve curve :inline :offset-assert 16) + (num-cverts int32 :offset 20) + (cverts (inline-array vector) :score 100 :offset 16) ) :method-count-assert 21 :size-assert #x24 :flag-assert #x1500000024 (:methods - (new (symbol type process symbol float) _type_ 0) - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) - (dummy-14 () none 14) - (length-as-float (_type_) float 15) - (dummy-16 () none 16) - (get-num-verts (_type_) int 17) - (should-display? (_type_) symbol 18) - (dummy-19 () none 19) - (dummy-20 () none 20) - ) + (new (symbol type process symbol float) _type_) + (dummy-9 (_type_) none 9) + (eval-path-curve-div! (_type_ vector float symbol) vector 10) + (get-random-point (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ vector float) vector 12) + (eval-path-curve! (_type_ vector float symbol) vector 13) + (TODO-RENAME-14 (_type_ vector float) vector 14) + (length-as-float (_type_) float 15) + (path-distance (_type_) float 16) + (get-num-verts (_type_) int 17) + (should-display? (_type_) symbol 18) + (TODO-RENAME-19 (_type_) float 19) + (TODO-RENAME-20 (_type_) float 20) + ) ) ;; A curve-control is very similar, but also gets knots. @@ -63,7 +66,7 @@ (goto cfg-9) ) - (set! (-> obj process) proc) + (set! (-> obj process) (the-as process-drawable proc)) (set! (-> obj name) name) (let ((ent (-> proc entity))) (when (= name 'path) @@ -128,7 +131,7 @@ (defmethod new curve-control ((allocation symbol) (type-to-make type) (proc process) (name symbol) (time float)) (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) - (set! (-> obj process) proc) + (set! (-> obj process) (the-as process-drawable proc)) (set! (-> obj name) name) (let* ((ent (the-as entity (-> proc entity))) (v1-2 name) diff --git a/goal_src/engine/nav/path.gc b/goal_src/engine/nav/path.gc index c86e5cb5c..358bd9223 100644 --- a/goal_src/engine/nav/path.gc +++ b/goal_src/engine/nav/path.gc @@ -5,3 +5,463 @@ ;; name in dgo: path ;; dgos: GAME, ENGINE +;; definition for method 9 of type path-control +;; INFO: Return type mismatch int vs none. +(defmethod dummy-9 path-control ((obj path-control)) + (cond + ((nonzero? (logand (-> obj flags) (path-control-flag not-found))) + (when + (and + (type-type? (-> obj process type) process-drawable) + *display-entity-errors* + ) + (let ((s5-0 add-debug-text-3d) + (s4-0 #t) + (s3-0 68) + ) + (format + (clear *temp-string*) + "path data error in ~S" + (-> obj process name) + ) + (s5-0 + s4-0 + (the-as bucket-id s3-0) + *temp-string* + (-> obj process root trans) + (new 'static 'rgba :r #x3) + (the-as vector2h #f) + ) + ) + ) + ) + ((let ((a0-5 obj)) + (and + *display-path-marks* + (nonzero? (logand (-> a0-5 flags) (path-control-flag display))) + ) + ) + (dotimes (s5-1 (-> obj curve num-cverts)) + (let ((s4-1 (-> obj cverts s5-1))) + (if + (and + (nonzero? (logand (-> obj flags) (path-control-flag draw-line))) + (< s5-1 (+ (-> obj curve num-cverts) -1)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + s4-1 + (-> obj cverts (+ s5-1 1)) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + #f + (the-as rgba -1) + ) + ) + (if (nonzero? (logand (-> obj flags) (path-control-flag draw-point))) + (add-debug-x + #t + (bucket-id debug-draw1) + s4-1 + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (nonzero? (logand (-> obj flags) (path-control-flag draw-text))) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-0 68) + ) + (format (clear *temp-string*) "~D" s5-1) + (s3-1 + s2-1 + (the-as bucket-id s1-0) + *temp-string* + s4-1 + (new 'static 'rgba :r #x4) + (the-as vector2h #f) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 16 of type path-control +(defmethod path-distance path-control ((obj path-control)) + (let ((f30-0 0.0)) + (dotimes (s5-0 (+ (-> obj curve num-cverts) -1)) + (+! + f30-0 + (vector-vector-distance (-> obj cverts s5-0) (-> obj cverts (+ s5-0 1))) + ) + ) + f30-0 + ) + ) + +;; definition for method 16 of type curve-control +(defmethod path-distance curve-control ((obj curve-control)) + (let ((f0-0 (-> obj curve length))) + (when (= f0-0 0.0) + (set! f0-0 (curve-length (the-as curve (&-> obj cverts)))) + (set! (-> obj curve length) f0-0) + ) + f0-0 + ) + ) + +;; definition for method 10 of type path-control +;; Used lq/sq +(defmethod + eval-path-curve-div! + path-control + ((obj path-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (let ((a1-1 (-> obj curve num-cverts)) + (f0-3 (the float (the int arg1))) + ) + (cond + ((< arg1 0.0) + (set! (-> arg0 quad) (-> obj cverts 0 quad)) + ) + ((>= f0-3 (the float (+ a1-1 -1))) + (set! (-> arg0 quad) (-> obj cverts (+ a1-1 -1) quad)) + ) + (else + (if (or (= arg2 'exact) (= f0-3 arg1)) + (set! (-> arg0 quad) (-> obj cverts (the int f0-3) quad)) + (vector-lerp! + arg0 + (-> obj cverts (the int f0-3)) + (-> obj cverts (the int (+ 1.0 f0-3))) + (- arg1 f0-3) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for method 11 of type path-control +;; Used lq/sq +(defmethod get-random-point path-control ((obj path-control) (arg0 vector)) + (with-pp + (cond + ((> (-> obj curve num-cverts) 0) + (let ((s4-0 (rand-vu-int-count (-> obj curve num-cverts)))) + (when *run-time-assert-enable* + (set-pos *__private-assert-info* "path" (the-as uint 83) (the-as uint 6)) + (__assert-zero-lim-range-int + s4-0 + (-> obj curve num-cverts) + "rand-index" + "(-> obj num-cverts)" + ) + ) + (set! (-> arg0 quad) (-> obj cverts s4-0 quad)) + ) + ) + (else + (format + #t + "WARNING: method get-random-point called on a path-control object with no vertices.~%" + ) + (if pp + (format #t "current process is ~A~%" (-> pp name)) + ) + (set! (-> arg0 quad) (-> *null-vector* quad)) + ) + ) + arg0 + ) + ) + +;; definition for method 13 of type path-control +(defmethod + eval-path-curve! + path-control + ((obj path-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (eval-path-curve-div! + obj + arg0 + (* arg1 (the float (+ (-> obj curve num-cverts) -1))) + arg2 + ) + ) + +;; definition for method 13 of type curve-control +;; INFO: Return type mismatch object vs vector. +(defmethod + eval-path-curve! + curve-control + ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (the-as + vector + (if (nonzero? (logand (-> obj flags) (path-control-flag not-found))) + 0.0 + (curve-evaluate! + arg0 + arg1 + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + ) + ) + ) + +;; definition for method 10 of type curve-control +;; INFO: Return type mismatch object vs vector. +(defmethod + eval-path-curve-div! + curve-control + ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (the-as + vector + (if (nonzero? (logand (-> obj flags) (path-control-flag not-found))) + 0.0 + (curve-evaluate! + arg0 + (/ arg1 (the float (+ (-> obj curve num-cverts) -1))) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + ) + ) + ) + +;; definition for method 12 of type path-control +(defmethod + TODO-RENAME-12 + path-control + ((obj path-control) (arg0 vector) (arg1 float)) + (when (zero? (logand (-> obj flags) (path-control-flag not-found))) + (let ((v1-3 (-> obj curve num-cverts)) + (f0-3 (the float (the int arg1))) + ) + (cond + ((< v1-3 2) + ) + ((< arg1 0.0) + (vector-! arg0 (-> obj cverts 1) (-> obj cverts 0)) + ) + (else + (let ((f0-4 (fmin f0-3 (the float (+ v1-3 -2))))) + (vector-! + arg0 + (-> obj cverts (the int (+ 1.0 f0-4))) + (-> obj cverts (the int f0-4)) + ) + ) + ) + ) + ) + ) + (vector-normalize! arg0 1.0) + ) + +;; definition for method 14 of type path-control +(defmethod + TODO-RENAME-14 + path-control + ((obj path-control) (arg0 vector) (arg1 float)) + (TODO-RENAME-12 + obj + arg0 + (* arg1 (the float (+ (-> obj curve num-cverts) -1))) + ) + ) + +;; definition for method 14 of type curve-control +(defmethod + TODO-RENAME-14 + curve-control + ((obj curve-control) (arg0 vector) (arg1 float)) + (when (zero? (logand (-> obj flags) (path-control-flag not-found))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (curve-evaluate! + arg0 + arg1 + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (cond + ((< arg1 0.99) + (curve-evaluate! + s4-0 + (+ 0.01 arg1) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (vector-! arg0 s4-0 arg0) + ) + (else + (curve-evaluate! + s4-0 + (+ -0.01 arg1) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (vector-! arg0 arg0 s4-0) + ) + ) + ) + ) + (vector-normalize! arg0 1.0) + ) + +;; definition for method 12 of type curve-control +(defmethod + TODO-RENAME-12 + curve-control + ((obj curve-control) (arg0 vector) (arg1 float)) + (TODO-RENAME-14 + obj + arg0 + (/ arg1 (the float (+ (-> obj curve num-cverts) -1))) + ) + ) + +;; definition for method 19 of type path-control +;; Used lq/sq +(defmethod TODO-RENAME-19 path-control ((obj path-control)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (f30-0 4096000000.0) + (f28-0 0.0) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (set! (-> s3-0 quad) (-> (target-pos 0) quad)) + (set! (-> s3-0 y) 0.0) + (eval-path-curve-div! obj s4-0 0.0 'interp) + (set! (-> s4-0 y) 0.0) + (dotimes (s1-1 (+ (-> obj curve num-cverts) -1)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (eval-path-curve-div! obj s4-0 (the float (+ s1-1 1)) 'interp) + (set! (-> s4-0 y) 0.0) + (let ((f0-5 (vector-segment-distance-point! s3-0 s5-0 s4-0 s2-0))) + (when (< f0-5 f30-0) + (set! f30-0 f0-5) + (set! + f28-0 + (+ + (/ + (vector-vector-xz-distance s2-0 s5-0) + (vector-vector-xz-distance s4-0 s5-0) + ) + (the float s1-1) + ) + ) + ) + ) + ) + ) + f28-0 + ) + ) + +;; definition for method 20 of type path-control +(defmethod TODO-RENAME-20 path-control ((obj path-control)) + (/ (TODO-RENAME-19 obj) (the float (+ (-> obj curve num-cverts) -1))) + ) + +;; definition for method 9 of type curve-control +;; INFO: Return type mismatch int vs none. +(defmethod dummy-9 curve-control ((obj curve-control)) + (cond + ((nonzero? (logand (-> obj flags) (path-control-flag not-found))) + (when + (and + (type-type? (-> obj process type) process-drawable) + *display-entity-errors* + ) + (let ((s5-0 add-debug-text-3d) + (s4-0 #t) + (s3-0 68) + ) + (format + (clear *temp-string*) + "curve data error in ~S" + (-> obj process name) + ) + (s5-0 + s4-0 + (the-as bucket-id s3-0) + *temp-string* + (-> obj process root trans) + (new 'static 'rgba :r #x3) + (the-as vector2h #f) + ) + ) + ) + ) + ((let ((a0-5 obj)) + (and + *display-path-marks* + (nonzero? (logand (-> a0-5 flags) (path-control-flag display))) + ) + ) + (if + (and + (nonzero? (logand (-> obj flags) (path-control-flag draw-line))) + (> (-> obj curve num-cverts) 0) + ) + (add-debug-curve2 + #t + (bucket-id debug-draw1) + (the-as curve (&-> obj cverts)) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + #f + ) + ) + (dotimes (s5-1 (-> obj curve num-cverts)) + (let ((s4-1 (-> obj cverts s5-1))) + (if (nonzero? (logand (-> obj flags) (path-control-flag draw-point))) + (add-debug-x + #t + (bucket-id debug-draw1) + s4-1 + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (nonzero? (logand (-> obj flags) (path-control-flag draw-text))) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-0 68) + ) + (format (clear *temp-string*) "~D" s5-1) + (s3-1 + s2-1 + (the-as bucket-id s1-0) + *temp-string* + s4-1 + (new 'static 'rgba :r #x4) + (the-as vector2h #f) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + + + + diff --git a/test/decompiler/reference/engine/nav/path-h_REF.gc b/test/decompiler/reference/engine/nav/path-h_REF.gc index d435d8522..65b2e517f 100644 --- a/test/decompiler/reference/engine/nav/path-h_REF.gc +++ b/test/decompiler/reference/engine/nav/path-h_REF.gc @@ -3,30 +3,30 @@ ;; definition of type path-control (deftype path-control (basic) - ((flags path-control-flag :offset-assert 4) - (name basic :offset-assert 8) - (process basic :offset-assert 12) - (curve curve :inline :offset-assert 16) - (num-cverts int32 :offset 20) - (cverts pointer :offset 16) + ((flags path-control-flag :offset-assert 4) + (name symbol :offset-assert 8) + (process process-drawable :offset-assert 12) + (curve curve :inline :offset-assert 16) + (num-cverts int32 :offset 20) + (cverts (inline-array vector) :offset 16) ) :method-count-assert 21 :size-assert #x24 :flag-assert #x1500000024 (:methods (new (symbol type process symbol float) _type_ 0) - (dummy-9 () none 9) - (dummy-10 () none 10) - (dummy-11 () none 11) - (dummy-12 () none 12) - (dummy-13 () none 13) - (dummy-14 () none 14) + (dummy-9 (_type_) none 9) + (eval-path-curve-div! (_type_ vector float symbol) vector 10) + (get-random-point (_type_ vector) vector 11) + (TODO-RENAME-12 (_type_ vector float) vector 12) + (eval-path-curve! (_type_ vector float symbol) vector 13) + (TODO-RENAME-14 (_type_ vector float) vector 14) (length-as-float (_type_) float 15) - (dummy-16 () none 16) + (path-distance (_type_) float 16) (get-num-verts (_type_) int 17) (should-display? (_type_) symbol 18) - (dummy-19 () none 19) - (dummy-20 () none 20) + (TODO-RENAME-19 (_type_) float 19) + (TODO-RENAME-20 (_type_) float 20) ) ) @@ -36,9 +36,9 @@ (format #t "~Tflags: #x~X~%" (-> obj flags)) (format #t "~Tname: ~A~%" (-> obj name)) (format #t "~Tprocess: ~A~%" (-> obj process)) - (format #t "~Tcurve: #~%" (-> obj curve)) + (format #t "~Tcurve: #~%" (&-> obj cverts)) (format #t "~Tnum-cverts: ~D~%" (-> obj curve num-cverts)) - (format #t "~Tcverts: #x~X~%" (-> obj curve cverts)) + (format #t "~Tcverts: #x~X~%" (-> obj cverts)) obj ) @@ -59,9 +59,9 @@ (format #t "~Tflags: #x~X~%" (-> obj flags)) (format #t "~Tname: ~A~%" (-> obj name)) (format #t "~Tprocess: ~A~%" (-> obj process)) - (format #t "~Tcurve: #~%" (-> obj curve)) + (format #t "~Tcurve: #~%" (&-> obj cverts)) (format #t "~Tnum-cverts: ~D~%" (-> obj curve num-cverts)) - (format #t "~Tcverts: #x~X~%" (-> obj curve cverts)) + (format #t "~Tcverts: #x~X~%" (-> obj cverts)) obj ) @@ -96,7 +96,7 @@ (goto cfg-9) ) ) - (set! (-> obj process) proc) + (set! (-> obj process) (the-as process-drawable proc)) (set! (-> obj name) name) (let ((ent (-> proc entity))) (when (= name 'path) @@ -122,7 +122,7 @@ ) (cond (data - (set! (-> obj curve cverts) data) + (set! (-> obj cverts) (the-as (inline-array vector) data)) (set! (-> obj curve num-cverts) (the-as int (-> tag elt-count))) ) (else @@ -130,7 +130,7 @@ (-> obj flags) (logior (-> obj flags) (path-control-flag not-found)) ) - (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj cverts) (the-as (inline-array vector) #f)) (set! (-> obj curve num-cverts) 0) 0 ) @@ -176,7 +176,7 @@ (object-new allocation type-to-make (the-as int (-> type-to-make size))) ) ) - (set! (-> obj process) proc) + (set! (-> obj process) (the-as process-drawable proc)) (set! (-> obj name) name) (let* ((ent (-> proc entity)) (v1-2 name) @@ -198,7 +198,8 @@ (set! ent lookup-entity) ) ) - (when (not (get-curve-data! ent (-> obj curve) name s2-0 time)) + (when + (not (get-curve-data! ent (the-as curve (&-> obj cverts)) name s2-0 time)) (cond ((> (-> obj curve num-cverts) 0) (set! (-> obj type) path-control) @@ -208,7 +209,7 @@ (-> obj flags) (logior (-> obj flags) (path-control-flag not-found)) ) - (set! (-> obj curve cverts) (the-as pointer #f)) + (set! (-> obj cverts) (the-as (inline-array vector) #f)) (set! (-> obj curve num-cverts) 0) 0 ) diff --git a/test/decompiler/reference/engine/nav/path_REF.gc b/test/decompiler/reference/engine/nav/path_REF.gc new file mode 100644 index 000000000..24b5c0032 --- /dev/null +++ b/test/decompiler/reference/engine/nav/path_REF.gc @@ -0,0 +1,463 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 9 of type path-control +;; INFO: Return type mismatch int vs none. +(defmethod dummy-9 path-control ((obj path-control)) + (cond + ((nonzero? (logand (-> obj flags) (path-control-flag not-found))) + (when + (and + (type-type? (-> obj process type) process-drawable) + *display-entity-errors* + ) + (let ((s5-0 add-debug-text-3d) + (s4-0 #t) + (s3-0 68) + ) + (format + (clear *temp-string*) + "path data error in ~S" + (-> obj process name) + ) + (s5-0 + s4-0 + (the-as bucket-id s3-0) + *temp-string* + (-> obj process root trans) + (new 'static 'rgba :r #x3) + (the-as vector2h #f) + ) + ) + ) + ) + ((let ((a0-5 obj)) + (and + *display-path-marks* + (nonzero? (logand (-> a0-5 flags) (path-control-flag display))) + ) + ) + (dotimes (s5-1 (-> obj curve num-cverts)) + (let ((s4-1 (-> obj cverts s5-1))) + (if + (and + (nonzero? (logand (-> obj flags) (path-control-flag draw-line))) + (< s5-1 (+ (-> obj curve num-cverts) -1)) + ) + (add-debug-line + #t + (bucket-id debug-draw1) + s4-1 + (-> obj cverts (+ s5-1 1)) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + #f + (the-as rgba -1) + ) + ) + (if (nonzero? (logand (-> obj flags) (path-control-flag draw-point))) + (add-debug-x + #t + (bucket-id debug-draw1) + s4-1 + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (nonzero? (logand (-> obj flags) (path-control-flag draw-text))) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-0 68) + ) + (format (clear *temp-string*) "~D" s5-1) + (s3-1 + s2-1 + (the-as bucket-id s1-0) + *temp-string* + s4-1 + (new 'static 'rgba :r #x4) + (the-as vector2h #f) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 16 of type path-control +(defmethod path-distance path-control ((obj path-control)) + (let ((f30-0 0.0)) + (dotimes (s5-0 (+ (-> obj curve num-cverts) -1)) + (+! + f30-0 + (vector-vector-distance (-> obj cverts s5-0) (-> obj cverts (+ s5-0 1))) + ) + ) + f30-0 + ) + ) + +;; definition for method 16 of type curve-control +(defmethod path-distance curve-control ((obj curve-control)) + (let ((f0-0 (-> obj curve length))) + (when (= f0-0 0.0) + (set! f0-0 (curve-length (the-as curve (&-> obj cverts)))) + (set! (-> obj curve length) f0-0) + ) + f0-0 + ) + ) + +;; definition for method 10 of type path-control +;; Used lq/sq +(defmethod + eval-path-curve-div! + path-control + ((obj path-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (let ((a1-1 (-> obj curve num-cverts)) + (f0-3 (the float (the int arg1))) + ) + (cond + ((< arg1 0.0) + (set! (-> arg0 quad) (-> obj cverts 0 quad)) + ) + ((>= f0-3 (the float (+ a1-1 -1))) + (set! (-> arg0 quad) (-> obj cverts (+ a1-1 -1) quad)) + ) + (else + (if (or (= arg2 'exact) (= f0-3 arg1)) + (set! (-> arg0 quad) (-> obj cverts (the int f0-3) quad)) + (vector-lerp! + arg0 + (-> obj cverts (the int f0-3)) + (-> obj cverts (the int (+ 1.0 f0-3))) + (- arg1 f0-3) + ) + ) + ) + ) + ) + arg0 + ) + +;; definition for method 11 of type path-control +;; Used lq/sq +(defmethod get-random-point path-control ((obj path-control) (arg0 vector)) + (with-pp + (cond + ((> (-> obj curve num-cverts) 0) + (let ((s4-0 (rand-vu-int-count (-> obj curve num-cverts)))) + (when *run-time-assert-enable* + (set-pos *__private-assert-info* "path" (the-as uint 83) (the-as uint 6)) + (__assert-zero-lim-range-int + s4-0 + (-> obj curve num-cverts) + "rand-index" + "(-> obj num-cverts)" + ) + ) + (set! (-> arg0 quad) (-> obj cverts s4-0 quad)) + ) + ) + (else + (format + #t + "WARNING: method get-random-point called on a path-control object with no vertices.~%" + ) + (if pp + (format #t "current process is ~A~%" (-> pp name)) + ) + (set! (-> arg0 quad) (-> *null-vector* quad)) + ) + ) + arg0 + ) + ) + +;; definition for method 13 of type path-control +(defmethod + eval-path-curve! + path-control + ((obj path-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (eval-path-curve-div! + obj + arg0 + (* arg1 (the float (+ (-> obj curve num-cverts) -1))) + arg2 + ) + ) + +;; definition for method 13 of type curve-control +;; INFO: Return type mismatch object vs vector. +(defmethod + eval-path-curve! + curve-control + ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (the-as + vector + (if (nonzero? (logand (-> obj flags) (path-control-flag not-found))) + 0.0 + (curve-evaluate! + arg0 + arg1 + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + ) + ) + ) + +;; definition for method 10 of type curve-control +;; INFO: Return type mismatch object vs vector. +(defmethod + eval-path-curve-div! + curve-control + ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol)) + (the-as + vector + (if (nonzero? (logand (-> obj flags) (path-control-flag not-found))) + 0.0 + (curve-evaluate! + arg0 + (/ arg1 (the float (+ (-> obj curve num-cverts) -1))) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + ) + ) + ) + +;; definition for method 12 of type path-control +(defmethod + TODO-RENAME-12 + path-control + ((obj path-control) (arg0 vector) (arg1 float)) + (when (zero? (logand (-> obj flags) (path-control-flag not-found))) + (let ((v1-3 (-> obj curve num-cverts)) + (f0-3 (the float (the int arg1))) + ) + (cond + ((< v1-3 2) + ) + ((< arg1 0.0) + (vector-! arg0 (-> obj cverts 1) (-> obj cverts 0)) + ) + (else + (let ((f0-4 (fmin f0-3 (the float (+ v1-3 -2))))) + (vector-! + arg0 + (-> obj cverts (the int (+ 1.0 f0-4))) + (-> obj cverts (the int f0-4)) + ) + ) + ) + ) + ) + ) + (vector-normalize! arg0 1.0) + ) + +;; definition for method 14 of type path-control +(defmethod + TODO-RENAME-14 + path-control + ((obj path-control) (arg0 vector) (arg1 float)) + (TODO-RENAME-12 + obj + arg0 + (* arg1 (the float (+ (-> obj curve num-cverts) -1))) + ) + ) + +;; definition for method 14 of type curve-control +(defmethod + TODO-RENAME-14 + curve-control + ((obj curve-control) (arg0 vector) (arg1 float)) + (when (zero? (logand (-> obj flags) (path-control-flag not-found))) + (let ((s4-0 (new 'stack-no-clear 'vector))) + (curve-evaluate! + arg0 + arg1 + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (cond + ((< arg1 0.99) + (curve-evaluate! + s4-0 + (+ 0.01 arg1) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (vector-! arg0 s4-0 arg0) + ) + (else + (curve-evaluate! + s4-0 + (+ -0.01 arg1) + (the-as pointer (-> obj cverts)) + (-> obj curve num-cverts) + (-> obj curve knots) + (-> obj curve num-knots) + ) + (vector-! arg0 arg0 s4-0) + ) + ) + ) + ) + (vector-normalize! arg0 1.0) + ) + +;; definition for method 12 of type curve-control +(defmethod + TODO-RENAME-12 + curve-control + ((obj curve-control) (arg0 vector) (arg1 float)) + (TODO-RENAME-14 + obj + arg0 + (/ arg1 (the float (+ (-> obj curve num-cverts) -1))) + ) + ) + +;; definition for method 19 of type path-control +;; Used lq/sq +(defmethod TODO-RENAME-19 path-control ((obj path-control)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + (s3-0 (new 'stack-no-clear 'vector)) + (f30-0 4096000000.0) + (f28-0 0.0) + ) + (let ((s2-0 (new 'stack-no-clear 'vector))) + (set! (-> s3-0 quad) (-> (target-pos 0) quad)) + (set! (-> s3-0 y) 0.0) + (eval-path-curve-div! obj s4-0 0.0 'interp) + (set! (-> s4-0 y) 0.0) + (dotimes (s1-1 (+ (-> obj curve num-cverts) -1)) + (set! (-> s5-0 quad) (-> s4-0 quad)) + (eval-path-curve-div! obj s4-0 (the float (+ s1-1 1)) 'interp) + (set! (-> s4-0 y) 0.0) + (let ((f0-5 (vector-segment-distance-point! s3-0 s5-0 s4-0 s2-0))) + (when (< f0-5 f30-0) + (set! f30-0 f0-5) + (set! + f28-0 + (+ + (/ + (vector-vector-xz-distance s2-0 s5-0) + (vector-vector-xz-distance s4-0 s5-0) + ) + (the float s1-1) + ) + ) + ) + ) + ) + ) + f28-0 + ) + ) + +;; definition for method 20 of type path-control +(defmethod TODO-RENAME-20 path-control ((obj path-control)) + (/ (TODO-RENAME-19 obj) (the float (+ (-> obj curve num-cverts) -1))) + ) + +;; definition for method 9 of type curve-control +;; INFO: Return type mismatch int vs none. +(defmethod dummy-9 curve-control ((obj curve-control)) + (cond + ((nonzero? (logand (-> obj flags) (path-control-flag not-found))) + (when + (and + (type-type? (-> obj process type) process-drawable) + *display-entity-errors* + ) + (let ((s5-0 add-debug-text-3d) + (s4-0 #t) + (s3-0 68) + ) + (format + (clear *temp-string*) + "curve data error in ~S" + (-> obj process name) + ) + (s5-0 + s4-0 + (the-as bucket-id s3-0) + *temp-string* + (-> obj process root trans) + (new 'static 'rgba :r #x3) + (the-as vector2h #f) + ) + ) + ) + ) + ((let ((a0-5 obj)) + (and + *display-path-marks* + (nonzero? (logand (-> a0-5 flags) (path-control-flag display))) + ) + ) + (if + (and + (nonzero? (logand (-> obj flags) (path-control-flag draw-line))) + (> (-> obj curve num-cverts) 0) + ) + (add-debug-curve2 + #t + (bucket-id debug-draw1) + (the-as curve (&-> obj cverts)) + (new 'static 'rgba :r #xff :g #x80 :a #x80) + #f + ) + ) + (dotimes (s5-1 (-> obj curve num-cverts)) + (let ((s4-1 (-> obj cverts s5-1))) + (if (nonzero? (logand (-> obj flags) (path-control-flag draw-point))) + (add-debug-x + #t + (bucket-id debug-draw1) + s4-1 + (new 'static 'rgba :r #xff :a #x80) + ) + ) + (when (nonzero? (logand (-> obj flags) (path-control-flag draw-text))) + (let ((s3-1 add-debug-text-3d) + (s2-1 #t) + (s1-0 68) + ) + (format (clear *temp-string*) "~D" s5-1) + (s3-1 + s2-1 + (the-as bucket-id s1-0) + *temp-string* + s4-1 + (new 'static 'rgba :r #x4) + (the-as vector2h #f) + ) + ) + ) + ) + ) + ) + ) + 0 + (none) + ) + + + +