void eval_divide(Expr *expr) { Expr *l = expr->l, *r = expr->r; l->fn(l); r->fn(r); expr->v.x = l->v.x / r->v.x; if(l->isvec) { if(r->isvec) { expr->v.y = l->v.y / r->v.y; expr->v.z = l->v.z / r->v.z; } else { expr->v.y = l->v.y / r->v.x; expr->v.z = l->v.z / r->v.x; } expr->isvec = 1; } else if(r->isvec) { expr->v.y = l->v.x / r->v.y; expr->v.z = l->v.x / r->v.z; expr->isvec = 1; } else expr->isvec = 0; }
void eval_multiply(Expr *expr) { Expr *l = expr->l, *r = expr->r; l->fn(l); r->fn(r); expr->v.x = l->v.x * r->v.x; if(l->isvec) { if(r->isvec) { expr->v.y = l->v.y * r->v.y; expr->v.z = l->v.z * r->v.z; } else { expr->v.y = l->v.y * r->v.x; expr->v.z = l->v.z * r->v.x; } expr->isvec = 1; } else if(r->isvec) { expr->v.y = l->v.x * r->v.y; expr->v.z = l->v.x * r->v.z; expr->isvec = 1; } else expr->isvec = 0; }
void eval_minus(Expr *expr) { Expr *l = expr->l, *r = expr->r; l->fn(l); r->fn(r); expr->v.x = l->v.x - r->v.x; if(l->isvec) { if(r->isvec) { expr->v.y = l->v.y - r->v.y; expr->v.z = l->v.z - r->v.z; } else { expr->v.y = l->v.y - r->v.x; expr->v.z = l->v.z - r->v.x; } expr->isvec = 1; } else if(r->isvec) { expr->v.y = l->v.x - r->v.y; expr->v.z = l->v.x - r->v.z; expr->isvec = 1; } else expr->isvec = 0; }
void eval_ternary(Expr *expr) { Expr *e; expr->l->fn(expr->l); e = (expr->l->v.x) ? expr->r->l : expr->r->r; e->fn(e); V3Copy(&expr->v, &e->v); expr->isvec = e->isvec; }
void eval_checker2(Expr *expr) { Expr *e; expr->l->l->fn(expr->l->l); e = (((int)floor(expr->l->l->v.x + EPSILON) + (int)floor(expr->l->l->v.y + EPSILON) + (int)floor(expr->l->l->v.z + EPSILON)) & 1) ? expr->l->r : expr->r; e->fn(e); V3Copy(&expr->v, &e->v); expr->isvec = e->isvec; }
void eval_hexagon2(Expr *expr) { int result; Expr *e = expr->l->l->l; e->l->fn(e->l); e->r->fn(e->r); result = Hexagon2D(e->l->v.x, e->r->v.x); e = (result < 0) ? expr->l->l->r : (result > 0) ? expr->r : expr->l->r; e->fn(e); V3Copy(&expr->v, &e->v); expr->isvec = e->isvec; }
void eval_pow(Expr *expr) { Expr *l = expr->l, *r = expr->r; l->fn(l); r->fn(r); expr->v.x = pow(l->v.x, r->v.x); }