mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-05 23:41:10 +00:00
clean up the vector def setup
This commit is contained in:
parent
b519c0b7cd
commit
cbffb4b140
1 changed files with 35 additions and 41 deletions
|
@ -128,6 +128,35 @@ new_scope (scope_type type, defspace_t *space, scope_t *parent)
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char *vector_component_names[] = {"%s_x", "%s_y", "%s_z"};
|
||||||
|
|
||||||
|
static void
|
||||||
|
vector_component (def_t *vec, int comp, scope_t *scope)
|
||||||
|
{
|
||||||
|
def_t *d;
|
||||||
|
|
||||||
|
d = new_def (&type_float, va (vector_component_names[comp], vec->name),
|
||||||
|
scope);
|
||||||
|
d->used = 1;
|
||||||
|
d->parent = vec;
|
||||||
|
d->ofs = vec->ofs + comp;
|
||||||
|
Hash_Add (defs_by_name, d);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
vector_field_component (def_t *vec, int comp, scope_t *scope)
|
||||||
|
{
|
||||||
|
def_t *d;
|
||||||
|
|
||||||
|
d = new_def (&type_floatfield, va (vector_component_names[comp], vec->name),
|
||||||
|
scope);
|
||||||
|
d->used = 1; // always `used'
|
||||||
|
d->parent = vec;
|
||||||
|
d->ofs = vec->ofs + comp;
|
||||||
|
G_INT (d->ofs) = G_INT (vec->ofs) + comp;
|
||||||
|
Hash_Add (defs_by_name, d);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
get_def
|
get_def
|
||||||
|
|
||||||
|
@ -157,53 +186,18 @@ get_def (type_t *type, const char *name, scope_t *scope, int allocate)
|
||||||
as .origin_x, .origin_y, and .origin_z
|
as .origin_x, .origin_y, and .origin_z
|
||||||
*/
|
*/
|
||||||
if (type->type == ev_vector && name) {
|
if (type->type == ev_vector && name) {
|
||||||
def_t *d;
|
vector_component (def, 0, scope);
|
||||||
|
vector_component (def, 1, scope);
|
||||||
d = new_def (&type_float, va ("%s_x", name), scope);
|
vector_component (def, 2, scope);
|
||||||
d->used = 1;
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 0;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
|
|
||||||
d = new_def (&type_float, va ("%s_y", name), scope);
|
|
||||||
d->used = 1;
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 1;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
|
|
||||||
d = new_def (&type_float, va ("%s_z", name), scope);
|
|
||||||
d->used = 1;
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 2;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type->type == ev_field) {
|
if (type->type == ev_field) {
|
||||||
G_INT (def->ofs) = new_location (type->aux_type, pr.entity_data);
|
G_INT (def->ofs) = new_location (type->aux_type, pr.entity_data);
|
||||||
|
|
||||||
if (type->aux_type->type == ev_vector) {
|
if (type->aux_type->type == ev_vector) {
|
||||||
def_t *d;
|
vector_field_component (def, 0, scope);
|
||||||
|
vector_field_component (def, 1, scope);
|
||||||
d = new_def (&type_floatfield, va ("%s_x", name), scope);
|
vector_field_component (def, 2, scope);
|
||||||
d->used = 1; // always `used'
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 0;
|
|
||||||
G_INT (d->ofs) = G_INT (def->ofs) + 0;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
|
|
||||||
d = new_def (&type_floatfield, va ("%s_y", name), scope);
|
|
||||||
d->used = 1; // always `used'
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 1;
|
|
||||||
G_INT (d->ofs) = G_INT (def->ofs) + 1;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
|
|
||||||
d = new_def (&type_floatfield, va ("%s_z", name), scope);
|
|
||||||
d->used = 1; // always `used'
|
|
||||||
d->parent = def;
|
|
||||||
d->ofs = def->ofs + 2;
|
|
||||||
G_INT (d->ofs) = G_INT (def->ofs) + 2;
|
|
||||||
Hash_Add (defs_by_name, d);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue