From 732d6a15205fac4746d415e563711922b3f1f7ed Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Fri, 14 Dec 2012 12:25:23 +0900 Subject: [PATCH] Provide emulation for vector / float and quaternion / float. The VM doesn't have such instructions, so emulate them via vector * (1 / float) and quaternion * (1 / float). --- tools/qfcc/source/constfold.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/qfcc/source/constfold.c b/tools/qfcc/source/constfold.c index 2da959716..32be99827 100644 --- a/tools/qfcc/source/constfold.c +++ b/tools/qfcc/source/constfold.c @@ -324,6 +324,9 @@ do_op_vector (int op, expr_t *e, expr_t *e1, expr_t *e2) e->e.expr.type = &type_float; } else if (op == '*' && get_type (e2) == &type_vector) { e->e.expr.type = &type_float; + } else if (op == '/' && !is_constant (e1)) { + e2 = fold_constants (binary_expr ('/', new_float_expr (1), e2)); + e = fold_constants (binary_expr ('*', e1, e2)); } else { e->e.expr.type = &type_vector; } @@ -553,6 +556,9 @@ do_op_quaternion (int op, expr_t *e, expr_t *e1, expr_t *e2) e->e.expr.type = &type_integer; else e->e.expr.type = &type_float; + } else if (op == '/' && !is_constant (e1)) { + e2 = fold_constants (binary_expr ('/', new_float_expr (1), e2)); + e = fold_constants (binary_expr ('*', e1, e2)); } else { e->e.expr.type = &type_quaternion; }