diff --git a/decompiler/IR2/Form.cpp b/decompiler/IR2/Form.cpp index 2c5306afef..6534863bc5 100644 --- a/decompiler/IR2/Form.cpp +++ b/decompiler/IR2/Form.cpp @@ -1542,6 +1542,8 @@ std::string fixed_operator_to_string(FixedOperatorKind kind) { return "&"; case FixedOperatorKind::ASM_SLLV_R0: return ".asm.sllv.r0"; + case FixedOperatorKind::ASM_MADDS: + return ".asm.madd.s"; default: assert(false); return ""; @@ -2493,4 +2495,16 @@ FormElement* make_cast_using_existing(FormElement* elt, const TypeSpec& type, Fo } } +GenericElement* alloc_generic_token_op(const std::string& name, + const std::vector& args, + FormPool& pool) { + auto op = GenericOperator::make_function( + pool.alloc_single_element_form(nullptr, name)); + return pool.alloc_element(op, args); +} + +Form* alloc_var_form(const RegisterAccess& var, FormPool& pool) { + return pool.alloc_single_element_form(nullptr, SimpleAtom::make_var(var)); +} + } // namespace decompiler diff --git a/decompiler/IR2/Form.h b/decompiler/IR2/Form.h index cdb7c742ca..e09735c3ad 100644 --- a/decompiler/IR2/Form.h +++ b/decompiler/IR2/Form.h @@ -1645,4 +1645,8 @@ std::optional form_element_as_atom(const FormElement* f); std::optional form_as_atom(const Form* f); FormElement* make_cast_using_existing(Form* form, const TypeSpec& type, FormPool& pool); FormElement* make_cast_using_existing(FormElement* elt, const TypeSpec& type, FormPool& pool); +GenericElement* alloc_generic_token_op(const std::string& name, + const std::vector& args, + FormPool& pool); +Form* alloc_var_form(const RegisterAccess& var, FormPool& pool); } // namespace decompiler diff --git a/decompiler/IR2/FormExpressionAnalysis.cpp b/decompiler/IR2/FormExpressionAnalysis.cpp index 5ac7b5f2f2..7bd95d14cb 100644 --- a/decompiler/IR2/FormExpressionAnalysis.cpp +++ b/decompiler/IR2/FormExpressionAnalysis.cpp @@ -3110,6 +3110,29 @@ void push_asm_pextuw_to_stack(const AsmOp* op, } } +void push_asm_madds_to_stack(const AsmOp* op, + FormElement* /*form_elt*/, + const Env& env, + FormPool& pool, + FormStack& stack) { + auto src0 = op->src(0); + assert(src0.has_value()); + + auto src1 = op->src(1); + assert(src1.has_value()); + + auto dst = op->dst(); + assert(dst.has_value()); + + auto vars = pop_to_forms({*src0, *src1}, env, pool, stack, true); + + stack.push_value_to_reg( + *dst, + pool.alloc_single_element_form( + nullptr, GenericOperator::make_fixed(FixedOperatorKind::ASM_MADDS), vars), + true, env.get_variable_type(*dst, true)); +} + void push_asm_to_stack(const AsmOp* op, FormElement* form_elt, const Env& env, @@ -3128,6 +3151,11 @@ void push_asm_to_stack(const AsmOp* op, case InstructionKind::PEXTUW: push_asm_pextuw_to_stack(op, form_elt, env, pool, stack); break; + /* + case InstructionKind::MADDS: + push_asm_madds_to_stack(op, form_elt, env, pool, stack); + break; + */ default: stack.push_form_element(form_elt, true); break; diff --git a/decompiler/IR2/IR2_common.h b/decompiler/IR2/IR2_common.h index 5c41b53860..e00f1063c4 100644 --- a/decompiler/IR2/IR2_common.h +++ b/decompiler/IR2/IR2_common.h @@ -147,6 +147,7 @@ enum class FixedOperatorKind { SYMBOL_TO_STRING, ADDRESS_OF, ASM_SLLV_R0, + ASM_MADDS, INVALID }; diff --git a/decompiler/analysis/insert_lets.cpp b/decompiler/analysis/insert_lets.cpp index 57e051f8be..702bd51da3 100644 --- a/decompiler/analysis/insert_lets.cpp +++ b/decompiler/analysis/insert_lets.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "insert_lets.h" #include "decompiler/IR2/GenericElementMatcher.h" @@ -383,6 +384,105 @@ FormElement* rewrite_let(LetElement* in, const Env& env, FormPool& pool) { return nullptr; } +FormElement* rewrite_multi_let_as_vector_dot(LetElement* in, const Env& env, FormPool& pool) { + if (in->body()->size() != 3) { + return nullptr; + } + + /* The body: + (.mula.s f1-11 f4-0) + (.madda.s f2-1 f5-0) + (.madd.s f1-12 f3-0 f6-0) + */ + + // get asm ops + std::array vars; + std::array kinds = {InstructionKind::MULAS, InstructionKind::MADDAS, + InstructionKind::MADDS}; + for (int i = 0; i < 3; i++) { + auto as_op = dynamic_cast(in->body()->at(i)); + if (!as_op) { + return nullptr; + } + if (as_op->op()->instruction().kind != kinds[i]) { + return nullptr; + } + for (int j = 0; j < 2; j++) { + assert(as_op->op()->src(j).has_value()); + vars[i][j] = *as_op->op()->src(j); + } + } + + RegisterAccess output = *dynamic_cast(in->body()->at(2))->op()->dst(); + int start_idx = in->entries().size() - 6; + + std::optional in_vars[2]; + for (int in_var = 0; in_var < 2; in_var++) { + for (int axis = 0; axis < 3; axis++) { + int idx = start_idx + in_var * 3 + axis; + std::string axis_name(1, "xyz"[axis]); + auto matcher = + Matcher::deref(Matcher::any_reg(0), false, {DerefTokenMatcher::string(axis_name)}); + auto mr = match(matcher, in->entries().at(idx).src); + if (!mr.matched) { + return nullptr; + } + auto this_var = mr.maps.regs.at(0); + assert(this_var.has_value()); + if (in_vars[in_var].has_value()) { + // seen it before + if (env.get_variable_name(*this_var) != env.get_variable_name(*in_vars[in_var])) { + return nullptr; + } + } else { + assert(axis == 0); + // first time seeing it. + in_vars[in_var] = this_var; + } + + if (env.get_variable_name(vars[axis][in_var]) != + env.get_variable_name(in->entries().at(idx).dest)) { + return nullptr; + } + } + } + + // don't inline in the actual function... + if (env.func->guessed_name.to_string() == "vector-dot") { + return nullptr; + } + + auto dot_op = alloc_generic_token_op( + "vector-dot", {alloc_var_form(*in_vars[0], pool), alloc_var_form(*in_vars[1], pool)}, pool); + auto dot_set = pool.alloc_element(output, pool.alloc_single_form(nullptr, dot_op), + true, TypeSpec("float")); + + // remove let forms: + for (int i = 0; i < 6; i++) { + in->entries().pop_back(); + } + + if (in->entries().empty()) { + dot_set->parent_form = in->parent_form; + return dot_set; + } + // replace body: + in->body()->elts().clear(); + in->body()->push_back(dot_set); + return in; +} + +FormElement* rewrite_multi_let(LetElement* in, const Env& env, FormPool& pool) { + if (in->entries().size() >= 6) { + auto as_vector_dot = rewrite_multi_let_as_vector_dot(in, env, pool); + if (as_vector_dot) { + return as_vector_dot; + } + } + + return in; +} + Form* insert_cast_for_let(RegisterAccess dst, const TypeSpec& src_type, Form* src, @@ -668,37 +768,44 @@ LetStats insert_lets(const Function& func, Env& env, FormPool& pool, Form* top_l bool changed = true; while (changed) { changed = false; - top_level_form->apply([&](FormElement* f) { - auto as_let = dynamic_cast(f); - if (!as_let) { - return; - } + top_level_form->apply_form([&](Form* form) { + for (int idx = 0; idx < form->size(); idx++) { + auto* f = form->at(idx); + auto as_let = dynamic_cast(f); + if (!as_let) { + continue; + } - auto inner_let = dynamic_cast(as_let->body()->try_as_single_element()); - if (!inner_let) { - return; - } + auto inner_let = dynamic_cast(as_let->body()->try_as_single_element()); + if (!inner_let) { + continue; + } - for (auto& e : inner_let->entries()) { - if (!as_let->is_star()) { - RegAccessSet used; - e.src->collect_vars(used, true); - std::unordered_set used_by_name; - for (auto used_var : used) { - used_by_name.insert(env.get_variable_name(used_var)); - } - for (auto& old_entry : as_let->entries()) { - if (used_by_name.find(env.get_variable_name(old_entry.dest)) != used_by_name.end()) { - as_let->make_let_star(); - break; + for (auto& e : inner_let->entries()) { + if (!as_let->is_star()) { + RegAccessSet used; + e.src->collect_vars(used, true); + std::unordered_set used_by_name; + for (auto used_var : used) { + used_by_name.insert(env.get_variable_name(used_var)); + } + for (auto& old_entry : as_let->entries()) { + if (used_by_name.find(env.get_variable_name(old_entry.dest)) != used_by_name.end()) { + as_let->make_let_star(); + break; + } } } + as_let->add_entry(e); } - as_let->add_entry(e); - } - as_let->set_body(inner_let->body()); - changed = true; + as_let->set_body(inner_let->body()); + + // rewrite: + form->at(idx) = rewrite_multi_let(as_let, env, pool); + assert(form->at(idx)->parent_form == form); + changed = true; + } }); } diff --git a/decompiler/config/all-types.gc b/decompiler/config/all-types.gc index 88ff072e01..597363d75b 100644 --- a/decompiler/config/all-types.gc +++ b/decompiler/config/all-types.gc @@ -1573,9 +1573,9 @@ ;; - Types (deftype matrix (structure) - ((data float 16 :offset-assert 0) - (vector vector 4 :inline :offset 0) + ((vector vector 4 :inline :offset 0) (quad uint128 4 :offset 0) + (data float 16 :offset 0) ) :method-count-assert 10 :size-assert #x40 diff --git a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc index e8452dc768..cb9856899d 100644 --- a/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/type_casts.jsonc @@ -470,7 +470,7 @@ "(method 11 joint-mod)": [ [15, "s3", "process-drawable"], [[26, 66], "s3", "fact-info-enemy"], - [46, "v1", "(pointer process)"] + [[45, 50], "v1", "(pointer process)"] ], "joint-mod-look-at-handler": [[[2, 254], "gp", "joint-mod"]], diff --git a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc index 48f9873ad5..6b3d71121e 100644 --- a/decompiler/config/jak1_ntsc_black_label/var_names.jsonc +++ b/decompiler/config/jak1_ntsc_black_label/var_names.jsonc @@ -1804,7 +1804,7 @@ "(method 14 joint-mod)": { "args": ["obj", "trans", "rot", "scale"] }, "(method 11 joint-mod)": { "args": ["obj", "target-trans", "option", "proc"], - "vars": { "s1-0": "proc-drawable", "s3-1": "enemy-facts", "f30-0": "dist" } + "vars": { "s1-0": "proc-drawable", "s3-1": ["enemy-facts", "fact-info-enemy"], "f30-0": "dist", "v1-12": ["ppointer", "(pointer process)"] } }, "joint-mod-look-at-handler": { "args": ["csp", "xform", "mat"] } diff --git a/goal_src/engine/anim/joint-h.gc b/goal_src/engine/anim/joint-h.gc index 6cabfcbae0..24771dc105 100644 --- a/goal_src/engine/anim/joint-h.gc +++ b/goal_src/engine/anim/joint-h.gc @@ -98,3 +98,7 @@ :size-assert #x3640 :flag-assert #x900003640 ) + +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) +(define-extern cspace<-transformq! (function cspace transformq matrix)) +(define-extern vector<-cspace! (function vector cspace vector)) \ No newline at end of file diff --git a/goal_src/engine/debug/debug-h.gc b/goal_src/engine/debug/debug-h.gc index 0e89a803c8..5c8520beb0 100644 --- a/goal_src/engine/debug/debug-h.gc +++ b/goal_src/engine/debug/debug-h.gc @@ -41,3 +41,5 @@ ) +(define-extern add-debug-matrix (function symbol bucket-id matrix none)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba none)) \ No newline at end of file diff --git a/goal_src/engine/game/game-h.gc b/goal_src/engine/game/game-h.gc index 56b305adff..909fc8c21c 100644 --- a/goal_src/engine/game/game-h.gc +++ b/goal_src/engine/game/game-h.gc @@ -129,3 +129,4 @@ ) +(declare-type target basic) \ No newline at end of file diff --git a/goal_src/engine/math/matrix-h.gc b/goal_src/engine/math/matrix-h.gc index 41779ac998..599748123b 100644 --- a/goal_src/engine/math/matrix-h.gc +++ b/goal_src/engine/math/matrix-h.gc @@ -7,9 +7,9 @@ ;; A 4x4 matrix, stored in row-major order (deftype matrix (structure) - ((data float 16 :offset-assert 0) - (vector vector 4 :inline :offset 0) + ((vector vector 4 :inline :offset-assert 0) (quad uint128 4 :offset 0) + (data float 16 :offset 0) ;; moved so the decompiler looks at vector first. ) :method-count-assert 10 :size-assert #x40 diff --git a/goal_src/engine/target/joint-mod-h.gc b/goal_src/engine/target/joint-mod-h.gc index 43cca30ee6..978945c59c 100644 --- a/goal_src/engine/target/joint-mod-h.gc +++ b/goal_src/engine/target/joint-mod-h.gc @@ -5,3 +5,1061 @@ ;; name in dgo: joint-mod-h ;; dgos: GAME, ENGINE +;; The joint-mod system allows an animated character to change in a way that's not described in +;; an animation. For example, this is used to point Jak's head toward an attacking enemy. + +(define-extern joint-mod-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-world-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-rotate-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set*-handler (function cspace transformq none)) + +;; There are several modes available for joint-mod. +(defenum joint-mod-handler-mode + :bitfield #t + :type uint32 + (flex-blend 0) ;; 1 + (look-at 1) ;; 2 + (world-look-at 2) ;; 4 + (rotate 3) ;; 8 + (joint-set 4) ;; 16 + (joint-set* 5) ;; 32 + ;; ?? ;; 64 + (reset 7) ;; 128 + ) + +;; The joint-mod itself represents a modification to a single joint. +;; Although the mode is a bitfield, it appears that multiple kinds of mods cannot be +;; activated at the same time. +(deftype joint-mod (basic) + ((mode joint-mod-handler-mode :offset-assert 4) + (process process-drawable :offset-assert 8) + (joint cspace :offset-assert 12) + (target vector :inline :offset-assert 16) + (twist vector :inline :offset-assert 32) + (twist-max vector :inline :offset-assert 48) + (trans vector :inline :offset-assert 64) + (quat quaternion :inline :offset-assert 80) + (scale vector :inline :offset-assert 96) + (notice-time uint64 :offset-assert 112) + (flex-blend float :offset-assert 120) + (blend float :offset-assert 124) + (max-dist float :offset-assert 128) + (ignore-angle float :offset-assert 132) + (up uint8 :offset-assert 136) + (nose uint8 :offset-assert 137) + (ear uint8 :offset-assert 138) + (shutting-down? basic :offset-assert 140) + (parented-scale? basic :offset 128) + ) + :method-count-assert 16 + :size-assert #x90 + :flag-assert #x1000000090 + (:methods + (new (symbol type joint-mod-handler-mode process-drawable int) _type_ 0) + (set-mode! (_type_ joint-mod-handler-mode) _type_ 9) + (set-target! (_type_ vector) none 10) + (look-at-enemy! (_type_ vector symbol process) none 11) + (reset-blend! (_type_) _type_ 12) + (set-twist! (_type_ float float float) vector 13) + (set-trs! (_type_ vector quaternion vector) none 14) + (shut-down! (_type_) float 15) + ) + ) + +(defun-debug joint-mod-debug-draw ((mod joint-mod)) + "Draw a frame at the bone." + ;; I believe this draws a set of coordinate axes that represent the transformation matrix. + (add-debug-matrix #t (bucket-id debug-draw) (-> mod joint bone transform)) + (none) + ) + +(defmethod new joint-mod ((allocation symbol) (type-to-make type) (mode joint-mod-handler-mode) (proc process-drawable) (joint-idx int)) + "Construct a new joint-mod. It will work on the given process-drawable's joint." + (let ((obj (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> obj process) proc) + ;; grab the joint from our node-list. + (set! (-> obj joint) (-> (-> proc node-list) data joint-idx)) + (set-mode! obj mode) + ;; set defaults. + (let ((twist-max (-> obj twist-max))) + (set! (-> twist-max x) 8192.0) + (set! (-> twist-max y) 11832.889) + (set! (-> twist-max z) 0.0) + (set! (-> twist-max w) 1.0) + ) + (set! (-> obj up) (the-as uint 1)) + (set! (-> obj nose) (the-as uint 2)) + (set! (-> obj ear) (the-as uint 0)) + (set! (-> obj max-dist) 122880.0) + (set! (-> obj ignore-angle) 65536.0) + (set! (-> obj flex-blend) 1.0) + (set! (-> obj shutting-down?) #f) + obj + ) + ) + +(defmethod set-mode! joint-mod ((obj joint-mod) (handler-mode joint-mod-handler-mode)) + "Set up the joint-mod for the given mode. You can only pick one mode at a time." + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> obj mode) handler-mode) + (let ((joint (-> obj joint)) + (mode handler-mode) + ) + (cond + ((= mode (joint-mod-handler-mode flex-blend)) + (set! (-> joint param0) #f) + (set! (-> joint param1) #f) + (set! (-> joint param2) #f) + ;; use flex-bend instead of bend. + (set! (-> obj blend) 0.0) + (set! (-> obj flex-blend) 1.0) + ) + ((= mode (joint-mod-handler-mode reset)) + (set! (-> joint param0) #f) + (set! (-> joint param1) #f) + (set! (-> joint param2) #f) + ;; set blend to 0 for no effect. + (set! (-> obj blend) 0.0) + (set! (-> obj shutting-down?) #f) + ) + ((= mode (joint-mod-handler-mode look-at)) + (set! (-> joint param0) joint-mod-look-at-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + ) + ((= mode (joint-mod-handler-mode world-look-at)) + (set! (-> joint param0) joint-mod-world-look-at-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + ) + ((= mode (joint-mod-handler-mode rotate)) + (set! (-> joint param0) joint-mod-rotate-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (set! (-> obj blend) 1.0) + ) + ((= mode (joint-mod-handler-mode joint-set)) + (set! (-> joint param0) joint-mod-joint-set-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (.svf (&-> (-> obj trans) quad) vf0) + (quaternion-identity! (-> obj quat)) + (let ((v1-2 (-> obj scale))) + (set! (-> v1-2 x) 1.0) + (set! (-> v1-2 y) 1.0) + (set! (-> v1-2 z) 1.0) + (set! (-> v1-2 w) 1.0) + ) + (set! (-> obj max-dist) (the-as float #f)) + ) + ((= mode (joint-mod-handler-mode joint-set*)) + (set! (-> joint param0) joint-mod-joint-set*-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (.svf (&-> (-> obj trans) quad) vf0) + (quaternion-identity! (-> obj quat)) + (let ((v1-4 (-> obj scale))) + (set! (-> v1-4 x) 1.0) + (set! (-> v1-4 y) 1.0) + (set! (-> v1-4 z) 1.0) + (set! (-> v1-4 w) 1.0) + ) + (set! (-> obj max-dist) (the-as float #f)) + ) + ) + ) + obj + ) + ) + +(defmethod reset-blend! joint-mod ((obj joint-mod)) + "Reset the blend to 0." + (set! (-> obj blend) 0.0) + obj + ) + +(defmethod shut-down! joint-mod ((obj joint-mod)) + "Shut down and set the blend to zero." + (set! (-> obj shutting-down?) #t) + (let ((f0-0 0.0)) + (set! (-> obj blend) f0-0) + f0-0 + ) + ) + +(defmethod set-twist! joint-mod ((obj joint-mod) (x float) (y float) (z float)) + "Set the twist. You can use #f to not change the current value." + (if x (set! (-> obj twist x) x)) + (if y (set! (-> obj twist y) y)) + (if z (set! (-> obj twist z) z)) + (-> obj twist) + ) + +(defmethod set-trs! joint-mod ((obj joint-mod) (trans vector) (rot quaternion) (scale vector)) + "Set the translation, rotation, and scale." + (when trans + (let ((v1-1 (-> obj trans))) + (set! (-> v1-1 quad) (-> trans quad)) + ) + ) + (if rot + (quaternion-copy! (-> obj quat) rot) + ) + (when scale + (let ((v1-5 (-> obj scale))) + (set! (-> v1-5 quad) (-> scale quad)) + ) + ) + (none) + ) + +(defmethod set-target! joint-mod ((obj joint-mod) (target-trans vector)) + "Set the joint-mod to look-at if we aren't in a mode, and look at the given target-trans." + + ;; set mode, if we aren't in one. + (if (= (-> obj mode) (joint-mod-handler-mode reset)) + (set-mode! obj (joint-mod-handler-mode look-at)) + ) + ;; how far are we from the target? + (let ((distance (vector-vector-distance (-> obj process root trans) target-trans))) + (set! (-> obj shutting-down?) #f) + (let ((v1-6 (-> obj target))) + (set! (-> v1-6 quad) (-> target-trans quad)) + ) + (if (< distance (-> obj max-dist)) + (set! (-> obj blend) 1.0) ;; in range, set blend to 1.0 to start + (set! (-> obj blend) 0.0) ;; not in range, set blend to 0.0 to disable. + ) + ) + (none) + ) + +;; this type is for storing what we tried to look at last. +(deftype try-to-look-at-info (basic) + ((who handle :offset-assert 8) + (horz float :offset-assert 16) + (vert float :offset-assert 20) + ) + :method-count-assert 9 + :size-assert #x18 + :flag-assert #x900000018 + ) + +;; this is the last thing we tried to look at. +;; There's only one global instance of this, likely used by Jak looking at enemies. +(define last-try-to-look-at-data (new 'global 'try-to-look-at-info)) + +(defmethod look-at-enemy! joint-mod ((obj joint-mod) (target-trans vector) (option symbol) (proc process)) + "Set up animation for Jak looking at an enemy. If option is 'attacking, remember when this happened. + Will only override an existing look-at if this one is closer, or option is 'force. + " + (when (= option 'attacking) + ;; make sure we got a process-drawable + (let* ((s3-0 proc) + (proc-drawable + (if (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) + (the-as process-drawable s3-0) + ) + ) + ) + (when proc-drawable + ;; get enemy fact info + (let* ((s0-0 (-> proc-drawable fact)) + (enemy-facts (the-as fact-info-enemy (if (and (nonzero? s0-0) (type-type? (-> s0-0 type) fact-info-enemy)) + (the-as fact-info-enemy s0-0) + ) + ) + ) + ) + ;; check that we have enemy facts, and that we are within the notice distance + (when (and enemy-facts (< (vector-vector-distance (-> obj process root trans) (-> proc-drawable root trans)) + (-> enemy-facts cam-notice-dist) + ) + ) + ;; success! we consider this a noticed and remember when + (set! (-> obj notice-time) (-> *display* base-frame-counter)) + ;; and update the look at data + (let ((ppointer (the-as (pointer process) + (if proc + (the-as (pointer process) (-> proc ppointer)) + ) + ) + ) + ) + (set! (-> last-try-to-look-at-data who) + (new 'static 'handle :process ppointer :pid (-> ppointer 0 pid)) + ) + ) + ;; not sure what these are yet. + (if (< (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) + (set! (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) + ) + (if (< (-> last-try-to-look-at-data horz) (-> enemy-facts cam-horz)) + (set! (-> last-try-to-look-at-data horz) (-> enemy-facts cam-horz)) + ) + ) + ) + ) + ) + ) + + ;; in all cases, + (let ((dist (vector-vector-distance (-> obj process root trans) target-trans))) + (when (and + ;; done with previous + (or (= (-> obj blend) 0.0) + ;; closer than previous. + (or (< dist (vector-vector-distance (-> obj process root trans) (-> obj target))) + ;; force + (= option 'force) + ) + ) + ;; and in range + (< dist (-> obj max-dist)) + ) + ;; set mode, if we aren't in one + (if (= (-> obj mode) (joint-mod-handler-mode reset)) + (set-mode! obj (joint-mod-handler-mode look-at)) + ) + ;; set our target. + (let ((v1-37 (-> obj target))) + (set! (-> v1-37 quad) (-> target-trans quad)) + ) + ;; activate us. + (set! (-> obj blend) 1.0) + (set! (-> obj shutting-down?) #f) + ) + ) + (none) + ) + +(defun joint-mod-look-at-handler ((csp cspace) (xform transformq)) + "Update bone transforms for look-at" + (local-vars + (v0-20 quaternion) + (f1-12 float) + (sv-48 vector) + (sv-52 vector) + (sv-56 vector) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> csp param1)))) + (cspace<-parented-transformq-joint! csp xform) + (set! sv-48 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! sv-52 (vector-normalize! (-> (-> csp bone) transform vector (-> gp-0 nose)) 1.0)) + (let ((t9-3 vector-normalize!) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (let ((v1-6 (-> gp-0 target)) + (a1-5 (-> csp bone transform vector 3)) + ) + (.lvf vf4 (&-> v1-6 quad)) + (.lvf vf5 (&-> a1-5 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-5 quad) vf6) + (set! sv-56 (t9-3 a0-5 1.0)) + ) + (let* ((f30-0 (vector-y-angle sv-52)) + (t9-5 vector-flatten!) + (a0-7 (new-stack-vector0)) + (a0-8 (t9-5 a0-7 sv-56 sv-48)) + (f0-0 (vector-y-angle a0-8)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let ((f30-1 + (fmax (fmin (* (* f0-1 (-> gp-0 blend)) (-> gp-0 flex-blend)) (-> gp-0 twist-max y)) + (- (-> gp-0 twist-max y)) + ) + ) + ) + (if (and (-> gp-0 shutting-down?) (= (-> gp-0 twist y) f30-1)) + (set-mode! gp-0 (joint-mod-handler-mode reset)) + ) + (set! (-> gp-0 twist y) + (deg-seek (-> gp-0 twist y) f30-1 (* 0.1 (fabs (deg-diff f30-1 (-> gp-0 twist y))))) + ) + ) + ) + (let ((v1-15 (-> gp-0 up))) + (cond + ((zero? v1-15) + (quaternion-rotate-x! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist y)) + ) + ((= v1-15 1) + (quaternion-rotate-local-y! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist y)) + ) + (else + (quaternion-rotate-z! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist y)) + ) + ) + ) + (let* ((s3-1 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (t9-16 vector-flatten!) + (a0-19 (new-stack-vector0)) + (s3-2 (t9-16 a0-19 sv-56 s3-1)) + (f0-15 (vector-x-angle s3-2)) + (f0-21 + (fmax (fmin (* (* (- (deg-diff f30-2 f0-15)) (-> gp-0 blend)) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (let* ((v1-22 sv-52)) + (set! f1-12 (vector-dot s3-2 v1-22)) + ) + (if (< f1-12 0.1) + (set! f0-21 0.0) + ) + (set! (-> gp-0 twist x) + (deg-seek (-> gp-0 twist x) f0-21 (* 0.1 (fabs (deg-diff f0-21 (-> gp-0 twist x))))) + ) + ) + (let ((v1-27 (-> gp-0 ear))) + (cond + ((zero? v1-27) + (set! v0-20 + (quaternion-rotate-x! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist x)) + ) + ) + ((= v1-27 1) + (set! v0-20 + (quaternion-rotate-local-y! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist x))) + ) + (else + (set! v0-20 + (quaternion-rotate-z! (the-as quaternion (-> xform rot)) (the-as quaternion (-> xform rot)) (-> gp-0 twist x)) + ) + ) + ) + ) + (cspace<-parented-transformq-joint! csp xform) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id debug-draw) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (none) + ) + ) + +(defun joint-mod-world-look-at-handler ((arg0 cspace) (arg1 transformq)) + (local-vars (f1-14 float) (sv-48 vector) (sv-52 vector) (sv-56 vector)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s5-0 (-> arg0 bone transform))) + (cspace<-parented-transformq-joint! arg0 arg1) + (set! sv-48 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! sv-52 (vector-normalize! (-> s5-0 vector (-> gp-0 nose)) 1.0)) + (let ((t9-3 vector-normalize!) + (a0-3 (new 'stack-no-clear 'vector)) + ) + (let ((v1-7 (-> gp-0 target)) + (a1-3 (-> s5-0 vector 3)) + ) + (.lvf vf4 (&-> v1-7 quad)) + (.lvf vf5 (&-> a1-3 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-3 quad) vf6) + (set! sv-56 (t9-3 a0-3 1.0)) + ) + (let* ((f30-0 (vector-y-angle sv-52)) + (t9-5 vector-flatten!) + (a0-5 (new-stack-vector0)) + (a0-6 (t9-5 a0-5 sv-56 sv-48)) + (f0-0 (vector-y-angle a0-6)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let ((f0-5 + (fmax (fmin (* (* f0-1 (-> gp-0 blend)) (-> gp-0 flex-blend)) (-> gp-0 twist-max y)) + (- (-> gp-0 twist-max y)) + ) + ) + ) + (set! (-> gp-0 twist y) + (deg-seek (-> gp-0 twist y) f0-5 (fmax 1.0 (* 0.1 (fabs (deg-diff f0-5 (-> gp-0 twist y)))))) + ) + ) + ) + (when (!= (-> gp-0 twist y) 0.0) + (let ((a2-3 (matrix-rotate-y! (new 'stack-no-clear 'matrix) (-> gp-0 twist y))) + (s4-2 (-> s5-0 vector 3 quad)) + ) + (matrix*! s5-0 s5-0 a2-3) + (set! (-> s5-0 vector 3 quad) s4-2) + ) + ) + (let* ((s4-3 (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (t9-14 vector-flatten!) + (a0-14 (new-stack-vector0)) + (s4-4 (t9-14 a0-14 sv-56 s4-3)) + (f0-14 (vector-x-angle s4-4)) + (f0-20 (fmax (fmin (* (* (- (deg-diff f30-2 f0-14)) (-> gp-0 blend)) (-> gp-0 flex-blend)) (-> gp-0 twist-max x)) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (let* ((v1-14 sv-52)) + (set! f1-14 (vector-dot s4-4 v1-14)) + ) + (if (< f1-14 0.1) + (set! f0-20 0.0) + ) + (let ((v0-17 (the-as object + (deg-seek (-> gp-0 twist x) f0-20 + (fmax 1.0 (* 0.1 (fabs (deg-diff f0-20 (-> gp-0 twist x))))) + ) + ) + ) + ) + (set! (-> gp-0 twist x) (the-as float v0-17)) + (when (!= (-> gp-0 twist x) 0.0) + (let* ((v1-20 (-> gp-0 ear)) + (a1-17 ((cond + ((zero? v1-20) + matrix-rotate-x! + ) + ((= v1-20 1) + matrix-rotate-y! + ) + (else + matrix-rotate-z! + ) + ) + (new 'stack-no-clear 'matrix) (-> gp-0 twist x) + ) + ) + ) + (set! v0-17 (matrix*! s5-0 a1-17 s5-0)) + ) + ) + ) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id debug-draw) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (none) + ) + ) + +(defun joint-mod-rotate-handler ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1))) + (s3-0 (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + ) + ) + ) + (let* ((v1-2 (-> s3-0 (-> s4-0 ear))) + (a1-2 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-2 x) + (-> v1-2 y) + (-> v1-2 z) + (* (* (-> s4-0 twist x) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-2 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + (let* ((v1-6 (-> s3-0 (-> s4-0 up))) + (a1-4 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-6 x) + (-> v1-6 y) + (-> v1-6 z) + (* (* (-> s4-0 twist y) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-4 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + (let* ((v1-10 (-> s3-0 (-> s4-0 nose))) + (a1-6 (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-10 x) + (-> v1-10 y) + (-> v1-10 z) + (* (* (-> s4-0 twist z) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-6 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +(defun joint-mod-joint-set-handler ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1)))) + (let ((v1-0 (-> arg1 trans))) + (set! (-> v1-0 quad) (-> s4-0 trans quad)) + ) + (quaternion-copy! (the-as quaternion (-> arg1 rot)) (-> s4-0 quat)) + (let ((v1-1 (-> arg1 scale))) + (set! (-> v1-1 quad) (-> s4-0 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +(defun joint-mod-joint-set*-handler ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((a1-1 (-> arg1 trans))) + (let ((v1-0 (-> arg1 trans)) + (a0-1 (-> s5-0 trans)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> v1-0 quad)) + (.lvf vf5 (&-> a0-1 quad)) + ) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-1 quad) vf6) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> arg1 rot)) + (-> s5-0 quat) + ) + ) + (vector*! (-> arg1 scale) (-> arg1 scale) (-> s5-0 scale)) + (cspace<-parented-transformq-joint! arg0 arg1) + (when (-> s5-0 max-dist) + (let ((v1-4 (-> arg0 bone scale))) + (set! (-> v1-4 x) 1.0) + (set! (-> v1-4 y) 1.0) + (set! (-> v1-4 z) 1.0) + (set! (-> v1-4 w) 1.0) + ) + ) + ) + (none) + ) + ) + +(define *joint-axis-vectors* + (new 'static 'inline-array vector 6 + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + (new 'static 'vector :x -1.0 :w 1.0) + (new 'static 'vector :y -1.0 :w 1.0) + (new 'static 'vector :z -1.0 :w 1.0) + ) + ) + +;; These joint-mod types contain a bit of extra state required for special types of joint-mods +(deftype joint-mod-wheel (basic) + ((last-position vector :inline :offset-assert 16) + (angle float :offset-assert 32) + (process process-drawable :offset-assert 36) + (wheel-radius float :offset-assert 40) + (wheel-axis int8 :offset-assert 44) + ) + :method-count-assert 9 + :size-assert #x2d + :flag-assert #x90000002d + (:methods + (new (symbol type process-drawable int float int) _type_ 0) + ) + ) + +(defun joint-mod-wheel-callback ((arg0 cspace) (arg1 transformq)) + (local-vars (f0-3 float)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (the-as joint-mod-wheel (-> arg0 param1)))) + (let ((v1-1 (-> s4-0 process root)) + (s1-0 (new-stack-vector0)) + (s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + ) + (let ((f0-0 0.0)) + ) + (let ((f0-1 0.0)) + ) + (vector-z-quaternion! s2-0 (the-as quaternion (-> v1-1 rot))) + (vector<-cspace! s1-0 arg0) + (let ((a1-3 s3-0)) + (let ((v1-2 s1-0) + (a0-3 (-> s4-0 last-position)) + ) + (.lvf vf4 (&-> v1-2 quad)) + (.lvf vf5 (&-> a0-3 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-3 quad) vf6) + ) + (let ((v1-3 (-> s4-0 last-position))) + (set! (-> v1-3 quad) (-> s1-0 quad)) + ) + (set! f0-3 (vector-dot s2-0 s3-0)) + ) + (let* ((f0-4 f0-3) + (f1-1 65536.0) + (f2-2 (* 6.28318 (-> s4-0 wheel-radius))) + (f0-5 (* (* f1-1 (/ 1.0 f2-2)) f0-4)) + ) + (set! (-> s4-0 angle) (+ (-> s4-0 angle) f0-5)) + ) + (quaternion-vector-angle! + (the-as quaternion (-> arg1 rot)) + (-> *joint-axis-vectors* (-> s4-0 wheel-axis)) + (-> s4-0 angle) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + ) + +(defmethod new joint-mod-wheel ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 float) (arg3 int)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 process) arg0) + (set! (-> v0-0 wheel-radius) arg2) + (set! (-> v0-0 wheel-axis) arg3) + (set! (-> v0-0 angle) 0.0) + (let ((v1-2 (-> v0-0 last-position))) + (set! (-> v1-2 x) 0.0) + (set! (-> v1-2 y) 0.0) + (set! (-> v1-2 z) 0.0) + (set! (-> v1-2 w) 1.0) + ) + (let ((v1-5 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-5 param0) joint-mod-wheel-callback) + (set! (-> v1-5 param1) v0-0) + ) + v0-0 + ) + ) + +(deftype joint-mod-set-local (basic) + ((transform transformq :inline :offset-assert 16) + (set-rotation basic :offset-assert 64) + (set-scale basic :offset-assert 68) + (set-translation basic :offset-assert 72) + (enable basic :offset-assert 76) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + (:methods + (new (symbol type process-drawable int basic basic basic) _type_ 0) + ) + ) + + +(defun joint-mod-set-local-callback ((arg0 cspace) (arg1 transformq)) + (let ((v1-0 (the-as joint-mod-set-local (-> arg0 param1)))) + (cond + ((-> v1-0 enable) + (when (not (-> v1-0 set-translation)) + (let ((a2-3 (-> v1-0 transform))) + (set! (-> a2-3 trans quad) (-> arg1 trans quad)) + ) + ) + (when (not (-> v1-0 set-rotation)) + (let ((a2-6 (-> v1-0 transform rot))) + (set! (-> a2-6 quad) (-> arg1 rot quad)) + ) + ) + (when (not (-> v1-0 set-scale)) + (let ((a2-9 (-> v1-0 transform scale))) + (set! (-> a2-9 quad) (-> arg1 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 (-> v1-0 transform)) + ) + (else + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + ) + (none) + ) + +(defmethod new joint-mod-set-local ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 basic) (arg3 basic) (arg4 basic)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 set-translation) arg2) + (set! (-> v0-0 set-rotation) arg3) + (set! (-> v0-0 set-scale) arg4) + (set! (-> v0-0 enable) #t) + (let ((v1-3 (-> v0-0 transform))) + (set! (-> v1-3 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform rot))) + (set! (-> v1-4 quad) (-> *null-vector* quad)) + ) + (let ((v1-5 (-> v0-0 transform scale))) + (set! (-> v1-5 quad) (-> *identity-vector* quad)) + ) + (let ((v1-8 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-8 param0) joint-mod-set-local-callback) + (set! (-> v1-8 param1) v0-0) + ) + v0-0 + ) + ) + +(deftype joint-mod-set-world (basic) + ((transform transformq :inline :offset-assert 16) + (node-index int32 :offset-assert 64) + (enable basic :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + (:methods + (new (symbol type process-drawable int basic) _type_ 0) + ) + ) + +(defun joint-mod-set-world-callback ((arg0 cspace) (arg1 transformq)) + (let ((v1-0 (the-as joint-mod-set-world (-> arg0 param1)))) + (if (-> v1-0 enable) + (cspace<-transformq! arg0 (-> v1-0 transform)) + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + (none) + ) + +(defmethod new joint-mod-set-world ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 basic)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 node-index) arg1) + (set! (-> v0-0 enable) arg2) + (let ((v1-2 (-> v0-0 transform))) + (set! (-> v1-2 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-3 (-> v0-0 transform rot))) + (set! (-> v1-3 quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform scale))) + (set! (-> v1-4 quad) (-> *identity-vector* quad)) + ) + (let ((v1-7 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-7 param0) joint-mod-set-world-callback) + (set! (-> v1-7 param1) v0-0) + ) + v0-0 + ) + ) + +(deftype joint-mod-blend-local (basic) + ((transform transformq :inline :offset-assert 16) + (blend-transform transformq :inline :offset-assert 64) + (node-index int32 :offset-assert 112) + (blend float :offset-assert 116) + (enable basic :offset-assert 120) + ) + :method-count-assert 9 + :size-assert #x7c + :flag-assert #x90000007c + (:methods + (new (symbol type process-drawable int basic) _type_ 0) + ) + ) + +(defun joint-mod-blend-local-callback ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod-blend-local (-> arg0 param1)))) + (cond + ((-> gp-0 enable) + (vector-lerp! + (the-as vector (-> gp-0 blend-transform)) + (-> arg1 trans) + (the-as vector (-> gp-0 transform)) + (-> gp-0 blend) + ) + (vector-lerp! + (-> gp-0 blend-transform scale) + (-> arg1 scale) + (-> gp-0 transform scale) + (-> gp-0 blend) + ) + (quaternion-slerp! + (the-as quaternion (-> gp-0 blend-transform rot)) + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> gp-0 transform rot)) + (-> gp-0 blend) + ) + (cspace<-parented-transformq-joint! arg0 (-> gp-0 blend-transform)) + ) + (else + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + ) + (none) + ) + +(defmethod new joint-mod-blend-local ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 basic)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (set! (-> v0-0 node-index) arg1) + (set! (-> v0-0 enable) arg2) + (set! (-> v0-0 blend) 0.0) + (let ((v1-2 (-> v0-0 transform))) + (set! (-> v1-2 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-3 (-> v0-0 transform rot))) + (set! (-> v1-3 quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform scale))) + (set! (-> v1-4 quad) (-> *identity-vector* quad)) + ) + (let ((v1-7 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-7 param0) joint-mod-blend-local-callback) + (set! (-> v1-7 param1) v0-0) + ) + v0-0 + ) + ) + +(deftype joint-mod-spinner (basic) + ((spin-axis vector :inline :offset-assert 16) + (angle float :offset-assert 32) + (spin-rate float :offset-assert 36) + (enable basic :offset-assert 40) + ) + :method-count-assert 9 + :size-assert #x2c + :flag-assert #x90000002c + (:methods + (new (symbol type process-drawable int vector float) _type_ 0) + ) + ) + +(defun joint-mod-spinner-callback ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod-spinner (-> arg0 param1)))) + (when (-> gp-0 enable) + (let ((f30-0 (+ (-> gp-0 angle) + (* (-> gp-0 spin-rate) (-> *display* seconds-per-frame)) + ) + ) + ) + (if (< 32768.0 f30-0) + (set! f30-0 (+ -65536.0 f30-0)) + ) + (if (< f30-0 -32768.0) + (set! f30-0 (+ 65536.0 f30-0)) + ) + (quaternion-vector-angle! + (the-as quaternion (-> arg1 rot)) + (-> gp-0 spin-axis) + f30-0 + ) + (set! (-> gp-0 angle) f30-0) + ) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +(defmethod new joint-mod-spinner ((allocation symbol) (type-to-make type) (arg0 process-drawable) (arg1 int) (arg2 vector) (arg3 float)) + (let ((v0-0 (object-new allocation type-to-make (the-as int (-> type-to-make size))))) + (let ((v1-2 (-> v0-0 spin-axis))) + (set! (-> v1-2 quad) (-> arg2 quad)) + ) + (set! (-> v0-0 spin-rate) arg3) + (set! (-> v0-0 enable) #t) + (set! (-> v0-0 angle) 0.0) + (let ((v1-6 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-6 param0) joint-mod-spinner-callback) + (set! (-> v1-6 param1) v0-0) + ) + v0-0 + ) + ) + diff --git a/test/decompiler/reference/all_forward_declarations.gc b/test/decompiler/reference/all_forward_declarations.gc index 68c6a62b52..d6fc4f000d 100644 --- a/test/decompiler/reference/all_forward_declarations.gc +++ b/test/decompiler/reference/all_forward_declarations.gc @@ -734,4 +734,73 @@ ) (define-extern process-drawable-art-error state) -(define-extern *res-static-buf* pointer) \ No newline at end of file +(define-extern *res-static-buf* pointer) +(define-extern vector-dot (function vector vector float)) + +(declare-type cspace structure) + +(define-extern joint-mod-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-world-look-at-handler (function cspace transformq none)) +(define-extern joint-mod-rotate-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set-handler (function cspace transformq none)) +(define-extern joint-mod-joint-set*-handler (function cspace transformq none)) + +(defenum joint-mod-handler-mode + :bitfield #t + :type uint32 + (flex-blend 0) ;; 1 + (look-at 1) ;; 2 + (world-look-at 2) ;; 4 + (rotate 3) ;; 8 + (joint-set 4) ;; 16 + (joint-set* 5) ;; 32 + ;; ?? ;; 64 + (reset 7) ;; 128 + ) + +(defenum bucket-id + :type uint32 + :bitfield #f + + (tfrag-tex0 5) + ;; merc0 10 + ;; generic0 11 + + (tfrag-tex1 12) + ;; merc1 17 + ;; generic1 18 + + (shrub-tex0 19) + + (shrub-tex1 25) + + (alpha-tex0 31) + + (alpha-tex1 38) + + (pris-tex0 48) + ;; merc0 49 + ;; generic0 50 + + (pris-tex1 51) + ;; merc1 52 + ;; generic1 53 + + (water-tex0 57) + ;; merc0 58 (+ default) + ;; generic0 59 (+ default) + + (water-tex1 60) + ;; merc1 61 + ;; generic1 62 + ;; debug text 68 + (debug-draw 68) + ) + +(define-extern cspace<-parented-transformq-joint! (function cspace transformq none)) +(define-extern cspace<-transformq! (function cspace transformq matrix)) +(define-extern vector<-cspace! (function vector cspace vector)) +(define-extern add-debug-text-sphere (function symbol bucket-id vector float string rgba none)) +(define-extern add-debug-matrix (function symbol bucket-id matrix none)) + +(define-extern vector-flatten! (function vector vector vector vector)) \ No newline at end of file diff --git a/test/decompiler/reference/engine/anim/mspace-h_REF.gc b/test/decompiler/reference/engine/anim/mspace-h_REF.gc index 8aaeff8892..a90bc2966f 100644 --- a/test/decompiler/reference/engine/anim/mspace-h_REF.gc +++ b/test/decompiler/reference/engine/anim/mspace-h_REF.gc @@ -61,7 +61,7 @@ (defmethod inspect bone ((obj bone)) (format #t "[~8x] ~A~%" obj 'bone) (format #t "~Ttransform: #~%" (-> obj transform)) - (format #t "~Tposition: #~%" (&-> obj transform data 12)) + (format #t "~Tposition: #~%" (-> obj transform vector 3)) (format #t "~Tscale: #~%" (-> obj scale)) (format #t "~Tcache: #~%" (-> obj cache)) obj diff --git a/test/decompiler/reference/engine/camera/cam-interface_REF.gc b/test/decompiler/reference/engine/camera/cam-interface_REF.gc index 11b26b9b1a..c6b2b703a1 100644 --- a/test/decompiler/reference/engine/camera/cam-interface_REF.gc +++ b/test/decompiler/reference/engine/camera/cam-interface_REF.gc @@ -15,10 +15,10 @@ ) (init-vf0-vector) (let ((v1-0 arg0)) - (let ((a0-2 (&-> *math-camera* inv-camera-rot data 8)) + (let ((a0-2 (-> *math-camera* inv-camera-rot vector 2)) (f0-0 arg1) ) - (.lvf vf1 a0-2) + (.lvf vf1 (&-> a0-2 quad)) (let ((a0-3 f0-0)) (.mov vf2 a0-3) ) @@ -27,12 +27,7 @@ (.mul.x.vf vf1 vf1 vf2 :mask #b111) (.svf (&-> v1-0 quad) vf1) ) - (vector+float*! - arg0 - arg0 - (the-as vector (&-> *math-camera* inv-camera-rot data 4)) - arg2 - ) + (vector+float*! arg0 arg0 (-> *math-camera* inv-camera-rot vector 1) arg2) (let ((a0-5 arg0)) (let ((v1-3 arg0) (a1-3 (-> *math-camera* trans)) @@ -93,8 +88,8 @@ ;; definition for function camera-angle (defun camera-angle () - (let ((f0-0 (-> *math-camera* camera-rot data 0)) - (f1-0 (-> *math-camera* camera-rot data 2)) + (let ((f0-0 (-> *math-camera* camera-rot vector 0 x)) + (f1-0 (-> *math-camera* camera-rot vector 0 z)) ) (atan f1-0 f0-0) ) @@ -128,6 +123,3 @@ (none) ) - - - diff --git a/test/decompiler/reference/engine/camera/math-camera_REF.gc b/test/decompiler/reference/engine/camera/math-camera_REF.gc index e24c2a01c1..b585a40aa1 100644 --- a/test/decompiler/reference/engine/camera/math-camera_REF.gc +++ b/test/decompiler/reference/engine/camera/math-camera_REF.gc @@ -171,29 +171,29 @@ (cam-fov-mult (-> math-cam fov-correction-factor)) ) (set! - (-> math-cam perspective data 0) + (-> math-cam perspective vector 0 x) (* cam-fov-mult (- (/ (-> math-cam x-pix) (* (-> math-cam x-ratio) (-> math-cam d)))) ) ) (set! - (-> math-cam perspective data 5) + (-> math-cam perspective vector 1 y) (* cam-fov-mult (- (/ (-> math-cam y-pix) (* (-> math-cam y-ratio) (-> math-cam d)))) ) ) (set! - (-> math-cam perspective data 10) + (-> math-cam perspective vector 2 z) (* (* cam-fov-mult (+ (-> math-cam f) (-> math-cam d))) corrected-fog) ) (set! - (-> math-cam perspective data 11) + (-> math-cam perspective vector 2 w) (* (/ cam-fov-mult (-> math-cam d)) fog-at-near-plane) ) (set! - (-> math-cam perspective data 14) + (-> math-cam perspective vector 3 z) (* (* (* (* -2.0 corrected-fog) (-> math-cam f)) (-> math-cam d)) cam-fov-mult @@ -235,36 +235,36 @@ (set! (-> math-cam guard y) (/ (-> math-cam y-clip) (-> math-cam y-pix))) (set! (-> math-cam guard z) 1.0) (set! (-> math-cam guard w) 1.0) - (set! (-> math-cam isometric data 14) (- 16777215.0 hvdf-z)) + (set! (-> math-cam isometric vector 3 z) (- 16777215.0 hvdf-z)) ) - (set! (-> math-cam isometric data 15) fog-at-near-plane) - (let ((persp-xx (-> math-cam perspective data 0)) - (persp-yy (-> math-cam perspective data 5)) - (persp-x (* -1.9996 (-> math-cam perspective data 0))) + (set! (-> math-cam isometric vector 3 w) fog-at-near-plane) + (let ((persp-xx (-> math-cam perspective vector 0 x)) + (persp-yy (-> math-cam perspective vector 1 y)) + (persp-x (* -1.9996 (-> math-cam perspective vector 0 x))) ) (let ((sprite-row-0 (-> math-cam sprite-2d))) - (set! (-> sprite-row-0 data 0) persp-x) - (set! (-> sprite-row-0 data 1) 0.0) - (set! (-> sprite-row-0 data 2) 0.0) - (set! (-> sprite-row-0 data 3) 0.0) + (set! (-> sprite-row-0 vector 0 x) persp-x) + (set! (-> sprite-row-0 vector 0 y) 0.0) + (set! (-> sprite-row-0 vector 0 z) 0.0) + (set! (-> sprite-row-0 vector 0 w) 0.0) ) - (let ((sprite-row-1 (&-> math-cam sprite-2d data 4))) - (set! (-> sprite-row-1 0) 0.0) - (set! (-> sprite-row-1 1) (- (* (/ persp-yy persp-xx) persp-x))) - (set! (-> sprite-row-1 2) 0.0) - (set! (-> sprite-row-1 3) 0.0) + (let ((sprite-row-1 (-> math-cam sprite-2d vector 1))) + (set! (-> sprite-row-1 x) 0.0) + (set! (-> sprite-row-1 y) (- (* (/ persp-yy persp-xx) persp-x))) + (set! (-> sprite-row-1 z) 0.0) + (set! (-> sprite-row-1 w) 0.0) ) - (let ((sprite-row-2 (&-> math-cam sprite-2d data 8))) - (set! (-> sprite-row-2 0) 0.0) - (set! (-> sprite-row-2 1) 0.0) - (set! (-> sprite-row-2 2) (- persp-x)) - (set! (-> sprite-row-2 3) 0.0) + (let ((sprite-row-2 (-> math-cam sprite-2d vector 2))) + (set! (-> sprite-row-2 x) 0.0) + (set! (-> sprite-row-2 y) 0.0) + (set! (-> sprite-row-2 z) (- persp-x)) + (set! (-> sprite-row-2 w) 0.0) ) - (let ((sprite-row-3 (&-> math-cam sprite-2d data 12))) - (set! (-> sprite-row-3 0) 0.0) - (set! (-> sprite-row-3 1) 0.0) - (set! (-> sprite-row-3 2) (* 500000000.0 persp-x)) - (set! (-> sprite-row-3 3) (* (* 60.0 persp-x) (-> math-cam pfog0))) + (let ((sprite-row-3 (-> math-cam sprite-2d vector 3))) + (set! (-> sprite-row-3 x) 0.0) + (set! (-> sprite-row-3 y) 0.0) + (set! (-> sprite-row-3 z) (* 500000000.0 persp-x)) + (set! (-> sprite-row-3 w) (* (* 60.0 persp-x) (-> math-cam pfog0))) ) ) (let ((v1-15 (-> math-cam sprite-2d-hvdf))) @@ -339,9 +339,9 @@ (matrix-identity! (-> gp-0 inv-camera-rot)) (matrix-identity! (-> gp-0 camera-rot)) (.svf (&-> (-> gp-0 trans) quad) vf0) - (set! (-> gp-0 isometric data 0) 1.0) - (set! (-> gp-0 isometric data 5) 0.5) - (set! (-> gp-0 isometric data 10) -1.0) + (set! (-> gp-0 isometric vector 0 x) 1.0) + (set! (-> gp-0 isometric vector 1 y) 0.5) + (set! (-> gp-0 isometric vector 2 z) -1.0) (set! (-> gp-0 reset) 1) (set! (-> gp-0 smooth-step) 0.0) (set! (-> gp-0 smooth-t) 0.0) diff --git a/test/decompiler/reference/engine/gfx/font-h_REF.gc b/test/decompiler/reference/engine/gfx/font-h_REF.gc index d47ba71b1d..817bfa034f 100644 --- a/test/decompiler/reference/engine/gfx/font-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/font-h_REF.gc @@ -41,24 +41,12 @@ (define *font-default-matrix* (new 'static 'matrix - :data - (new 'static 'array float 16 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - 0.0 - 0.0 - 0.0 - 1.0 - 0.0 - -256.0 - 0.0 - 0.0 - 1.0 + :vector + (new 'static 'inline-array vector 4 + (new 'static 'vector :x 1.0) + (new 'static 'vector :y 1.0) + (new 'static 'vector :z 1.0) + (new 'static 'vector :x -256.0 :w 1.0) ) ) ) @@ -204,7 +192,7 @@ (cond ((= z 0.0) (let ((v1-4 obj)) - (set! (-> v1-4 origin z) (-> *math-camera* isometric data 14)) + (set! (-> v1-4 origin z) (-> *math-camera* isometric vector 3 z)) ) ) (else diff --git a/test/decompiler/reference/engine/gfx/lights-h_REF.gc b/test/decompiler/reference/engine/gfx/lights-h_REF.gc index f11b578838..6631dd37eb 100644 --- a/test/decompiler/reference/engine/gfx/lights-h_REF.gc +++ b/test/decompiler/reference/engine/gfx/lights-h_REF.gc @@ -66,10 +66,10 @@ (format #t "[~8x] ~A~%" obj 'light-ellipse) (format #t "~Tmatrix: #~%" (-> obj matrix)) (format #t "~Tcolor: #~%" (-> obj color)) - (format #t "~Tname: ~A~%" (-> obj matrix data 3)) - (format #t "~Tdecay-start: ~f~%" (-> obj matrix data 7)) - (format #t "~Tambient-point-ratio: ~f~%" (-> obj matrix data 11)) - (format #t "~Tlevel: ~f~%" (-> obj matrix data 15)) + (format #t "~Tname: ~A~%" (-> obj matrix vector 0 w)) + (format #t "~Tdecay-start: ~f~%" (-> obj matrix vector 1 w)) + (format #t "~Tambient-point-ratio: ~f~%" (-> obj matrix vector 2 w)) + (format #t "~Tlevel: ~f~%" (-> obj matrix vector 3 w)) (format #t "~Tfunc-symbol: ~A~%" (-> obj color w)) (format #t "~Tfunc: ~A~%" (-> obj color w)) obj @@ -208,7 +208,3 @@ ;; failed to figure out what this is: (let ((v0-9 0)) ) - - - - diff --git a/test/decompiler/reference/engine/math/matrix-h_REF.gc b/test/decompiler/reference/engine/math/matrix-h_REF.gc index 2b21c81052..abd1e461b1 100644 --- a/test/decompiler/reference/engine/math/matrix-h_REF.gc +++ b/test/decompiler/reference/engine/math/matrix-h_REF.gc @@ -3,9 +3,9 @@ ;; definition of type matrix (deftype matrix (structure) - ((data float 16 :offset-assert 0) - (vector vector 4 :inline :offset 0) + ((vector vector 4 :inline :offset 0) (quad uint128 4 :offset 0) + (data float 16 :offset 0) ) :method-count-assert 10 :size-assert #x40 @@ -19,9 +19,9 @@ ;; INFO: this function exists in multiple non-identical object files (defmethod inspect matrix ((obj matrix)) (format #t "[~8x] ~A~%" obj 'matrix) - (format #t "~Tdata[16] @ #x~X~%" (-> obj data)) - (format #t "~Tvector[4] @ #x~X~%" (-> obj data)) - (format #t "~Tquad[4] @ #x~X~%" (-> obj data)) + (format #t "~Tdata[16] @ #x~X~%" (-> obj vector)) + (format #t "~Tvector[4] @ #x~X~%" (-> obj vector)) + (format #t "~Tquad[4] @ #x~X~%" (-> obj vector)) obj ) @@ -81,5 +81,3 @@ ) arg0 ) - - diff --git a/test/decompiler/reference/engine/math/matrix_REF.gc b/test/decompiler/reference/engine/math/matrix_REF.gc index e9c5ea8d10..ae11d6d5a5 100644 --- a/test/decompiler/reference/engine/math/matrix_REF.gc +++ b/test/decompiler/reference/engine/math/matrix_REF.gc @@ -8,34 +8,34 @@ (format #t "~T[~F] [~F] [~F] [~F]~%" - (-> obj data 0) - (-> obj data 1) - (-> obj data 2) - (-> obj data 3) + (-> obj vector 0 x) + (-> obj vector 0 y) + (-> obj vector 0 z) + (-> obj vector 0 w) ) (format #t "~T[~F] [~F] [~F] [~F]~%" - (-> obj data 4) - (-> obj data 5) - (-> obj data 6) - (-> obj data 7) + (-> obj vector 1 x) + (-> obj vector 1 y) + (-> obj vector 1 z) + (-> obj vector 1 w) ) (format #t "~T[~F] [~F] [~F] [~F]~%" - (-> obj data 8) - (-> obj data 9) - (-> obj data 10) - (-> obj data 11) + (-> obj vector 2 x) + (-> obj vector 2 y) + (-> obj vector 2 z) + (-> obj vector 2 w) ) (format #t "~T[~F] [~F] [~F] [~F]~%" - (-> obj data 12) - (-> obj data 13) - (-> obj data 14) - (-> obj data 15) + (-> obj vector 3 x) + (-> obj vector 3 y) + (-> obj vector 3 z) + (-> obj vector 3 w) ) obj ) @@ -76,10 +76,10 @@ (set! (-> arg0 vector 2 quad) (the-as uint128 0)) (set! (-> arg0 vector 3 quad) (the-as uint128 0)) (let ((f0-0 1.0)) - (set! (-> arg0 data 15) f0-0) - (set! (-> arg0 data 10) f0-0) - (set! (-> arg0 data 5) f0-0) - (set! (-> arg0 data 0) f0-0) + (set! (-> arg0 vector 3 w) f0-0) + (set! (-> arg0 vector 2 z) f0-0) + (set! (-> arg0 vector 1 y) f0-0) + (set! (-> arg0 vector 0 x) f0-0) ) arg0 ) @@ -493,18 +493,18 @@ ;; definition for function matrix-translate! (defun matrix-translate! ((dst matrix) (trans vector)) (matrix-identity! dst) - (set! (-> dst data 12) (-> trans x)) - (set! (-> dst data 13) (-> trans y)) - (set! (-> dst data 14) (-> trans z)) + (set! (-> dst vector 3 x) (-> trans x)) + (set! (-> dst vector 3 y) (-> trans y)) + (set! (-> dst vector 3 z) (-> trans z)) dst ) ;; definition for function matrix-translate+! ;; Used lq/sq (defun matrix-translate+! ((dst matrix) (src matrix) (trans vector)) - (set! (-> dst data 12) (+ (-> src data 12) (-> trans x))) - (set! (-> dst data 13) (+ (-> src data 13) (-> trans y))) - (set! (-> dst data 14) (+ (-> src data 14) (-> trans z))) + (set! (-> dst vector 3 x) (+ (-> src vector 3 x) (-> trans x))) + (set! (-> dst vector 3 y) (+ (-> src vector 3 y) (-> trans y))) + (set! (-> dst vector 3 z) (+ (-> src vector 3 z) (-> trans z))) (when (!= dst src) (set! (-> dst vector 0 quad) (-> src vector 0 quad)) (set! (-> dst vector 1 quad) (-> src vector 1 quad)) @@ -520,10 +520,10 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) (-> scale x)) - (set! (-> dst data 5) (-> scale y)) - (set! (-> dst data 10) (-> scale z)) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 0 x) (-> scale x)) + (set! (-> dst vector 1 y) (-> scale y)) + (set! (-> dst vector 2 z) (-> scale z)) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -559,10 +559,10 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) (/ 1.0 (-> scale x))) - (set! (-> dst data 5) (/ 1.0 (-> scale y))) - (set! (-> dst data 10) (/ 1.0 (-> scale z))) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 0 x) (/ 1.0 (-> scale x))) + (set! (-> dst vector 1 y) (/ 1.0 (-> scale y))) + (set! (-> dst vector 2 z) (/ 1.0 (-> scale z))) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -601,13 +601,13 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) 1.0) - (set! (-> dst data 5) rot-cos) - (set! (-> dst data 6) rot-sin) - (set! (-> dst data 9) (- rot-sin)) - (set! (-> dst data 10) rot-cos) + (set! (-> dst vector 0 x) 1.0) + (set! (-> dst vector 1 y) rot-cos) + (set! (-> dst vector 1 z) rot-sin) + (set! (-> dst vector 2 y) (- rot-sin)) + (set! (-> dst vector 2 z) rot-cos) ) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -621,13 +621,13 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) rot-cos) - (set! (-> dst data 2) (- rot-sin)) - (set! (-> dst data 5) 1.0) - (set! (-> dst data 8) rot-sin) - (set! (-> dst data 10) rot-cos) + (set! (-> dst vector 0 x) rot-cos) + (set! (-> dst vector 0 z) (- rot-sin)) + (set! (-> dst vector 1 y) 1.0) + (set! (-> dst vector 2 x) rot-sin) + (set! (-> dst vector 2 z) rot-cos) ) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -641,13 +641,13 @@ (set! (-> dst vector 1 quad) (the-as uint128 0)) (set! (-> dst vector 2 quad) (the-as uint128 0)) (set! (-> dst vector 3 quad) (the-as uint128 0)) - (set! (-> dst data 0) rot-cos) - (set! (-> dst data 1) rot-sin) - (set! (-> dst data 4) (- rot-sin)) - (set! (-> dst data 5) rot-cos) + (set! (-> dst vector 0 x) rot-cos) + (set! (-> dst vector 0 y) rot-sin) + (set! (-> dst vector 1 x) (- rot-sin)) + (set! (-> dst vector 1 y) rot-cos) ) - (set! (-> dst data 10) 1.0) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 2 z) 1.0) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -746,24 +746,24 @@ (cos-z (-> cos-vec z)) (sin-z (-> sin-vec z)) ) - (set! (-> dst data 0) (- (* cos-y cos-z) (* (* sin-y cos-x) sin-z))) - (set! (-> dst data 1) (* sin-y sin-x)) - (set! (-> dst data 2) (- (+ (* cos-y sin-z) (* (* sin-y cos-x) cos-z)))) - (set! (-> dst data 3) 0.0) - (set! (-> dst data 4) (* sin-x sin-z)) - (set! (-> dst data 5) cos-x) - (set! (-> dst data 6) (* sin-x cos-z)) - (set! (-> dst data 7) 0.0) - (set! (-> dst data 8) (+ (* sin-y cos-z) (* (* cos-y cos-x) sin-z))) - (set! (-> dst data 9) (- (* cos-y sin-x))) - (set! (-> dst data 10) (- (* (* cos-y cos-x) cos-z) (* sin-y sin-z))) + (set! (-> dst vector 0 x) (- (* cos-y cos-z) (* (* sin-y cos-x) sin-z))) + (set! (-> dst vector 0 y) (* sin-y sin-x)) + (set! (-> dst vector 0 z) (- (+ (* cos-y sin-z) (* (* sin-y cos-x) cos-z)))) + (set! (-> dst vector 0 w) 0.0) + (set! (-> dst vector 1 x) (* sin-x sin-z)) + (set! (-> dst vector 1 y) cos-x) + (set! (-> dst vector 1 z) (* sin-x cos-z)) + (set! (-> dst vector 1 w) 0.0) + (set! (-> dst vector 2 x) (+ (* sin-y cos-z) (* (* cos-y cos-x) sin-z))) + (set! (-> dst vector 2 y) (- (* cos-y sin-x))) + (set! (-> dst vector 2 z) (- (* (* cos-y cos-x) cos-z) (* sin-y sin-z))) ) ) - (set! (-> dst data 11) 0.0) - (set! (-> dst data 12) 0.0) - (set! (-> dst data 13) 0.0) - (set! (-> dst data 14) 0.0) - (set! (-> dst data 15) 1.0) + (set! (-> dst vector 2 w) 0.0) + (set! (-> dst vector 3 x) 0.0) + (set! (-> dst vector 3 y) 0.0) + (set! (-> dst vector 3 z) 0.0) + (set! (-> dst vector 3 w) 1.0) dst ) @@ -835,15 +835,15 @@ ;; definition for function matrix-3x3-determinant (defun matrix-3x3-determinant ((mat matrix)) - (let ((f8-0 (-> mat data 0)) - (f1-0 (-> mat data 1)) - (f4-0 (-> mat data 2)) - (f2-0 (-> mat data 4)) - (f5-0 (-> mat data 5)) - (f9-0 (-> mat data 6)) - (f3-0 (-> mat data 8)) - (f6-0 (-> mat data 9)) - (f0-0 (-> mat data 10)) + (let ((f8-0 (-> mat vector 0 x)) + (f1-0 (-> mat vector 0 y)) + (f4-0 (-> mat vector 0 z)) + (f2-0 (-> mat vector 1 x)) + (f5-0 (-> mat vector 1 y)) + (f9-0 (-> mat vector 1 z)) + (f3-0 (-> mat vector 2 x)) + (f6-0 (-> mat vector 2 y)) + (f0-0 (-> mat vector 2 z)) ) (- (+ (+ (* (* f8-0 f5-0) f0-0) (* (* f1-0 f9-0) f3-0)) (* (* f4-0 f2-0) f6-0)) @@ -877,77 +877,92 @@ (defun matrix-3x3-inverse! ((dst matrix) (src matrix)) (let ((f0-0 (matrix-3x3-determinant src))) (set! - (-> dst data 0) + (-> dst vector 0 x) (/ (- - (* (-> src data 5) (-> src data 10)) - (* (-> src data 6) (-> src data 9)) + (* (-> src vector 1 y) (-> src vector 2 z)) + (* (-> src vector 1 z) (-> src vector 2 y)) ) f0-0 ) ) (set! - (-> dst data 4) + (-> dst vector 1 x) (/ (- - (* (-> src data 6) (-> src data 8)) - (* (-> src data 4) (-> src data 10)) + (* (-> src vector 1 z) (-> src vector 2 x)) + (* (-> src vector 1 x) (-> src vector 2 z)) ) f0-0 ) ) (set! - (-> dst data 8) - (/ - (- (* (-> src data 4) (-> src data 9)) (* (-> src data 5) (-> src data 8))) - f0-0 - ) - ) - (set! - (-> dst data 1) + (-> dst vector 2 x) (/ (- - (* (-> src data 9) (-> src data 2)) - (* (-> src data 10) (-> src data 1)) + (* (-> src vector 1 x) (-> src vector 2 y)) + (* (-> src vector 1 y) (-> src vector 2 x)) ) f0-0 ) ) (set! - (-> dst data 5) + (-> dst vector 0 y) (/ (- - (* (-> src data 10) (-> src data 0)) - (* (-> src data 8) (-> src data 2)) + (* (-> src vector 2 y) (-> src vector 0 z)) + (* (-> src vector 2 z) (-> src vector 0 y)) ) f0-0 ) ) (set! - (-> dst data 9) + (-> dst vector 1 y) (/ - (- (* (-> src data 8) (-> src data 1)) (* (-> src data 9) (-> src data 0))) + (- + (* (-> src vector 2 z) (-> src vector 0 x)) + (* (-> src vector 2 x) (-> src vector 0 z)) + ) f0-0 ) ) (set! - (-> dst data 2) + (-> dst vector 2 y) (/ - (- (* (-> src data 1) (-> src data 6)) (* (-> src data 2) (-> src data 5))) + (- + (* (-> src vector 2 x) (-> src vector 0 y)) + (* (-> src vector 2 y) (-> src vector 0 x)) + ) f0-0 ) ) (set! - (-> dst data 6) + (-> dst vector 0 z) (/ - (- (* (-> src data 2) (-> src data 4)) (* (-> src data 0) (-> src data 6))) + (- + (* (-> src vector 0 y) (-> src vector 1 z)) + (* (-> src vector 0 z) (-> src vector 1 y)) + ) f0-0 ) ) (set! - (-> dst data 10) + (-> dst vector 1 z) (/ - (- (* (-> src data 0) (-> src data 5)) (* (-> src data 1) (-> src data 4))) + (- + (* (-> src vector 0 z) (-> src vector 1 x)) + (* (-> src vector 0 x) (-> src vector 1 z)) + ) + f0-0 + ) + ) + (set! + (-> dst vector 2 z) + (/ + (- + (* (-> src vector 0 x) (-> src vector 1 y)) + (* (-> src vector 0 y) (-> src vector 1 x)) + ) f0-0 ) ) @@ -959,77 +974,92 @@ (defun matrix-3x3-inverse-transpose! ((dst matrix) (src matrix)) (let ((f0-0 (matrix-3x3-determinant src))) (set! - (-> dst data 0) + (-> dst vector 0 x) (/ (- - (* (-> src data 5) (-> src data 10)) - (* (-> src data 6) (-> src data 9)) + (* (-> src vector 1 y) (-> src vector 2 z)) + (* (-> src vector 1 z) (-> src vector 2 y)) ) f0-0 ) ) (set! - (-> dst data 1) + (-> dst vector 0 y) (/ (- - (* (-> src data 6) (-> src data 8)) - (* (-> src data 4) (-> src data 10)) + (* (-> src vector 1 z) (-> src vector 2 x)) + (* (-> src vector 1 x) (-> src vector 2 z)) ) f0-0 ) ) (set! - (-> dst data 2) - (/ - (- (* (-> src data 4) (-> src data 9)) (* (-> src data 5) (-> src data 8))) - f0-0 - ) - ) - (set! - (-> dst data 4) + (-> dst vector 0 z) (/ (- - (* (-> src data 9) (-> src data 2)) - (* (-> src data 10) (-> src data 1)) + (* (-> src vector 1 x) (-> src vector 2 y)) + (* (-> src vector 1 y) (-> src vector 2 x)) ) f0-0 ) ) (set! - (-> dst data 5) + (-> dst vector 1 x) (/ (- - (* (-> src data 10) (-> src data 0)) - (* (-> src data 8) (-> src data 2)) + (* (-> src vector 2 y) (-> src vector 0 z)) + (* (-> src vector 2 z) (-> src vector 0 y)) ) f0-0 ) ) (set! - (-> dst data 6) + (-> dst vector 1 y) (/ - (- (* (-> src data 8) (-> src data 1)) (* (-> src data 9) (-> src data 0))) + (- + (* (-> src vector 2 z) (-> src vector 0 x)) + (* (-> src vector 2 x) (-> src vector 0 z)) + ) f0-0 ) ) (set! - (-> dst data 8) + (-> dst vector 1 z) (/ - (- (* (-> src data 1) (-> src data 6)) (* (-> src data 2) (-> src data 5))) + (- + (* (-> src vector 2 x) (-> src vector 0 y)) + (* (-> src vector 2 y) (-> src vector 0 x)) + ) f0-0 ) ) (set! - (-> dst data 9) + (-> dst vector 2 x) (/ - (- (* (-> src data 2) (-> src data 4)) (* (-> src data 0) (-> src data 6))) + (- + (* (-> src vector 0 y) (-> src vector 1 z)) + (* (-> src vector 0 z) (-> src vector 1 y)) + ) f0-0 ) ) (set! - (-> dst data 10) + (-> dst vector 2 y) (/ - (- (* (-> src data 0) (-> src data 5)) (* (-> src data 1) (-> src data 4))) + (- + (* (-> src vector 0 z) (-> src vector 1 x)) + (* (-> src vector 0 x) (-> src vector 1 z)) + ) + f0-0 + ) + ) + (set! + (-> dst vector 2 z) + (/ + (- + (* (-> src vector 0 x) (-> src vector 1 y)) + (* (-> src vector 0 y) (-> src vector 1 x)) + ) f0-0 ) ) @@ -1083,22 +1113,22 @@ ;; definition for function matrix-4x4-determinant (defun matrix-4x4-determinant ((dst matrix)) - (let ((f15-0 (-> dst data 0)) - (f14-0 (-> dst data 1)) - (f10-0 (-> dst data 2)) - (f2-0 (-> dst data 3)) - (f9-0 (-> dst data 4)) - (f6-0 (-> dst data 5)) - (f3-0 (-> dst data 6)) - (f11-0 (-> dst data 7)) - (f5-0 (-> dst data 8)) - (f1-0 (-> dst data 9)) - (f8-0 (-> dst data 10)) - (f13-0 (-> dst data 11)) - (f0-0 (-> dst data 12)) - (f7-0 (-> dst data 13)) - (f4-0 (-> dst data 14)) - (f12-0 (-> dst data 15)) + (let ((f15-0 (-> dst vector 0 x)) + (f14-0 (-> dst vector 0 y)) + (f10-0 (-> dst vector 0 z)) + (f2-0 (-> dst vector 0 w)) + (f9-0 (-> dst vector 1 x)) + (f6-0 (-> dst vector 1 y)) + (f3-0 (-> dst vector 1 z)) + (f11-0 (-> dst vector 1 w)) + (f5-0 (-> dst vector 2 x)) + (f1-0 (-> dst vector 2 y)) + (f8-0 (-> dst vector 2 z)) + (f13-0 (-> dst vector 2 w)) + (f0-0 (-> dst vector 3 x)) + (f7-0 (-> dst vector 3 y)) + (f4-0 (-> dst vector 3 z)) + (f12-0 (-> dst vector 3 w)) ) (- (+ @@ -1176,18 +1206,18 @@ ;; definition for function matrix-4x4-inverse-transpose! (defun matrix-4x4-inverse-transpose! ((dst matrix) (src matrix)) (let ((f0-0 (matrix-4x4-determinant src))) - (let ((f9-0 (-> src data 5)) - (f2-0 (-> src data 6)) - (f5-0 (-> src data 7)) - (f3-0 (-> src data 9)) - (f6-0 (-> src data 10)) - (f10-0 (-> src data 11)) - (f4-0 (-> src data 13)) - (f7-0 (-> src data 14)) - (f1-0 (-> src data 15)) + (let ((f9-0 (-> src vector 1 y)) + (f2-0 (-> src vector 1 z)) + (f5-0 (-> src vector 1 w)) + (f3-0 (-> src vector 2 y)) + (f6-0 (-> src vector 2 z)) + (f10-0 (-> src vector 2 w)) + (f4-0 (-> src vector 3 y)) + (f7-0 (-> src vector 3 z)) + (f1-0 (-> src vector 3 w)) ) (set! - (-> dst data 0) + (-> dst vector 0 x) (/ (- (+ @@ -1203,18 +1233,18 @@ ) ) ) - (let ((f9-2 (-> src data 4)) - (f2-2 (-> src data 6)) - (f5-2 (-> src data 7)) - (f3-1 (-> src data 8)) - (f6-1 (-> src data 10)) - (f10-1 (-> src data 11)) - (f4-3 (-> src data 12)) - (f7-2 (-> src data 14)) - (f1-6 (-> src data 15)) + (let ((f9-2 (-> src vector 1 x)) + (f2-2 (-> src vector 1 z)) + (f5-2 (-> src vector 1 w)) + (f3-1 (-> src vector 2 x)) + (f6-1 (-> src vector 2 z)) + (f10-1 (-> src vector 2 w)) + (f4-3 (-> src vector 3 x)) + (f7-2 (-> src vector 3 z)) + (f1-6 (-> src vector 3 w)) ) (set! - (-> dst data 1) + (-> dst vector 0 y) (- (/ (- @@ -1232,18 +1262,18 @@ ) ) ) - (let ((f9-4 (-> src data 4)) - (f2-4 (-> src data 5)) - (f5-4 (-> src data 7)) - (f3-2 (-> src data 8)) - (f6-2 (-> src data 9)) - (f10-2 (-> src data 11)) - (f4-6 (-> src data 12)) - (f7-4 (-> src data 13)) - (f1-13 (-> src data 15)) + (let ((f9-4 (-> src vector 1 x)) + (f2-4 (-> src vector 1 y)) + (f5-4 (-> src vector 1 w)) + (f3-2 (-> src vector 2 x)) + (f6-2 (-> src vector 2 y)) + (f10-2 (-> src vector 2 w)) + (f4-6 (-> src vector 3 x)) + (f7-4 (-> src vector 3 y)) + (f1-13 (-> src vector 3 w)) ) (set! - (-> dst data 2) + (-> dst vector 0 z) (/ (- (+ @@ -1259,18 +1289,18 @@ ) ) ) - (let ((f9-6 (-> src data 4)) - (f2-6 (-> src data 5)) - (f5-6 (-> src data 6)) - (f3-3 (-> src data 8)) - (f6-3 (-> src data 9)) - (f10-3 (-> src data 10)) - (f4-9 (-> src data 12)) - (f7-6 (-> src data 13)) - (f1-19 (-> src data 14)) + (let ((f9-6 (-> src vector 1 x)) + (f2-6 (-> src vector 1 y)) + (f5-6 (-> src vector 1 z)) + (f3-3 (-> src vector 2 x)) + (f6-3 (-> src vector 2 y)) + (f10-3 (-> src vector 2 z)) + (f4-9 (-> src vector 3 x)) + (f7-6 (-> src vector 3 y)) + (f1-19 (-> src vector 3 z)) ) (set! - (-> dst data 3) + (-> dst vector 0 w) (- (/ (- @@ -1288,18 +1318,18 @@ ) ) ) - (let ((f9-8 (-> src data 1)) - (f2-8 (-> src data 2)) - (f5-8 (-> src data 3)) - (f3-4 (-> src data 9)) - (f6-4 (-> src data 10)) - (f10-4 (-> src data 11)) - (f4-12 (-> src data 13)) - (f7-8 (-> src data 14)) - (f1-26 (-> src data 15)) + (let ((f9-8 (-> src vector 0 y)) + (f2-8 (-> src vector 0 z)) + (f5-8 (-> src vector 0 w)) + (f3-4 (-> src vector 2 y)) + (f6-4 (-> src vector 2 z)) + (f10-4 (-> src vector 2 w)) + (f4-12 (-> src vector 3 y)) + (f7-8 (-> src vector 3 z)) + (f1-26 (-> src vector 3 w)) ) (set! - (-> dst data 4) + (-> dst vector 1 x) (- (/ (- @@ -1317,18 +1347,18 @@ ) ) ) - (let ((f9-10 (-> src data 0)) - (f2-10 (-> src data 2)) - (f5-10 (-> src data 3)) - (f3-5 (-> src data 8)) - (f6-5 (-> src data 10)) - (f10-5 (-> src data 11)) - (f4-15 (-> src data 12)) - (f7-10 (-> src data 14)) - (f1-33 (-> src data 15)) + (let ((f9-10 (-> src vector 0 x)) + (f2-10 (-> src vector 0 z)) + (f5-10 (-> src vector 0 w)) + (f3-5 (-> src vector 2 x)) + (f6-5 (-> src vector 2 z)) + (f10-5 (-> src vector 2 w)) + (f4-15 (-> src vector 3 x)) + (f7-10 (-> src vector 3 z)) + (f1-33 (-> src vector 3 w)) ) (set! - (-> dst data 5) + (-> dst vector 1 y) (/ (- (+ @@ -1344,18 +1374,18 @@ ) ) ) - (let ((f9-12 (-> src data 0)) - (f2-12 (-> src data 1)) - (f5-12 (-> src data 3)) - (f3-6 (-> src data 8)) - (f6-6 (-> src data 9)) - (f10-6 (-> src data 11)) - (f4-18 (-> src data 12)) - (f7-12 (-> src data 13)) - (f1-39 (-> src data 15)) + (let ((f9-12 (-> src vector 0 x)) + (f2-12 (-> src vector 0 y)) + (f5-12 (-> src vector 0 w)) + (f3-6 (-> src vector 2 x)) + (f6-6 (-> src vector 2 y)) + (f10-6 (-> src vector 2 w)) + (f4-18 (-> src vector 3 x)) + (f7-12 (-> src vector 3 y)) + (f1-39 (-> src vector 3 w)) ) (set! - (-> dst data 6) + (-> dst vector 1 z) (- (/ (- @@ -1373,18 +1403,18 @@ ) ) ) - (let ((f9-14 (-> src data 0)) - (f2-14 (-> src data 1)) - (f5-14 (-> src data 2)) - (f3-7 (-> src data 8)) - (f6-7 (-> src data 9)) - (f10-7 (-> src data 10)) - (f4-21 (-> src data 12)) - (f7-14 (-> src data 13)) - (f1-46 (-> src data 14)) + (let ((f9-14 (-> src vector 0 x)) + (f2-14 (-> src vector 0 y)) + (f5-14 (-> src vector 0 z)) + (f3-7 (-> src vector 2 x)) + (f6-7 (-> src vector 2 y)) + (f10-7 (-> src vector 2 z)) + (f4-21 (-> src vector 3 x)) + (f7-14 (-> src vector 3 y)) + (f1-46 (-> src vector 3 z)) ) (set! - (-> dst data 7) + (-> dst vector 1 w) (/ (- (+ @@ -1400,18 +1430,18 @@ ) ) ) - (let ((f9-16 (-> src data 1)) - (f2-16 (-> src data 2)) - (f5-16 (-> src data 3)) - (f3-8 (-> src data 5)) - (f6-8 (-> src data 6)) - (f10-8 (-> src data 7)) - (f4-24 (-> src data 13)) - (f7-16 (-> src data 14)) - (f1-52 (-> src data 15)) + (let ((f9-16 (-> src vector 0 y)) + (f2-16 (-> src vector 0 z)) + (f5-16 (-> src vector 0 w)) + (f3-8 (-> src vector 1 y)) + (f6-8 (-> src vector 1 z)) + (f10-8 (-> src vector 1 w)) + (f4-24 (-> src vector 3 y)) + (f7-16 (-> src vector 3 z)) + (f1-52 (-> src vector 3 w)) ) (set! - (-> dst data 8) + (-> dst vector 2 x) (/ (- (+ @@ -1427,18 +1457,18 @@ ) ) ) - (let ((f9-18 (-> src data 0)) - (f2-18 (-> src data 2)) - (f5-18 (-> src data 3)) - (f3-9 (-> src data 4)) - (f6-9 (-> src data 6)) - (f10-9 (-> src data 7)) - (f4-27 (-> src data 12)) - (f7-18 (-> src data 14)) - (f1-58 (-> src data 15)) + (let ((f9-18 (-> src vector 0 x)) + (f2-18 (-> src vector 0 z)) + (f5-18 (-> src vector 0 w)) + (f3-9 (-> src vector 1 x)) + (f6-9 (-> src vector 1 z)) + (f10-9 (-> src vector 1 w)) + (f4-27 (-> src vector 3 x)) + (f7-18 (-> src vector 3 z)) + (f1-58 (-> src vector 3 w)) ) (set! - (-> dst data 9) + (-> dst vector 2 y) (- (/ (- @@ -1456,18 +1486,18 @@ ) ) ) - (let ((f9-20 (-> src data 0)) - (f2-20 (-> src data 1)) - (f5-20 (-> src data 3)) - (f3-10 (-> src data 4)) - (f6-10 (-> src data 5)) - (f10-10 (-> src data 7)) - (f4-30 (-> src data 12)) - (f7-20 (-> src data 13)) - (f1-65 (-> src data 15)) + (let ((f9-20 (-> src vector 0 x)) + (f2-20 (-> src vector 0 y)) + (f5-20 (-> src vector 0 w)) + (f3-10 (-> src vector 1 x)) + (f6-10 (-> src vector 1 y)) + (f10-10 (-> src vector 1 w)) + (f4-30 (-> src vector 3 x)) + (f7-20 (-> src vector 3 y)) + (f1-65 (-> src vector 3 w)) ) (set! - (-> dst data 10) + (-> dst vector 2 z) (/ (- (+ @@ -1483,18 +1513,18 @@ ) ) ) - (let ((f9-22 (-> src data 0)) - (f2-22 (-> src data 1)) - (f5-22 (-> src data 2)) - (f3-11 (-> src data 4)) - (f6-11 (-> src data 5)) - (f10-11 (-> src data 6)) - (f4-33 (-> src data 12)) - (f7-22 (-> src data 13)) - (f1-71 (-> src data 14)) + (let ((f9-22 (-> src vector 0 x)) + (f2-22 (-> src vector 0 y)) + (f5-22 (-> src vector 0 z)) + (f3-11 (-> src vector 1 x)) + (f6-11 (-> src vector 1 y)) + (f10-11 (-> src vector 1 z)) + (f4-33 (-> src vector 3 x)) + (f7-22 (-> src vector 3 y)) + (f1-71 (-> src vector 3 z)) ) (set! - (-> dst data 11) + (-> dst vector 2 w) (- (/ (- @@ -1512,18 +1542,18 @@ ) ) ) - (let ((f9-24 (-> src data 1)) - (f2-24 (-> src data 2)) - (f5-24 (-> src data 3)) - (f3-12 (-> src data 5)) - (f6-12 (-> src data 6)) - (f10-12 (-> src data 7)) - (f4-36 (-> src data 9)) - (f7-24 (-> src data 10)) - (f1-78 (-> src data 11)) + (let ((f9-24 (-> src vector 0 y)) + (f2-24 (-> src vector 0 z)) + (f5-24 (-> src vector 0 w)) + (f3-12 (-> src vector 1 y)) + (f6-12 (-> src vector 1 z)) + (f10-12 (-> src vector 1 w)) + (f4-36 (-> src vector 2 y)) + (f7-24 (-> src vector 2 z)) + (f1-78 (-> src vector 2 w)) ) (set! - (-> dst data 12) + (-> dst vector 3 x) (- (/ (- @@ -1541,18 +1571,18 @@ ) ) ) - (let ((f9-26 (-> src data 0)) - (f2-26 (-> src data 2)) - (f5-26 (-> src data 3)) - (f3-13 (-> src data 4)) - (f6-13 (-> src data 6)) - (f10-13 (-> src data 7)) - (f4-39 (-> src data 8)) - (f7-26 (-> src data 10)) - (f1-85 (-> src data 11)) + (let ((f9-26 (-> src vector 0 x)) + (f2-26 (-> src vector 0 z)) + (f5-26 (-> src vector 0 w)) + (f3-13 (-> src vector 1 x)) + (f6-13 (-> src vector 1 z)) + (f10-13 (-> src vector 1 w)) + (f4-39 (-> src vector 2 x)) + (f7-26 (-> src vector 2 z)) + (f1-85 (-> src vector 2 w)) ) (set! - (-> dst data 13) + (-> dst vector 3 y) (/ (- (+ @@ -1568,18 +1598,18 @@ ) ) ) - (let ((f9-28 (-> src data 0)) - (f2-28 (-> src data 1)) - (f5-28 (-> src data 3)) - (f3-14 (-> src data 4)) - (f6-14 (-> src data 5)) - (f10-14 (-> src data 7)) - (f4-42 (-> src data 8)) - (f7-28 (-> src data 9)) - (f1-91 (-> src data 11)) + (let ((f9-28 (-> src vector 0 x)) + (f2-28 (-> src vector 0 y)) + (f5-28 (-> src vector 0 w)) + (f3-14 (-> src vector 1 x)) + (f6-14 (-> src vector 1 y)) + (f10-14 (-> src vector 1 w)) + (f4-42 (-> src vector 2 x)) + (f7-28 (-> src vector 2 y)) + (f1-91 (-> src vector 2 w)) ) (set! - (-> dst data 14) + (-> dst vector 3 z) (- (/ (- @@ -1597,18 +1627,18 @@ ) ) ) - (let ((f8-60 (-> src data 0)) - (f1-98 (-> src data 1)) - (f5-30 (-> src data 2)) - (f2-30 (-> src data 4)) - (f6-15 (-> src data 5)) - (f9-30 (-> src data 6)) - (f4-45 (-> src data 8)) - (f7-30 (-> src data 9)) - (f3-15 (-> src data 10)) + (let ((f8-60 (-> src vector 0 x)) + (f1-98 (-> src vector 0 y)) + (f5-30 (-> src vector 0 z)) + (f2-30 (-> src vector 1 x)) + (f6-15 (-> src vector 1 y)) + (f9-30 (-> src vector 1 z)) + (f4-45 (-> src vector 2 x)) + (f7-30 (-> src vector 2 y)) + (f3-15 (-> src vector 2 z)) ) (set! - (-> dst data 15) + (-> dst vector 3 w) (/ (- (+ @@ -1630,8 +1660,8 @@ ;; definition for function matrix-y-angle (defun matrix-y-angle ((mat matrix)) - (let ((z-row (&-> mat data 8))) - (atan (-> z-row 0) (-> z-row 2)) + (let ((z-row (-> mat vector 2))) + (atan (-> z-row x) (-> z-row z)) ) ) diff --git a/test/decompiler/reference/engine/math/quaternion_REF.gc b/test/decompiler/reference/engine/math/quaternion_REF.gc index 31221b272e..418573115a 100644 --- a/test/decompiler/reference/engine/math/quaternion_REF.gc +++ b/test/decompiler/reference/engine/math/quaternion_REF.gc @@ -365,22 +365,22 @@ (f1-0 (-> arg1 z)) (f0-0 (-> arg1 w)) ) - (set! (-> arg0 data 0) f0-0) - (set! (-> arg0 data 1) f1-0) - (set! (-> arg0 data 2) (- f2-0)) - (set! (-> arg0 data 3) f3-0) - (set! (-> arg0 data 4) (- f1-0)) - (set! (-> arg0 data 5) f0-0) - (set! (-> arg0 data 6) f3-0) - (set! (-> arg0 data 7) f2-0) - (set! (-> arg0 data 8) f2-0) - (set! (-> arg0 data 9) (- f3-0)) - (set! (-> arg0 data 10) f0-0) - (set! (-> arg0 data 11) f1-0) - (set! (-> arg0 data 12) (- f3-0)) - (set! (-> arg0 data 13) (- f2-0)) - (set! (-> arg0 data 14) (- f1-0)) - (set! (-> arg0 data 15) f0-0) + (set! (-> arg0 vector 0 x) f0-0) + (set! (-> arg0 vector 0 y) f1-0) + (set! (-> arg0 vector 0 z) (- f2-0)) + (set! (-> arg0 vector 0 w) f3-0) + (set! (-> arg0 vector 1 x) (- f1-0)) + (set! (-> arg0 vector 1 y) f0-0) + (set! (-> arg0 vector 1 z) f3-0) + (set! (-> arg0 vector 1 w) f2-0) + (set! (-> arg0 vector 2 x) f2-0) + (set! (-> arg0 vector 2 y) (- f3-0)) + (set! (-> arg0 vector 2 z) f0-0) + (set! (-> arg0 vector 2 w) f1-0) + (set! (-> arg0 vector 3 x) (- f3-0)) + (set! (-> arg0 vector 3 y) (- f2-0)) + (set! (-> arg0 vector 3 z) (- f1-0)) + (set! (-> arg0 vector 3 w) f0-0) ) arg0 ) @@ -392,23 +392,23 @@ (f0-0 (-> arg1 z)) ) (let ((f3-0 (-> arg1 w))) - (set! (-> arg0 data 0) f2-0) - (set! (-> arg0 data 1) f3-0) - (set! (-> arg0 data 2) (- f0-0)) - (set! (-> arg0 data 3) f1-0) - (set! (-> arg0 data 4) f1-0) - (set! (-> arg0 data 5) f0-0) - (set! (-> arg0 data 6) f3-0) - (set! (-> arg0 data 7) (- f3-0)) - (set! (-> arg0 data 8) f0-0) - (set! (-> arg0 data 9) (- f1-0)) - (set! (-> arg0 data 10) f2-0) - (set! (-> arg0 data 11) f3-0) - (set! (-> arg0 data 12) f3-0) + (set! (-> arg0 vector 0 x) f2-0) + (set! (-> arg0 vector 0 y) f3-0) + (set! (-> arg0 vector 0 z) (- f0-0)) + (set! (-> arg0 vector 0 w) f1-0) + (set! (-> arg0 vector 1 x) f1-0) + (set! (-> arg0 vector 1 y) f0-0) + (set! (-> arg0 vector 1 z) f3-0) + (set! (-> arg0 vector 1 w) (- f3-0)) + (set! (-> arg0 vector 2 x) f0-0) + (set! (-> arg0 vector 2 y) (- f1-0)) + (set! (-> arg0 vector 2 z) f2-0) + (set! (-> arg0 vector 2 w) f3-0) + (set! (-> arg0 vector 3 x) f3-0) ) - (set! (-> arg0 data 13) (- f2-0)) - (set! (-> arg0 data 14) (- f1-0)) - (set! (-> arg0 data 15) (- f0-0)) + (set! (-> arg0 vector 3 y) (- f2-0)) + (set! (-> arg0 vector 3 z) (- f1-0)) + (set! (-> arg0 vector 3 w) (- f0-0)) ) arg0 ) @@ -454,15 +454,19 @@ ;; definition for function matrix->quaternion (defun matrix->quaternion ((arg0 quaternion) (arg1 matrix)) - (let ((f0-2 (+ (+ (-> arg1 data 0) (-> arg1 data 5)) (-> arg1 data 10)))) + (let + ((f0-2 + (+ (+ (-> arg1 vector 0 x) (-> arg1 vector 1 y)) (-> arg1 vector 2 z)) + ) + ) (cond ((< 0.0 f0-2) (let ((f0-4 (sqrtf (+ 1.0 f0-2)))) (set! (-> arg0 w) (* 0.5 f0-4)) (let ((f0-5 (/ 0.5 f0-4))) - (set! (-> arg0 x) (* f0-5 (- (-> arg1 data 6) (-> arg1 data 9)))) - (set! (-> arg0 y) (* f0-5 (- (-> arg1 data 8) (-> arg1 data 2)))) - (set! (-> arg0 z) (* f0-5 (- (-> arg1 data 1) (-> arg1 data 4)))) + (set! (-> arg0 x) (* f0-5 (- (-> arg1 vector 1 z) (-> arg1 vector 2 y)))) + (set! (-> arg0 y) (* f0-5 (- (-> arg1 vector 2 x) (-> arg1 vector 0 z)))) + (set! (-> arg0 z) (* f0-5 (- (-> arg1 vector 0 y) (-> arg1 vector 1 x)))) ) ) ) @@ -471,7 +475,7 @@ (a3-0 1) (v1-1 2) ) - (when (< (-> arg1 data 0) (-> arg1 data 5)) + (when (< (-> arg1 vector 0 x) (-> arg1 vector 1 y)) (set! a2-0 1) (set! a3-0 2) (set! v1-1 0) @@ -484,7 +488,7 @@ (+ (+ (* a2-0 4) (* a2-0 16)) (the-as int arg1)) ) ) - (-> arg1 data 10) + (-> arg1 vector 2 z) ) (set! a2-0 2) (set! a3-0 0) @@ -618,46 +622,30 @@ (vf7 :class vf) ) (let ((v1-0 (new-stack-matrix0))) - (let* ((a3-0 (-> arg1 data)) - (a2-0 (-> arg1 data)) - (f0-0 (-> a3-0 0)) - (f1-0 (-> a3-0 1)) - (f2-0 (-> a3-0 2)) - (f3-0 (-> a2-0 0)) - (f4-0 (-> a2-0 1)) - (f5-0 (-> a2-0 2)) + (let* ((a3-0 (-> arg1 vector)) + (a2-0 (-> arg1 vector)) + (f0-0 (-> a3-0 0 x)) + (f1-0 (-> a3-0 0 y)) + (f2-0 (-> a3-0 0 z)) + (f3-0 (-> a2-0 0 x)) + (f4-0 (-> a2-0 0 y)) + (f5-0 (-> a2-0 0 z)) ) (.mula.s f0-0 f3-0) (.madda.s f1-0 f4-0) (.madd.s f0-1 f2-0 f5-0) ) (let ((f0-2 f0-1)) - (let* ((a3-1 (&-> arg1 data 4)) - (a2-2 (&-> arg1 data 4)) - (f1-1 (-> a3-1 0)) - (f2-1 (-> a3-1 1)) - (f3-1 (-> a3-1 2)) - (f4-1 (-> a2-2 0)) - (f5-1 (-> a2-2 1)) - (f6-0 (-> a2-2 2)) + (let* ((a3-1 (-> arg1 vector 1)) + (a2-2 (-> arg1 vector 1)) ) - (.mula.s f1-1 f4-1) - (.madda.s f2-1 f5-1) - (.madd.s f1-2 f3-1 f6-0) + (set! f1-2 (vector-dot a3-1 a2-2)) ) (let ((f1-3 f1-2)) - (let* ((a3-2 (&-> arg1 data 8)) - (a2-4 (&-> arg1 data 8)) - (f2-2 (-> a3-2 0)) - (f3-2 (-> a3-2 1)) - (f4-2 (-> a3-2 2)) - (f5-2 (-> a2-4 0)) - (f6-1 (-> a2-4 1)) - (f7-0 (-> a2-4 2)) + (let* ((a3-2 (-> arg1 vector 2)) + (a2-4 (-> arg1 vector 2)) ) - (.mula.s f2-2 f5-2) - (.madda.s f3-2 f6-1) - (.madd.s f2-3 f4-2 f7-0) + (set! f2-3 (vector-dot a3-2 a2-4)) ) (let* ((f2-4 f2-3) (f0-4 (/ 1.0 (sqrtf f0-2))) @@ -893,7 +881,7 @@ (defun vector-x-quaternion! ((arg0 vector) (arg1 quaternion)) (let ((s5-0 (new-stack-matrix0))) (quaternion->matrix s5-0 arg1) - (set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 data)) 0)) + (set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 vector)) 0)) ) arg0 ) @@ -903,7 +891,7 @@ (defun vector-y-quaternion! ((arg0 vector) (arg1 quaternion)) (let ((s5-0 (new-stack-matrix0))) (quaternion->matrix s5-0 arg1) - (set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 4)) 0)) + (set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 vector 1)) 0)) ) arg0 ) @@ -913,7 +901,7 @@ (defun vector-z-quaternion! ((arg0 vector) (arg1 quaternion)) (let ((s5-0 (new-stack-matrix0))) (quaternion->matrix s5-0 arg1) - (set! (-> arg0 quad) (-> (the-as (pointer uint128) (&-> s5-0 data 8)) 0)) + (set! (-> arg0 quad) (-> (the-as (pointer uint128) (-> s5-0 vector 2)) 0)) ) arg0 ) @@ -1033,16 +1021,8 @@ (let ((gp-0 acos)) (let* ((s5-0 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg0)) (v1-1 (vector-z-quaternion! (new 'stack-no-clear 'vector) arg1)) - (f0-0 (-> s5-0 x)) - (f1-0 (-> s5-0 y)) - (f2-0 (-> s5-0 z)) - (f3-0 (-> v1-1 x)) - (f4-0 (-> v1-1 y)) - (f5-0 (-> v1-1 z)) ) - (.mula.s f0-0 f3-0) - (.madda.s f1-0 f4-0) - (.madd.s f0-1 f2-0 f5-0) + (set! f0-1 (vector-dot s5-0 v1-1)) ) (gp-0 f0-1) ) diff --git a/test/decompiler/reference/engine/target/joint-mod-h_REF.gc b/test/decompiler/reference/engine/target/joint-mod-h_REF.gc new file mode 100644 index 0000000000..b047c1780e --- /dev/null +++ b/test/decompiler/reference/engine/target/joint-mod-h_REF.gc @@ -0,0 +1,1375 @@ +;;-*-Lisp-*- +(in-package goal) + +;; definition of type joint-mod +(deftype joint-mod (basic) + ((mode joint-mod-handler-mode :offset-assert 4) + (process process-drawable :offset-assert 8) + (joint cspace :offset-assert 12) + (target vector :inline :offset-assert 16) + (twist vector :inline :offset-assert 32) + (twist-max vector :inline :offset-assert 48) + (trans vector :inline :offset-assert 64) + (quat quaternion :inline :offset-assert 80) + (scale vector :inline :offset-assert 96) + (notice-time uint64 :offset-assert 112) + (flex-blend float :offset-assert 120) + (blend float :offset-assert 124) + (max-dist float :offset-assert 128) + (ignore-angle float :offset-assert 132) + (up uint8 :offset-assert 136) + (nose uint8 :offset-assert 137) + (ear uint8 :offset-assert 138) + (shutting-down? basic :offset-assert 140) + (parented-scale? basic :offset 128) + ) + :method-count-assert 16 + :size-assert #x90 + :flag-assert #x1000000090 + (:methods + (new (symbol type joint-mod-handler-mode process-drawable int) _type_ 0) + (set-mode! (_type_ joint-mod-handler-mode) _type_ 9) + (set-target! (_type_ vector) none 10) + (look-at-enemy! (_type_ vector symbol process) none 11) + (reset-blend! (_type_) _type_ 12) + (set-twist! (_type_ float float float) vector 13) + (set-trs! (_type_ vector quaternion vector) none 14) + (shut-down! (_type_) float 15) + ) + ) + +;; definition for method 3 of type joint-mod +(defmethod inspect joint-mod ((obj joint-mod)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tmode: ~D~%" (-> obj mode)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Tjoint: #~%" (-> obj joint)) + (format #t "~Ttarget: ~`vector`P~%" (-> obj target)) + (format #t "~Ttwist: ~`vector`P~%" (-> obj twist)) + (format #t "~Ttwist-max: ~`vector`P~%" (-> obj twist-max)) + (format #t "~Ttrans: ~`vector`P~%" (-> obj trans)) + (format #t "~Tquat: ~`quaternion`P~%" (-> obj quat)) + (format #t "~Tscale: ~`vector`P~%" (-> obj scale)) + (format #t "~Tnotice-time: ~D~%" (-> obj notice-time)) + (format #t "~Tflex-blend: ~f~%" (-> obj flex-blend)) + (format #t "~Tblend: ~f~%" (-> obj blend)) + (format #t "~Tmax-dist: (meters ~m)~%" (-> obj max-dist)) + (format #t "~Tignore-angle: (deg ~r)~%" (-> obj ignore-angle)) + (format #t "~Tup: ~D~%" (-> obj up)) + (format #t "~Tnose: ~D~%" (-> obj nose)) + (format #t "~Tear: ~D~%" (-> obj ear)) + (format #t "~Tshutting-down?: ~A~%" (-> obj shutting-down?)) + (format #t "~Tparented-scale?: ~A~%" (-> obj max-dist)) + obj + ) + +;; definition (debug) for function joint-mod-debug-draw +;; INFO: Return type mismatch int vs none. +(defun-debug joint-mod-debug-draw ((mod joint-mod)) + (add-debug-matrix #t (bucket-id debug-draw) (-> mod joint bone transform)) + (let ((v0-0 0)) + ) + (none) + ) + +;; definition for method 0 of type joint-mod +(defmethod + new + joint-mod + ((allocation symbol) + (type-to-make type) + (mode joint-mod-handler-mode) + (proc process-drawable) + (joint-idx int) + ) + (let + ((obj + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> obj process) proc) + (set! (-> obj joint) (-> (-> proc node-list) data joint-idx)) + (set-mode! obj mode) + (let ((twist-max (-> obj twist-max))) + (set! (-> twist-max x) 8192.0) + (set! (-> twist-max y) 11832.889) + (set! (-> twist-max z) 0.0) + (set! (-> twist-max w) 1.0) + ) + (set! (-> obj up) (the-as uint 1)) + (set! (-> obj nose) (the-as uint 2)) + (set! (-> obj ear) (the-as uint 0)) + (set! (-> obj max-dist) 122880.0) + (set! (-> obj ignore-angle) 65536.0) + (set! (-> obj flex-blend) 1.0) + (set! (-> obj shutting-down?) #f) + obj + ) + ) + +;; definition for method 9 of type joint-mod +(defmethod + set-mode! + joint-mod + ((obj joint-mod) (handler-mode joint-mod-handler-mode)) + (rlet ((vf0 :class vf)) + (init-vf0-vector) + (set! (-> obj mode) handler-mode) + (let ((joint (-> obj joint)) + (mode handler-mode) + ) + (cond + ((= mode (joint-mod-handler-mode flex-blend)) + (set! (-> joint param0) #f) + (set! (-> joint param1) #f) + (set! (-> joint param2) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj flex-blend) 1.0) + ) + ((= mode (joint-mod-handler-mode reset)) + (set! (-> joint param0) #f) + (set! (-> joint param1) #f) + (set! (-> joint param2) #f) + (set! (-> obj blend) 0.0) + (set! (-> obj shutting-down?) #f) + ) + ((= mode (joint-mod-handler-mode look-at)) + (set! (-> joint param0) joint-mod-look-at-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + ) + ((= mode (joint-mod-handler-mode world-look-at)) + (set! (-> joint param0) joint-mod-world-look-at-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + ) + ((= mode (joint-mod-handler-mode rotate)) + (set! (-> joint param0) joint-mod-rotate-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (set! (-> obj blend) 1.0) + ) + ((= mode (joint-mod-handler-mode joint-set)) + (set! (-> joint param0) joint-mod-joint-set-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (.svf (&-> (-> obj trans) quad) vf0) + (quaternion-identity! (-> obj quat)) + (let ((v1-2 (-> obj scale))) + (set! (-> v1-2 x) 1.0) + (set! (-> v1-2 y) 1.0) + (set! (-> v1-2 z) 1.0) + (set! (-> v1-2 w) 1.0) + ) + (set! (-> obj max-dist) (the-as float #f)) + ) + ((= mode (joint-mod-handler-mode joint-set*)) + (set! (-> joint param0) joint-mod-joint-set*-handler) + (set! (-> joint param1) obj) + (set! (-> joint param2) #f) + (.svf (&-> (-> obj trans) quad) vf0) + (quaternion-identity! (-> obj quat)) + (let ((v1-4 (-> obj scale))) + (set! (-> v1-4 x) 1.0) + (set! (-> v1-4 y) 1.0) + (set! (-> v1-4 z) 1.0) + (set! (-> v1-4 w) 1.0) + ) + (set! (-> obj max-dist) (the-as float #f)) + ) + ) + ) + obj + ) + ) + +;; definition for method 12 of type joint-mod +(defmethod reset-blend! joint-mod ((obj joint-mod)) + (set! (-> obj blend) 0.0) + obj + ) + +;; definition for method 15 of type joint-mod +(defmethod shut-down! joint-mod ((obj joint-mod)) + (set! (-> obj shutting-down?) #t) + (let ((f0-0 0.0)) + (set! (-> obj blend) f0-0) + f0-0 + ) + ) + +;; definition for method 13 of type joint-mod +(defmethod set-twist! joint-mod ((obj joint-mod) (x float) (y float) (z float)) + (if x + (set! (-> obj twist x) x) + ) + (if y + (set! (-> obj twist y) y) + ) + (if z + (set! (-> obj twist z) z) + ) + (-> obj twist) + ) + +;; definition for method 14 of type joint-mod +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + set-trs! + joint-mod + ((obj joint-mod) (trans vector) (rot quaternion) (scale vector)) + (when trans + (let ((v1-1 (-> obj trans))) + (set! (-> v1-1 quad) (-> trans quad)) + ) + ) + (if rot + (quaternion-copy! (-> obj quat) rot) + ) + (when scale + (let ((v1-5 (-> obj scale))) + (set! (-> v1-5 quad) (-> scale quad)) + ) + ) + (let ((v0-1 0)) + ) + (none) + ) + +;; definition for method 10 of type joint-mod +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod set-target! joint-mod ((obj joint-mod) (target-trans vector)) + (if (= (-> obj mode) (joint-mod-handler-mode reset)) + (set-mode! obj (joint-mod-handler-mode look-at)) + ) + (let + ((distance (vector-vector-distance (-> obj process root trans) target-trans)) + ) + (set! (-> obj shutting-down?) #f) + (let ((v1-6 (-> obj target))) + (set! (-> v1-6 quad) (-> target-trans quad)) + ) + (if (< distance (-> obj max-dist)) + (set! (-> obj blend) 1.0) + (set! (-> obj blend) 0.0) + ) + ) + (let ((v0-2 0)) + ) + (none) + ) + +;; definition of type try-to-look-at-info +(deftype try-to-look-at-info (basic) + ((who handle :offset-assert 8) + (horz float :offset-assert 16) + (vert float :offset-assert 20) + ) + :method-count-assert 9 + :size-assert #x18 + :flag-assert #x900000018 + ) + +;; definition for method 3 of type try-to-look-at-info +(defmethod inspect try-to-look-at-info ((obj try-to-look-at-info)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Twho: ~D~%" (-> obj who)) + (format #t "~Thorz: ~f~%" (-> obj horz)) + (format #t "~Tvert: ~f~%" (-> obj vert)) + obj + ) + +;; definition for symbol last-try-to-look-at-data, type try-to-look-at-info +(define last-try-to-look-at-data (new 'global 'try-to-look-at-info)) + +;; definition for method 11 of type joint-mod +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defmethod + look-at-enemy! + joint-mod + ((obj joint-mod) (target-trans vector) (option symbol) (proc process)) + (when (= option 'attacking) + (let* ((s3-0 proc) + (proc-drawable + (if + (and (nonzero? s3-0) (type-type? (-> s3-0 type) process-drawable)) + (the-as process-drawable s3-0) + ) + ) + ) + (when proc-drawable + (let* ((s0-0 (-> proc-drawable fact)) + (enemy-facts + (the-as + fact-info-enemy + (if + (and (nonzero? s0-0) (type-type? (-> s0-0 type) fact-info-enemy)) + (the-as fact-info-enemy s0-0) + ) + ) + ) + ) + (when + (and + enemy-facts + (< + (vector-vector-distance + (-> obj process root trans) + (-> proc-drawable root trans) + ) + (-> enemy-facts cam-notice-dist) + ) + ) + (set! (-> obj notice-time) (-> *display* base-frame-counter)) + (let ((ppointer (the-as (pointer process) (if proc + (the-as + (pointer process) + (-> proc ppointer) + ) + ) + ) + ) + ) + (set! + (-> last-try-to-look-at-data who) + (new 'static 'handle :process ppointer :pid (-> ppointer 0 pid)) + ) + ) + (if (< (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) + (set! (-> last-try-to-look-at-data vert) (-> enemy-facts cam-vert)) + ) + (if (< (-> last-try-to-look-at-data horz) (-> enemy-facts cam-horz)) + (set! (-> last-try-to-look-at-data horz) (-> enemy-facts cam-horz)) + ) + ) + ) + ) + ) + ) + (let + ((dist (vector-vector-distance (-> obj process root trans) target-trans))) + (when + (and + (or + (= (-> obj blend) 0.0) + (or + (< + dist + (vector-vector-distance (-> obj process root trans) (-> obj target)) + ) + (= option 'force) + ) + ) + (< dist (-> obj max-dist)) + ) + (if (= (-> obj mode) (joint-mod-handler-mode reset)) + (set-mode! obj (joint-mod-handler-mode look-at)) + ) + (let ((v1-37 (-> obj target))) + (set! (-> v1-37 quad) (-> target-trans quad)) + ) + (set! (-> obj blend) 1.0) + (set! (-> obj shutting-down?) #f) + ) + ) + (let ((v0-6 0)) + ) + (none) + ) + +;; definition for function joint-mod-look-at-handler +;; INFO: Return type mismatch int vs none. +;; WARN: Unsupported inline assembly instruction kind - [mula.s f1, f4] +;; WARN: Unsupported inline assembly instruction kind - [madda.s f2, f5] +;; WARN: Unsupported inline assembly instruction kind - [madd.s f1, f3, f6] +;; Used lq/sq +(defun joint-mod-look-at-handler ((csp cspace) (xform transformq)) + (local-vars + (v0-20 quaternion) + (f1-12 float) + (sv-48 vector) + (sv-52 vector) + (sv-56 vector) + ) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> csp param1)))) + (cspace<-parented-transformq-joint! csp xform) + (set! + sv-48 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! + sv-52 + (vector-normalize! (-> (-> csp bone) transform vector (-> gp-0 nose)) 1.0) + ) + (let ((t9-3 vector-normalize!) + (a0-5 (new 'stack-no-clear 'vector)) + ) + (let ((v1-6 (-> gp-0 target)) + (a1-5 (-> csp bone transform vector 3)) + ) + (.lvf vf4 (&-> v1-6 quad)) + (.lvf vf5 (&-> a1-5 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-5 quad) vf6) + (set! sv-56 (t9-3 a0-5 1.0)) + ) + (let* ((f30-0 (vector-y-angle sv-52)) + (t9-5 vector-flatten!) + (a0-7 (new-stack-vector0)) + (a0-8 (t9-5 a0-7 sv-56 sv-48)) + (f0-0 (vector-y-angle a0-8)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let + ((f30-1 + (fmax + (fmin + (* (* f0-1 (-> gp-0 blend)) (-> gp-0 flex-blend)) + (-> gp-0 twist-max y) + ) + (- (-> gp-0 twist-max y)) + ) + ) + ) + (if (and (-> gp-0 shutting-down?) (= (-> gp-0 twist y) f30-1)) + (set-mode! gp-0 (joint-mod-handler-mode reset)) + ) + (set! + (-> gp-0 twist y) + (deg-seek + (-> gp-0 twist y) + f30-1 + (* 0.1 (fabs (deg-diff f30-1 (-> gp-0 twist y)))) + ) + ) + ) + ) + (let ((v1-15 (-> gp-0 up))) + (cond + ((zero? v1-15) + (quaternion-rotate-x! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist y) + ) + ) + ((= v1-15 1) + (quaternion-rotate-local-y! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist y) + ) + ) + (else + (quaternion-rotate-z! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist y) + ) + ) + ) + ) + (let* + ((s3-1 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (t9-16 vector-flatten!) + (a0-19 (new-stack-vector0)) + (s3-2 (t9-16 a0-19 sv-56 s3-1)) + (f0-15 (vector-x-angle s3-2)) + (f0-21 + (fmax + (fmin + (* (* (- (deg-diff f30-2 f0-15)) (-> gp-0 blend)) (-> gp-0 flex-blend)) + (-> gp-0 twist-max x) + ) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (let* ((v1-22 sv-52)) + (set! f1-12 (vector-dot s3-2 v1-22)) + ) + (if (< f1-12 0.1) + (set! f0-21 0.0) + ) + (set! + (-> gp-0 twist x) + (deg-seek + (-> gp-0 twist x) + f0-21 + (* 0.1 (fabs (deg-diff f0-21 (-> gp-0 twist x)))) + ) + ) + ) + (let ((v1-27 (-> gp-0 ear))) + (cond + ((zero? v1-27) + (set! + v0-20 + (quaternion-rotate-x! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist x) + ) + ) + ) + ((= v1-27 1) + (set! + v0-20 + (quaternion-rotate-local-y! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist x) + ) + ) + ) + (else + (set! + v0-20 + (quaternion-rotate-z! + (the-as quaternion (-> xform rot)) + (the-as quaternion (-> xform rot)) + (-> gp-0 twist x) + ) + ) + ) + ) + ) + (cspace<-parented-transformq-joint! csp xform) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id debug-draw) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (let ((v0-21 0)) + ) + (none) + ) + ) + +;; definition for function joint-mod-world-look-at-handler +;; INFO: Return type mismatch int vs none. +;; WARN: Unsupported inline assembly instruction kind - [mula.s f1, f4] +;; WARN: Unsupported inline assembly instruction kind - [madda.s f2, f5] +;; WARN: Unsupported inline assembly instruction kind - [madd.s f1, f3, f6] +;; Used lq/sq +(defun joint-mod-world-look-at-handler ((arg0 cspace) (arg1 transformq)) + (local-vars (f1-14 float) (sv-48 vector) (sv-52 vector) (sv-56 vector)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((gp-0 (the-as joint-mod (-> arg0 param1)))) + (let ((s5-0 (-> arg0 bone transform))) + (cspace<-parented-transformq-joint! arg0 arg1) + (set! + sv-48 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (-> gp-0 process node-list data 0 bone transform vector 1) + 1.0 + ) + ) + (set! sv-52 (vector-normalize! (-> s5-0 vector (-> gp-0 nose)) 1.0)) + (let ((t9-3 vector-normalize!) + (a0-3 (new 'stack-no-clear 'vector)) + ) + (let ((v1-7 (-> gp-0 target)) + (a1-3 (-> s5-0 vector 3)) + ) + (.lvf vf4 (&-> v1-7 quad)) + (.lvf vf5 (&-> a1-3 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a0-3 quad) vf6) + (set! sv-56 (t9-3 a0-3 1.0)) + ) + (let* ((f30-0 (vector-y-angle sv-52)) + (t9-5 vector-flatten!) + (a0-5 (new-stack-vector0)) + (a0-6 (t9-5 a0-5 sv-56 sv-48)) + (f0-0 (vector-y-angle a0-6)) + (f0-1 (deg-diff f30-0 f0-0)) + ) + (if (< (-> gp-0 ignore-angle) (fabs f0-1)) + (set! f0-1 0.0) + ) + (let + ((f0-5 + (fmax + (fmin + (* (* f0-1 (-> gp-0 blend)) (-> gp-0 flex-blend)) + (-> gp-0 twist-max y) + ) + (- (-> gp-0 twist-max y)) + ) + ) + ) + (set! + (-> gp-0 twist y) + (deg-seek + (-> gp-0 twist y) + f0-5 + (fmax 1.0 (* 0.1 (fabs (deg-diff f0-5 (-> gp-0 twist y))))) + ) + ) + ) + ) + (when (!= (-> gp-0 twist y) 0.0) + (let + ((a2-3 + (matrix-rotate-y! (new 'stack-no-clear 'matrix) (-> gp-0 twist y)) + ) + (s4-2 (-> s5-0 vector 3 quad)) + ) + (matrix*! s5-0 s5-0 a2-3) + (set! (-> s5-0 vector 3 quad) s4-2) + ) + ) + (let* + ((s4-3 + (vector-normalize-copy! + (new 'stack-no-clear 'vector) + (the-as vector (-> gp-0 process node-list data 0 bone transform)) + 1.0 + ) + ) + (f30-2 (vector-x-angle sv-52)) + (t9-14 vector-flatten!) + (a0-14 (new-stack-vector0)) + (s4-4 (t9-14 a0-14 sv-56 s4-3)) + (f0-14 (vector-x-angle s4-4)) + (f0-20 + (fmax + (fmin + (* + (* (- (deg-diff f30-2 f0-14)) (-> gp-0 blend)) + (-> gp-0 flex-blend) + ) + (-> gp-0 twist-max x) + ) + (- (-> gp-0 twist-max x)) + ) + ) + ) + (let* ((v1-14 sv-52)) + (set! f1-14 (vector-dot s4-4 v1-14)) + ) + (if (< f1-14 0.1) + (set! f0-20 0.0) + ) + (let + ((v0-17 + (the-as + object + (deg-seek + (-> gp-0 twist x) + f0-20 + (fmax 1.0 (* 0.1 (fabs (deg-diff f0-20 (-> gp-0 twist x))))) + ) + ) + ) + ) + (set! (-> gp-0 twist x) (the-as float v0-17)) + (when (!= (-> gp-0 twist x) 0.0) + (let* ((v1-20 (-> gp-0 ear)) + (a1-17 ((cond + ((zero? v1-20) + matrix-rotate-x! + ) + ((= v1-20 1) + matrix-rotate-y! + ) + (else + matrix-rotate-z! + ) + ) + (new 'stack-no-clear 'matrix) (-> gp-0 twist x) + ) + ) + ) + (set! v0-17 (matrix*! s5-0 a1-17 s5-0)) + ) + ) + ) + ) + ) + (if (and (= (-> gp-0 process type) target) (!= (-> gp-0 blend) 0.0)) + (add-debug-text-sphere + *display-target-marks* + (bucket-id debug-draw) + (-> gp-0 target) + 819.2 + "look" + (new 'static 'rgba :r #xff :g #xff :a #x80) + ) + ) + ) + (let ((v0-19 0)) + ) + (none) + ) + ) + +;; definition for function joint-mod-rotate-handler +;; INFO: Return type mismatch int vs none. +(defun joint-mod-rotate-handler ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1))) + (s3-0 + (new 'static 'inline-array vector 3 + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + ) + ) + ) + (let* ((v1-2 (-> s3-0 (-> s4-0 ear))) + (a1-2 + (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-2 x) + (-> v1-2 y) + (-> v1-2 z) + (* (* (-> s4-0 twist x) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-2 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + (let* ((v1-6 (-> s3-0 (-> s4-0 up))) + (a1-4 + (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-6 x) + (-> v1-6 y) + (-> v1-6 z) + (* (* (-> s4-0 twist y) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-4 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + (let* ((v1-10 (-> s3-0 (-> s4-0 nose))) + (a1-6 + (quaternion-axis-angle! + (new 'stack-no-clear 'quaternion) + (-> v1-10 x) + (-> v1-10 y) + (-> v1-10 z) + (* (* (-> s4-0 twist z) (-> s4-0 blend)) (-> s4-0 flex-blend)) + ) + ) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + a1-6 + (the-as quaternion (-> arg1 rot)) + ) + ) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((v0-9 0)) + ) + (none) + ) + +;; definition for function joint-mod-joint-set-handler +;; INFO: Return type mismatch int vs none. +;; Used lq/sq +(defun joint-mod-joint-set-handler ((arg0 cspace) (arg1 transformq)) + (let ((s4-0 (the-as joint-mod (-> arg0 param1)))) + (let ((v1-0 (-> arg1 trans))) + (set! (-> v1-0 quad) (-> s4-0 trans quad)) + ) + (quaternion-copy! (the-as quaternion (-> arg1 rot)) (-> s4-0 quat)) + (let ((v1-1 (-> arg1 scale))) + (set! (-> v1-1 quad) (-> s4-0 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (let ((v0-1 0)) + ) + (none) + ) + +;; definition for function joint-mod-joint-set*-handler +;; INFO: Return type mismatch int vs none. +(defun joint-mod-joint-set*-handler ((arg0 cspace) (arg1 transformq)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s5-0 (the-as joint-mod (-> arg0 param1)))) + (let ((a1-1 (-> arg1 trans))) + (let ((v1-0 (-> arg1 trans)) + (a0-1 (-> s5-0 trans)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.lvf vf4 (&-> v1-0 quad)) + (.lvf vf5 (&-> a0-1 quad)) + ) + (.add.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-1 quad) vf6) + ) + (quaternion-normalize! + (quaternion*! + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> arg1 rot)) + (-> s5-0 quat) + ) + ) + (vector*! (-> arg1 scale) (-> arg1 scale) (-> s5-0 scale)) + (cspace<-parented-transformq-joint! arg0 arg1) + (when (-> s5-0 max-dist) + (let ((v1-4 (-> arg0 bone scale))) + (set! (-> v1-4 x) 1.0) + (set! (-> v1-4 y) 1.0) + (set! (-> v1-4 z) 1.0) + (set! (-> v1-4 w) 1.0) + ) + ) + ) + (let ((v0-3 0)) + ) + (none) + ) + ) + +;; definition for symbol *joint-axis-vectors*, type (inline-array vector) +(define + *joint-axis-vectors* + (new 'static 'inline-array vector 6 + (new 'static 'vector :x 1.0 :w 1.0) + (new 'static 'vector :y 1.0 :w 1.0) + (new 'static 'vector :z 1.0 :w 1.0) + (new 'static 'vector :x -1.0 :w 1.0) + (new 'static 'vector :y -1.0 :w 1.0) + (new 'static 'vector :z -1.0 :w 1.0) + ) + ) + +;; definition of type joint-mod-wheel +(deftype joint-mod-wheel (basic) + ((last-position vector :inline :offset-assert 16) + (angle float :offset-assert 32) + (process process-drawable :offset-assert 36) + (wheel-radius float :offset-assert 40) + (wheel-axis int8 :offset-assert 44) + ) + :method-count-assert 9 + :size-assert #x2d + :flag-assert #x90000002d + (:methods + (new (symbol type process-drawable int float int) _type_ 0) + ) + ) + +;; definition for method 3 of type joint-mod-wheel +(defmethod inspect joint-mod-wheel ((obj joint-mod-wheel)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tlast-position: #~%" (-> obj last-position)) + (format #t "~Tangle: ~f~%" (-> obj angle)) + (format #t "~Tprocess: ~A~%" (-> obj process)) + (format #t "~Twheel-radius: ~f~%" (-> obj wheel-radius)) + (format #t "~Twheel-axis: ~D~%" (-> obj wheel-axis)) + obj + ) + +;; definition for function joint-mod-wheel-callback +;; WARN: Unsupported inline assembly instruction kind - [mula.s f0, f3] +;; WARN: Unsupported inline assembly instruction kind - [madda.s f1, f4] +;; WARN: Unsupported inline assembly instruction kind - [madd.s f0, f2, f5] +;; Used lq/sq +(defun joint-mod-wheel-callback ((arg0 cspace) (arg1 transformq)) + (local-vars (f0-3 float)) + (rlet ((vf0 :class vf) + (vf4 :class vf) + (vf5 :class vf) + (vf6 :class vf) + ) + (init-vf0-vector) + (let ((s4-0 (the-as joint-mod-wheel (-> arg0 param1)))) + (let ((v1-1 (-> s4-0 process root)) + (s1-0 (new-stack-vector0)) + (s3-0 (new-stack-vector0)) + (s2-0 (new-stack-vector0)) + ) + (let ((f0-0 0.0)) + ) + (let ((f0-1 0.0)) + ) + (vector-z-quaternion! s2-0 (the-as quaternion (-> v1-1 rot))) + (vector<-cspace! s1-0 arg0) + (let ((a1-3 s3-0)) + (let ((v1-2 s1-0) + (a0-3 (-> s4-0 last-position)) + ) + (.lvf vf4 (&-> v1-2 quad)) + (.lvf vf5 (&-> a0-3 quad)) + ) + (.mov.vf vf6 vf0 :mask #b1000) + (.sub.vf vf6 vf4 vf5 :mask #b111) + (.svf (&-> a1-3 quad) vf6) + ) + (let ((v1-3 (-> s4-0 last-position))) + (set! (-> v1-3 quad) (-> s1-0 quad)) + ) + (set! f0-3 (vector-dot s2-0 s3-0)) + ) + (let* ((f0-4 f0-3) + (f1-1 65536.0) + (f2-2 (* 6.28318 (-> s4-0 wheel-radius))) + (f0-5 (* (* f1-1 (/ 1.0 f2-2)) f0-4)) + ) + (set! (-> s4-0 angle) (+ (-> s4-0 angle) f0-5)) + ) + (quaternion-vector-angle! + (the-as quaternion (-> arg1 rot)) + (-> *joint-axis-vectors* (-> s4-0 wheel-axis)) + (-> s4-0 angle) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + ) + +;; definition for method 0 of type joint-mod-wheel +(defmethod + new + joint-mod-wheel + ((allocation symbol) + (type-to-make type) + (arg0 process-drawable) + (arg1 int) + (arg2 float) + (arg3 int) + ) + (let + ((v0-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> v0-0 process) arg0) + (set! (-> v0-0 wheel-radius) arg2) + (set! (-> v0-0 wheel-axis) arg3) + (set! (-> v0-0 angle) 0.0) + (let ((v1-2 (-> v0-0 last-position))) + (set! (-> v1-2 x) 0.0) + (set! (-> v1-2 y) 0.0) + (set! (-> v1-2 z) 0.0) + (set! (-> v1-2 w) 1.0) + ) + (let ((v1-5 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-5 param0) joint-mod-wheel-callback) + (set! (-> v1-5 param1) v0-0) + ) + v0-0 + ) + ) + +;; definition of type joint-mod-set-local +(deftype joint-mod-set-local (basic) + ((transform transformq :inline :offset-assert 16) + (set-rotation basic :offset-assert 64) + (set-scale basic :offset-assert 68) + (set-translation basic :offset-assert 72) + (enable basic :offset-assert 76) + ) + :method-count-assert 9 + :size-assert #x50 + :flag-assert #x900000050 + (:methods + (new (symbol type process-drawable int basic basic basic) _type_ 0) + ) + ) + +;; definition for method 3 of type joint-mod-set-local +(defmethod inspect joint-mod-set-local ((obj joint-mod-set-local)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Ttransform: #~%" (-> obj transform)) + (format #t "~Tset-rotation: ~A~%" (-> obj set-rotation)) + (format #t "~Tset-scale: ~A~%" (-> obj set-scale)) + (format #t "~Tset-translation: ~A~%" (-> obj set-translation)) + (format #t "~Tenable: ~A~%" (-> obj enable)) + obj + ) + +;; definition for function joint-mod-set-local-callback +;; Used lq/sq +(defun joint-mod-set-local-callback ((arg0 cspace) (arg1 transformq)) + (let ((v1-0 (the-as joint-mod-set-local (-> arg0 param1)))) + (cond + ((-> v1-0 enable) + (when (not (-> v1-0 set-translation)) + (let ((a2-3 (-> v1-0 transform))) + (set! (-> a2-3 trans quad) (-> arg1 trans quad)) + ) + ) + (when (not (-> v1-0 set-rotation)) + (let ((a2-6 (-> v1-0 transform rot))) + (set! (-> a2-6 quad) (-> arg1 rot quad)) + ) + ) + (when (not (-> v1-0 set-scale)) + (let ((a2-9 (-> v1-0 transform scale))) + (set! (-> a2-9 quad) (-> arg1 scale quad)) + ) + ) + (cspace<-parented-transformq-joint! arg0 (-> v1-0 transform)) + ) + (else + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + ) + (none) + ) + +;; definition for method 0 of type joint-mod-set-local +;; Used lq/sq +(defmethod + new + joint-mod-set-local + ((allocation symbol) + (type-to-make type) + (arg0 process-drawable) + (arg1 int) + (arg2 basic) + (arg3 basic) + (arg4 basic) + ) + (let + ((v0-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> v0-0 set-translation) arg2) + (set! (-> v0-0 set-rotation) arg3) + (set! (-> v0-0 set-scale) arg4) + (set! (-> v0-0 enable) #t) + (let ((v1-3 (-> v0-0 transform))) + (set! (-> v1-3 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform rot))) + (set! (-> v1-4 quad) (-> *null-vector* quad)) + ) + (let ((v1-5 (-> v0-0 transform scale))) + (set! (-> v1-5 quad) (-> *identity-vector* quad)) + ) + (let ((v1-8 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-8 param0) joint-mod-set-local-callback) + (set! (-> v1-8 param1) v0-0) + ) + v0-0 + ) + ) + +;; definition of type joint-mod-set-world +(deftype joint-mod-set-world (basic) + ((transform transformq :inline :offset-assert 16) + (node-index int32 :offset-assert 64) + (enable basic :offset-assert 68) + ) + :method-count-assert 9 + :size-assert #x48 + :flag-assert #x900000048 + (:methods + (new (symbol type process-drawable int basic) _type_ 0) + ) + ) + +;; definition for method 3 of type joint-mod-set-world +(defmethod inspect joint-mod-set-world ((obj joint-mod-set-world)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Ttransform: #~%" (-> obj transform)) + (format #t "~Tnode-index: ~D~%" (-> obj node-index)) + (format #t "~Tenable: ~A~%" (-> obj enable)) + obj + ) + +;; definition for function joint-mod-set-world-callback +(defun joint-mod-set-world-callback ((arg0 cspace) (arg1 transformq)) + (let ((v1-0 (the-as joint-mod-set-world (-> arg0 param1)))) + (if (-> v1-0 enable) + (cspace<-transformq! arg0 (-> v1-0 transform)) + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + (none) + ) + +;; definition for method 0 of type joint-mod-set-world +;; Used lq/sq +(defmethod + new + joint-mod-set-world + ((allocation symbol) + (type-to-make type) + (arg0 process-drawable) + (arg1 int) + (arg2 basic) + ) + (let + ((v0-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> v0-0 node-index) arg1) + (set! (-> v0-0 enable) arg2) + (let ((v1-2 (-> v0-0 transform))) + (set! (-> v1-2 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-3 (-> v0-0 transform rot))) + (set! (-> v1-3 quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform scale))) + (set! (-> v1-4 quad) (-> *identity-vector* quad)) + ) + (let ((v1-7 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-7 param0) joint-mod-set-world-callback) + (set! (-> v1-7 param1) v0-0) + ) + v0-0 + ) + ) + +;; definition of type joint-mod-blend-local +(deftype joint-mod-blend-local (basic) + ((transform transformq :inline :offset-assert 16) + (blend-transform transformq :inline :offset-assert 64) + (node-index int32 :offset-assert 112) + (blend float :offset-assert 116) + (enable basic :offset-assert 120) + ) + :method-count-assert 9 + :size-assert #x7c + :flag-assert #x90000007c + (:methods + (new (symbol type process-drawable int basic) _type_ 0) + ) + ) + +;; definition for method 3 of type joint-mod-blend-local +(defmethod inspect joint-mod-blend-local ((obj joint-mod-blend-local)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Ttransform: #~%" (-> obj transform)) + (format + #t + "~Tblend-transform: #~%" + (-> obj blend-transform) + ) + (format #t "~Tnode-index: ~D~%" (-> obj node-index)) + (format #t "~Tblend: ~f~%" (-> obj blend)) + (format #t "~Tenable: ~A~%" (-> obj enable)) + obj + ) + +;; definition for function joint-mod-blend-local-callback +(defun joint-mod-blend-local-callback ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod-blend-local (-> arg0 param1)))) + (cond + ((-> gp-0 enable) + (vector-lerp! + (the-as vector (-> gp-0 blend-transform)) + (-> arg1 trans) + (the-as vector (-> gp-0 transform)) + (-> gp-0 blend) + ) + (vector-lerp! + (-> gp-0 blend-transform scale) + (-> arg1 scale) + (-> gp-0 transform scale) + (-> gp-0 blend) + ) + (quaternion-slerp! + (the-as quaternion (-> gp-0 blend-transform rot)) + (the-as quaternion (-> arg1 rot)) + (the-as quaternion (-> gp-0 transform rot)) + (-> gp-0 blend) + ) + (cspace<-parented-transformq-joint! arg0 (-> gp-0 blend-transform)) + ) + (else + (cspace<-parented-transformq-joint! arg0 arg1) + ) + ) + ) + (none) + ) + +;; definition for method 0 of type joint-mod-blend-local +;; Used lq/sq +(defmethod + new + joint-mod-blend-local + ((allocation symbol) + (type-to-make type) + (arg0 process-drawable) + (arg1 int) + (arg2 basic) + ) + (let + ((v0-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (set! (-> v0-0 node-index) arg1) + (set! (-> v0-0 enable) arg2) + (set! (-> v0-0 blend) 0.0) + (let ((v1-2 (-> v0-0 transform))) + (set! (-> v1-2 trans quad) (-> *null-vector* quad)) + ) + (let ((v1-3 (-> v0-0 transform rot))) + (set! (-> v1-3 quad) (-> *null-vector* quad)) + ) + (let ((v1-4 (-> v0-0 transform scale))) + (set! (-> v1-4 quad) (-> *identity-vector* quad)) + ) + (let ((v1-7 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-7 param0) joint-mod-blend-local-callback) + (set! (-> v1-7 param1) v0-0) + ) + v0-0 + ) + ) + +;; definition of type joint-mod-spinner +(deftype joint-mod-spinner (basic) + ((spin-axis vector :inline :offset-assert 16) + (angle float :offset-assert 32) + (spin-rate float :offset-assert 36) + (enable basic :offset-assert 40) + ) + :method-count-assert 9 + :size-assert #x2c + :flag-assert #x90000002c + (:methods + (new (symbol type process-drawable int vector float) _type_ 0) + ) + ) + +;; definition for method 3 of type joint-mod-spinner +(defmethod inspect joint-mod-spinner ((obj joint-mod-spinner)) + (format #t "[~8x] ~A~%" obj (-> obj type)) + (format #t "~Tspin-axis: #~%" (-> obj spin-axis)) + (format #t "~Tangle: ~f~%" (-> obj angle)) + (format #t "~Tspin-rate: ~f~%" (-> obj spin-rate)) + (format #t "~Tenable: ~A~%" (-> obj enable)) + obj + ) + +;; definition for function joint-mod-spinner-callback +(defun joint-mod-spinner-callback ((arg0 cspace) (arg1 transformq)) + (let ((gp-0 (the-as joint-mod-spinner (-> arg0 param1)))) + (when (-> gp-0 enable) + (let + ((f30-0 + (+ + (-> gp-0 angle) + (* (-> gp-0 spin-rate) (-> *display* seconds-per-frame)) + ) + ) + ) + (if (< 32768.0 f30-0) + (set! f30-0 (+ -65536.0 f30-0)) + ) + (if (< f30-0 -32768.0) + (set! f30-0 (+ 65536.0 f30-0)) + ) + (quaternion-vector-angle! + (the-as quaternion (-> arg1 rot)) + (-> gp-0 spin-axis) + f30-0 + ) + (set! (-> gp-0 angle) f30-0) + ) + ) + ) + (cspace<-parented-transformq-joint! arg0 arg1) + (none) + ) + +;; definition for method 0 of type joint-mod-spinner +;; Used lq/sq +(defmethod + new + joint-mod-spinner + ((allocation symbol) + (type-to-make type) + (arg0 process-drawable) + (arg1 int) + (arg2 vector) + (arg3 float) + ) + (let + ((v0-0 + (object-new allocation type-to-make (the-as int (-> type-to-make size))) + ) + ) + (let ((v1-2 (-> v0-0 spin-axis))) + (set! (-> v1-2 quad) (-> arg2 quad)) + ) + (set! (-> v0-0 spin-rate) arg3) + (set! (-> v0-0 enable) #t) + (set! (-> v0-0 angle) 0.0) + (let ((v1-6 (-> (-> arg0 node-list) data arg1))) + (set! (-> v1-6 param0) joint-mod-spinner-callback) + (set! (-> v1-6 param1) v0-0) + ) + v0-0 + ) + ) + + + + diff --git a/test/decompiler/test_FormExpressionBuild2.cpp b/test/decompiler/test_FormExpressionBuild2.cpp index 6cb9c14c02..4872079864 100644 --- a/test/decompiler/test_FormExpressionBuild2.cpp +++ b/test/decompiler/test_FormExpressionBuild2.cpp @@ -91,7 +91,7 @@ TEST_F(FormRegressionTest, VectorXQuaternionWithCast) { "(begin\n" " (let ((s5-0 (new-stack-matrix0)))\n" " (quaternion->matrix s5-0 arg1)\n" - " (set! (-> arg0 vec quad) (-> (the-as (pointer uint128) (-> s5-0 data)) 0))\n" + " (set! (-> arg0 vec quad) (-> (the-as (pointer uint128) (-> s5-0 vector)) 0))\n" " )\n" " arg0\n" " )"; diff --git a/test/offline/offline_test_main.cpp b/test/offline/offline_test_main.cpp index b716870537..3247ced5e4 100644 --- a/test/offline/offline_test_main.cpp +++ b/test/offline/offline_test_main.cpp @@ -119,9 +119,8 @@ const std::unordered_set g_functions_to_skip_compiling = { "vector-dot", // fpu acc "vector4-dot", // fpu acc - // QUATERNION - "matrix-with-scale->quaternion", // fpu acc - "quaternion-delta-y", // fpu acc + // quaternion + "matrix-with-scale->quaternion", // fpu-acc "(method 3 profile-frame)", // double definition.