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).
This commit is contained in:
Bill Currie 2012-12-14 12:25:23 +09:00
parent dc55034708
commit 732d6a1520

View file

@ -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;
}