mirror of
https://github.com/open-goal/jak-project
synced 2026-08-03 08:53:42 -04:00
d/jak2: finish drawable-group | drawable-inline-array | drawable-tree and path (#1899)
This commit is contained in:
+1
-1
@@ -149,7 +149,7 @@
|
||||
;; definition for function close-sky-buffer
|
||||
;; INFO: Used lq/sq
|
||||
;; INFO: Return type mismatch pointer vs none.
|
||||
;; WARN: Function may read a register that is not set: ra
|
||||
;; ERROR: Function may read a register that is not set: ra
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
|
||||
(defun close-sky-buffer ((arg0 dma-buffer))
|
||||
(local-vars (ra-0 none))
|
||||
|
||||
+1
-1
@@ -396,7 +396,7 @@
|
||||
|
||||
;; definition for function bsp-camera-asm
|
||||
;; INFO: Return type mismatch int vs none.
|
||||
;; WARN: Function may read a register that is not set: a2
|
||||
;; ERROR: Function may read a register that is not set: a2
|
||||
(defun bsp-camera-asm ((bsp-hdr bsp-header) (camera-pos vector))
|
||||
(local-vars (v1-1 float) (real-node bsp-node))
|
||||
(rlet ((vf1 :class vf)
|
||||
|
||||
+1
-1
@@ -873,7 +873,7 @@
|
||||
;; definition for function race-time-save
|
||||
;; ERROR: Type Propagation failed: Failed type prop at op 6 ((set! v1 (l.wu (+ a0 -4)))): Could not get type of load: (set! v1 (l.wu (+ a0 -4))).
|
||||
;; ERROR: Type analysis failed
|
||||
;; WARN: Function may read a register that is not set: a2
|
||||
;; ERROR: Function may read a register that is not set: a2
|
||||
(defun race-time-save ((a0-0 race-time) (a1-0 task-control))
|
||||
(local-vars
|
||||
(v0-0 none)
|
||||
|
||||
+1
-1
@@ -943,7 +943,7 @@ swamp-rat-nest-default-event-handler
|
||||
;; definition for function swamp-rat-nest-spawn-rat
|
||||
;; INFO: Used lq/sq
|
||||
;; INFO: Return type mismatch (pointer process) vs (pointer swamp-rat).
|
||||
;; WARN: Function may read a register that is not set: t2
|
||||
;; ERROR: Function may read a register that is not set: t2
|
||||
(defbehavior swamp-rat-nest-spawn-rat swamp-rat-nest ()
|
||||
(local-vars (t2-0 none))
|
||||
(the-as
|
||||
|
||||
+1
-1
@@ -1459,7 +1459,7 @@
|
||||
)
|
||||
|
||||
;; definition for function cspace<-parented-transformq-joint!
|
||||
;; WARN: Function may read a register that is not set: ra
|
||||
;; ERROR: Function may read a register that is not set: ra
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
|
||||
;; ERROR: Unsupported inline assembly instruction kind - [jr ra]
|
||||
(defun cspace<-parented-transformq-joint! ((arg0 cspace) (arg1 transformq))
|
||||
|
||||
+3
-4
@@ -9,6 +9,9 @@
|
||||
:method-count-assert 17
|
||||
:size-assert #x20
|
||||
:flag-assert #x1100000020
|
||||
(:methods
|
||||
(new (symbol type int) _type_ 0)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 3 of type drawable-group
|
||||
@@ -31,7 +34,3 @@
|
||||
|
||||
;; failed to figure out what this is:
|
||||
0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 0 of type drawable-group
|
||||
(defmethod new drawable-group ((allocation symbol) (type-to-make type) (length int))
|
||||
"Create a new [[drawable-group]] which can hold the provided number of [[drawable]]s"
|
||||
(let ((new-obj (object-new allocation type-to-make (the-as int (+ (-> type-to-make size) (* length 4))))))
|
||||
(set! (-> new-obj length) length)
|
||||
new-obj
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 2 of type drawable-group
|
||||
(defmethod print drawable-group ((obj drawable-group))
|
||||
(format #t "#<~A @ #x~X [~D]" (-> obj type) obj (-> obj length))
|
||||
(dotimes (idx (-> obj length))
|
||||
(format #t " ~A" (-> obj data idx))
|
||||
)
|
||||
(format #t ">")
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 4 of type drawable-group
|
||||
(defmethod length drawable-group ((obj drawable-group))
|
||||
(-> obj length)
|
||||
)
|
||||
|
||||
;; definition for method 5 of type drawable-group
|
||||
;; WARN: Return type mismatch uint vs int.
|
||||
(defmethod asize-of drawable-group ((obj drawable-group))
|
||||
(the-as int (+ (-> drawable-group size) (* (-> obj length) 4)))
|
||||
)
|
||||
|
||||
;; definition for method 8 of type drawable-group
|
||||
(defmethod mem-usage drawable-group ((obj drawable-group) (arg0 memory-usage-block) (arg1 int))
|
||||
(set! (-> arg0 length) (max 1 (-> arg0 length)))
|
||||
(set! (-> arg0 data 0 name) "drawable-group")
|
||||
(+! (-> arg0 data 0 count) 1)
|
||||
(let ((obj-size (asize-of obj)))
|
||||
(+! (-> arg0 data 0 used) obj-size)
|
||||
(+! (-> arg0 data 0 total) (logand -16 (+ obj-size 15)))
|
||||
)
|
||||
(dotimes (idx (-> obj length))
|
||||
(mem-usage (-> obj data idx) arg0 arg1)
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 9 of type drawable-group
|
||||
(defmethod login drawable-group ((obj drawable-group))
|
||||
(dotimes (idx (-> obj length))
|
||||
(login (-> obj data idx))
|
||||
)
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 10 of type drawable-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod draw drawable-group ((obj drawable-group) (arg0 drawable-group) (arg1 display-frame))
|
||||
(when (vis-cull (-> obj id))
|
||||
(when (sphere-cull (-> obj bsphere))
|
||||
(dotimes (idx (-> obj length))
|
||||
(draw (-> obj data idx) (-> arg0 data idx) arg1)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type drawable-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod collect-stats drawable-group ((obj drawable-group))
|
||||
(when (vis-cull (-> obj id))
|
||||
(when (sphere-cull (-> obj bsphere))
|
||||
(dotimes (idx (-> obj length))
|
||||
(collect-stats (-> obj data idx))
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type drawable-group
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw drawable-group ((obj drawable-group) (arg0 drawable) (arg1 display-frame))
|
||||
(when (vis-cull (-> obj id))
|
||||
(when (sphere-cull (-> obj bsphere))
|
||||
(dotimes (idx (-> obj length))
|
||||
(debug-draw (-> obj data idx) (-> (the-as drawable-group arg0) data idx) arg1)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 15 of type drawable-group
|
||||
(defmethod unpack-vis drawable-group ((obj drawable-group) (arg0 (pointer int8)) (arg1 (pointer int8)))
|
||||
(dotimes (idx (-> obj length))
|
||||
(set! arg1 (unpack-vis (-> obj data idx) arg0 arg1))
|
||||
)
|
||||
arg1
|
||||
)
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 4 of type drawable-inline-array
|
||||
(defmethod length drawable-inline-array ((obj drawable-inline-array))
|
||||
(-> obj length)
|
||||
)
|
||||
|
||||
;; definition for method 9 of type drawable-inline-array
|
||||
(defmethod login drawable-inline-array ((obj drawable-inline-array))
|
||||
obj
|
||||
)
|
||||
|
||||
;; definition for method 10 of type drawable-inline-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod draw drawable-inline-array ((obj drawable-inline-array) (arg0 drawable-inline-array) (arg1 display-frame))
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type drawable-inline-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod collect-stats drawable-inline-array ((obj drawable-inline-array))
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type drawable-inline-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw drawable-inline-array ((obj drawable-inline-array) (arg0 drawable) (arg1 display-frame))
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 10 of type drawable-tree-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod draw drawable-tree-array ((obj drawable-tree-array) (arg0 drawable-tree-array) (arg1 display-frame))
|
||||
(case (-> *level* draw-level *draw-index* display?)
|
||||
(('special #f)
|
||||
)
|
||||
(else
|
||||
(dotimes (idx (-> obj length))
|
||||
(draw (-> obj trees idx) (-> arg0 trees idx) arg1)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type drawable-tree-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod collect-stats drawable-tree-array ((obj drawable-tree-array))
|
||||
(dotimes (idx (-> obj length))
|
||||
(collect-stats (-> obj trees idx))
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type drawable-tree-array
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw drawable-tree-array ((obj drawable-tree-array) (arg0 drawable) (arg1 display-frame))
|
||||
(dotimes (idx (-> obj length))
|
||||
(debug-draw (-> obj trees idx) (-> (the-as drawable-tree-array arg0) trees idx) arg1)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 15 of type drawable-tree
|
||||
(defmethod unpack-vis drawable-tree ((obj drawable-tree) (arg0 (pointer int8)) (arg1 (pointer int8)))
|
||||
(local-vars (t5-1 uint))
|
||||
(let* ((v1-0 (the-as drawable-inline-array-node (-> obj data 0)))
|
||||
(a3-1 (/ (-> v1-0 data 0 id) 8))
|
||||
(t0-0 (-> v1-0 length))
|
||||
(v1-1 (&+ arg0 a3-1))
|
||||
(a3-3 (/ (+ t0-0 7) 8))
|
||||
)
|
||||
(dotimes (t0-1 a3-3)
|
||||
(let ((t1-0 (-> arg1 0)))
|
||||
(set! arg1 (&-> arg1 1))
|
||||
(set! (-> v1-1 0) t1-0)
|
||||
)
|
||||
(set! v1-1 (&-> v1-1 1))
|
||||
)
|
||||
)
|
||||
(let ((v1-5 (+ (-> obj length) -1)))
|
||||
(when (nonzero? v1-5)
|
||||
(dotimes (a3-5 v1-5)
|
||||
(let* ((t0-4 (-> obj data a3-5))
|
||||
(t2-0 (the-as drawable-inline-array-node (-> obj data (+ a3-5 1))))
|
||||
(t1-5 (/ (-> (the-as drawable-inline-array-node t0-4) data 0 id) 8))
|
||||
(t2-2 (/ (-> t2-0 data 0 id) 8))
|
||||
(t0-5 (-> (the-as drawable-inline-array-node t0-4) length))
|
||||
(t1-6 (&+ arg0 t1-5))
|
||||
(t2-3 (the-as object (&+ arg0 t2-2)))
|
||||
)
|
||||
(loop
|
||||
(let ((t3-0 (-> t1-6 0)))
|
||||
(set! t1-6 (&-> t1-6 1))
|
||||
(let ((t4-0 128))
|
||||
(label cfg-7)
|
||||
(b! (zero? (logand t3-0 t4-0)) cfg-9 :delay (set! t5-1 (the-as uint (-> arg1 0))))
|
||||
(set! arg1 (&-> arg1 1))
|
||||
(set! (-> (the-as (pointer int8) t2-3) 0) (the-as int t5-1))
|
||||
(label cfg-9)
|
||||
(+! t0-5 -1)
|
||||
(b! (zero? t0-5) cfg-12 :delay (shift-arith-right-32 t4-0 t4-0 1))
|
||||
(b! (nonzero? (the-as uint t4-0)) cfg-7 :delay (set! t2-3 (&-> (the-as (pointer int8) t2-3) 1)))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
(label cfg-12)
|
||||
(nop!)
|
||||
0
|
||||
)
|
||||
)
|
||||
)
|
||||
arg1
|
||||
)
|
||||
+23
-21
@@ -3,12 +3,14 @@
|
||||
|
||||
;; definition of type path-control
|
||||
(deftype path-control (basic)
|
||||
((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)
|
||||
"An abstraction around a [[curve]], providing tools such as:
|
||||
- debug drawing
|
||||
- conveniant vertex accessing
|
||||
- vertex finding/searching algorithms"
|
||||
((flags path-control-flag :offset-assert 4)
|
||||
(name symbol :offset-assert 8)
|
||||
(process process-drawable :offset-assert 12)
|
||||
(curve curve :inline :offset-assert 16)
|
||||
)
|
||||
:method-count-assert 27
|
||||
:size-assert #x24
|
||||
@@ -16,23 +18,23 @@
|
||||
(:methods
|
||||
(new (symbol type process symbol float entity symbol) _type_ 0)
|
||||
(debug-draw (_type_) none 9)
|
||||
(path-control-method-10 () none 10)
|
||||
(path-control-method-11 () none 11)
|
||||
(path-control-method-12 () none 12)
|
||||
(path-control-method-13 () none 13)
|
||||
(path-control-method-14 () none 14)
|
||||
(path-control-method-15 () none 15)
|
||||
(path-control-method-16 () none 16)
|
||||
(get-point-in-path! (_type_ vector float symbol) vector 10)
|
||||
(get-random-point (_type_ vector) vector :behavior process 11)
|
||||
(displacement-between-two-points-copy! (_type_ vector float float) vector 12)
|
||||
(displacement-between-two-points-normalized! (_type_ vector float) vector 13)
|
||||
(get-point-at-percent-along-path! (_type_ vector float symbol) vector 14)
|
||||
(displacement-between-points-at-percent-scaled! (_type_ vector float float) vector 15)
|
||||
(displacement-between-points-at-percent-normalized! (_type_ vector float) vector 16)
|
||||
(get-num-segments (_type_) float 17)
|
||||
(path-control-method-18 () none 18)
|
||||
(total-distance (_type_) float 18)
|
||||
(get-num-verts (_type_) int 19)
|
||||
(path-distance-equal-spacing (_type_ float) float 20)
|
||||
(average-segment-length (_type_ float) float 21)
|
||||
(path-control-method-22 () none 22)
|
||||
(path-control-method-23 () none 23)
|
||||
(path-control-method-24 () none 24)
|
||||
(get-furthest-point-on-path (_type_ vector) float 22)
|
||||
(get-path-percentage-at-furthest-point (_type_ vector) float 23)
|
||||
(path-control-method-24 (_type_ vector) vector 24)
|
||||
(should-display-marks? (_type_) symbol 25)
|
||||
(path-control-method-26 () none 26)
|
||||
(displacement-between-two-points! (_type_ vector float float) vector 26)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -58,6 +60,7 @@
|
||||
|
||||
;; definition of type curve-control
|
||||
(deftype curve-control (path-control)
|
||||
"Identical in terms of data to a [[path-control]] but has different implementation"
|
||||
()
|
||||
:method-count-assert 27
|
||||
:size-assert #x24
|
||||
@@ -176,9 +179,8 @@
|
||||
)
|
||||
|
||||
;; definition for method 19 of type path-control
|
||||
;; WARN: Return type mismatch int32 vs int.
|
||||
(defmethod get-num-verts path-control ((obj path-control))
|
||||
(the-as int (-> obj curve num-cverts))
|
||||
(-> obj curve num-cverts)
|
||||
)
|
||||
|
||||
;; definition for method 20 of type path-control
|
||||
@@ -218,7 +220,7 @@
|
||||
)
|
||||
(when (not (get-curve-data! s3-1 (-> gp-0 curve) arg1 s2-0 arg2))
|
||||
(cond
|
||||
((> (the-as int (-> gp-0 curve num-cverts)) 0)
|
||||
((> (-> gp-0 curve num-cverts) 0)
|
||||
(set! (-> gp-0 type) path-control)
|
||||
)
|
||||
(else
|
||||
|
||||
+510
@@ -0,0 +1,510 @@
|
||||
;;-*-Lisp-*-
|
||||
(in-package goal)
|
||||
|
||||
;; definition for method 9 of type path-control
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw path-control ((obj path-control))
|
||||
(cond
|
||||
((logtest? (-> obj flags) (path-control-flag not-found))
|
||||
(when (and (type? (-> obj process) process-drawable) *display-entity-errors*)
|
||||
(let ((s5-0 add-debug-text-3d)
|
||||
(s4-0 #t)
|
||||
(s3-0 318)
|
||||
)
|
||||
(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)
|
||||
(font-color precursor-#ec3b00)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
((let ((a0-5 obj))
|
||||
(and *display-path-marks* (logtest? (-> a0-5 flags) (path-control-flag display)))
|
||||
)
|
||||
(dotimes (s5-1 (-> obj curve num-cverts))
|
||||
(let ((s4-1 (-> obj curve cverts s5-1)))
|
||||
(if (and (logtest? (-> obj flags) (path-control-flag draw-line)) (< s5-1 (+ (-> obj curve num-cverts) -1)))
|
||||
(add-debug-line
|
||||
#t
|
||||
(bucket-id debug-no-zbuf1)
|
||||
s4-1
|
||||
(-> obj curve cverts (+ s5-1 1))
|
||||
(new 'static 'rgba :r #xff :g #x80 :a #x80)
|
||||
#f
|
||||
(the-as rgba -1)
|
||||
)
|
||||
)
|
||||
(if (logtest? (-> obj flags) (path-control-flag draw-point))
|
||||
(add-debug-x #t (bucket-id debug-no-zbuf1) s4-1 (new 'static 'rgba :r #xff :a #x80))
|
||||
)
|
||||
(when (logtest? (-> obj flags) (path-control-flag draw-text))
|
||||
(let ((s3-1 add-debug-text-3d)
|
||||
(s2-1 #t)
|
||||
(s1-0 318)
|
||||
)
|
||||
(format (clear *temp-string*) "~D" s5-1)
|
||||
(s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 18 of type path-control
|
||||
(defmethod total-distance path-control ((obj path-control))
|
||||
"Calcuate the total path length by summing the distance between each adjacent [[curve]] vertex"
|
||||
(let ((f30-0 0.0))
|
||||
(dotimes (s5-0 (+ (-> obj curve num-cverts) -1))
|
||||
(+! f30-0 (vector-vector-distance (-> obj curve cverts s5-0) (-> obj curve cverts (+ s5-0 1))))
|
||||
)
|
||||
f30-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 18 of type curve-control
|
||||
(defmethod total-distance curve-control ((obj curve-control))
|
||||
"Calcuate the total path length by summing the distance between each adjacent [[curve]] vertex"
|
||||
(let ((f0-0 (-> obj curve length)))
|
||||
(when (= f0-0 0.0)
|
||||
(set! f0-0 (curve-length (-> obj curve)))
|
||||
(set! (-> obj curve length) f0-0)
|
||||
)
|
||||
f0-0
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 10 of type path-control
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod get-point-in-path! path-control ((obj path-control) (ret vector) (idx float) (search-type symbol))
|
||||
"Depending on the value of `idx`, the result can be quite different:
|
||||
- if `idx` is less than `0.0` - return the first vertex in the path
|
||||
- if `idx` is greater than the number of vertices in the path, return the last vertex
|
||||
- if `search-type` is equal to `exact` OR `idx` is an integral number (ex 1.0), return that vertex
|
||||
- otherwise, do a linear interpolation between the vertex at `idx` (truncated) and the next vertex
|
||||
using the fractional component of `idx` as the interpolant, return this result
|
||||
|
||||
@param! ret The [[vector]] that is used to hold the return value
|
||||
@param idx Either the vertex index or also partially the interpolant in a LERP
|
||||
@param search-type The only recognized value is `exact`
|
||||
@returns Either a distinct vertex along the path, or some fractional point between two vertices"
|
||||
(let ((num-vertices (-> obj curve num-cverts))
|
||||
(vert-idx (the float (the int idx)))
|
||||
)
|
||||
(cond
|
||||
((< idx 0.0)
|
||||
(set! (-> ret quad) (-> obj curve cverts 0 quad))
|
||||
)
|
||||
((>= vert-idx (the float (+ num-vertices -1)))
|
||||
(set! (-> ret quad) (-> obj curve cverts (+ num-vertices -1) quad))
|
||||
)
|
||||
((or (= search-type 'exact) (= vert-idx idx))
|
||||
(set! (-> ret quad) (-> obj curve cverts (the int vert-idx) quad))
|
||||
)
|
||||
(else
|
||||
(vector-lerp!
|
||||
ret
|
||||
(-> obj curve cverts (the int vert-idx))
|
||||
(-> obj curve cverts (the int (+ 1.0 vert-idx)))
|
||||
(- idx vert-idx)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
ret
|
||||
)
|
||||
|
||||
;; definition for method 11 of type path-control
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod get-random-point path-control ((obj path-control) (arg0 vector))
|
||||
"Attempts to retrieve a random point along the path, returns the [[*null-vector*]] if no vertices are defined"
|
||||
(cond
|
||||
((> (-> obj curve num-cverts) 0)
|
||||
(let ((a0-2 (rand-vu-int-count (-> obj curve num-cverts))))
|
||||
(set! (-> arg0 quad) (-> obj curve cverts a0-2 quad))
|
||||
)
|
||||
)
|
||||
(else
|
||||
(format #t "WARNING: method get-random-point called on a path-control object with no vertices.~%")
|
||||
(if self
|
||||
(format #t "current process is ~A~%" (-> self name))
|
||||
)
|
||||
(set! (-> arg0 quad) (-> *null-vector* quad))
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for method 14 of type path-control
|
||||
(defmethod get-point-at-percent-along-path! path-control ((obj path-control) (ret vector) (percent float) (search-type symbol))
|
||||
"@param! ret The [[vector]] that is used to hold the return value
|
||||
@param percent The percentage along the path
|
||||
@param search-type The only recognized value is `exact`
|
||||
@returns the point closest to some arbitrary percentage along the path
|
||||
@see [[path-control::10]]"
|
||||
(get-point-in-path! obj ret (* percent (the float (+ (-> obj curve num-cverts) -1))) search-type)
|
||||
)
|
||||
|
||||
;; definition for method 14 of type curve-control
|
||||
(defmethod get-point-at-percent-along-path! curve-control ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol))
|
||||
"@param! ret The [[vector]] that is used to hold the return value
|
||||
@param percent The percentage along the path
|
||||
@param search-type The only recognized value is `exact`
|
||||
@returns the point closest to some arbitrary percentage along the path
|
||||
@see [[path-control::10]]"
|
||||
(if (zero? (logand (-> obj flags) (path-control-flag not-found)))
|
||||
(curve-evaluate!
|
||||
arg0
|
||||
arg1
|
||||
(-> obj curve cverts)
|
||||
(-> obj curve num-cverts)
|
||||
(-> obj curve knots)
|
||||
(-> obj curve num-knots)
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for method 10 of type curve-control
|
||||
(defmethod get-point-in-path! curve-control ((obj curve-control) (arg0 vector) (arg1 float) (arg2 symbol))
|
||||
"Depending on the value of `idx`, the result can be quite different:
|
||||
- if `idx` is less than `0.0` - return the first vertex in the path
|
||||
- if `idx` is greater than the number of vertices in the path, return the last vertex
|
||||
- if `search-type` is equal to `exact` OR `idx` is an integral number (ex 1.0), return that vertex
|
||||
- otherwise, do a linear interpolation between the vertex at `idx` (truncated) and the next vertex
|
||||
using the fractional component of `idx` as the interpolant, return this result
|
||||
|
||||
@param! ret The [[vector]] that is used to hold the return value
|
||||
@param idx Either the vertex index or also partially the interpolant in a LERP
|
||||
@param search-type The only recognized value is `exact`
|
||||
@returns Either a distinct vertex along the path, or some fractional point between two vertices"
|
||||
(if (zero? (logand (-> obj flags) (path-control-flag not-found)))
|
||||
(curve-evaluate!
|
||||
arg0
|
||||
(/ arg1 (the float (+ (-> obj curve num-cverts) -1)))
|
||||
(-> obj curve cverts)
|
||||
(-> obj curve num-cverts)
|
||||
(-> obj curve knots)
|
||||
(-> obj curve num-knots)
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
|
||||
;; definition for method 26 of type path-control
|
||||
(defmethod displacement-between-two-points! path-control ((obj path-control) (ret vector) (idx float) (mag float))
|
||||
"Return value can differ quite a bit:
|
||||
- If [[path-control-flag::4]] is set OR there are less than 2 vertices OR `idx` is less than `0.0` - return [[*null-vector*]]
|
||||
- Otherwise, find the scaled (by `mag`) displacement vector between two points in the path:
|
||||
- If `idx` is not beyond the second last vertex, the result is between vertex `idx` and `idx+1`
|
||||
- else, the result is between the second last vertex and the last
|
||||
|
||||
@param! ret The [[vector]] that is used to hold the return value
|
||||
@param idx The vertex index
|
||||
@param mag The magnitude to scale the resulting displacement vector by
|
||||
@returns The displacement [[vector]] between two points in the path, the last 2, or the [[*null-vector*]]"
|
||||
(let ((num-vertices (-> obj curve num-cverts))
|
||||
(vert-idx (the float (the int idx)))
|
||||
)
|
||||
(cond
|
||||
((or (logtest? (-> obj flags) (path-control-flag not-found)) (< num-vertices 2) (< idx 0.0))
|
||||
(vector-reset! ret)
|
||||
)
|
||||
(else
|
||||
(let ((capped-idx (fmin vert-idx (the float (+ num-vertices -2)))))
|
||||
(vector-! ret (-> obj curve cverts (the int (+ 1.0 capped-idx))) (-> obj curve cverts (the int capped-idx)))
|
||||
)
|
||||
(vector-float*! ret ret mag)
|
||||
)
|
||||
)
|
||||
)
|
||||
ret
|
||||
)
|
||||
|
||||
;; definition for method 12 of type path-control
|
||||
(defmethod displacement-between-two-points-copy! path-control ((obj path-control) (ret vector) (idx float) (mag float))
|
||||
"Calls [[path-control::26]] with the provided args
|
||||
@see [[path-control::26]]"
|
||||
(displacement-between-two-points! obj ret idx mag)
|
||||
)
|
||||
|
||||
;; definition for method 15 of type path-control
|
||||
(defmethod displacement-between-points-at-percent-scaled! path-control ((obj path-control) (ret vector) (percent float) (mag float))
|
||||
"Calls [[path-control::12], with the `idx` at a given percent along the path
|
||||
@param ret The [[vector]] that is used to hold the return value
|
||||
@param percent The percentage along the path to find the first index
|
||||
@param mag Multiplied by the number of points in the path and scales the resulting vector
|
||||
@returns The displacement between the last two points of the path scaled to the magnitude equal to the number of points in the path"
|
||||
(displacement-between-two-points-copy!
|
||||
obj
|
||||
ret
|
||||
(* percent (the float (+ (-> obj curve num-cverts) -1)))
|
||||
(* mag (the float (+ (-> obj curve num-cverts) -1)))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type path-control
|
||||
(defmethod displacement-between-two-points-normalized! path-control ((obj path-control) (ret vector) (idx float))
|
||||
"Calls [[path-control::26], with the provided `idx`
|
||||
@param! ret The [[vector]] the result is stored within
|
||||
@param idx The vertex index
|
||||
@returns The resulting displacement vector, normalized
|
||||
@see [[path-control::26]]"
|
||||
(displacement-between-two-points! obj ret idx 1.0)
|
||||
(vector-normalize! ret 1.0)
|
||||
)
|
||||
|
||||
;; definition for method 16 of type path-control
|
||||
(defmethod displacement-between-points-at-percent-normalized! path-control ((obj path-control) (ret vector) (percent float))
|
||||
"Calls [[path-control::13], with the `idx` at a given percent along the path
|
||||
@param! ret The [[vector]] the result is stored within
|
||||
@param percent The percentage along the path
|
||||
@returns The resulting displacement vector, normalized
|
||||
@see [[path-control::13]]
|
||||
@see [[path-control::14]]"
|
||||
(displacement-between-two-points-normalized! obj ret (* percent (the float (+ (-> obj curve num-cverts) -1))))
|
||||
)
|
||||
|
||||
;; definition for method 26 of type curve-control
|
||||
(defmethod displacement-between-two-points! curve-control ((obj curve-control) (arg0 vector) (arg1 float) (arg2 float))
|
||||
"Return value can differ quite a bit:
|
||||
- If [[path-control-flag::4]] is set OR there are less than 2 vertices OR `idx` is less than `0.0` - return [[*null-vector*]]
|
||||
- Otherwise, find the scaled (by `mag`) displacement vector between two points in the path:
|
||||
- If `idx` is not beyond the second last vertex, the result is between vertex `idx` and `idx+1`
|
||||
- else, the result is between the second last vertex and the last
|
||||
|
||||
@param! ret The [[vector]] that is used to hold the return value
|
||||
@param idx The vertex index
|
||||
@param mag The magnitude to scale the resulting displacement vector by
|
||||
@returns The displacement [[vector]] between two points in the path, the last 2, or the [[*null-vector*]]"
|
||||
(when (zero? (logand (-> obj flags) (path-control-flag not-found)))
|
||||
(let ((s4-0 (new 'stack-no-clear 'vector)))
|
||||
(curve-evaluate!
|
||||
arg0
|
||||
arg1
|
||||
(-> obj curve cverts)
|
||||
(-> obj curve num-cverts)
|
||||
(-> obj curve knots)
|
||||
(-> obj curve num-knots)
|
||||
)
|
||||
(cond
|
||||
((< arg1 (- 1.0 arg2))
|
||||
(curve-evaluate!
|
||||
s4-0
|
||||
(+ arg1 arg2)
|
||||
(-> obj curve cverts)
|
||||
(-> obj curve num-cverts)
|
||||
(-> obj curve knots)
|
||||
(-> obj curve num-knots)
|
||||
)
|
||||
(vector-! arg0 s4-0 arg0)
|
||||
)
|
||||
(else
|
||||
(curve-evaluate!
|
||||
s4-0
|
||||
(- arg1 arg2)
|
||||
(-> obj curve cverts)
|
||||
(-> obj curve num-cverts)
|
||||
(-> obj curve knots)
|
||||
(-> obj curve num-knots)
|
||||
)
|
||||
(vector-! arg0 arg0 s4-0)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 12 of type curve-control
|
||||
(defmethod displacement-between-two-points-copy! curve-control ((obj curve-control) (ret vector) (percent float) (mag float))
|
||||
"Calls [[path-control::26]] with the provided args
|
||||
@see [[path-control::26]]"
|
||||
(displacement-between-two-points! obj ret (/ percent (the float (+ (-> obj curve num-cverts) -1))) mag)
|
||||
)
|
||||
|
||||
;; definition for method 15 of type curve-control
|
||||
(defmethod displacement-between-points-at-percent-scaled! curve-control ((obj curve-control) (ret vector) (idx float) (mag float))
|
||||
"Calls [[path-control::12], with the `idx` at a given percent along the path
|
||||
@param ret The [[vector]] that is used to hold the return value
|
||||
@param percent The percentage along the path to find the first index
|
||||
@param mag Multiplied by the number of points in the path and scales the resulting vector
|
||||
@returns The displacement between the last two points of the path scaled to the magnitude equal to the number of points in the path"
|
||||
(displacement-between-two-points! obj ret idx mag)
|
||||
)
|
||||
|
||||
;; definition for method 16 of type curve-control
|
||||
(defmethod displacement-between-points-at-percent-normalized! curve-control ((obj curve-control) (ret vector) (percent float))
|
||||
"Calls [[path-control::13], with the `idx` at a given percent along the path
|
||||
@param! ret The [[vector]] the result is stored within
|
||||
@param percent The percentage along the path
|
||||
@returns The resulting displacement vector, normalized
|
||||
@see [[path-control::13]]
|
||||
@see [[path-control::14]]"
|
||||
(displacement-between-two-points! obj ret percent 0.01)
|
||||
(vector-normalize! ret 1.0)
|
||||
)
|
||||
|
||||
;; definition for method 13 of type curve-control
|
||||
(defmethod displacement-between-two-points-normalized! curve-control ((obj curve-control) (ret vector) (idx float))
|
||||
"Calls [[path-control::26], with the provided `idx`
|
||||
@param! ret The [[vector]] the result is stored within
|
||||
@param idx The vertex index
|
||||
@returns The resulting displacement vector, normalized
|
||||
@see [[path-control::26]]"
|
||||
(displacement-between-points-at-percent-normalized!
|
||||
obj
|
||||
ret
|
||||
(/ idx (the float (+ (-> obj curve num-cverts) -1)))
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 22 of type path-control
|
||||
;; INFO: Used lq/sq
|
||||
(defmethod get-furthest-point-on-path path-control ((obj path-control) (point vector))
|
||||
"@param point The point to calculate distance from
|
||||
@returns the `vertex-idx.interpolant` value to the point on the path furthest away from the `point`
|
||||
@see [[path-control::10]]"
|
||||
(let ((curr-point (new 'stack-no-clear 'vector))
|
||||
(next-point (new 'stack-no-clear 'vector))
|
||||
(given-point (new 'stack-no-clear 'vector))
|
||||
(furthest-dist 4096000000.0)
|
||||
(vert-idx 0.0)
|
||||
)
|
||||
(let ((closest-point (new 'stack-no-clear 'vector)))
|
||||
(set! (-> given-point quad) (-> point quad))
|
||||
(set! (-> given-point y) 0.0)
|
||||
(get-point-in-path! obj next-point 0.0 'interp)
|
||||
(set! (-> next-point y) 0.0)
|
||||
(dotimes (idx (+ (-> obj curve num-cverts) -1))
|
||||
(set! (-> curr-point quad) (-> next-point quad))
|
||||
(get-point-in-path! obj next-point (the float (+ idx 1)) 'interp)
|
||||
(set! (-> next-point y) 0.0)
|
||||
(let ((dist-to-point (vector-segment-distance-point! given-point curr-point next-point closest-point)))
|
||||
(when (< dist-to-point furthest-dist)
|
||||
(set! furthest-dist dist-to-point)
|
||||
(set! vert-idx
|
||||
(+ (/ (vector-vector-xz-distance closest-point curr-point) (vector-vector-xz-distance next-point curr-point))
|
||||
(the float idx)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
vert-idx
|
||||
)
|
||||
)
|
||||
|
||||
;; definition for method 23 of type path-control
|
||||
(defmethod get-path-percentage-at-furthest-point path-control ((obj path-control) (point vector))
|
||||
"@param point The point to calculate distance from
|
||||
@returns the percentage of path completion from the point on the path furthest away from the `point`
|
||||
@see [[path-control::14]]"
|
||||
(/ (get-furthest-point-on-path obj point) (the float (+ (-> obj curve num-cverts) -1)))
|
||||
)
|
||||
|
||||
;; definition for method 9 of type curve-control
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
(defmethod debug-draw curve-control ((obj curve-control))
|
||||
(cond
|
||||
((logtest? (-> obj flags) (path-control-flag not-found))
|
||||
(when (and (type? (-> obj process) process-drawable) *display-entity-errors*)
|
||||
(let ((s5-0 add-debug-text-3d)
|
||||
(s4-0 #t)
|
||||
(s3-0 318)
|
||||
)
|
||||
(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)
|
||||
(font-color precursor-#ec3b00)
|
||||
(the-as vector2h #f)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
((let ((a0-5 obj))
|
||||
(and *display-path-marks* (logtest? (-> a0-5 flags) (path-control-flag display)))
|
||||
)
|
||||
(if (and (logtest? (-> obj flags) (path-control-flag draw-line)) (> (-> obj curve num-cverts) 0))
|
||||
(add-debug-curve2 #t (bucket-id debug-no-zbuf1) (-> obj curve) (new 'static 'rgba :r #xff :g #x80 :a #x80) #f)
|
||||
)
|
||||
(dotimes (s5-1 (-> obj curve num-cverts))
|
||||
(let ((s4-1 (-> obj curve cverts s5-1)))
|
||||
(if (logtest? (-> obj flags) (path-control-flag draw-point))
|
||||
(add-debug-x #t (bucket-id debug-no-zbuf1) s4-1 (new 'static 'rgba :r #xff :a #x80))
|
||||
)
|
||||
(when (logtest? (-> obj flags) (path-control-flag draw-text))
|
||||
(let ((s3-1 add-debug-text-3d)
|
||||
(s2-1 #t)
|
||||
(s1-0 318)
|
||||
)
|
||||
(format (clear *temp-string*) "~D" s5-1)
|
||||
(s3-1 s2-1 (the-as bucket-id s1-0) *temp-string* s4-1 (font-color gold-#ba9200) (the-as vector2h #f))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
0
|
||||
(none)
|
||||
)
|
||||
|
||||
;; definition for method 24 of type path-control
|
||||
(defmethod path-control-method-24 path-control ((obj path-control) (arg0 vector))
|
||||
"TODO"
|
||||
(rlet ((acc :class vf)
|
||||
(vf0 :class vf)
|
||||
(vf1 :class vf)
|
||||
(vf2 :class vf)
|
||||
(vf3 :class vf)
|
||||
(vf4 :class vf)
|
||||
)
|
||||
(init-vf0-vector)
|
||||
(let ((s4-0 (-> obj curve num-cverts)))
|
||||
(let ((f30-0 (/ 1.0 (the float s4-0))))
|
||||
(set-vector! arg0 0.0 0.0 0.0 0.0)
|
||||
(dotimes (s3-0 s4-0)
|
||||
(let ((s2-0 arg0))
|
||||
(let ((s1-0 arg0)
|
||||
(v1-4 (get-point-in-path! obj (new 'stack-no-clear 'vector) (the float s3-0) 'interp))
|
||||
(f0-7 f30-0)
|
||||
)
|
||||
(.lvf vf2 (&-> v1-4 quad))
|
||||
(.lvf vf1 (&-> s1-0 quad))
|
||||
(let ((v1-5 f0-7))
|
||||
(.mov vf3 v1-5)
|
||||
)
|
||||
)
|
||||
(.add.x.vf vf4 vf0 vf0 :mask #b1000)
|
||||
(.mul.x.vf acc vf2 vf3)
|
||||
(.add.mul.w.vf vf4 vf1 vf0 acc :mask #b111)
|
||||
(.svf (&-> s2-0 quad) vf4)
|
||||
)
|
||||
)
|
||||
)
|
||||
(dotimes (s3-1 s4-0)
|
||||
(let ((f0-10
|
||||
(vector-vector-distance arg0 (get-point-in-path! obj (new 'stack-no-clear 'vector) (the float s3-1) 'interp))
|
||||
)
|
||||
)
|
||||
(if (< (-> arg0 w) f0-10)
|
||||
(set! (-> arg0 w) (+ 4096.0 f0-10))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
arg0
|
||||
)
|
||||
)
|
||||
+1
-1
@@ -505,7 +505,7 @@
|
||||
|
||||
;; definition for function print-collide-stats
|
||||
;; WARN: Return type mismatch int vs none.
|
||||
;; WARN: Function may read a register that is not set: t0
|
||||
;; ERROR: Function may read a register that is not set: t0
|
||||
(defun print-collide-stats ()
|
||||
(local-vars (t0-0 none))
|
||||
(format *stdcon* "~0k~%count cycles instr icache dcache vu0/to/from~%")
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@
|
||||
)
|
||||
|
||||
;; definition for method 2 of type surface
|
||||
;; WARN: Function may read a register that is not set: t3
|
||||
;; ERROR: Function may read a register that is not set: t3
|
||||
(defmethod print surface ((obj surface))
|
||||
(local-vars (t3-0 none))
|
||||
(format
|
||||
|
||||
Reference in New Issue
Block a user