From 42287f1e0ef5985f4880fb419b79eb76867bfa61 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 17 Aug 2022 16:03:51 +0900 Subject: [PATCH] [qfcc] Allow binary operations between vector and vec3 While I might need to tighten up the rules later, this allows binary operations between vector (the type) and explicitly typed vec3 constants (and non-constants, about which I am undecided). The idea is that explicit constants such as '1 2 3'f should be compatible with either type. This applies to quaternions as well. --- tools/qfcc/source/expr_binary.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/qfcc/source/expr_binary.c b/tools/qfcc/source/expr_binary.c index 1c0429d09..d8888dc7f 100644 --- a/tools/qfcc/source/expr_binary.c +++ b/tools/qfcc/source/expr_binary.c @@ -1094,6 +1094,12 @@ binary_expr (int op, expr_t *e1, expr_t *e2) e2 = cast_expr (t1, e2); } else if (type_promotes (base_type (t2), base_type (t1))) { e1 = cast_expr (t2, e1); + } else if (base_type (t1) == base_type (t2)) { + if (is_vector (t1) || is_quaternion (t1)) { + e2 = cast_expr (t1, e2); + } else if (is_vector (t2) || is_quaternion (t2)) { + e1 = cast_expr (t2, e1); + } } else { debug (e1, "%d %d\n", e1->implicit, e2->implicit); return invalid_binary_expr (op, e1, e2);