Factor out polymodel color switch

This commit is contained in:
Kp 2015-02-28 22:34:06 +00:00
parent aafe252c6d
commit 655dc60850

View file

@ -140,6 +140,10 @@ public:
{
return w(p);
}
static uint_fast32_t translate_opcode(const uint8_t *, const uint16_t op)
{
return op;
}
static uint16_t get_op_subcount(const uint8_t *const p)
{
return w(p + 2);
@ -735,52 +739,7 @@ int get_chunks(const uint8_t *data, uint8_t *new_data, chunk *list, int *no)
int g3_poly_get_color(const uint8_t *p)
{
g3_poly_get_color_state state;
while (w(p) != OP_EOF)
switch (w(p)) {
case OP_DEFPOINTS: {
const auto n = state.get_op_subcount(p);
state.op_defpoints(p, n);
p += n * sizeof(vms_vector) + 4;
break;
}
case OP_DEFP_START: {
const auto n = state.get_op_subcount(p);
state.op_defp_start(p, n);
p += n * sizeof(vms_vector) + 8;
break;
}
case OP_FLATPOLY: {
const auto nv = state.get_op_subcount(p);
state.op_flatpoly(p, nv);
p += 30 + ((nv&~1)+1)*2;
break;
}
case OP_TMAPPOLY: {
const auto nv = state.get_op_subcount(p);
state.op_tmappoly(p, nv);
p += 30 + ((nv&~1)+1)*2 + nv*12;
break;
}
case OP_SORTNORM:
state.op_sortnorm(p);
p += 32;
break;
case OP_RODBM:
state.op_rodbm(p);
p+=36;
break;
case OP_SUBCALL:
state.op_subcall(p);
p += 20;
break;
case OP_GLOW:
state.op_glow(p);
p += 4;
break;
default:
state.op_default();
break;
}
iterate_polymodel(p, state);
return state.color;
}