mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
Allow quat * vec in ruamoko.
This commit is contained in:
parent
1a0ccf6a92
commit
e06ee34287
2 changed files with 39 additions and 1 deletions
|
@ -479,6 +479,28 @@ do_op_pointer (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
|||
return e;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_quatvect (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
if (op != '*')
|
||||
return error (e1, "invalid operator for quaternion and vector");
|
||||
if (is_constant (e1) && QuatIsZero (expr_quaternion (e1)))
|
||||
return new_vector_expr (vec3_origin);
|
||||
if (is_constant (e2) && VectorIsZero (expr_vector (e2)))
|
||||
return new_vector_expr (vec3_origin);
|
||||
if (is_constant (e1) && is_constant (e2)) {
|
||||
const vec_t *q, *v;
|
||||
vec3_t r;
|
||||
|
||||
q = expr_quaternion (e1);
|
||||
v = expr_vector (e2);
|
||||
QuatMultVec (q, v, r);
|
||||
return new_vector_expr (r);
|
||||
}
|
||||
e->e.expr.type = &type_vector;
|
||||
return e;
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
do_op_quaternion (int op, expr_t *e, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
|
@ -994,7 +1016,7 @@ static operation_t op_quaternion[ev_type_count] = {
|
|||
do_op_invalid, // ev_void
|
||||
do_op_invalid, // ev_string
|
||||
do_op_quaternion, // ev_float
|
||||
do_op_invalid, // ev_vector
|
||||
do_op_quatvect, // ev_vector
|
||||
do_op_invalid, // ev_entity
|
||||
do_op_invalid, // ev_field
|
||||
do_op_invalid, // ev_func
|
||||
|
|
16
tools/qfcc/test/quattest.r
Normal file
16
tools/qfcc/test/quattest.r
Normal file
|
@ -0,0 +1,16 @@
|
|||
void printf (string fmt, ...) = #0;
|
||||
|
||||
quaternion q;
|
||||
vector v;
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
quaternion tq;
|
||||
q = '0.6 0.48 0.64 0';
|
||||
v = '1 2 3';
|
||||
tq.s = 0;
|
||||
tq.v = v;
|
||||
printf ("%v %q\n", q * v, q * tq * ~q);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue