mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
Support vector/quaternion division by float
Implemented via v*(1/f) or q*(1/f) to give CSE a chance to optimize the division if necessary as otherwise the engine would have to divide every time.
This commit is contained in:
parent
7dc1a0640a
commit
83fb588727
1 changed files with 12 additions and 2 deletions
|
@ -46,6 +46,7 @@ typedef struct {
|
|||
} expr_type_t;
|
||||
|
||||
static expr_t *pointer_arithmetic (int op, expr_t *e1, expr_t *e2);
|
||||
static expr_t *inverse_multiply (int op, expr_t *e1, expr_t *e2);
|
||||
|
||||
static expr_type_t string_string[] = {
|
||||
{'+', &type_string},
|
||||
|
@ -85,7 +86,7 @@ static expr_type_t float_vector[] = {
|
|||
|
||||
static expr_type_t float_quat[] = {
|
||||
{'*', &type_quaternion},
|
||||
{'/', &type_quaternion},
|
||||
{'/', 0, 0, 0, inverse_multiply},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
@ -113,7 +114,7 @@ static expr_type_t float_integer[] = {
|
|||
|
||||
static expr_type_t vector_float[] = {
|
||||
{'*', &type_vector},
|
||||
{'/', &type_vector},
|
||||
{'/', 0, 0, 0, inverse_multiply},
|
||||
{0, 0}
|
||||
};
|
||||
|
||||
|
@ -601,6 +602,15 @@ pointer_arithmetic (int op, expr_t *e1, expr_t *e2)
|
|||
return cast_expr (ptype, e);
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
inverse_multiply (int op, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
// There is no vector/float or quaternion/float instruction and adding
|
||||
// one would mean the engine would have to do 1/f every time
|
||||
expr_t *one = new_float_expr (1);
|
||||
return binary_expr ('*', e1, binary_expr ('/', one, e2));
|
||||
}
|
||||
|
||||
static expr_t *
|
||||
invalid_binary_expr (int op, expr_t *e1, expr_t *e2)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue