mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
more quaternion work (should be working, haven't come up with tests yet)
This commit is contained in:
parent
4882005a49
commit
fc2413ff72
7 changed files with 33 additions and 7 deletions
|
@ -649,9 +649,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
|
|||
fi = &(*fi)->next;
|
||||
break;
|
||||
case 'v':
|
||||
case 'q':
|
||||
// vector
|
||||
{
|
||||
int i;
|
||||
int i, count = 3;
|
||||
int flags = (*fi)->flags;
|
||||
int precision = (*fi)->precision;
|
||||
unsigned minWidth = (*fi)->minFieldWidth;
|
||||
|
@ -660,7 +661,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
|
|||
(*fi)->precision = -1;
|
||||
(*fi)->minFieldWidth = 0;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (*c == 'q')
|
||||
count = 4;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (i == 0) {
|
||||
(*fi)->type = 's';
|
||||
(*fi)->data.string_var = "'";
|
||||
|
|
|
@ -60,7 +60,7 @@ typedef struct struct_s {
|
|||
struct_field_t *struct_head;
|
||||
struct_field_t **struct_tail;
|
||||
int size;
|
||||
void *return_addr; // who allocated this
|
||||
void *return_addr; // who allocated this
|
||||
} struct_t;
|
||||
|
||||
typedef struct enum_s {
|
||||
|
|
|
@ -172,7 +172,7 @@ build_scope (function_t *f, def_t *func, param_t *params)
|
|||
|
||||
if (args) {
|
||||
while (i < MAX_PARMS) {
|
||||
def = get_def (&type_vector, 0, f->scope, st_local);
|
||||
def = get_def (&type_vector, 0, f->scope, st_local);//XXX param
|
||||
def->used = 1;
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -240,6 +240,9 @@ WriteProgdefs (const char *filename)
|
|||
fprintf (f, "\tvec3_t\t%s;\n", d->name);
|
||||
d = d->def_next->def_next->def_next; // skip the elements
|
||||
break;
|
||||
case ev_quat:
|
||||
fprintf (f, "\tquat_t\t%s;\n", d->name);
|
||||
break;
|
||||
case ev_string:
|
||||
fprintf (f, "\tstring_t\t%s;\n", d->name);
|
||||
break;
|
||||
|
|
|
@ -213,7 +213,7 @@ ReuseConstant (expr_t *expr, def_t *def)
|
|||
type = &type_vector;
|
||||
break;
|
||||
case ex_quaternion:
|
||||
tab = vector_imm_defs;
|
||||
tab = quaternion_imm_defs;
|
||||
type = &type_quaternion;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -168,8 +168,10 @@ m ([\-+]?)
|
|||
|
||||
'{s}*{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}*' {
|
||||
sscanf (yytext, "' %f %f %f %f '",
|
||||
&yylval.vector_val[0], &yylval.vector_val[1],
|
||||
&yylval.vector_val[2], &yylval.vector_val[3]);
|
||||
&yylval.quaternion_val[0],
|
||||
&yylval.quaternion_val[1],
|
||||
&yylval.quaternion_val[2],
|
||||
&yylval.quaternion_val[3]);
|
||||
return QUATERNION_VAL;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,7 @@ type_t type_param;
|
|||
type_t type_zero;
|
||||
|
||||
struct_t *vector_struct;
|
||||
struct_t *quaterion_struct;
|
||||
|
||||
type_t type_floatfield = { ev_field, ".float", NULL, &type_float };
|
||||
|
||||
|
@ -653,12 +654,28 @@ init_types (void)
|
|||
if (options.traditional)
|
||||
return;
|
||||
|
||||
strct = type_zero.s.strct;
|
||||
new_struct_field (strct, &type_vector, "vector_val", vis_public);
|
||||
new_struct_field (strct, &type_quaternion, "quaternion_val", vis_public);
|
||||
|
||||
strct = type_param.s.strct;
|
||||
new_struct_field (strct, &type_quaternion, "quaternion_val", vis_public);
|
||||
|
||||
strct = vector_struct = get_struct (0, 1);
|
||||
init_struct (strct, new_type (), str_struct, 0);
|
||||
new_struct_field (strct, &type_float, "x", vis_public);
|
||||
new_struct_field (strct, &type_float, "y", vis_public);
|
||||
new_struct_field (strct, &type_float, "z", vis_public);
|
||||
|
||||
strct = quaterion_struct = get_struct (0, 1);
|
||||
init_struct (strct, new_type (), str_struct, 0);
|
||||
new_struct_field (strct, &type_float, "s", vis_public);
|
||||
new_struct_field (strct, &type_float, "x", vis_public);
|
||||
new_struct_field (strct, &type_float, "y", vis_public);
|
||||
new_struct_field (strct, &type_float, "z", vis_public);
|
||||
strct->size = 1; // evil hack for the vector access
|
||||
new_struct_field (strct, &type_vector, "v", vis_public);
|
||||
|
||||
strct = get_struct (0, 1);
|
||||
init_struct (strct, new_type (), str_struct, 0);
|
||||
new_struct_field (strct, &type_string, "sel_id", vis_public);
|
||||
|
|
Loading…
Reference in a new issue