more quaternion work (should be working, haven't come up with tests yet)

This commit is contained in:
Bill Currie 2004-04-08 03:32:14 +00:00
parent 4882005a49
commit fc2413ff72
7 changed files with 33 additions and 7 deletions

View file

@ -649,9 +649,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
fi = &(*fi)->next; fi = &(*fi)->next;
break; break;
case 'v': case 'v':
case 'q':
// vector // vector
{ {
int i; int i, count = 3;
int flags = (*fi)->flags; int flags = (*fi)->flags;
int precision = (*fi)->precision; int precision = (*fi)->precision;
unsigned minWidth = (*fi)->minFieldWidth; unsigned minWidth = (*fi)->minFieldWidth;
@ -660,7 +661,10 @@ PR_Sprintf (progs_t *pr, dstring_t *result, const char *name,
(*fi)->precision = -1; (*fi)->precision = -1;
(*fi)->minFieldWidth = 0; (*fi)->minFieldWidth = 0;
for (i = 0; i < 3; i++) { if (*c == 'q')
count = 4;
for (i = 0; i < count; i++) {
if (i == 0) { if (i == 0) {
(*fi)->type = 's'; (*fi)->type = 's';
(*fi)->data.string_var = "'"; (*fi)->data.string_var = "'";

View file

@ -60,7 +60,7 @@ typedef struct struct_s {
struct_field_t *struct_head; struct_field_t *struct_head;
struct_field_t **struct_tail; struct_field_t **struct_tail;
int size; int size;
void *return_addr; // who allocated this void *return_addr; // who allocated this
} struct_t; } struct_t;
typedef struct enum_s { typedef struct enum_s {

View file

@ -172,7 +172,7 @@ build_scope (function_t *f, def_t *func, param_t *params)
if (args) { if (args) {
while (i < MAX_PARMS) { 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; def->used = 1;
i++; i++;
} }

View file

@ -240,6 +240,9 @@ WriteProgdefs (const char *filename)
fprintf (f, "\tvec3_t\t%s;\n", d->name); fprintf (f, "\tvec3_t\t%s;\n", d->name);
d = d->def_next->def_next->def_next; // skip the elements d = d->def_next->def_next->def_next; // skip the elements
break; break;
case ev_quat:
fprintf (f, "\tquat_t\t%s;\n", d->name);
break;
case ev_string: case ev_string:
fprintf (f, "\tstring_t\t%s;\n", d->name); fprintf (f, "\tstring_t\t%s;\n", d->name);
break; break;

View file

@ -213,7 +213,7 @@ ReuseConstant (expr_t *expr, def_t *def)
type = &type_vector; type = &type_vector;
break; break;
case ex_quaternion: case ex_quaternion:
tab = vector_imm_defs; tab = quaternion_imm_defs;
type = &type_quaternion; type = &type_quaternion;
break; break;
default: default:

View file

@ -168,8 +168,10 @@ m ([\-+]?)
'{s}*{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}*' { '{s}*{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}+{m}{NUM}{s}*' {
sscanf (yytext, "' %f %f %f %f '", sscanf (yytext, "' %f %f %f %f '",
&yylval.vector_val[0], &yylval.vector_val[1], &yylval.quaternion_val[0],
&yylval.vector_val[2], &yylval.vector_val[3]); &yylval.quaternion_val[1],
&yylval.quaternion_val[2],
&yylval.quaternion_val[3]);
return QUATERNION_VAL; return QUATERNION_VAL;
} }

View file

@ -99,6 +99,7 @@ type_t type_param;
type_t type_zero; type_t type_zero;
struct_t *vector_struct; struct_t *vector_struct;
struct_t *quaterion_struct;
type_t type_floatfield = { ev_field, ".float", NULL, &type_float }; type_t type_floatfield = { ev_field, ".float", NULL, &type_float };
@ -653,12 +654,28 @@ init_types (void)
if (options.traditional) if (options.traditional)
return; 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); strct = vector_struct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0); init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_float, "x", 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, "y", vis_public);
new_struct_field (strct, &type_float, "z", 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); strct = get_struct (0, 1);
init_struct (strct, new_type (), str_struct, 0); init_struct (strct, new_type (), str_struct, 0);
new_struct_field (strct, &type_string, "sel_id", vis_public); new_struct_field (strct, &type_string, "sel_id", vis_public);