diff options
| author | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-05 19:11:34 +0000 |
|---|---|---|
| committer | Magnus Auvinen <magnus.auvinen@gmail.com> | 2008-02-05 19:11:34 +0000 |
| commit | 91e4c2252b1a07df013cde773d1cead3712bca43 (patch) | |
| tree | 29af0b7c51da9ef48b0c2d66f779f3b43a755e64 /src/game/editor/ed_layer_quads.cpp | |
| parent | da2d792186d53794d25438c157ac039adbb8c1a6 (diff) | |
| download | zcatch-91e4c2252b1a07df013cde773d1cead3712bca43.tar.gz zcatch-91e4c2252b1a07df013cde773d1cead3712bca43.zip | |
added rotate to editor. fixed so that the game handles envelopes
Diffstat (limited to 'src/game/editor/ed_layer_quads.cpp')
| -rw-r--r-- | src/game/editor/ed_layer_quads.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/game/editor/ed_layer_quads.cpp b/src/game/editor/ed_layer_quads.cpp index 316d2e1f..da7e70b8 100644 --- a/src/game/editor/ed_layer_quads.cpp +++ b/src/game/editor/ed_layer_quads.cpp @@ -157,6 +157,35 @@ void LAYER_QUADS::brush_flip_y() { } +void rotate(vec2 *center, vec2 *point, float rotation) +{ + float x = point->x - center->x; + float y = point->y - center->y; + point->x = x * cosf(rotation) - y * sinf(rotation) + center->x; + point->y = x * sinf(rotation) + y * cosf(rotation) + center->y; +} + +void LAYER_QUADS::brush_rotate(float amount) +{ + vec2 center; + get_size(¢er.x, ¢er.y); + center.x /= 2; + center.y /= 2; + + for(int i = 0; i < quads.len(); i++) + { + QUAD *q = &quads[i]; + + for(int p = 0; p < 5; p++) + { + vec2 pos(fx2f(q->points[p].x), fx2f(q->points[p].y)); + rotate(¢er, &pos, amount); + q->points[p].x = f2fx(pos.x); + q->points[p].y = f2fx(pos.y); + } + } +} + void LAYER_QUADS::get_size(float *w, float *h) { *w = 0; *h = 0; |