jak-project/goal_src/engine/nav/path-h.gc
ManDude 5b44aece75
random fixes + support clang-cl on visual studio (#1129)
* delete unused shaders

* hide some options in debug menu

* change fullscreen logic a bit

* add "all actors" toggle

* borderless fix and fix alpha in direct renderer untextured (do we need a separate shader for that?)

* fix fuel cell orbit icons in widescreen

* fix `curve` types

* refs

* fix levitator task...

* fix some task stuff

* update font code a bit (temp)

* cmake, third-party and visual studio overhaul

* Update .gitmodules

* update modules

* clone repos

* fix encoding in zydis

* where did these come from

* try again

* add submodule

* Update 11zip

* Update 11zip

* Update 11zip

* delete

* try again

* clang

* update compiler flags

* delete 11zip. go away.

* Create memory-dump-p2s.py

* properly

* fix minimum architecture c++ compiler flags

* fix zydis

* oops

* Update all-types.gc

* fix clang-cl tests

* make "all actors" work better, entity debug qol

* update game-text conversion code to be more modularized

* Create vendor.txt

* fix typos and minor things

* update refs

* clang

* Attempt to add clang-cl support to vs2019 and CI

* vs2022 + clang-cl

* srsly? fix clang build

* Update launch.vs.json

* extend windows CI timer
2022-02-07 19:15:37 -05:00

166 lines
5.4 KiB
Common Lisp

;;-*-Lisp-*-
(in-package goal)
;; name: path-h.gc
;; name in dgo: path-h
;; dgos: GAME, ENGINE
(defenum path-control-flag
: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 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_)
(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.
(deftype curve-control (path-control)
()
:method-count-assert 21
:size-assert #x24
:flag-assert #x1500000024
(:methods
(new (symbol type process symbol float) _type_ 0)
)
)
(defmethod new path-control ((allocation symbol) (type-to-make type) (proc process) (name symbol) (time float))
(local-vars (tag res-tag))
(let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size)))))
(when (zero? obj)
;; allocation failed.
(go process-drawable-art-error "memory")
(set! obj (the-as path-control 0))
(goto cfg-9)
)
(set! (-> obj process) (the-as process-drawable proc))
(set! (-> obj name) name)
(let ((ent (-> proc entity)))
(when (= name 'path)
;; if we are a path, try to look up the path-actor.
(let ((lookup-entity (entity-actor-lookup (the-as res-lump ent) 'path-actor 0)))
(if lookup-entity
(set! ent lookup-entity)
)
)
)
;; look up the curve data
(set! tag (new 'static 'res-tag))
(let ((data (res-lump-data ent name pointer :tag-ptr (& tag) :time time)))
(cond
(data
;; success, we got some data
(set! (-> obj cverts) (the-as (inline-array vector) data))
(set! (-> obj curve num-cverts) (the-as int (-> tag elt-count)))
)
(else
;; did not find the data. Set flags and zero stuff
(logior! (-> obj flags) (path-control-flag not-found))
(set! (-> obj cverts) (the-as (inline-array vector) #f))
(set! (-> obj curve num-cverts) 0)
)
)
)
)
(label cfg-9)
(the-as path-control obj)
)
)
(defmethod should-display? path-control ((obj path-control))
"Should we display path marks?"
(and *display-path-marks*
(logtest? (-> obj flags) (path-control-flag display))
)
)
(defmethod length-as-float path-control ((obj path-control))
"Get the number of edges as a float"
(the float (+ (-> obj curve num-cverts) -1))
)
(defmethod get-num-verts path-control ((obj path-control))
"Get the number of vertices"
(-> obj curve num-cverts)
)
(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) (the-as process-drawable proc))
(set! (-> obj name) name)
(let* ((ent (the-as entity (-> proc entity)))
(v1-2 name)
(s2-0 (cond
((= v1-2 'path)
'path-k ;; for knots?
)
(else
;; appends a -k to the symbol name.
(let ((s2-1 string->symbol))
(format (clear *temp-string*) "~A-k" name)
(s2-1 *temp-string*)
)
)
)
)
)
(let ((lookup-entity (entity-actor-lookup ent 'path-actor 0)))
(if lookup-entity
(set! ent lookup-entity)
)
)
(when (not (get-curve-data! ent (-> obj curve) name s2-0 time))
(cond
((> (-> obj curve num-cverts) 0)
;; downgrade us to a path-control, we got cverts but no knots.
(set! (-> obj type) path-control)
)
(else
;; couldn't get anything, mark as bad.
(logior! (-> obj flags) (path-control-flag not-found))
(set! (-> obj flags) (logior (-> obj flags) (path-control-flag not-found)))
(set! (-> obj curve cverts) (the-as (inline-array vector) #f))
(set! (-> obj curve num-cverts) 0)
)
)
)
)
obj
)
)