diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2025-11-23 22:12:27 +0100 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2025-11-23 22:12:27 +0100 |
| commit | f8463d52a7c6cb6de6fde0f2472c44cf35e2452a (patch) | |
| tree | 13850d2d04d72d67b04cc1375f8a2111432e41c2 /src/construction.c | |
| parent | 84f11b37d178242d4ff80c4f3b4eddb54efe59ea (diff) | |
Move angle offsets to the construction VM
Diffstat (limited to 'src/construction.c')
| -rw-r--r-- | src/construction.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/construction.c b/src/construction.c index b73ee69..209b167 100644 --- a/src/construction.c +++ b/src/construction.c @@ -66,13 +66,20 @@ struct element* insert_cmd(struct drawing *drawing, struct command cmd) { return &new->result; } +#define SETSIGN(b, v) ((v) * ((2 * (b)) - 1)) void execute_drawing(struct drawing *drawing, double inputs[]) { for(struct command *current = drawing->root; current != NULL; current = current->next) { switch(current->op) { case CMD_VALUE_INPUT: { assert(current->result.type == ETYPE_VALUE); - current->result.value = inputs[current->index]; + current->result.value = SETSIGN(current->dir, inputs[current->index]); + }break; + case CMD_OFFSET_INPUT: { + assert(current->arg1->type == ETYPE_VALUE); + assert(current->result.type == ETYPE_VALUE); + current->result.value = current->arg1->value + SETSIGN(current->dir, inputs[current->index]); + current->result.value -= (M_PI*2.0) * floor(current->result.value / (M_PI*2.0)); }break; case CMD_ORIGIN: { assert(current->result.type == ETYPE_POINT); |
