From 4f331b5f796e2f52bd55d78b74cd189261f381c7 Mon Sep 17 00:00:00 2001 From: Tyler Wilding Date: Sat, 7 Aug 2021 18:29:44 -0400 Subject: [PATCH] decomp: finalize `rigid-body` --- decompiler/IR2/FormExpressionAnalysis.cpp | 6 +- decompiler/config/all-types.gc | 24 +- .../jak1_ntsc_black_label/label_types.jsonc | 7 + .../stack_structures.jsonc | 7 + .../jak1_ntsc_black_label/type_casts.jsonc | 12 +- goal_src/engine/collide/collide-shape-h.gc | 18 +- goal_src/engine/collide/collide-shape.gc | 2 + goal_src/engine/draw/process-drawable.gc | 3 + goal_src/engine/entity/entity.gc | 3 + goal_src/engine/gfx/ocean/ocean.gc | 2 + goal_src/kernel-defs.gc | 4 +- goal_src/kernel/gkernel-h.gc | 13 +- goal_src/levels/common/rigid-body-h.gc | 28 +- goal_src/levels/common/rigid-body.gc | 1259 ++++++++++++++++ .../engine/collide/collide-shape-h_REF.gc | 8 +- .../reference/levels/common/rigid-body_REF.gc | 1261 +++++++++++++++++ 16 files changed, 2601 insertions(+), 56 deletions(-) create mode 100644 test/decompiler/reference/levels/common/rigid-body_REF.gc diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index a3d88a267..9e606cd05 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -654,9 +654,9 @@ void SimpleExpressionElement::update_from_stack_float_2(const Env& env, } else { auto type0 = env.get_types_before_op(m_my_idx).get(m_expr.get_arg(0).var().reg()); auto type1 = env.get_types_before_op(m_my_idx).get(m_expr.get_arg(1).var().reg()); - throw std::runtime_error( - fmt::format("[OP: {}] - Floating point math attempted on invalid types: {} and {} in op {}.", - m_my_idx, type0.print(), type1.print(), to_string(env))); + throw std::runtime_error(fmt::format( + "[OP: {}] - Floating point math attempted on invalid types: {} and {} in op {}.", m_my_idx, + type0.print(), type1.print(), to_string(env))); } } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 33df434de..b70d7b51d 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -988,7 +988,7 @@ (define-extern process-tree type) ; deftype provided by C Kernel (declare-type process basic) - +(declare-type res-lump basic) (deftype process-tree (basic) ((name basic :offset-assert 4) (mask process-mask :offset-assert 8) @@ -1002,7 +1002,7 @@ (new (symbol type basic) _type_ 0) (activate (_type_ process-tree basic pointer) process-tree 9) (deactivate (_type_) none 10) - (dummy-method-11 (_type_ object) none 11) + (copy-defaults (_type_ res-lump) none 11) (run-logic? (_type_) symbol 12) (dummy-method () none 13) ) @@ -1245,11 +1245,6 @@ ) (:methods (new (symbol type basic int) _type_ 0) - (activate (_type_ process-tree basic pointer) process-tree 9) - (deactivate (process) none 10) - (dummy-method-11 (_type_ object) none 11) - (run-logic? (process) symbol 12) - (dummy-method () none 13) ) :size-assert #x70 :method-count-assert 14 @@ -10687,12 +10682,13 @@ :flag-assert #x900000020 ) +(declare-type collide-shape-prim basic) (deftype collide-shape-intersect (basic) ((move-vec vector :inline :offset-assert 16) (best-u float :offset-assert 32) (best-tri collide-tri-result :inline :offset-assert 48) - (best-from-prim basic :offset-assert 132) - (best-to-prim basic :offset-assert 136) + (best-from-prim collide-shape-prim :offset-assert 132) + (best-to-prim collide-shape-prim :offset-assert 136) ) :method-count-assert 10 :size-assert #x8c @@ -10702,10 +10698,11 @@ ) ) +(declare-type collide-shape-prim basic) (deftype collide-overlap-result (structure) ((best-dist float :offset-assert 0) - (best-from-prim basic :offset-assert 4) - (best-to-prim basic :offset-assert 8) + (best-from-prim collide-shape-prim :offset-assert 4) + (best-to-prim collide-shape-prim :offset-assert 8) (best-from-tri collide-tri-result :inline :offset-assert 16) ) :method-count-assert 10 @@ -17583,7 +17580,7 @@ (define-extern target-attack-up function) (define-extern find-ground-point function) -(define-extern default-collision-reaction function) +(define-extern default-collision-reaction (function collide-shape-moving collide-shape-intersect vector vector none)) ;; TODO - not completely confirmed (define-extern simple-collision-reaction function) (define-extern collide-shape-draw-debug-marks (function none)) (define-extern debug-report-col-stats function) @@ -22055,7 +22052,7 @@ ;; - Functions (define-extern matrix-3x3-triple-transpose-product (function matrix matrix matrix matrix)) -(define-extern rigid-body-platform-event-handler (function process int symbol event-message-block object :behavior rigid-body-platform)) +(define-extern rigid-body-platform-event-handler (function process int symbol event-message-block vector :behavior rigid-body-platform)) (define-extern rigid-body-platform-post (function int :behavior rigid-body-platform)) ;; - Unknowns @@ -31448,7 +31445,6 @@ :size-assert #x17c :flag-assert #x350110017c (:methods - (dummy-method-11 (_type_ object) none 11) (dummy-31 (_type_) none 31) (dummy-32 (_type_ symbol) spool-anim 32) (dummy-41 (_type_) none 41) diff --git a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc index 62a5c0104..4227027ff 100644 --- a/decompiler/config/jak1_ntsc_black_label/label_types.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/label_types.jsonc @@ -1414,6 +1414,13 @@ ], "rigid-body": [ + ["L8", "_lambda_", true], + ["L10", "_lambda_", true], + ["L13", "_lambda_", true], + ["L15", "_lambda_", true], + ["L89", "rigid-body-platform-constants", true], + ["L90", "state", true], + ["L91", "state", true], ["L106", "float", true] ], diff --git a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc index 31f4c1358..ff2b7b6de 100644 --- a/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/stack_structures.jsonc @@ -873,5 +873,12 @@ [16, "event-message-block"] ], + "default-collision-reaction": [ + [16, "vector"], + [32, "vector"], + [48, "vector"], + [96, "vector"] + ], + "placeholder-do-not-add-below!": [] } diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index 14627808b..85335c425 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -1823,12 +1823,14 @@ "rigid-body-platform-event-handler": [ [28, "v1", "process-drawable"], + [34, "v1", "float"], [83, "v1", "process-drawable"], [119, "v1", "process-drawable"], [125, "v1", "process-drawable"], [158, "v1", "vector"], [170, "v1", "vector"], - [184, "v1", "symbol"] + [184, "v1", "(pointer handle)"], + [213, "v1", "process-drawable"] ], "(anon-function 9 plat-eco)": [ @@ -1841,5 +1843,13 @@ [14, "t9", "(function process-drawable int process-drawable)"] ], + "(method 10 rigid-body)": [ + [50, "v1", "vector"] + ], + + "(method 11 rigid-body-platform)": [ + [5, "v1", "process-mask"] + ], + "placeholder-do-not-add-below": [] } diff --git a/goal_src/engine/collide/collide-shape-h.gc b/goal_src/engine/collide/collide-shape-h.gc index ff994e4df..64a9519b0 100644 --- a/goal_src/engine/collide/collide-shape-h.gc +++ b/goal_src/engine/collide/collide-shape-h.gc @@ -62,33 +62,35 @@ :flag-assert #x900000020 ) +(declare-type collide-shape-prim basic) (deftype collide-shape-intersect (basic) ((move-vec vector :inline :offset-assert 16) (best-u float :offset-assert 32) (best-tri collide-tri-result :inline :offset-assert 48) - (best-from-prim basic :offset-assert 132) - (best-to-prim basic :offset-assert 136) + (best-from-prim collide-shape-prim :offset-assert 132) + (best-to-prim collide-shape-prim :offset-assert 136) ) :method-count-assert 10 :size-assert #x8c :flag-assert #xa0000008c (:methods - (dummy-9 () none 9) - ) + (dummy-9 () none 9) + ) ) +(declare-type collide-shape-prim basic) (deftype collide-overlap-result (structure) ((best-dist float :offset-assert 0) - (best-from-prim basic :offset-assert 4) - (best-to-prim basic :offset-assert 8) + (best-from-prim collide-shape-prim :offset-assert 4) + (best-to-prim collide-shape-prim :offset-assert 8) (best-from-tri collide-tri-result :inline :offset-assert 16) ) :method-count-assert 10 :size-assert #x64 :flag-assert #xa00000064 (:methods - (reset! (_type_) none 9) - ) + (reset! (_type_) none 9) + ) ) (defmethod reset! collide-overlap-result ((obj collide-overlap-result)) diff --git a/goal_src/engine/collide/collide-shape.gc b/goal_src/engine/collide/collide-shape.gc index 12d5f368c..83faf485e 100644 --- a/goal_src/engine/collide/collide-shape.gc +++ b/goal_src/engine/collide/collide-shape.gc @@ -5,3 +5,5 @@ ;; name in dgo: collide-shape ;; dgos: GAME, ENGINE +;; TODO - for rigid-body +(define-extern default-collision-reaction (function collide-shape-moving collide-shape-intersect vector vector none)) ;; TODO - not completely confirmed diff --git a/goal_src/engine/draw/process-drawable.gc b/goal_src/engine/draw/process-drawable.gc index 8441827b2..8739e34c8 100644 --- a/goal_src/engine/draw/process-drawable.gc +++ b/goal_src/engine/draw/process-drawable.gc @@ -7,3 +7,6 @@ ;; TODO - for water-anim (define-extern ja-post (function int)) +;; TODO - for rigid-body +(define-extern rider-post (function int)) +(define-extern transform-post (function int)) diff --git a/goal_src/engine/entity/entity.gc b/goal_src/engine/entity/entity.gc index b2d79afba..ac41d819c 100644 --- a/goal_src/engine/entity/entity.gc +++ b/goal_src/engine/entity/entity.gc @@ -117,3 +117,6 @@ ) (the-as entity-actor #f) ) + +;; TODO - for rigid-body +(define-extern process-drawable-from-entity! (function process-drawable object none)) diff --git a/goal_src/engine/gfx/ocean/ocean.gc b/goal_src/engine/gfx/ocean/ocean.gc index a7aca41e6..aae27a448 100644 --- a/goal_src/engine/gfx/ocean/ocean.gc +++ b/goal_src/engine/gfx/ocean/ocean.gc @@ -7,3 +7,5 @@ ;; TODO - for ocean-transition (define-extern *ocean-map* ocean-map) +;; TODO - for rigid-body +(define-extern ocean-get-height (function vector float)) diff --git a/goal_src/kernel-defs.gc b/goal_src/kernel-defs.gc index 75b040f58..93799c8f1 100644 --- a/goal_src/kernel-defs.gc +++ b/goal_src/kernel-defs.gc @@ -228,7 +228,7 @@ ) (declare-type process basic) - +(declare-type res-lump basic) (deftype process-tree (basic) ((name basic :offset-assert 4) (mask process-mask :offset-assert 8) @@ -243,7 +243,7 @@ (new (symbol type basic) _type_ 0) (activate (_type_ process-tree basic pointer) process-tree 9) (deactivate (_type_) none 10) - (dummy-method-11 (_type_ object) none 11) + (copy-defaults (_type_ res-lump) none 11) (run-logic? (_type_) symbol 12) (dummy-method () none 13) ) diff --git a/goal_src/kernel/gkernel-h.gc b/goal_src/kernel/gkernel-h.gc index 623b9e961..bd7131301 100644 --- a/goal_src/kernel/gkernel-h.gc +++ b/goal_src/kernel/gkernel-h.gc @@ -212,7 +212,7 @@ (new (symbol type basic) _type_ 0) (activate (_type_ process-tree basic pointer) process-tree 9) (deactivate (_type_) none 10) - (dummy-method-11 (_type_ object) none 11) + (copy-defaults (_type_ res-lump) none 11) (run-logic? (_type_) symbol 12) (dummy-method () none 13) ) @@ -246,16 +246,9 @@ (connection-list connectable :inline :offset-assert #x60) (stack uint8 :dynamic :offset-assert #x70) ) - (:methods (new (symbol type basic int) _type_ 0) - (activate (_type_ process-tree basic pointer) process-tree 9) - (deactivate (process) none 10) - (dummy-method-11 (_type_ object) none 11) - (run-logic? (process) symbol 12) - (dummy-method () none 13) - ) - + ) :size-assert #x70 :method-count-assert 14 :no-runtime-type ;; already defined by kscheme. Don't do it again. @@ -593,4 +586,4 @@ (defmacro scratchpad-object (type &key (offset 0)) "Access an object on the scratchpad." `(the-as ,type (&+ *fake-scratchpad-data* ,offset)) - ) \ No newline at end of file + ) diff --git a/goal_src/levels/common/rigid-body-h.gc b/goal_src/levels/common/rigid-body-h.gc index de995e780..325ece7a2 100644 --- a/goal_src/levels/common/rigid-body-h.gc +++ b/goal_src/levels/common/rigid-body-h.gc @@ -31,20 +31,20 @@ :size-assert #x1a8 :flag-assert #x17000001a8 (:methods - (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-15 () none 15) - (dummy-16 () none 16) - (dummy-17 () none 17) - (dummy-18 () none 18) - (dummy-19 () none 19) - (dummy-20 () none 20) - (dummy-21 () none 21) - (dummy-22 () none 22) + (TODO-RENAME-9 (_type_ float float float float) none 9) + (dummy-10 (_type_ float) none 10) + (clear-force-torque! (_type_) none 11) + (clear-momentum! (_type_) none 12) + (TODO-RENAME-13 (_type_ vector vector) none 13) + (TODO-RENAME-14 (_type_ vector vector) none 14) + (TODO-RENAME-15 (_type_ vector) none 15) + (TODO-RENAME-16 (_type_ vector vector float) none 16) + (TODO-RENAME-17 (_type_ vector vector) vector 17) + (TODO-RENAME-18 (_type_ vector) vector 18) + (dummy-19 (_type_) none 19) + (dummy-20 (_type_) none 20) + (TODO-RENAME-21 (_type_) none 21) + (TODO-RENAME-22 (_type_ vector quaternion float float) none 22) ) ) diff --git a/goal_src/levels/common/rigid-body.gc b/goal_src/levels/common/rigid-body.gc index fdf6cad47..938f150e1 100644 --- a/goal_src/levels/common/rigid-body.gc +++ b/goal_src/levels/common/rigid-body.gc @@ -5,3 +5,1262 @@ ;; name in dgo: rigid-body ;; dgos: GAME, COMMON, L1 +;; definition for method 11 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod clear-force-torque! rigid-body ((obj rigid-body)) + (set! (-> obj force quad) (-> *null-vector* quad)) + (set! (-> obj torque quad) (-> *null-vector* quad)) + 0 + (none) + ) + +;; definition for method 12 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod clear-momentum! rigid-body ((obj rigid-body)) + (set! (-> obj lin-momentum quad) (-> *null-vector* quad)) + (set! (-> obj ang-momentum quad) (-> *null-vector* quad)) + 0 + (none) + ) + +;; definition for method 21 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-21 rigid-body ((obj rigid-body)) + (quaternion->matrix (-> obj matrix) (-> obj rotation)) + (TODO-RENAME-18 obj (-> obj matrix vector 3)) + 0 + (none) + ) + +;; definition for method 22 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + TODO-RENAME-22 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 quaternion) (arg2 float) (arg3 float)) + (clear-force-torque! obj) + (clear-momentum! obj) + (vector+! (-> obj position) arg0 (-> obj cm-offset-joint)) + (quaternion-copy! (-> obj rotation) arg1) + (quaternion-normalize! (-> obj rotation)) + (set! (-> obj lin-momentum-damping-factor) arg2) + (set! (-> obj ang-momentum-damping-factor) arg3) + (TODO-RENAME-21 obj) + (set! (-> obj lin-velocity quad) (-> *null-vector* quad)) + (set! (-> obj ang-velocity quad) (-> *null-vector* quad)) + (set! (-> obj inv-i-world vector 0 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 1 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 2 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 3 quad) (the-as uint128 0)) + (set! (-> obj max-ang-velocity) 0.0) + (set! (-> obj max-ang-momentum) 0.0) + 0 + (none) + ) + +;; definition for method 9 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-9 + rigid-body + ((obj rigid-body) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> obj mass) arg0) + (let ((f0-1 arg0)) + (set! (-> obj inv-mass) (/ 1.0 f0-1)) + ) + (matrix-identity! (-> obj inertial-tensor)) + (matrix-identity! (-> obj inv-inertial-tensor)) + (let* ((f0-4 arg0) + (f1-1 12.0) + (f0-5 (* f0-4 (/ 1.0 f1-1))) + ) + (let* ((f1-4 arg2) + (f1-6 (* f1-4 f1-4)) + (f2-1 arg3) + ) + (set! (-> obj inertial-tensor vector 0 x) (* f0-5 (+ f1-6 (* f2-1 f2-1)))) + ) + (let* ((f1-9 arg1) + (f1-11 (* f1-9 f1-9)) + (f2-4 arg3) + ) + (set! (-> obj inertial-tensor vector 1 y) (* f0-5 (+ f1-11 (* f2-4 f2-4)))) + ) + (let* ((f1-14 arg1) + (f1-16 (* f1-14 f1-14)) + (f2-7 arg2) + ) + (set! (-> obj inertial-tensor vector 2 z) (* f0-5 (+ f1-16 (* f2-7 f2-7)))) + ) + ) + (let ((f0-7 (-> obj inertial-tensor vector 0 x))) + (set! (-> obj inv-inertial-tensor vector 0 x) (/ 1.0 f0-7)) + ) + (let ((f0-10 (-> obj inertial-tensor vector 1 y))) + (set! (-> obj inv-inertial-tensor vector 1 y) (/ 1.0 f0-10)) + ) + (let ((f0-13 (-> obj inertial-tensor vector 2 z))) + (set! (-> obj inv-inertial-tensor vector 2 z) (/ 1.0 f0-13)) + ) + 0 + (none) + ) + +;; definition for method 17 of type rigid-body +(defmethod + TODO-RENAME-17 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position)))) + (vector-cross! arg1 (-> obj ang-velocity) v1-1) + ) + (vector+! arg1 arg1 (-> obj lin-velocity)) + arg1 + ) + +;; definition for function matrix-3x3-triple-transpose-product +(defun + matrix-3x3-triple-transpose-product + ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + (let ((s2-0 (new 'stack-no-clear 'matrix)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-transpose! s2-0 arg1) + (cond + (#t + (matrix*! s3-0 arg1 arg2) + (matrix*! arg0 s3-0 s2-0) + ) + (else + (matrix*! s3-0 s2-0 arg2) + (matrix*! arg0 s3-0 arg1) + ) + ) + ) + arg0 + ) + +;; definition for method 10 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod dummy-10 rigid-body ((obj rigid-body) (arg0 float)) + (vector+*! (-> obj lin-momentum) (-> obj lin-momentum) (-> obj force) arg0) + (vector+*! (-> obj ang-momentum) (-> obj ang-momentum) (-> obj torque) arg0) + (vector-float*! + (-> obj lin-momentum) + (-> obj lin-momentum) + (-> obj lin-momentum-damping-factor) + ) + (vector-float*! + (-> obj ang-momentum) + (-> obj ang-momentum) + (-> obj ang-momentum-damping-factor) + ) + (vector-float*! (-> obj lin-velocity) (-> obj lin-momentum) (-> obj inv-mass)) + (set! (-> obj matrix vector 3 quad) (-> *null-vector* quad)) + (matrix-3x3-triple-transpose-product + (-> obj inv-i-world) + (-> obj matrix) + (-> obj inv-inertial-tensor) + ) + (vector-rotate*! + (-> obj ang-velocity) + (-> obj ang-momentum) + (-> obj inv-i-world) + ) + (vector+*! (-> obj position) (-> obj position) (-> obj lin-velocity) arg0) + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (set! (-> (the-as vector (&-> s4-0 x)) quad) (-> obj ang-velocity quad)) + (set! (-> s4-0 w) 0.0) + (quaternion*! s4-0 s4-0 (-> obj rotation)) + (quaternion-float*! s4-0 s4-0 0.5) + (+! (-> obj rotation x) (* (-> s4-0 x) arg0)) + (+! (-> obj rotation y) (* (-> s4-0 y) arg0)) + (+! (-> obj rotation z) (* (-> s4-0 z) arg0)) + (+! (-> obj rotation w) (* (-> s4-0 w) arg0)) + ) + (quaternion-normalize! (-> obj rotation)) + (quaternion->matrix (-> obj matrix) (-> obj rotation)) + (TODO-RENAME-18 obj (-> obj matrix vector 3)) + 0 + (none) + ) + +;; definition for method 13 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-13 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (vector+! (-> obj force) (-> obj force) arg1) + (let* ((v1-2 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position))) + (a1-2 (vector-cross! (new 'stack-no-clear 'vector) v1-2 arg1)) + ) + (vector+! (-> obj torque) (-> obj torque) a1-2) + ) + 0 + (none) + ) + +;; definition for method 16 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-16 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector) (arg2 float)) + (vector+! (-> obj force) (-> obj force) arg1) + (let* ((a0-3 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position))) + (s4-1 (vector-cross! (new 'stack-no-clear 'vector) a0-3 arg1)) + ) + (let ((f0-0 (vector-length a0-3))) + (if (< arg2 f0-0) + (vector-float*! s4-1 s4-1 (/ arg2 f0-0)) + ) + ) + (vector+! (-> obj torque) (-> obj torque) s4-1) + ) + 0 + (none) + ) + +;; definition for method 14 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-14 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (vector-rotate*! s4-0 arg1 (-> obj matrix)) + (vector-rotate*! s5-0 arg0 (-> obj matrix)) + (vector+! s5-0 s5-0 (-> obj position)) + (TODO-RENAME-13 obj s5-0 s4-0) + ) + 0 + (none) + ) + +;; definition for method 15 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-15 rigid-body ((obj rigid-body) (arg0 vector)) + (vector+! (-> obj force) (-> obj force) arg0) + 0 + (none) + ) + +;; definition for method 18 of type rigid-body +(defmethod TODO-RENAME-18 rigid-body ((obj rigid-body) (arg0 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-rotate*! gp-0 (-> obj cm-offset-joint) (-> obj matrix)) + (vector-! arg0 (-> obj position) gp-0) + ) + arg0 + ) + +;; definition for method 19 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod dummy-19 rigid-body ((obj rigid-body)) + (format + #t + " force ~M ~M ~M" + (-> obj force x) + (-> obj force y) + (-> obj force z) + ) + (format + #t + " torque ~f ~f ~f~%" + (-> obj torque x) + (-> obj torque y) + (-> obj torque z) + ) + (format + #t + " position ~M ~M ~M" + (-> obj position x) + (-> obj position y) + (-> obj position z) + ) + (format + #t + " rotation ~f ~f ~f ~f~%" + (-> obj rotation x) + (-> obj rotation y) + (-> obj rotation z) + (-> obj rotation w) + ) + (format + #t + " lin-mom ~M ~M ~M" + (-> obj lin-momentum x) + (-> obj lin-momentum y) + (-> obj lin-momentum z) + ) + (format + #t + " ang-mom ~f ~f ~f~%" + (-> obj ang-momentum x) + (-> obj ang-momentum y) + (-> obj ang-momentum z) + ) + (format + #t + " lin-vel ~M ~M ~M" + (-> obj lin-velocity x) + (-> obj lin-velocity y) + (-> obj lin-velocity z) + ) + (format + #t + " ang-vel ~f ~f ~f~%" + (-> obj ang-velocity x) + (-> obj ang-velocity y) + (-> obj ang-velocity z) + ) + 0 + (none) + ) + +;; definition for method 20 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod dummy-20 rigid-body ((obj rigid-body)) + (format + #t + " force ~M ~M ~M" + (-> obj force x) + (-> obj force y) + (-> obj force z) + ) + (format + #t + " torque ~f ~f ~f~%" + (-> obj torque x) + (-> obj torque y) + (-> obj torque z) + ) + 0 + (none) + ) + +;; definition of type rigid-body-platform-constants +(deftype rigid-body-platform-constants (structure) + ((drag-factor float :offset-assert 0) + (buoyancy-factor float :offset-assert 4) + (max-buoyancy-depth meters :offset-assert 8) + (gravity-factor float :offset-assert 12) + (gravity meters :offset-assert 16) + (player-weight meters :offset-assert 20) + (player-bonk-factor float :offset-assert 24) + (player-dive-factor float :offset-assert 28) + (player-force-distance meters :offset-assert 32) + (player-force-clamp meters :offset-assert 36) + (player-force-timeout uint64 :offset-assert 40) + (explosion-force meters :offset-assert 48) + (linear-damping float :offset-assert 52) + (angular-damping float :offset-assert 56) + (control-point-count int32 :offset-assert 60) + (mass float :offset-assert 64) + (inertial-tensor-x meters :offset-assert 68) + (inertial-tensor-y meters :offset-assert 72) + (inertial-tensor-z meters :offset-assert 76) + (cm-joint-x meters :offset-assert 80) + (cm-joint-y meters :offset-assert 84) + (cm-joint-z meters :offset-assert 88) + (idle-distance meters :offset-assert 92) + (platform basic :offset-assert 96) + (sound-name basic :offset-assert 100) + ) + :method-count-assert 9 + :size-assert #x68 + :flag-assert #x900000068 + ) + +;; definition for method 3 of type rigid-body-platform-constants +(defmethod + inspect + rigid-body-platform-constants + ((obj rigid-body-platform-constants)) + (format #t "[~8x] ~A~%" obj 'rigid-body-platform-constants) + (format #t "~Tdrag-factor: ~f~%" (-> obj drag-factor)) + (format #t "~Tbuoyancy-factor: ~f~%" (-> obj buoyancy-factor)) + (format #t "~Tmax-buoyancy-depth: (meters ~m)~%" (-> obj max-buoyancy-depth)) + (format #t "~Tgravity-factor: ~f~%" (-> obj gravity-factor)) + (format #t "~Tgravity: (meters ~m)~%" (-> obj gravity)) + (format #t "~Tplayer-weight: (meters ~m)~%" (-> obj player-weight)) + (format #t "~Tplayer-bonk-factor: ~f~%" (-> obj player-bonk-factor)) + (format #t "~Tplayer-dive-factor: ~f~%" (-> obj player-dive-factor)) + (format + #t + "~Tplayer-force-distance: (meters ~m)~%" + (-> obj player-force-distance) + ) + (format #t "~Tplayer-force-clamp: (meters ~m)~%" (-> obj player-force-clamp)) + (format #t "~Tplayer-force-timeout: ~D~%" (-> obj player-force-timeout)) + (format #t "~Texplosion-force: (meters ~m)~%" (-> obj explosion-force)) + (format #t "~Tlinear-damping: ~f~%" (-> obj linear-damping)) + (format #t "~Tangular-damping: ~f~%" (-> obj angular-damping)) + (format #t "~Tcontrol-point-count: ~D~%" (-> obj control-point-count)) + (format #t "~Tmass: ~f~%" (-> obj mass)) + (format #t "~Tinertial-tensor-x: (meters ~m)~%" (-> obj inertial-tensor-x)) + (format #t "~Tinertial-tensor-y: (meters ~m)~%" (-> obj inertial-tensor-y)) + (format #t "~Tinertial-tensor-z: (meters ~m)~%" (-> obj inertial-tensor-z)) + (format #t "~Tcm-joint-x: (meters ~m)~%" (-> obj cm-joint-x)) + (format #t "~Tcm-joint-y: (meters ~m)~%" (-> obj cm-joint-y)) + (format #t "~Tcm-joint-z: (meters ~m)~%" (-> obj cm-joint-z)) + (format #t "~Tidle-distance: (meters ~m)~%" (-> obj idle-distance)) + (format #t "~Tplatform: ~A~%" (-> obj platform)) + (format #t "~Tsound-name: ~A~%" (-> obj sound-name)) + obj + ) + +;; definition of type rigid-body-control-point-inline-array +(deftype rigid-body-control-point-inline-array (inline-array-class) + ((data rigid-body-control-point :inline :dynamic :offset 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type rigid-body-control-point-inline-array +(defmethod + inspect + rigid-body-control-point-inline-array + ((obj rigid-body-control-point-inline-array)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj data)) + obj + ) + +;; failed to figure out what this is: +(set! (-> rigid-body-control-point-inline-array heap-base) (the-as uint 48)) + +;; definition of type rigid-body-platform +(deftype rigid-body-platform (process-drawable) + ((root-overlay collide-shape-moving :offset 112) + (info rigid-body-platform-constants :offset-assert 176) + (rbody rigid-body :inline :offset-assert 192) + (control-point-array rigid-body-control-point-inline-array :offset-assert 616) + (player-velocity vector :inline :offset-assert 624) + (player-velocity-prev vector :inline :offset-assert 640) + (player-force-position vector :inline :offset-assert 656) + (player-force vector :inline :offset-assert 672) + (sim-time-remaining float :offset-assert 688) + (float-height-offset float :offset-assert 692) + (player-attack-id int32 :offset-assert 696) + (player-bonk-timeout uint64 :offset-assert 704) + (water-anim water-anim :offset-assert 712) + (player-contact basic :offset-assert 716) + (player-impulse collide-shape-prim-mesh :offset-assert 720) + ) + :heap-base #x270 + :method-count-assert 35 + :size-assert #x2d4 + :flag-assert #x23027002d4 + (:methods + (rigid-body-platform-idle () none 20) + (rigid-body-platform-float () none 21) + (TODO-RENAME-22 (_type_ vector basic) float 22) + (TODO-RENAME-23 (_type_ basic) none 23) + (TODO-RENAME-24 (_type_ rigid-body-control-point basic) none 24) + (TODO-RENAME-25 (_type_) none 25) + (TODO-RENAME-26 (_type_) none 26) + (TODO-RENAME-27 (_type_ vector) none 27) + (TODO-RENAME-28 (_type_) none 28) + (TODO-RENAME-29 (_type_ rigid-body-platform-constants) none 29) + (TODO-RENAME-30 (_type_) none 30) + (TODO-RENAME-31 (_type_) none 31) + (dummy-32 (_type_) none 32) + (dummy-33 (_type_) none 33) + (TODO-RENAME-34 (_type_) none 34) + ) + ) + +;; definition for method 3 of type rigid-body-platform +(defmethod inspect rigid-body-platform ((obj rigid-body-platform)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format + #t + "~T~Tinfo: #~%" + (-> obj info) + ) + (format #t "~T~Trbody: #~%" (-> obj rbody)) + (format #t "~T~Tcontrol-point-array: ~A~%" (-> obj control-point-array)) + (format #t "~T~Tplayer-velocity: #~%" (-> obj player-velocity)) + (format + #t + "~T~Tplayer-velocity-prev: #~%" + (-> obj player-velocity-prev) + ) + (format + #t + "~T~Tplayer-force-position: #~%" + (-> obj player-force-position) + ) + (format #t "~T~Tplayer-force: #~%" (-> obj player-force)) + (format #t "~T~Tsim-time-remaining: ~f~%" (-> obj sim-time-remaining)) + (format #t "~T~Tfloat-height-offset: ~f~%" (-> obj float-height-offset)) + (format #t "~T~Tplayer-attack-id: ~D~%" (-> obj player-attack-id)) + (format #t "~T~Tplayer-bonk-timeout: ~D~%" (-> obj player-bonk-timeout)) + (format #t "~T~Twater-anim: ~A~%" (-> obj water-anim)) + (format #t "~T~Tplayer-contact: ~A~%" (-> obj player-contact)) + (format #t "~T~Tplayer-impulse: ~A~%" (-> obj player-impulse)) + obj + ) + +;; definition for method 7 of type rigid-body-platform +;; INFO: Return type mismatch process-drawable vs rigid-body-platform. +(defmethod relocate rigid-body-platform ((obj rigid-body-platform) (arg0 int)) + (if (nonzero? (-> obj control-point-array)) + (set! + (-> obj control-point-array) + (the-as + rigid-body-control-point-inline-array + (+ (the-as int (-> obj control-point-array)) arg0) + ) + ) + ) + (the-as + rigid-body-platform + ((the-as + (function process-drawable int process-drawable) + (find-parent-method rigid-body-platform 7) + ) + obj + arg0 + ) + ) + ) + +;; definition for method 22 of type rigid-body-platform +(defmethod + TODO-RENAME-22 + rigid-body-platform + ((obj rigid-body-platform) (arg0 vector) (arg1 basic)) + (let ((v1-0 (-> obj water-anim))) + 0.0 + (+ (the-as float (cond + (v1-0 + (let* ((a2-1 v1-0) + (a0-1 (if a2-1 + (-> a2-1 ppointer-water-anim 3) + ) + ) + ) + (if a0-1 + (get-ripple-height a0-1 arg0) + (-> v1-0 ppointer-water-anim 9) + ) + ) + ) + (else + (ocean-get-height arg0) + ) + ) + ) + (-> obj float-height-offset) + ) + ) + ) + +;; definition for method 24 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-24 + rigid-body-platform + ((obj rigid-body-platform) (arg0 rigid-body-control-point) (arg1 basic)) + (set! (-> arg0 world-pos w) (TODO-RENAME-22 obj (-> arg0 world-pos) arg1)) + (let* ((s4-0 (new 'stack-no-clear 'vector)) + (f0-2 (- (-> arg0 world-pos w) (-> arg0 world-pos y))) + (f30-0 (/ f0-2 (-> obj info max-buoyancy-depth))) + ) + (when (< 0.0 f0-2) + (vector-float*! + s4-0 + *y-vector* + (* + (* + (* + (* (-> obj rbody mass) (fmin 1.0 f30-0)) + (/ (-> obj info gravity) (the float (-> obj info control-point-count))) + ) + (-> obj info gravity-factor) + ) + (-> obj info buoyancy-factor) + ) + ) + (TODO-RENAME-13 (-> obj rbody) (-> arg0 world-pos) s4-0) + (vector-float*! + s4-0 + (-> arg0 velocity) + (* (* -1.0 (-> obj info drag-factor)) (fmin 1.0 f30-0)) + ) + (TODO-RENAME-13 (-> obj rbody) (-> arg0 world-pos) s4-0) + ) + ) + 0 + 0 + (none) + ) + +;; definition for method 25 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-25 rigid-body-platform ((obj rigid-body-platform)) + (when (or (-> obj player-impulse) (-> obj player-contact)) + (set! (-> obj player-impulse) #f) + (TODO-RENAME-16 + (-> obj rbody) + (-> obj player-force-position) + (-> obj player-force) + (-> obj info player-force-distance) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-26 rigid-body-platform ((obj rigid-body-platform)) + (let ((a1-0 (new 'stack-no-clear 'vector))) + (vector-float*! + a1-0 + *y-vector* + (* + (* (* -1.0 (-> obj info gravity-factor)) (-> obj info gravity)) + (-> obj rbody mass) + ) + ) + (TODO-RENAME-15 (-> obj rbody) a1-0) + ) + 0 + (none) + ) + +;; definition for method 27 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-27 + rigid-body-platform + ((obj rigid-body-platform) (arg0 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 arg0 (-> obj rbody position)) + (set! (-> gp-0 y) 0.0) + (let* ((f0-1 (vector-length gp-0)) + (f1-1 (* 10.0 (fmax 0.0 (fmin 4096.0 (+ -4096.0 f0-1))))) + ) + (when (< 0.0 f1-1) + (vector-float*! gp-0 gp-0 (/ f1-1 f0-1)) + (TODO-RENAME-15 (-> obj rbody) gp-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 23 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-23 + rigid-body-platform + ((obj rigid-body-platform) (arg0 basic)) + (let ((s4-0 (-> obj rbody matrix))) + (dotimes (s3-0 (-> obj info control-point-count)) + (let ((s2-0 (-> obj control-point-array data s3-0))) + (vector-matrix*! (-> s2-0 world-pos) (-> s2-0 local-pos) s4-0) + (TODO-RENAME-17 (-> obj rbody) (-> s2-0 world-pos) (-> s2-0 velocity)) + (TODO-RENAME-24 obj s2-0 arg0) + ) + ) + ) + (TODO-RENAME-26 obj) + (TODO-RENAME-25 obj) + 0 + (none) + ) + +;; definition for method 28 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod TODO-RENAME-28 rigid-body-platform ((obj rigid-body-platform)) + (if (-> obj info platform) + (dummy-35 (-> obj root-overlay)) + ) + (set! (-> obj player-velocity-prev quad) (-> obj player-velocity quad)) + (if *target* + (set! (-> obj player-velocity quad) (-> *target* control transv quad)) + (set! (-> obj player-velocity quad) (-> *null-vector* quad)) + ) + (+! + (-> obj sim-time-remaining) + (* + 0.0033333334 + (the + float + (- (-> *display* base-frame-counter) (-> *display* old-base-frame-counter)) + ) + ) + ) + (let ((f30-0 0.016666668) + (f28-0 + (* + 0.0033333334 + (the float (logand #xffffff (-> *display* base-frame-counter))) + ) + ) + ) + (while (>= (-> obj sim-time-remaining) (* 0.5 f30-0)) + (clear-force-torque! (-> obj rbody)) + (TODO-RENAME-23 obj (the-as basic f28-0)) + (dummy-10 (-> obj rbody) f30-0) + (set! (-> obj sim-time-remaining) (- (-> obj sim-time-remaining) f30-0)) + ) + ) + (set! (-> obj player-contact) #f) + 0 + (none) + ) + +;; definition for function rigid-body-platform-event-handler +;; INFO: Return type mismatch vector vs object. +;; Used lq/sq +(defbehavior + rigid-body-platform-event-handler rigid-body-platform + ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('bonk) + (when + (>= + (the-as + int + (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) + ) + (the-as int (-> self info player-force-timeout)) + ) + (set! (-> self player-bonk-timeout) (-> *display* base-frame-counter)) + (let* ((s5-0 arg0) + (v1-7 + (if + (and + (nonzero? s5-0) + (type-type? (-> s5-0 type) process-drawable) + ) + s5-0 + ) + ) + ) + (when v1-7 + (set! (-> self player-impulse) (the-as collide-shape-prim-mesh #t)) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-7) root trans quad) + ) + (let + ((f0-4 + (fmin + (* + (* + (* 0.00012207031 (the-as float (-> arg3 param 1))) + (-> self info player-bonk-factor) + ) + (-> self info player-weight) + ) + (-> self info player-force-clamp) + ) + ) + ) + (vector-float*! (-> self player-force) *y-vector* (- f0-4)) + ) + ) + ) + ) + ) + (('attack) + (let ((v1-16 (-> arg3 param 2))) + (when (!= v1-16 (-> self player-attack-id)) + (set! (-> self player-attack-id) (the-as int v1-16)) + (the-as vector (cond + ((= (-> arg3 param 1) 'flop) + (when + (>= + (the-as + int + (- + (-> *display* base-frame-counter) + (-> self player-bonk-timeout) + ) + ) + (the-as int (-> self info player-force-timeout)) + ) + (set! + (-> self player-bonk-timeout) + (-> *display* base-frame-counter) + ) + (let* ((gp-1 arg0) + (v1-24 + (if + (and + (nonzero? gp-1) + (type-type? (-> gp-1 type) process-drawable) + ) + gp-1 + ) + ) + ) + (when v1-24 + (set! + (-> self player-impulse) + (the-as collide-shape-prim-mesh #t) + ) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-24) root trans quad) + ) + (let + ((f0-9 + (fmin + (* + (* 16.0 (-> self info player-weight)) + (-> self info player-dive-factor) + ) + (-> self info player-force-clamp) + ) + ) + ) + (vector-float*! + (-> self player-force) + *y-vector* + (- f0-9) + ) + ) + ) + ) + ) + ) + ((= (-> arg3 param 1) 'explode) + (let* ((gp-2 arg0) + (v1-34 + (if + (and + (nonzero? gp-2) + (type-type? (-> gp-2 type) process-drawable) + ) + gp-2 + ) + ) + ) + (when v1-34 + (set! + (-> self player-impulse) + (the-as collide-shape-prim-mesh #t) + ) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-34) root trans quad) + ) + (vector-! + (-> self player-force) + (-> self rbody position) + (-> (the-as process-drawable v1-34) root trans) + ) + (vector-normalize! + (-> self player-force) + (-> self info explosion-force) + ) + ) + ) + ) + (else + (the-as vector #f) + ) + ) + ) + ) + ) + ) + (('impulse) + (let ((s5-1 arg0)) + (when + (if (and (nonzero? s5-1) (type-type? (-> s5-1 type) process-drawable)) + s5-1 + ) + (set! (-> self player-impulse) (the-as collide-shape-prim-mesh #t)) + (set! (-> self player-force-position quad) (-> self rbody position quad)) + (let ((v0-0 (-> self player-force))) + (set! (-> v0-0 quad) (-> (the-as vector (-> arg3 param 0)) quad)) + v0-0 + ) + ) + ) + ) + (('edge-grabbed) + (let ((v1-44 (-> arg3 param 0))) + (when (not (-> self player-impulse)) + (set! (-> self player-contact) #t) + (set! + (-> self player-force-position quad) + (-> (the-as vector (+ v1-44 32)) quad) + ) + (vector-float*! + (-> self player-force) + *y-vector* + (* -1.0 (-> self info player-weight)) + ) + ) + ) + ) + (('ridden) + (let ((v1-48 (the-as object (-> arg3 param 0)))) + (when (the-as uint v1-48) + (let ((v1-50 (handle->process (-> (the-as (pointer handle) v1-48) 0)))) + (when + (and + v1-50 + (= v1-50 *target*) + (!= (-> *target* control unknown-surface mode) 'swim) + ) + (when (not (-> self player-impulse)) + (set! (-> self player-contact) #t) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-50) root trans quad) + ) + (set! (-> self player-force quad) (-> *null-vector* quad)) + (vector+*! + (-> self player-force) + (-> self player-force) + *y-vector* + (* -1.0 (-> self info player-weight)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for function rigid-body-platform-post +(defbehavior rigid-body-platform-post rigid-body-platform () + (set! + (-> self rbody lin-momentum-damping-factor) + (-> self info linear-damping) + ) + (set! + (-> self rbody ang-momentum-damping-factor) + (-> self info angular-damping) + ) + (if (-> self player-impulse) + (sound-play-by-name + (string->sound-name (the-as string (-> self info sound-name))) + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (TODO-RENAME-28 self) + (quaternion-copy! (-> self root-overlay quat) (-> self rbody rotation)) + (TODO-RENAME-18 (-> self rbody) (-> self root-overlay trans)) + (if (-> self info platform) + (rider-post) + (transform-post) + ) + ) + +;; failed to figure out what this is: +(let + ((gp-0 + (new 'static 'state + :name 'rigid-body-platform-idle + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + ) + ) + (method-set! rigid-body-platform 20 (the-as function gp-0)) + (set! + (-> gp-0 trans) + (the-as + (function object) + (lambda :behavior rigid-body-platform + () + (when + (and + *target* + (>= + (-> self info idle-distance) + (vector-vector-distance + (-> self root-overlay trans) + (-> *target* control trans) + ) + ) + ) + (let ((t9-1 (the-as (function object) enter-state))) + (set! + (-> self next-state) + (the-as state (method-of-object self rigid-body-platform-float)) + ) + (t9-1) + ) + ) + (none) + ) + ) + ) + (set! (-> gp-0 code) (lambda :behavior rigid-body-platform () (while #t + (suspend) + ) + (none) + ) + ) + (set! (-> gp-0 post) ja-post) + ) + +;; failed to figure out what this is: +(let + ((gp-1 + (new 'static 'state + :name 'rigid-body-platform-float + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + ) + ) + (method-set! rigid-body-platform 21 (the-as function gp-1)) + (set! (-> gp-1 event) rigid-body-platform-event-handler) + (set! + (-> gp-1 trans) + (the-as + (function object) + (lambda :behavior rigid-body-platform + () + (when + (or + (not *target*) + (< + (-> self info idle-distance) + (vector-vector-distance + (-> self root-overlay trans) + (-> *target* control trans) + ) + ) + ) + (let ((t9-1 (the-as (function object) enter-state))) + (set! + (-> self next-state) + (the-as state (method-of-object self rigid-body-platform-idle)) + ) + (t9-1) + ) + ) + (none) + ) + ) + ) + (set! (-> gp-1 code) (lambda :behavior rigid-body-platform () (while #t + (suspend) + ) + (none) + ) + ) + (set! (-> gp-1 post) rigid-body-platform-post) + ) + +;; definition for method 29 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + TODO-RENAME-29 + rigid-body-platform + ((obj rigid-body-platform) (arg0 rigid-body-platform-constants)) + (set! (-> obj info) arg0) + (set! + (-> obj control-point-array) + (new + 'process + 'rigid-body-control-point-inline-array + (-> obj info control-point-count) + ) + ) + (logior! (-> obj skel status) 1) + (dummy-47 (-> obj root-overlay)) + (set-vector! + (-> obj rbody cm-offset-joint) + (-> obj info cm-joint-x) + (-> obj info cm-joint-y) + (-> obj info cm-joint-z) + 1.0 + ) + (TODO-RENAME-22 + (-> obj rbody) + (-> obj root-overlay trans) + (-> obj root-overlay quat) + (-> obj info linear-damping) + (-> obj info angular-damping) + ) + (TODO-RENAME-9 + (-> obj rbody) + (-> obj info mass) + (-> obj info inertial-tensor-x) + (-> obj info inertial-tensor-y) + (-> obj info inertial-tensor-z) + ) + (set! (-> obj player-impulse) #f) + (set! (-> obj player-contact) #f) + (set! (-> obj player-bonk-timeout) (-> *display* base-frame-counter)) + (set! (-> obj player-force quad) (-> *null-vector* quad)) + (set! (-> obj player-velocity quad) (-> *null-vector* quad)) + (set! (-> obj player-velocity-prev quad) (-> *null-vector* quad)) + (set! + (-> obj water-anim) + (the-as water-anim (entity-actor-lookup (-> obj entity) 'water-actor 0)) + ) + 0 + (none) + ) + +;; definition for method 30 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-30 rigid-body-platform ((obj rigid-body-platform)) + (let + ((s5-0 + (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)) + ) + ) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) default-collision-reaction) + (set! (-> s5-0 no-reaction) nothing) + (let ((t9-2 (method-of-object s5-0 dummy-29))) + 1 + (t9-2) + ) + (let + ((s4-0 + (new + 'process + 'collide-shape-prim-mesh + s5-0 + (the-as uint 0) + (the-as uint 0) + ) + ) + ) + (set! (-> s4-0 prim-core collide-as) (the-as uint 2048)) + (set! (-> s4-0 collide-with) (the-as uint 16)) + (set! (-> s4-0 prim-core action) (the-as uint 3)) + (set! (-> s4-0 prim-core offense) 4) + (set! (-> s4-0 transform-index) 0) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 20480.0) + ) + ((method-of-object s5-0 dummy-46)) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + ((method-of-object s5-0 dummy-50)) + (set! (-> obj root-overlay) s5-0) + ) + 0 + (none) + ) + +;; definition for symbol *rigid-body-platform-constants*, type rigid-body-platform-constants +(define + *rigid-body-platform-constants* + (new 'static 'rigid-body-platform-constants + :drag-factor 0.8 + :buoyancy-factor 1.5 + :max-buoyancy-depth (meters 1.5) + :gravity-factor 1.0 + :gravity (meters 10.0) + :player-weight (meters 6.6) + :player-bonk-factor 1.0 + :player-dive-factor 1.0 + :player-force-distance (meters 1000.0) + :player-force-clamp (meters 1000000.0) + :player-force-timeout #x1e + :explosion-force (meters 1000.0) + :linear-damping 1.0 + :angular-damping 1.0 + :control-point-count 1 + :mass 2.0 + :inertial-tensor-x (meters 3.0) + :inertial-tensor-y (meters 2.0) + :inertial-tensor-z (meters 3.0) + :idle-distance (meters 50.0) + :platform #t + :sound-name #f + ) + ) + +;; definition for method 34 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-34 rigid-body-platform ((obj rigid-body-platform)) + (with-pp + (let ((t9-0 (the-as (function object) enter-state))) + (set! + (-> pp next-state) + (the-as state (method-of-object obj rigid-body-platform-idle)) + ) + (t9-0) + ) + 0 + (none) + ) + ) + +;; definition for method 31 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-31 rigid-body-platform ((obj rigid-body-platform)) + (set! (-> obj float-height-offset) 0.0) + (TODO-RENAME-29 obj *rigid-body-platform-constants*) + (let ((s5-0 (-> obj info control-point-count))) + (dotimes (s4-0 s5-0) + (let ((s3-0 (-> obj control-point-array data s4-0))) + (let ((f30-0 (* 65536.0 (/ (the float s4-0) (the float s5-0))))) + (set! (-> s3-0 local-pos x) (* 12288.0 (sin f30-0))) + (set! (-> s3-0 local-pos y) -10240.0) + (set! (-> s3-0 local-pos z) (* 12288.0 (cos f30-0))) + ) + (set! (-> s3-0 local-pos w) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + copy-defaults + rigid-body-platform + ((obj rigid-body-platform) (arg0 res-lump)) + (set! (-> obj mask) (the-as process-mask (logior #x80000 (-> obj mask)))) + (TODO-RENAME-30 obj) + (process-drawable-from-entity! obj arg0) + (TODO-RENAME-31 obj) + (TODO-RENAME-34 obj) + 0 + (none) + ) diff --git a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc index 8375ee893..446e16bbe 100644 --- a/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc +++ b/test/decompiler/reference/engine/collide/collide-shape-h_REF.gc @@ -94,8 +94,8 @@ ((move-vec vector :inline :offset-assert 16) (best-u float :offset-assert 32) (best-tri collide-tri-result :inline :offset-assert 48) - (best-from-prim basic :offset-assert 132) - (best-to-prim basic :offset-assert 136) + (best-from-prim collide-shape-prim :offset-assert 132) + (best-to-prim collide-shape-prim :offset-assert 136) ) :method-count-assert 10 :size-assert #x8c @@ -119,8 +119,8 @@ ;; definition of type collide-overlap-result (deftype collide-overlap-result (structure) ((best-dist float :offset-assert 0) - (best-from-prim basic :offset-assert 4) - (best-to-prim basic :offset-assert 8) + (best-from-prim collide-shape-prim :offset-assert 4) + (best-to-prim collide-shape-prim :offset-assert 8) (best-from-tri collide-tri-result :inline :offset-assert 16) ) :method-count-assert 10 diff --git a/test/decompiler/reference/levels/common/rigid-body_REF.gc b/test/decompiler/reference/levels/common/rigid-body_REF.gc new file mode 100644 index 000000000..4c79a75d5 --- /dev/null +++ b/test/decompiler/reference/levels/common/rigid-body_REF.gc @@ -0,0 +1,1261 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition for method 11 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod clear-force-torque! rigid-body ((obj rigid-body)) + (set! (-> obj force quad) (-> *null-vector* quad)) + (set! (-> obj torque quad) (-> *null-vector* quad)) + 0 + (none) + ) + +;; definition for method 12 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod clear-momentum! rigid-body ((obj rigid-body)) + (set! (-> obj lin-momentum quad) (-> *null-vector* quad)) + (set! (-> obj ang-momentum quad) (-> *null-vector* quad)) + 0 + (none) + ) + +;; definition for method 21 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-21 rigid-body ((obj rigid-body)) + (quaternion->matrix (-> obj matrix) (-> obj rotation)) + (TODO-RENAME-18 obj (-> obj matrix vector 3)) + 0 + (none) + ) + +;; definition for method 22 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + TODO-RENAME-22 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 quaternion) (arg2 float) (arg3 float)) + (clear-force-torque! obj) + (clear-momentum! obj) + (vector+! (-> obj position) arg0 (-> obj cm-offset-joint)) + (quaternion-copy! (-> obj rotation) arg1) + (quaternion-normalize! (-> obj rotation)) + (set! (-> obj lin-momentum-damping-factor) arg2) + (set! (-> obj ang-momentum-damping-factor) arg3) + (TODO-RENAME-21 obj) + (set! (-> obj lin-velocity quad) (-> *null-vector* quad)) + (set! (-> obj ang-velocity quad) (-> *null-vector* quad)) + (set! (-> obj inv-i-world vector 0 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 1 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 2 quad) (the-as uint128 0)) + (set! (-> obj inv-i-world vector 3 quad) (the-as uint128 0)) + (set! (-> obj max-ang-velocity) 0.0) + (set! (-> obj max-ang-momentum) 0.0) + 0 + (none) + ) + +;; definition for method 9 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-9 + rigid-body + ((obj rigid-body) (arg0 float) (arg1 float) (arg2 float) (arg3 float)) + (set! (-> obj mass) arg0) + (let ((f0-1 arg0)) + (set! (-> obj inv-mass) (/ 1.0 f0-1)) + ) + (matrix-identity! (-> obj inertial-tensor)) + (matrix-identity! (-> obj inv-inertial-tensor)) + (let* ((f0-4 arg0) + (f1-1 12.0) + (f0-5 (* f0-4 (/ 1.0 f1-1))) + ) + (let* ((f1-4 arg2) + (f1-6 (* f1-4 f1-4)) + (f2-1 arg3) + ) + (set! (-> obj inertial-tensor vector 0 x) (* f0-5 (+ f1-6 (* f2-1 f2-1)))) + ) + (let* ((f1-9 arg1) + (f1-11 (* f1-9 f1-9)) + (f2-4 arg3) + ) + (set! (-> obj inertial-tensor vector 1 y) (* f0-5 (+ f1-11 (* f2-4 f2-4)))) + ) + (let* ((f1-14 arg1) + (f1-16 (* f1-14 f1-14)) + (f2-7 arg2) + ) + (set! (-> obj inertial-tensor vector 2 z) (* f0-5 (+ f1-16 (* f2-7 f2-7)))) + ) + ) + (let ((f0-7 (-> obj inertial-tensor vector 0 x))) + (set! (-> obj inv-inertial-tensor vector 0 x) (/ 1.0 f0-7)) + ) + (let ((f0-10 (-> obj inertial-tensor vector 1 y))) + (set! (-> obj inv-inertial-tensor vector 1 y) (/ 1.0 f0-10)) + ) + (let ((f0-13 (-> obj inertial-tensor vector 2 z))) + (set! (-> obj inv-inertial-tensor vector 2 z) (/ 1.0 f0-13)) + ) + 0 + (none) + ) + +;; definition for method 17 of type rigid-body +(defmethod + TODO-RENAME-17 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (let ((v1-1 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position)))) + (vector-cross! arg1 (-> obj ang-velocity) v1-1) + ) + (vector+! arg1 arg1 (-> obj lin-velocity)) + arg1 + ) + +;; definition for function matrix-3x3-triple-transpose-product +(defun + matrix-3x3-triple-transpose-product + ((arg0 matrix) (arg1 matrix) (arg2 matrix)) + (let ((s2-0 (new 'stack-no-clear 'matrix)) + (s3-0 (new 'stack-no-clear 'matrix)) + ) + (matrix-transpose! s2-0 arg1) + (cond + (#t + (matrix*! s3-0 arg1 arg2) + (matrix*! arg0 s3-0 s2-0) + ) + (else + (matrix*! s3-0 s2-0 arg2) + (matrix*! arg0 s3-0 arg1) + ) + ) + ) + arg0 + ) + +;; definition for method 10 of type rigid-body +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod dummy-10 rigid-body ((obj rigid-body) (arg0 float)) + (vector+*! (-> obj lin-momentum) (-> obj lin-momentum) (-> obj force) arg0) + (vector+*! (-> obj ang-momentum) (-> obj ang-momentum) (-> obj torque) arg0) + (vector-float*! + (-> obj lin-momentum) + (-> obj lin-momentum) + (-> obj lin-momentum-damping-factor) + ) + (vector-float*! + (-> obj ang-momentum) + (-> obj ang-momentum) + (-> obj ang-momentum-damping-factor) + ) + (vector-float*! (-> obj lin-velocity) (-> obj lin-momentum) (-> obj inv-mass)) + (set! (-> obj matrix vector 3 quad) (-> *null-vector* quad)) + (matrix-3x3-triple-transpose-product + (-> obj inv-i-world) + (-> obj matrix) + (-> obj inv-inertial-tensor) + ) + (vector-rotate*! + (-> obj ang-velocity) + (-> obj ang-momentum) + (-> obj inv-i-world) + ) + (vector+*! (-> obj position) (-> obj position) (-> obj lin-velocity) arg0) + (let ((s4-0 (new 'stack-no-clear 'quaternion))) + (set! (-> (the-as vector (&-> s4-0 x)) quad) (-> obj ang-velocity quad)) + (set! (-> s4-0 w) 0.0) + (quaternion*! s4-0 s4-0 (-> obj rotation)) + (quaternion-float*! s4-0 s4-0 0.5) + (+! (-> obj rotation x) (* (-> s4-0 x) arg0)) + (+! (-> obj rotation y) (* (-> s4-0 y) arg0)) + (+! (-> obj rotation z) (* (-> s4-0 z) arg0)) + (+! (-> obj rotation w) (* (-> s4-0 w) arg0)) + ) + (quaternion-normalize! (-> obj rotation)) + (quaternion->matrix (-> obj matrix) (-> obj rotation)) + (TODO-RENAME-18 obj (-> obj matrix vector 3)) + 0 + (none) + ) + +;; definition for method 13 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-13 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (vector+! (-> obj force) (-> obj force) arg1) + (let* ((v1-2 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position))) + (a1-2 (vector-cross! (new 'stack-no-clear 'vector) v1-2 arg1)) + ) + (vector+! (-> obj torque) (-> obj torque) a1-2) + ) + 0 + (none) + ) + +;; definition for method 16 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-16 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector) (arg2 float)) + (vector+! (-> obj force) (-> obj force) arg1) + (let* ((a0-3 (vector-! (new 'stack-no-clear 'vector) arg0 (-> obj position))) + (s4-1 (vector-cross! (new 'stack-no-clear 'vector) a0-3 arg1)) + ) + (let ((f0-0 (vector-length a0-3))) + (if (< arg2 f0-0) + (vector-float*! s4-1 s4-1 (/ arg2 f0-0)) + ) + ) + (vector+! (-> obj torque) (-> obj torque) s4-1) + ) + 0 + (none) + ) + +;; definition for method 14 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-14 + rigid-body + ((obj rigid-body) (arg0 vector) (arg1 vector)) + (let ((s5-0 (new 'stack-no-clear 'vector)) + (s4-0 (new 'stack-no-clear 'vector)) + ) + (vector-rotate*! s4-0 arg1 (-> obj matrix)) + (vector-rotate*! s5-0 arg0 (-> obj matrix)) + (vector+! s5-0 s5-0 (-> obj position)) + (TODO-RENAME-13 obj s5-0 s4-0) + ) + 0 + (none) + ) + +;; definition for method 15 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-15 rigid-body ((obj rigid-body) (arg0 vector)) + (vector+! (-> obj force) (-> obj force) arg0) + 0 + (none) + ) + +;; definition for method 18 of type rigid-body +(defmethod TODO-RENAME-18 rigid-body ((obj rigid-body) (arg0 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-rotate*! gp-0 (-> obj cm-offset-joint) (-> obj matrix)) + (vector-! arg0 (-> obj position) gp-0) + ) + arg0 + ) + +;; definition for method 19 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod dummy-19 rigid-body ((obj rigid-body)) + (format + #t + " force ~M ~M ~M" + (-> obj force x) + (-> obj force y) + (-> obj force z) + ) + (format + #t + " torque ~f ~f ~f~%" + (-> obj torque x) + (-> obj torque y) + (-> obj torque z) + ) + (format + #t + " position ~M ~M ~M" + (-> obj position x) + (-> obj position y) + (-> obj position z) + ) + (format + #t + " rotation ~f ~f ~f ~f~%" + (-> obj rotation x) + (-> obj rotation y) + (-> obj rotation z) + (-> obj rotation w) + ) + (format + #t + " lin-mom ~M ~M ~M" + (-> obj lin-momentum x) + (-> obj lin-momentum y) + (-> obj lin-momentum z) + ) + (format + #t + " ang-mom ~f ~f ~f~%" + (-> obj ang-momentum x) + (-> obj ang-momentum y) + (-> obj ang-momentum z) + ) + (format + #t + " lin-vel ~M ~M ~M" + (-> obj lin-velocity x) + (-> obj lin-velocity y) + (-> obj lin-velocity z) + ) + (format + #t + " ang-vel ~f ~f ~f~%" + (-> obj ang-velocity x) + (-> obj ang-velocity y) + (-> obj ang-velocity z) + ) + 0 + (none) + ) + +;; definition for method 20 of type rigid-body +;; INFO: Return type mismatch int vs none. +(defmethod dummy-20 rigid-body ((obj rigid-body)) + (format + #t + " force ~M ~M ~M" + (-> obj force x) + (-> obj force y) + (-> obj force z) + ) + (format + #t + " torque ~f ~f ~f~%" + (-> obj torque x) + (-> obj torque y) + (-> obj torque z) + ) + 0 + (none) + ) + +;; definition of type rigid-body-platform-constants +(deftype rigid-body-platform-constants (structure) + ((drag-factor float :offset-assert 0) + (buoyancy-factor float :offset-assert 4) + (max-buoyancy-depth meters :offset-assert 8) + (gravity-factor float :offset-assert 12) + (gravity meters :offset-assert 16) + (player-weight meters :offset-assert 20) + (player-bonk-factor float :offset-assert 24) + (player-dive-factor float :offset-assert 28) + (player-force-distance meters :offset-assert 32) + (player-force-clamp meters :offset-assert 36) + (player-force-timeout uint64 :offset-assert 40) + (explosion-force meters :offset-assert 48) + (linear-damping float :offset-assert 52) + (angular-damping float :offset-assert 56) + (control-point-count int32 :offset-assert 60) + (mass float :offset-assert 64) + (inertial-tensor-x meters :offset-assert 68) + (inertial-tensor-y meters :offset-assert 72) + (inertial-tensor-z meters :offset-assert 76) + (cm-joint-x meters :offset-assert 80) + (cm-joint-y meters :offset-assert 84) + (cm-joint-z meters :offset-assert 88) + (idle-distance meters :offset-assert 92) + (platform basic :offset-assert 96) + (sound-name basic :offset-assert 100) + ) + :method-count-assert 9 + :size-assert #x68 + :flag-assert #x900000068 + ) + +;; definition for method 3 of type rigid-body-platform-constants +(defmethod + inspect + rigid-body-platform-constants + ((obj rigid-body-platform-constants)) + (format #t "[~8x] ~A~%" obj 'rigid-body-platform-constants) + (format #t "~Tdrag-factor: ~f~%" (-> obj drag-factor)) + (format #t "~Tbuoyancy-factor: ~f~%" (-> obj buoyancy-factor)) + (format #t "~Tmax-buoyancy-depth: (meters ~m)~%" (-> obj max-buoyancy-depth)) + (format #t "~Tgravity-factor: ~f~%" (-> obj gravity-factor)) + (format #t "~Tgravity: (meters ~m)~%" (-> obj gravity)) + (format #t "~Tplayer-weight: (meters ~m)~%" (-> obj player-weight)) + (format #t "~Tplayer-bonk-factor: ~f~%" (-> obj player-bonk-factor)) + (format #t "~Tplayer-dive-factor: ~f~%" (-> obj player-dive-factor)) + (format + #t + "~Tplayer-force-distance: (meters ~m)~%" + (-> obj player-force-distance) + ) + (format #t "~Tplayer-force-clamp: (meters ~m)~%" (-> obj player-force-clamp)) + (format #t "~Tplayer-force-timeout: ~D~%" (-> obj player-force-timeout)) + (format #t "~Texplosion-force: (meters ~m)~%" (-> obj explosion-force)) + (format #t "~Tlinear-damping: ~f~%" (-> obj linear-damping)) + (format #t "~Tangular-damping: ~f~%" (-> obj angular-damping)) + (format #t "~Tcontrol-point-count: ~D~%" (-> obj control-point-count)) + (format #t "~Tmass: ~f~%" (-> obj mass)) + (format #t "~Tinertial-tensor-x: (meters ~m)~%" (-> obj inertial-tensor-x)) + (format #t "~Tinertial-tensor-y: (meters ~m)~%" (-> obj inertial-tensor-y)) + (format #t "~Tinertial-tensor-z: (meters ~m)~%" (-> obj inertial-tensor-z)) + (format #t "~Tcm-joint-x: (meters ~m)~%" (-> obj cm-joint-x)) + (format #t "~Tcm-joint-y: (meters ~m)~%" (-> obj cm-joint-y)) + (format #t "~Tcm-joint-z: (meters ~m)~%" (-> obj cm-joint-z)) + (format #t "~Tidle-distance: (meters ~m)~%" (-> obj idle-distance)) + (format #t "~Tplatform: ~A~%" (-> obj platform)) + (format #t "~Tsound-name: ~A~%" (-> obj sound-name)) + obj + ) + +;; definition of type rigid-body-control-point-inline-array +(deftype rigid-body-control-point-inline-array (inline-array-class) + ((data rigid-body-control-point :inline :dynamic :offset 16) + ) + :method-count-assert 9 + :size-assert #x10 + :flag-assert #x900000010 + ) + +;; definition for method 3 of type rigid-body-control-point-inline-array +(defmethod + inspect + rigid-body-control-point-inline-array + ((obj rigid-body-control-point-inline-array)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlength: ~D~%" (-> obj length)) + (format #t "~Tallocated-length: ~D~%" (-> obj allocated-length)) + (format #t "~Tdata[0] @ #x~X~%" (-> obj data)) + obj + ) + +;; failed to figure out what this is: +(set! (-> rigid-body-control-point-inline-array heap-base) (the-as uint 48)) + +;; definition of type rigid-body-platform +(deftype rigid-body-platform (process-drawable) + ((root-overlay collide-shape-moving :offset 112) + (info rigid-body-platform-constants :offset-assert 176) + (rbody rigid-body :inline :offset-assert 192) + (control-point-array rigid-body-control-point-inline-array :offset-assert 616) + (player-velocity vector :inline :offset-assert 624) + (player-velocity-prev vector :inline :offset-assert 640) + (player-force-position vector :inline :offset-assert 656) + (player-force vector :inline :offset-assert 672) + (sim-time-remaining float :offset-assert 688) + (float-height-offset float :offset-assert 692) + (player-attack-id int32 :offset-assert 696) + (player-bonk-timeout uint64 :offset-assert 704) + (water-anim water-anim :offset-assert 712) + (player-contact basic :offset-assert 716) + (player-impulse collide-shape-prim-mesh :offset-assert 720) + ) + :heap-base #x270 + :method-count-assert 35 + :size-assert #x2d4 + :flag-assert #x23027002d4 + (:methods + (rigid-body-platform-idle () none 20) + (rigid-body-platform-float () none 21) + (TODO-RENAME-22 (_type_ vector basic) float 22) + (TODO-RENAME-23 (_type_ basic) none 23) + (TODO-RENAME-24 (_type_ rigid-body-control-point basic) none 24) + (TODO-RENAME-25 (_type_) none 25) + (TODO-RENAME-26 (_type_) none 26) + (TODO-RENAME-27 (_type_ vector) none 27) + (TODO-RENAME-28 (_type_) none 28) + (TODO-RENAME-29 (_type_ rigid-body-platform-constants) none 29) + (TODO-RENAME-30 (_type_) none 30) + (TODO-RENAME-31 (_type_) none 31) + (dummy-32 (_type_) none 32) + (dummy-33 (_type_) none 33) + (TODO-RENAME-34 (_type_) none 34) + ) + ) + +;; definition for method 3 of type rigid-body-platform +(defmethod inspect rigid-body-platform ((obj rigid-body-platform)) + (let ((t9-0 (method-of-type process-drawable inspect))) + (t9-0 obj) + ) + (format + #t + "~T~Tinfo: #~%" + (-> obj info) + ) + (format #t "~T~Trbody: #~%" (-> obj rbody)) + (format #t "~T~Tcontrol-point-array: ~A~%" (-> obj control-point-array)) + (format #t "~T~Tplayer-velocity: #~%" (-> obj player-velocity)) + (format + #t + "~T~Tplayer-velocity-prev: #~%" + (-> obj player-velocity-prev) + ) + (format + #t + "~T~Tplayer-force-position: #~%" + (-> obj player-force-position) + ) + (format #t "~T~Tplayer-force: #~%" (-> obj player-force)) + (format #t "~T~Tsim-time-remaining: ~f~%" (-> obj sim-time-remaining)) + (format #t "~T~Tfloat-height-offset: ~f~%" (-> obj float-height-offset)) + (format #t "~T~Tplayer-attack-id: ~D~%" (-> obj player-attack-id)) + (format #t "~T~Tplayer-bonk-timeout: ~D~%" (-> obj player-bonk-timeout)) + (format #t "~T~Twater-anim: ~A~%" (-> obj water-anim)) + (format #t "~T~Tplayer-contact: ~A~%" (-> obj player-contact)) + (format #t "~T~Tplayer-impulse: ~A~%" (-> obj player-impulse)) + obj + ) + +;; definition for method 7 of type rigid-body-platform +;; INFO: Return type mismatch process-drawable vs rigid-body-platform. +(defmethod relocate rigid-body-platform ((obj rigid-body-platform) (arg0 int)) + (if (nonzero? (-> obj control-point-array)) + (set! + (-> obj control-point-array) + (the-as + rigid-body-control-point-inline-array + (+ (the-as int (-> obj control-point-array)) arg0) + ) + ) + ) + (the-as + rigid-body-platform + ((the-as + (function process-drawable int process-drawable) + (find-parent-method rigid-body-platform 7) + ) + obj + arg0 + ) + ) + ) + +;; definition for method 22 of type rigid-body-platform +(defmethod + TODO-RENAME-22 + rigid-body-platform + ((obj rigid-body-platform) (arg0 vector) (arg1 basic)) + (let ((v1-0 (-> obj water-anim))) + 0.0 + (+ (the-as float (cond + (v1-0 + (let* ((a2-1 v1-0) + (a0-1 (if a2-1 + (-> a2-1 ppointer-water-anim 3) + ) + ) + ) + (if a0-1 + (get-ripple-height a0-1 arg0) + (-> v1-0 ppointer-water-anim 9) + ) + ) + ) + (else + (ocean-get-height arg0) + ) + ) + ) + (-> obj float-height-offset) + ) + ) + ) + +;; definition for method 24 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-24 + rigid-body-platform + ((obj rigid-body-platform) (arg0 rigid-body-control-point) (arg1 basic)) + (set! (-> arg0 world-pos w) (TODO-RENAME-22 obj (-> arg0 world-pos) arg1)) + (let* ((s4-0 (new 'stack-no-clear 'vector)) + (f0-2 (- (-> arg0 world-pos w) (-> arg0 world-pos y))) + (f30-0 (/ f0-2 (-> obj info max-buoyancy-depth))) + ) + (when (< 0.0 f0-2) + (vector-float*! + s4-0 + *y-vector* + (* + (* + (* + (* (-> obj rbody mass) (fmin 1.0 f30-0)) + (/ (-> obj info gravity) (the float (-> obj info control-point-count))) + ) + (-> obj info gravity-factor) + ) + (-> obj info buoyancy-factor) + ) + ) + (TODO-RENAME-13 (-> obj rbody) (-> arg0 world-pos) s4-0) + (vector-float*! + s4-0 + (-> arg0 velocity) + (* (* -1.0 (-> obj info drag-factor)) (fmin 1.0 f30-0)) + ) + (TODO-RENAME-13 (-> obj rbody) (-> arg0 world-pos) s4-0) + ) + ) + 0 + 0 + (none) + ) + +;; definition for method 25 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-25 rigid-body-platform ((obj rigid-body-platform)) + (when (or (-> obj player-impulse) (-> obj player-contact)) + (set! (-> obj player-impulse) #f) + (TODO-RENAME-16 + (-> obj rbody) + (-> obj player-force-position) + (-> obj player-force) + (-> obj info player-force-distance) + ) + ) + 0 + (none) + ) + +;; definition for method 26 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-26 rigid-body-platform ((obj rigid-body-platform)) + (let ((a1-0 (new 'stack-no-clear 'vector))) + (vector-float*! + a1-0 + *y-vector* + (* + (* (* -1.0 (-> obj info gravity-factor)) (-> obj info gravity)) + (-> obj rbody mass) + ) + ) + (TODO-RENAME-15 (-> obj rbody) a1-0) + ) + 0 + (none) + ) + +;; definition for method 27 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-27 + rigid-body-platform + ((obj rigid-body-platform) (arg0 vector)) + (let ((gp-0 (new 'stack-no-clear 'vector))) + (vector-! gp-0 arg0 (-> obj rbody position)) + (set! (-> gp-0 y) 0.0) + (let* ((f0-1 (vector-length gp-0)) + (f1-1 (* 10.0 (fmax 0.0 (fmin 4096.0 (+ -4096.0 f0-1))))) + ) + (when (< 0.0 f1-1) + (vector-float*! gp-0 gp-0 (/ f1-1 f0-1)) + (TODO-RENAME-15 (-> obj rbody) gp-0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 23 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + TODO-RENAME-23 + rigid-body-platform + ((obj rigid-body-platform) (arg0 basic)) + (let ((s4-0 (-> obj rbody matrix))) + (dotimes (s3-0 (-> obj info control-point-count)) + (let ((s2-0 (-> obj control-point-array data s3-0))) + (vector-matrix*! (-> s2-0 world-pos) (-> s2-0 local-pos) s4-0) + (TODO-RENAME-17 (-> obj rbody) (-> s2-0 world-pos) (-> s2-0 velocity)) + (TODO-RENAME-24 obj s2-0 arg0) + ) + ) + ) + (TODO-RENAME-26 obj) + (TODO-RENAME-25 obj) + 0 + (none) + ) + +;; definition for method 28 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod TODO-RENAME-28 rigid-body-platform ((obj rigid-body-platform)) + (if (-> obj info platform) + (dummy-35 (-> obj root-overlay)) + ) + (set! (-> obj player-velocity-prev quad) (-> obj player-velocity quad)) + (if *target* + (set! (-> obj player-velocity quad) (-> *target* control transv quad)) + (set! (-> obj player-velocity quad) (-> *null-vector* quad)) + ) + (+! + (-> obj sim-time-remaining) + (* + 0.0033333334 + (the + float + (- (-> *display* base-frame-counter) (-> *display* old-base-frame-counter)) + ) + ) + ) + (let ((f30-0 0.016666668) + (f28-0 + (* + 0.0033333334 + (the float (logand #xffffff (-> *display* base-frame-counter))) + ) + ) + ) + (while (>= (-> obj sim-time-remaining) (* 0.5 f30-0)) + (clear-force-torque! (-> obj rbody)) + (TODO-RENAME-23 obj (the-as basic f28-0)) + (dummy-10 (-> obj rbody) f30-0) + (set! (-> obj sim-time-remaining) (- (-> obj sim-time-remaining) f30-0)) + ) + ) + (set! (-> obj player-contact) #f) + 0 + (none) + ) + +;; definition for function rigid-body-platform-event-handler +;; Used lq/sq +(defbehavior + rigid-body-platform-event-handler rigid-body-platform + ((arg0 process) (arg1 int) (arg2 symbol) (arg3 event-message-block)) + (case arg2 + (('bonk) + (when + (>= + (the-as + int + (- (-> *display* base-frame-counter) (-> self player-bonk-timeout)) + ) + (the-as int (-> self info player-force-timeout)) + ) + (set! (-> self player-bonk-timeout) (-> *display* base-frame-counter)) + (let* ((s5-0 arg0) + (v1-7 + (if + (and + (nonzero? s5-0) + (type-type? (-> s5-0 type) process-drawable) + ) + s5-0 + ) + ) + ) + (when v1-7 + (set! (-> self player-impulse) (the-as collide-shape-prim-mesh #t)) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-7) root trans quad) + ) + (let + ((f0-4 + (fmin + (* + (* + (* 0.00012207031 (the-as float (-> arg3 param 1))) + (-> self info player-bonk-factor) + ) + (-> self info player-weight) + ) + (-> self info player-force-clamp) + ) + ) + ) + (vector-float*! (-> self player-force) *y-vector* (- f0-4)) + ) + ) + ) + ) + ) + (('attack) + (let ((v1-16 (-> arg3 param 2))) + (when (!= v1-16 (-> self player-attack-id)) + (set! (-> self player-attack-id) (the-as int v1-16)) + (the-as vector (cond + ((= (-> arg3 param 1) 'flop) + (when + (>= + (the-as + int + (- + (-> *display* base-frame-counter) + (-> self player-bonk-timeout) + ) + ) + (the-as int (-> self info player-force-timeout)) + ) + (set! + (-> self player-bonk-timeout) + (-> *display* base-frame-counter) + ) + (let* ((gp-1 arg0) + (v1-24 + (if + (and + (nonzero? gp-1) + (type-type? (-> gp-1 type) process-drawable) + ) + gp-1 + ) + ) + ) + (when v1-24 + (set! + (-> self player-impulse) + (the-as collide-shape-prim-mesh #t) + ) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-24) root trans quad) + ) + (let + ((f0-9 + (fmin + (* + (* 16.0 (-> self info player-weight)) + (-> self info player-dive-factor) + ) + (-> self info player-force-clamp) + ) + ) + ) + (vector-float*! + (-> self player-force) + *y-vector* + (- f0-9) + ) + ) + ) + ) + ) + ) + ((= (-> arg3 param 1) 'explode) + (let* ((gp-2 arg0) + (v1-34 + (if + (and + (nonzero? gp-2) + (type-type? (-> gp-2 type) process-drawable) + ) + gp-2 + ) + ) + ) + (when v1-34 + (set! + (-> self player-impulse) + (the-as collide-shape-prim-mesh #t) + ) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-34) root trans quad) + ) + (vector-! + (-> self player-force) + (-> self rbody position) + (-> (the-as process-drawable v1-34) root trans) + ) + (vector-normalize! + (-> self player-force) + (-> self info explosion-force) + ) + ) + ) + ) + (else + (the-as vector #f) + ) + ) + ) + ) + ) + ) + (('impulse) + (let ((s5-1 arg0)) + (when + (if (and (nonzero? s5-1) (type-type? (-> s5-1 type) process-drawable)) + s5-1 + ) + (set! (-> self player-impulse) (the-as collide-shape-prim-mesh #t)) + (set! (-> self player-force-position quad) (-> self rbody position quad)) + (let ((v0-0 (-> self player-force))) + (set! (-> v0-0 quad) (-> (the-as vector (-> arg3 param 0)) quad)) + v0-0 + ) + ) + ) + ) + (('edge-grabbed) + (let ((v1-44 (-> arg3 param 0))) + (when (not (-> self player-impulse)) + (set! (-> self player-contact) #t) + (set! + (-> self player-force-position quad) + (-> (the-as vector (+ v1-44 32)) quad) + ) + (vector-float*! + (-> self player-force) + *y-vector* + (* -1.0 (-> self info player-weight)) + ) + ) + ) + ) + (('ridden) + (let ((v1-48 (the-as object (-> arg3 param 0)))) + (when (the-as uint v1-48) + (let ((v1-50 (handle->process (-> (the-as (pointer handle) v1-48) 0)))) + (when + (and + v1-50 + (= v1-50 *target*) + (!= (-> *target* control unknown-surface mode) 'swim) + ) + (when (not (-> self player-impulse)) + (set! (-> self player-contact) #t) + (set! + (-> self player-force-position quad) + (-> (the-as process-drawable v1-50) root trans quad) + ) + (set! (-> self player-force quad) (-> *null-vector* quad)) + (vector+*! + (-> self player-force) + (-> self player-force) + *y-vector* + (* -1.0 (-> self info player-weight)) + ) + ) + ) + ) + ) + ) + ) + ) + ) + +;; definition for function rigid-body-platform-post +(defbehavior rigid-body-platform-post rigid-body-platform () + (set! + (-> self rbody lin-momentum-damping-factor) + (-> self info linear-damping) + ) + (set! + (-> self rbody ang-momentum-damping-factor) + (-> self info angular-damping) + ) + (if (-> self player-impulse) + (sound-play-by-name + (string->sound-name (the-as string (-> self info sound-name))) + (new-sound-id) + 1024 + 0 + 0 + (the-as uint 1) + (the-as vector #t) + ) + ) + (TODO-RENAME-28 self) + (quaternion-copy! (-> self root-overlay quat) (-> self rbody rotation)) + (TODO-RENAME-18 (-> self rbody) (-> self root-overlay trans)) + (if (-> self info platform) + (rider-post) + (transform-post) + ) + ) + +;; failed to figure out what this is: +(let + ((gp-0 + (new 'static 'state + :name 'rigid-body-platform-idle + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + ) + ) + (method-set! rigid-body-platform 20 (the-as function gp-0)) + (set! + (-> gp-0 trans) + (the-as + (function object) + (lambda :behavior rigid-body-platform + () + (when + (and + *target* + (>= + (-> self info idle-distance) + (vector-vector-distance + (-> self root-overlay trans) + (-> *target* control trans) + ) + ) + ) + (let ((t9-1 (the-as (function object) enter-state))) + (set! + (-> self next-state) + (the-as state (method-of-object self rigid-body-platform-float)) + ) + (t9-1) + ) + ) + (none) + ) + ) + ) + (set! (-> gp-0 code) (lambda :behavior rigid-body-platform () (while #t + (suspend) + ) + (none) + ) + ) + (set! (-> gp-0 post) ja-post) + ) + +;; failed to figure out what this is: +(let + ((gp-1 + (new 'static 'state + :name 'rigid-body-platform-float + :next #f + :exit #f + :code #f + :trans #f + :post #f + :enter #f + :event #f + ) + ) + ) + (method-set! rigid-body-platform 21 (the-as function gp-1)) + (set! (-> gp-1 event) rigid-body-platform-event-handler) + (set! + (-> gp-1 trans) + (the-as + (function object) + (lambda :behavior rigid-body-platform + () + (when + (or + (not *target*) + (< + (-> self info idle-distance) + (vector-vector-distance + (-> self root-overlay trans) + (-> *target* control trans) + ) + ) + ) + (let ((t9-1 (the-as (function object) enter-state))) + (set! + (-> self next-state) + (the-as state (method-of-object self rigid-body-platform-idle)) + ) + (t9-1) + ) + ) + (none) + ) + ) + ) + (set! (-> gp-1 code) (lambda :behavior rigid-body-platform () (while #t + (suspend) + ) + (none) + ) + ) + (set! (-> gp-1 post) rigid-body-platform-post) + ) + +;; definition for method 29 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + TODO-RENAME-29 + rigid-body-platform + ((obj rigid-body-platform) (arg0 rigid-body-platform-constants)) + (set! (-> obj info) arg0) + (set! + (-> obj control-point-array) + (new + 'process + 'rigid-body-control-point-inline-array + (-> obj info control-point-count) + ) + ) + (logior! (-> obj skel status) 1) + (dummy-47 (-> obj root-overlay)) + (set-vector! + (-> obj rbody cm-offset-joint) + (-> obj info cm-joint-x) + (-> obj info cm-joint-y) + (-> obj info cm-joint-z) + 1.0 + ) + (TODO-RENAME-22 + (-> obj rbody) + (-> obj root-overlay trans) + (-> obj root-overlay quat) + (-> obj info linear-damping) + (-> obj info angular-damping) + ) + (TODO-RENAME-9 + (-> obj rbody) + (-> obj info mass) + (-> obj info inertial-tensor-x) + (-> obj info inertial-tensor-y) + (-> obj info inertial-tensor-z) + ) + (set! (-> obj player-impulse) #f) + (set! (-> obj player-contact) #f) + (set! (-> obj player-bonk-timeout) (-> *display* base-frame-counter)) + (set! (-> obj player-force quad) (-> *null-vector* quad)) + (set! (-> obj player-velocity quad) (-> *null-vector* quad)) + (set! (-> obj player-velocity-prev quad) (-> *null-vector* quad)) + (set! + (-> obj water-anim) + (the-as water-anim (entity-actor-lookup (-> obj entity) 'water-actor 0)) + ) + 0 + (none) + ) + +;; definition for method 30 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-30 rigid-body-platform ((obj rigid-body-platform)) + (let + ((s5-0 + (new 'process 'collide-shape-moving obj (collide-list-enum hit-by-player)) + ) + ) + (set! (-> s5-0 dynam) (copy *standard-dynamics* 'process)) + (set! (-> s5-0 reaction) default-collision-reaction) + (set! (-> s5-0 no-reaction) nothing) + (let ((t9-2 (method-of-object s5-0 dummy-29))) + 1 + (t9-2) + ) + (let + ((s4-0 + (new + 'process + 'collide-shape-prim-mesh + s5-0 + (the-as uint 0) + (the-as uint 0) + ) + ) + ) + (set! (-> s4-0 prim-core collide-as) (the-as uint 2048)) + (set! (-> s4-0 collide-with) (the-as uint 16)) + (set! (-> s4-0 prim-core action) (the-as uint 3)) + (set! (-> s4-0 prim-core offense) 4) + (set! (-> s4-0 transform-index) 0) + (set-vector! (-> s4-0 local-sphere) 0.0 0.0 0.0 20480.0) + ) + ((method-of-object s5-0 dummy-46)) + (set! (-> s5-0 nav-radius) (* 0.75 (-> s5-0 root-prim local-sphere w))) + ((method-of-object s5-0 dummy-50)) + (set! (-> obj root-overlay) s5-0) + ) + 0 + (none) + ) + +;; definition for symbol *rigid-body-platform-constants*, type rigid-body-platform-constants +(define + *rigid-body-platform-constants* + (new 'static 'rigid-body-platform-constants + :drag-factor 0.8 + :buoyancy-factor 1.5 + :max-buoyancy-depth (meters 1.5) + :gravity-factor 1.0 + :gravity (meters 10.0) + :player-weight (meters 6.6) + :player-bonk-factor 1.0 + :player-dive-factor 1.0 + :player-force-distance (meters 1000.0) + :player-force-clamp (meters 1000000.0) + :player-force-timeout #x1e + :explosion-force (meters 1000.0) + :linear-damping 1.0 + :angular-damping 1.0 + :control-point-count 1 + :mass 2.0 + :inertial-tensor-x (meters 3.0) + :inertial-tensor-y (meters 2.0) + :inertial-tensor-z (meters 3.0) + :idle-distance (meters 50.0) + :platform #t + :sound-name #f + ) + ) + +;; definition for method 34 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-34 rigid-body-platform ((obj rigid-body-platform)) + (with-pp + (let ((t9-0 (the-as (function object) enter-state))) + (set! + (-> pp next-state) + (the-as state (method-of-object obj rigid-body-platform-idle)) + ) + (t9-0) + ) + 0 + (none) + ) + ) + +;; definition for method 31 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod TODO-RENAME-31 rigid-body-platform ((obj rigid-body-platform)) + (set! (-> obj float-height-offset) 0.0) + (TODO-RENAME-29 obj *rigid-body-platform-constants*) + (let ((s5-0 (-> obj info control-point-count))) + (dotimes (s4-0 s5-0) + (let ((s3-0 (-> obj control-point-array data s4-0))) + (let ((f30-0 (* 65536.0 (/ (the float s4-0) (the float s5-0))))) + (set! (-> s3-0 local-pos x) (* 12288.0 (sin f30-0))) + (set! (-> s3-0 local-pos y) -10240.0) + (set! (-> s3-0 local-pos z) (* 12288.0 (cos f30-0))) + ) + (set! (-> s3-0 local-pos w) 1.0) + ) + ) + ) + 0 + (none) + ) + +;; definition for method 11 of type rigid-body-platform +;; INFO: Return type mismatch int vs none. +(defmethod + copy-defaults + rigid-body-platform + ((obj rigid-body-platform) (arg0 res-lump)) + (set! (-> obj mask) (the-as process-mask (logior #x80000 (-> obj mask)))) + (TODO-RENAME-30 obj) + (process-drawable-from-entity! obj arg0) + (TODO-RENAME-31 obj) + (TODO-RENAME-34 obj) + 0 + (none) + )