rgss 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.clang-format +6 -0
 - data/.gitignore +167 -0
 - data/.yardopts +6 -0
 - data/CHANGELOG.md +4 -0
 - data/Gemfile +4 -0
 - data/LICENSE.txt +21 -0
 - data/Rakefile +9 -0
 - data/ext/rgss/cglm-v0.7.9.tar.gz +0 -0
 - data/ext/rgss/color.c +599 -0
 - data/ext/rgss/entity.c +373 -0
 - data/ext/rgss/extconf.rb +53 -0
 - data/ext/rgss/font.c +135 -0
 - data/ext/rgss/game.c +469 -0
 - data/ext/rgss/game.h +99 -0
 - data/ext/rgss/gl.c +3217 -0
 - data/ext/rgss/glad.c +1140 -0
 - data/ext/rgss/glad.h +2129 -0
 - data/ext/rgss/glfw.c +1453 -0
 - data/ext/rgss/graphics.c +324 -0
 - data/ext/rgss/image.c +274 -0
 - data/ext/rgss/input.c +745 -0
 - data/ext/rgss/khrplatform.h +290 -0
 - data/ext/rgss/mat4.c +279 -0
 - data/ext/rgss/pax_global_header +1 -0
 - data/ext/rgss/point.c +253 -0
 - data/ext/rgss/rect.c +449 -0
 - data/ext/rgss/rgss.c +56 -0
 - data/ext/rgss/rgss.h +241 -0
 - data/ext/rgss/stb_image.h +7762 -0
 - data/ext/rgss/stb_image_write.h +1690 -0
 - data/ext/rgss/stb_rect_pack.h +628 -0
 - data/ext/rgss/stb_truetype.h +5011 -0
 - data/ext/rgss/utf8.h +1652 -0
 - data/ext/rgss/uthash.h +1133 -0
 - data/ext/rgss/vec.c +114 -0
 - data/ext/rgss/vec.h +192 -0
 - data/ext/rgss/vec2.c +489 -0
 - data/ext/rgss/vec3.c +751 -0
 - data/ext/rgss/vec4.c +681 -0
 - data/lib/rgss.rb +140 -0
 - data/lib/rgss/batch.rb +57 -0
 - data/lib/rgss/blend.rb +47 -0
 - data/lib/rgss/game_object.rb +28 -0
 - data/lib/rgss/plane.rb +95 -0
 - data/lib/rgss/renderable.rb +158 -0
 - data/lib/rgss/rgss.so +0 -0
 - data/lib/rgss/shader.rb +94 -0
 - data/lib/rgss/shaders/sprite-frag.glsl +40 -0
 - data/lib/rgss/shaders/sprite-vert.glsl +17 -0
 - data/lib/rgss/sprite.rb +139 -0
 - data/lib/rgss/stubs/color.rb +318 -0
 - data/lib/rgss/stubs/gl.rb +1999 -0
 - data/lib/rgss/stubs/glfw.rb +626 -0
 - data/lib/rgss/stubs/rect.rb +324 -0
 - data/lib/rgss/stubs/rpg.rb +267 -0
 - data/lib/rgss/stubs/tone.rb +65 -0
 - data/lib/rgss/texture.rb +132 -0
 - data/lib/rgss/tilemap.rb +116 -0
 - data/lib/rgss/version.rb +3 -0
 - data/lib/rgss/viewport.rb +67 -0
 - data/rgss.gemspec +44 -0
 - data/test.png +0 -0
 - metadata +178 -0
 
    
        data/ext/rgss/vec.c
    ADDED
    
    | 
         @@ -0,0 +1,114 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /** 
         
     | 
| 
      
 2 
     | 
    
         
            +
             * Copyright (c) 2014 rxi
         
     | 
| 
      
 3 
     | 
    
         
            +
             *
         
     | 
| 
      
 4 
     | 
    
         
            +
             * This library is free software; you can redistribute it and/or modify it
         
     | 
| 
      
 5 
     | 
    
         
            +
             * under the terms of the MIT license. See LICENSE for details.
         
     | 
| 
      
 6 
     | 
    
         
            +
             */
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            #include "vec.h"
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            int vec_expand_(char **data, int *length, int *capacity, int memsz) {
         
     | 
| 
      
 12 
     | 
    
         
            +
              if (*length + 1 > *capacity) {
         
     | 
| 
      
 13 
     | 
    
         
            +
                void *ptr;
         
     | 
| 
      
 14 
     | 
    
         
            +
                int n = (*capacity == 0) ? 1 : *capacity << 1;
         
     | 
| 
      
 15 
     | 
    
         
            +
                ptr = VEC_REALLOC(*data, n * memsz);
         
     | 
| 
      
 16 
     | 
    
         
            +
                if (ptr == NULL) return -1;
         
     | 
| 
      
 17 
     | 
    
         
            +
                *data = ptr;
         
     | 
| 
      
 18 
     | 
    
         
            +
                *capacity = n;
         
     | 
| 
      
 19 
     | 
    
         
            +
              }
         
     | 
| 
      
 20 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 21 
     | 
    
         
            +
            }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            int vec_reserve_(char **data, int *length, int *capacity, int memsz, int n) {
         
     | 
| 
      
 25 
     | 
    
         
            +
              (void) length;
         
     | 
| 
      
 26 
     | 
    
         
            +
              if (n > *capacity) {
         
     | 
| 
      
 27 
     | 
    
         
            +
                void *ptr = VEC_REALLOC(*data, n * memsz);
         
     | 
| 
      
 28 
     | 
    
         
            +
                if (ptr == NULL) return -1;
         
     | 
| 
      
 29 
     | 
    
         
            +
                *data = ptr;
         
     | 
| 
      
 30 
     | 
    
         
            +
                *capacity = n;
         
     | 
| 
      
 31 
     | 
    
         
            +
              }
         
     | 
| 
      
 32 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 33 
     | 
    
         
            +
            }
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            int vec_reserve_po2_(
         
     | 
| 
      
 37 
     | 
    
         
            +
              char **data, int *length, int *capacity, int memsz, int n
         
     | 
| 
      
 38 
     | 
    
         
            +
            ) {
         
     | 
| 
      
 39 
     | 
    
         
            +
              int n2 = 1;
         
     | 
| 
      
 40 
     | 
    
         
            +
              if (n == 0) return 0;
         
     | 
| 
      
 41 
     | 
    
         
            +
              while (n2 < n) n2 <<= 1;
         
     | 
| 
      
 42 
     | 
    
         
            +
              return vec_reserve_(data, length, capacity, memsz, n2);
         
     | 
| 
      
 43 
     | 
    
         
            +
            }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            int vec_compact_(char **data, int *length, int *capacity, int memsz) {
         
     | 
| 
      
 47 
     | 
    
         
            +
              if (*length == 0) {
         
     | 
| 
      
 48 
     | 
    
         
            +
                VEC_FREE(*data);
         
     | 
| 
      
 49 
     | 
    
         
            +
                *data = NULL;
         
     | 
| 
      
 50 
     | 
    
         
            +
                *capacity = 0;
         
     | 
| 
      
 51 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 52 
     | 
    
         
            +
              } else {
         
     | 
| 
      
 53 
     | 
    
         
            +
                void *ptr;
         
     | 
| 
      
 54 
     | 
    
         
            +
                int n = *length;
         
     | 
| 
      
 55 
     | 
    
         
            +
                ptr = VEC_REALLOC(*data, n * memsz);
         
     | 
| 
      
 56 
     | 
    
         
            +
                if (ptr == NULL) return -1;
         
     | 
| 
      
 57 
     | 
    
         
            +
                *capacity = n;
         
     | 
| 
      
 58 
     | 
    
         
            +
                *data = ptr;
         
     | 
| 
      
 59 
     | 
    
         
            +
              }
         
     | 
| 
      
 60 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 61 
     | 
    
         
            +
            }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
            int vec_insert_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 65 
     | 
    
         
            +
                             int idx
         
     | 
| 
      
 66 
     | 
    
         
            +
            ) {
         
     | 
| 
      
 67 
     | 
    
         
            +
              int err = vec_expand_(data, length, capacity, memsz);
         
     | 
| 
      
 68 
     | 
    
         
            +
              if (err) return err;
         
     | 
| 
      
 69 
     | 
    
         
            +
              memmove(*data + (idx + 1) * memsz,
         
     | 
| 
      
 70 
     | 
    
         
            +
                      *data + idx * memsz,
         
     | 
| 
      
 71 
     | 
    
         
            +
                      (*length - idx) * memsz);
         
     | 
| 
      
 72 
     | 
    
         
            +
              return 0;
         
     | 
| 
      
 73 
     | 
    
         
            +
            }
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            void vec_splice_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 77 
     | 
    
         
            +
                             int start, int count
         
     | 
| 
      
 78 
     | 
    
         
            +
            ) {
         
     | 
| 
      
 79 
     | 
    
         
            +
              (void) capacity;
         
     | 
| 
      
 80 
     | 
    
         
            +
              memmove(*data + start * memsz,
         
     | 
| 
      
 81 
     | 
    
         
            +
                      *data + (start + count) * memsz,
         
     | 
| 
      
 82 
     | 
    
         
            +
                      (*length - start - count) * memsz);
         
     | 
| 
      
 83 
     | 
    
         
            +
            }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            void vec_swapsplice_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 87 
     | 
    
         
            +
                                 int start, int count
         
     | 
| 
      
 88 
     | 
    
         
            +
            ) {
         
     | 
| 
      
 89 
     | 
    
         
            +
              (void) capacity;
         
     | 
| 
      
 90 
     | 
    
         
            +
              memmove(*data + start * memsz,
         
     | 
| 
      
 91 
     | 
    
         
            +
                      *data + (*length - count) * memsz,
         
     | 
| 
      
 92 
     | 
    
         
            +
                      count * memsz);
         
     | 
| 
      
 93 
     | 
    
         
            +
            }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            void vec_swap_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 97 
     | 
    
         
            +
                           int idx1, int idx2 
         
     | 
| 
      
 98 
     | 
    
         
            +
            ) {
         
     | 
| 
      
 99 
     | 
    
         
            +
              unsigned char *a, *b, tmp;
         
     | 
| 
      
 100 
     | 
    
         
            +
              int count;
         
     | 
| 
      
 101 
     | 
    
         
            +
              (void) length;
         
     | 
| 
      
 102 
     | 
    
         
            +
              (void) capacity;
         
     | 
| 
      
 103 
     | 
    
         
            +
              if (idx1 == idx2) return;
         
     | 
| 
      
 104 
     | 
    
         
            +
              a = (unsigned char*) *data + idx1 * memsz;
         
     | 
| 
      
 105 
     | 
    
         
            +
              b = (unsigned char*) *data + idx2 * memsz;
         
     | 
| 
      
 106 
     | 
    
         
            +
              count = memsz;
         
     | 
| 
      
 107 
     | 
    
         
            +
              while (count--) {
         
     | 
| 
      
 108 
     | 
    
         
            +
                tmp = *a;
         
     | 
| 
      
 109 
     | 
    
         
            +
                *a = *b;
         
     | 
| 
      
 110 
     | 
    
         
            +
                *b = tmp;
         
     | 
| 
      
 111 
     | 
    
         
            +
                a++, b++;
         
     | 
| 
      
 112 
     | 
    
         
            +
              }
         
     | 
| 
      
 113 
     | 
    
         
            +
            }
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
    
        data/ext/rgss/vec.h
    ADDED
    
    | 
         @@ -0,0 +1,192 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            /** 
         
     | 
| 
      
 2 
     | 
    
         
            +
             * Copyright (c) 2014 rxi
         
     | 
| 
      
 3 
     | 
    
         
            +
             *
         
     | 
| 
      
 4 
     | 
    
         
            +
             * This library is free software; you can redistribute it and/or modify it
         
     | 
| 
      
 5 
     | 
    
         
            +
             * under the terms of the MIT license. See LICENSE for details.
         
     | 
| 
      
 6 
     | 
    
         
            +
             */
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            #ifndef VEC_H
         
     | 
| 
      
 9 
     | 
    
         
            +
            #define VEC_H
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            #include <stdlib.h>
         
     | 
| 
      
 12 
     | 
    
         
            +
            #include <string.h>
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            #define VEC_VERSION "0.2.1"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            #define vec_unpack_(v)\
         
     | 
| 
      
 18 
     | 
    
         
            +
              (char**)&(v)->data, &(v)->length, &(v)->capacity, sizeof(*(v)->data)
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            #define vec_t(T)\
         
     | 
| 
      
 22 
     | 
    
         
            +
              struct { T *data; int length, capacity; }
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            #define vec_init(v)\
         
     | 
| 
      
 26 
     | 
    
         
            +
              memset((v), 0, sizeof(*(v)))
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            #define vec_deinit(v)\
         
     | 
| 
      
 30 
     | 
    
         
            +
              ( VEC_FREE((v)->data),\
         
     | 
| 
      
 31 
     | 
    
         
            +
                vec_init(v) ) 
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            #define vec_push(v, val)\
         
     | 
| 
      
 35 
     | 
    
         
            +
              ( vec_expand_(vec_unpack_(v)) ? -1 :\
         
     | 
| 
      
 36 
     | 
    
         
            +
                ((v)->data[(v)->length++] = (val), 0), 0 )
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            #define vec_pop(v)\
         
     | 
| 
      
 40 
     | 
    
         
            +
              (v)->data[--(v)->length]
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            #define vec_splice(v, start, count)\
         
     | 
| 
      
 44 
     | 
    
         
            +
              ( vec_splice_(vec_unpack_(v), start, count),\
         
     | 
| 
      
 45 
     | 
    
         
            +
                (v)->length -= (count) )
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            #define vec_swapsplice(v, start, count)\
         
     | 
| 
      
 49 
     | 
    
         
            +
              ( vec_swapsplice_(vec_unpack_(v), start, count),\
         
     | 
| 
      
 50 
     | 
    
         
            +
                (v)->length -= (count) )
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
            #define vec_insert(v, idx, val)\
         
     | 
| 
      
 54 
     | 
    
         
            +
              ( vec_insert_(vec_unpack_(v), idx) ? -1 :\
         
     | 
| 
      
 55 
     | 
    
         
            +
                ((v)->data[idx] = (val), 0), (v)->length++, 0 )
         
     | 
| 
      
 56 
     | 
    
         
            +
                
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
            #define vec_sort(v, fn)\
         
     | 
| 
      
 59 
     | 
    
         
            +
              qsort((v)->data, (v)->length, sizeof(*(v)->data), fn)
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            #define vec_swap(v, idx1, idx2)\
         
     | 
| 
      
 63 
     | 
    
         
            +
              vec_swap_(vec_unpack_(v), idx1, idx2)
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
            #define vec_truncate(v, len)\
         
     | 
| 
      
 67 
     | 
    
         
            +
              ((v)->length = (len) < (v)->length ? (len) : (v)->length)
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            #define vec_clear(v)\
         
     | 
| 
      
 71 
     | 
    
         
            +
              ((v)->length = 0)
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            #define vec_first(v)\
         
     | 
| 
      
 75 
     | 
    
         
            +
              (v)->data[0]
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            #define vec_last(v)\
         
     | 
| 
      
 79 
     | 
    
         
            +
              (v)->data[(v)->length - 1]
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            #define vec_reserve(v, n)\
         
     | 
| 
      
 83 
     | 
    
         
            +
              vec_reserve_(vec_unpack_(v), n)
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
             
         
     | 
| 
      
 86 
     | 
    
         
            +
            #define vec_compact(v)\
         
     | 
| 
      
 87 
     | 
    
         
            +
              vec_compact_(vec_unpack_(v))
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            #define vec_pusharr(v, arr, count)\
         
     | 
| 
      
 91 
     | 
    
         
            +
              do {\
         
     | 
| 
      
 92 
     | 
    
         
            +
                int i__, n__ = (count);\
         
     | 
| 
      
 93 
     | 
    
         
            +
                if (vec_reserve_po2_(vec_unpack_(v), (v)->length + n__) != 0) break;\
         
     | 
| 
      
 94 
     | 
    
         
            +
                for (i__ = 0; i__ < n__; i__++) {\
         
     | 
| 
      
 95 
     | 
    
         
            +
                  (v)->data[(v)->length++] = (arr)[i__];\
         
     | 
| 
      
 96 
     | 
    
         
            +
                }\
         
     | 
| 
      
 97 
     | 
    
         
            +
              } while (0)
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
            #define vec_extend(v, v2)\
         
     | 
| 
      
 101 
     | 
    
         
            +
              vec_pusharr((v), (v2)->data, (v2)->length)
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            #define vec_find(v, val, idx)\
         
     | 
| 
      
 105 
     | 
    
         
            +
              do {\
         
     | 
| 
      
 106 
     | 
    
         
            +
                for ((idx) = 0; (idx) < (v)->length; (idx)++) {\
         
     | 
| 
      
 107 
     | 
    
         
            +
                  if ((v)->data[(idx)] == (val)) break;\
         
     | 
| 
      
 108 
     | 
    
         
            +
                }\
         
     | 
| 
      
 109 
     | 
    
         
            +
                if ((idx) == (v)->length) (idx) = -1;\
         
     | 
| 
      
 110 
     | 
    
         
            +
              } while (0)
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            #define vec_remove(v, val)\
         
     | 
| 
      
 114 
     | 
    
         
            +
              do {\
         
     | 
| 
      
 115 
     | 
    
         
            +
                int idx__;\
         
     | 
| 
      
 116 
     | 
    
         
            +
                vec_find(v, val, idx__);\
         
     | 
| 
      
 117 
     | 
    
         
            +
                if (idx__ != -1) vec_splice(v, idx__, 1);\
         
     | 
| 
      
 118 
     | 
    
         
            +
              } while (0)
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            #define vec_reverse(v)\
         
     | 
| 
      
 122 
     | 
    
         
            +
              do {\
         
     | 
| 
      
 123 
     | 
    
         
            +
                int i__ = (v)->length / 2;\
         
     | 
| 
      
 124 
     | 
    
         
            +
                while (i__--) {\
         
     | 
| 
      
 125 
     | 
    
         
            +
                  vec_swap((v), i__, (v)->length - (i__ + 1));\
         
     | 
| 
      
 126 
     | 
    
         
            +
                }\
         
     | 
| 
      
 127 
     | 
    
         
            +
              } while (0)
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
            #define vec_foreach(v, var, iter)\
         
     | 
| 
      
 131 
     | 
    
         
            +
              if  ( (v)->length > 0 )\
         
     | 
| 
      
 132 
     | 
    
         
            +
              for ( (iter) = 0;\
         
     | 
| 
      
 133 
     | 
    
         
            +
                    (iter) < (v)->length && (((var) = (v)->data[(iter)]), 1);\
         
     | 
| 
      
 134 
     | 
    
         
            +
                    ++(iter))
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
             
     | 
| 
      
 137 
     | 
    
         
            +
            #define vec_foreach_rev(v, var, iter)\
         
     | 
| 
      
 138 
     | 
    
         
            +
              if  ( (v)->length > 0 )\
         
     | 
| 
      
 139 
     | 
    
         
            +
              for ( (iter) = (v)->length - 1;\
         
     | 
| 
      
 140 
     | 
    
         
            +
                    (iter) >= 0 && (((var) = (v)->data[(iter)]), 1);\
         
     | 
| 
      
 141 
     | 
    
         
            +
                    --(iter))
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
      
 143 
     | 
    
         
            +
             
     | 
| 
      
 144 
     | 
    
         
            +
            #define vec_foreach_ptr(v, var, iter)\
         
     | 
| 
      
 145 
     | 
    
         
            +
              if  ( (v)->length > 0 )\
         
     | 
| 
      
 146 
     | 
    
         
            +
              for ( (iter) = 0;\
         
     | 
| 
      
 147 
     | 
    
         
            +
                    (iter) < (v)->length && (((var) = &(v)->data[(iter)]), 1);\
         
     | 
| 
      
 148 
     | 
    
         
            +
                    ++(iter))
         
     | 
| 
      
 149 
     | 
    
         
            +
             
     | 
| 
      
 150 
     | 
    
         
            +
             
     | 
| 
      
 151 
     | 
    
         
            +
            #define vec_foreach_ptr_rev(v, var, iter)\
         
     | 
| 
      
 152 
     | 
    
         
            +
              if  ( (v)->length > 0 )\
         
     | 
| 
      
 153 
     | 
    
         
            +
              for ( (iter) = (v)->length - 1;\
         
     | 
| 
      
 154 
     | 
    
         
            +
                    (iter) >= 0 && (((var) = &(v)->data[(iter)]), 1);\
         
     | 
| 
      
 155 
     | 
    
         
            +
                    --(iter))
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            #if defined(VEC_FREE) && defined(VEC_REALLOC)
         
     | 
| 
      
 160 
     | 
    
         
            +
            // Both defined, no error
         
     | 
| 
      
 161 
     | 
    
         
            +
            #elif !defined(VEC_REALLOC) && !defined(VEC_FREE)
         
     | 
| 
      
 162 
     | 
    
         
            +
            // Neither defined, use stdlib
         
     | 
| 
      
 163 
     | 
    
         
            +
            #define VEC_FREE free
         
     | 
| 
      
 164 
     | 
    
         
            +
            #define VEC_REALLOC realloc
         
     | 
| 
      
 165 
     | 
    
         
            +
            #else
         
     | 
| 
      
 166 
     | 
    
         
            +
            #error "Must define all or none of VEC_FREE and VEC_REALLOC."
         
     | 
| 
      
 167 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
             
     | 
| 
      
 170 
     | 
    
         
            +
            int vec_expand_(char **data, int *length, int *capacity, int memsz);
         
     | 
| 
      
 171 
     | 
    
         
            +
            int vec_reserve_(char **data, int *length, int *capacity, int memsz, int n);
         
     | 
| 
      
 172 
     | 
    
         
            +
            int vec_reserve_po2_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 173 
     | 
    
         
            +
                                 int n);
         
     | 
| 
      
 174 
     | 
    
         
            +
            int vec_compact_(char **data, int *length, int *capacity, int memsz);
         
     | 
| 
      
 175 
     | 
    
         
            +
            int vec_insert_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 176 
     | 
    
         
            +
                            int idx);
         
     | 
| 
      
 177 
     | 
    
         
            +
            void vec_splice_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 178 
     | 
    
         
            +
                             int start, int count);
         
     | 
| 
      
 179 
     | 
    
         
            +
            void vec_swapsplice_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 180 
     | 
    
         
            +
                                 int start, int count);
         
     | 
| 
      
 181 
     | 
    
         
            +
            void vec_swap_(char **data, int *length, int *capacity, int memsz,
         
     | 
| 
      
 182 
     | 
    
         
            +
                           int idx1, int idx2);
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            typedef vec_t(void*) vec_void_t;
         
     | 
| 
      
 186 
     | 
    
         
            +
            typedef vec_t(char*) vec_str_t;
         
     | 
| 
      
 187 
     | 
    
         
            +
            typedef vec_t(int) vec_int_t;
         
     | 
| 
      
 188 
     | 
    
         
            +
            typedef vec_t(char) vec_char_t;
         
     | 
| 
      
 189 
     | 
    
         
            +
            typedef vec_t(float) vec_float_t;
         
     | 
| 
      
 190 
     | 
    
         
            +
            typedef vec_t(double) vec_double_t;
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
            #endif
         
     | 
    
        data/ext/rgss/vec2.c
    ADDED
    
    | 
         @@ -0,0 +1,489 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #include "game.h"
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            VALUE rb_cVec2;
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            CREATE_ALLOC_FUNC(vec2, RGSS_VEC2_ALIGN, RGSS_VEC2_SIZE)
         
     | 
| 
      
 6 
     | 
    
         
            +
            VEC_ATTR_ACCESSOR(vec2, x, 0)
         
     | 
| 
      
 7 
     | 
    
         
            +
            VEC_ATTR_ACCESSOR(vec2, y, 1)
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            static VALUE vec2_get(VALUE self, VALUE index)
         
     | 
| 
      
 10 
     | 
    
         
            +
            {
         
     | 
| 
      
 11 
     | 
    
         
            +
                int i = NUM2INT(index);
         
     | 
| 
      
 12 
     | 
    
         
            +
                if (index < 0 || index > 1)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    rb_raise(rb_eArgError, "index of of range (must be 0..1)");
         
     | 
| 
      
 14 
     | 
    
         
            +
                return DBL2NUM(((float*) DATA_PTR(self))[i]);
         
     | 
| 
      
 15 
     | 
    
         
            +
            }
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            static VALUE vec2_set(VALUE self, VALUE index, VALUE value)
         
     | 
| 
      
 18 
     | 
    
         
            +
            {
         
     | 
| 
      
 19 
     | 
    
         
            +
                int i = NUM2INT(index);
         
     | 
| 
      
 20 
     | 
    
         
            +
                if (index < 0 || index > 1)
         
     | 
| 
      
 21 
     | 
    
         
            +
                    rb_raise(rb_eArgError, "index of of range (must be 0..1)");
         
     | 
| 
      
 22 
     | 
    
         
            +
                ((float*) DATA_PTR(self))[i] = NUM2FLT(value);
         
     | 
| 
      
 23 
     | 
    
         
            +
                return value;
         
     | 
| 
      
 24 
     | 
    
         
            +
            }
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
            static VALUE vec2_copy(VALUE self)
         
     | 
| 
      
 27 
     | 
    
         
            +
            {
         
     | 
| 
      
 28 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 29 
     | 
    
         
            +
                glm_vec2_copy(DATA_PTR(self), d);
         
     | 
| 
      
 30 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 31 
     | 
    
         
            +
            }
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
            static VALUE vec2_zero(VALUE klass)
         
     | 
| 
      
 34 
     | 
    
         
            +
            {
         
     | 
| 
      
 35 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 36 
     | 
    
         
            +
                glm_vec2_zero(d);
         
     | 
| 
      
 37 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 38 
     | 
    
         
            +
            }
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            static VALUE vec2_one(VALUE klass)
         
     | 
| 
      
 41 
     | 
    
         
            +
            {
         
     | 
| 
      
 42 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 43 
     | 
    
         
            +
                glm_vec2_one(d);
         
     | 
| 
      
 44 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 45 
     | 
    
         
            +
            }
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            static VALUE vec2_dot(VALUE self, VALUE other)
         
     | 
| 
      
 48 
     | 
    
         
            +
            {
         
     | 
| 
      
 49 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_dot(DATA_PTR(self), DATA_PTR(other)));
         
     | 
| 
      
 50 
     | 
    
         
            +
            }
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
            static VALUE vec2_cross(VALUE self, VALUE other)
         
     | 
| 
      
 53 
     | 
    
         
            +
            {
         
     | 
| 
      
 54 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_cross(DATA_PTR(self), DATA_PTR(other)));
         
     | 
| 
      
 55 
     | 
    
         
            +
            }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            static VALUE vec2_length(VALUE self)
         
     | 
| 
      
 58 
     | 
    
         
            +
            {
         
     | 
| 
      
 59 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_norm(DATA_PTR(self)));
         
     | 
| 
      
 60 
     | 
    
         
            +
            }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            static VALUE vec2_length_squared(VALUE self)
         
     | 
| 
      
 63 
     | 
    
         
            +
            {
         
     | 
| 
      
 64 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_norm2(DATA_PTR(self)));
         
     | 
| 
      
 65 
     | 
    
         
            +
            }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            static VALUE vec2_add(VALUE self, VALUE other)
         
     | 
| 
      
 68 
     | 
    
         
            +
            {
         
     | 
| 
      
 69 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 70 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                if (RB_TYPE_P(other, T_DATA))
         
     | 
| 
      
 73 
     | 
    
         
            +
                {
         
     | 
| 
      
 74 
     | 
    
         
            +
                    glm_vec2_add(v, DATA_PTR(other), d);
         
     | 
| 
      
 75 
     | 
    
         
            +
                }
         
     | 
| 
      
 76 
     | 
    
         
            +
                else
         
     | 
| 
      
 77 
     | 
    
         
            +
                {
         
     | 
| 
      
 78 
     | 
    
         
            +
                    glm_vec2_adds(v, NUM2FLT(other), d);
         
     | 
| 
      
 79 
     | 
    
         
            +
                }
         
     | 
| 
      
 80 
     | 
    
         
            +
                
         
     | 
| 
      
 81 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 82 
     | 
    
         
            +
            }
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
            static VALUE vec2_sub(VALUE self, VALUE other)
         
     | 
| 
      
 85 
     | 
    
         
            +
            {
         
     | 
| 
      
 86 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 87 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                if (RB_TYPE_P(other, T_DATA))
         
     | 
| 
      
 90 
     | 
    
         
            +
                {
         
     | 
| 
      
 91 
     | 
    
         
            +
                    glm_vec2_sub(v, DATA_PTR(other), d);
         
     | 
| 
      
 92 
     | 
    
         
            +
                }
         
     | 
| 
      
 93 
     | 
    
         
            +
                else
         
     | 
| 
      
 94 
     | 
    
         
            +
                {
         
     | 
| 
      
 95 
     | 
    
         
            +
                    glm_vec2_subs(v, NUM2FLT(other), d);
         
     | 
| 
      
 96 
     | 
    
         
            +
                }
         
     | 
| 
      
 97 
     | 
    
         
            +
                
         
     | 
| 
      
 98 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 99 
     | 
    
         
            +
            }
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            static VALUE vec2_mul(VALUE self, VALUE other)
         
     | 
| 
      
 102 
     | 
    
         
            +
            {
         
     | 
| 
      
 103 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 104 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                if (RB_TYPE_P(other, T_DATA))
         
     | 
| 
      
 107 
     | 
    
         
            +
                {
         
     | 
| 
      
 108 
     | 
    
         
            +
                    glm_vec2_mul(v, DATA_PTR(other), d);
         
     | 
| 
      
 109 
     | 
    
         
            +
                }
         
     | 
| 
      
 110 
     | 
    
         
            +
                else
         
     | 
| 
      
 111 
     | 
    
         
            +
                {
         
     | 
| 
      
 112 
     | 
    
         
            +
                    glm_vec2_scale(v, NUM2FLT(other), d);
         
     | 
| 
      
 113 
     | 
    
         
            +
                }
         
     | 
| 
      
 114 
     | 
    
         
            +
                
         
     | 
| 
      
 115 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 116 
     | 
    
         
            +
            }
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            static VALUE vec2_div(VALUE self, VALUE other)
         
     | 
| 
      
 119 
     | 
    
         
            +
            {
         
     | 
| 
      
 120 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 121 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                if (RB_TYPE_P(other, T_DATA))
         
     | 
| 
      
 124 
     | 
    
         
            +
                {
         
     | 
| 
      
 125 
     | 
    
         
            +
                    glm_vec2_div(v, DATA_PTR(other), d);
         
     | 
| 
      
 126 
     | 
    
         
            +
                }
         
     | 
| 
      
 127 
     | 
    
         
            +
                else
         
     | 
| 
      
 128 
     | 
    
         
            +
                {
         
     | 
| 
      
 129 
     | 
    
         
            +
                    glm_vec2_divs(v, NUM2FLT(other), d);
         
     | 
| 
      
 130 
     | 
    
         
            +
                }
         
     | 
| 
      
 131 
     | 
    
         
            +
                
         
     | 
| 
      
 132 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 133 
     | 
    
         
            +
            }
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            static VALUE vec2_norm_scale(VALUE self, VALUE scalar)
         
     | 
| 
      
 136 
     | 
    
         
            +
            {
         
     | 
| 
      
 137 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 138 
     | 
    
         
            +
                glm_vec2_scale_as(DATA_PTR(self), NUM2FLT(scalar), d);
         
     | 
| 
      
 139 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 140 
     | 
    
         
            +
            }
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
            static VALUE vec2_add_add(VALUE self, VALUE other)
         
     | 
| 
      
 143 
     | 
    
         
            +
            {
         
     | 
| 
      
 144 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 145 
     | 
    
         
            +
                glm_vec2_addadd(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 146 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 147 
     | 
    
         
            +
            }
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
            static VALUE vec2_sub_add(VALUE self, VALUE other)
         
     | 
| 
      
 150 
     | 
    
         
            +
            {
         
     | 
| 
      
 151 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 152 
     | 
    
         
            +
                glm_vec2_subadd(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 153 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 154 
     | 
    
         
            +
            }
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            static VALUE vec2_mul_add(VALUE self, VALUE other)
         
     | 
| 
      
 157 
     | 
    
         
            +
            {
         
     | 
| 
      
 158 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 159 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
                if (RB_TYPE_P(other, T_DATA))
         
     | 
| 
      
 162 
     | 
    
         
            +
                {
         
     | 
| 
      
 163 
     | 
    
         
            +
                    glm_vec2_muladd(v, DATA_PTR(other), d);
         
     | 
| 
      
 164 
     | 
    
         
            +
                }
         
     | 
| 
      
 165 
     | 
    
         
            +
                else
         
     | 
| 
      
 166 
     | 
    
         
            +
                {
         
     | 
| 
      
 167 
     | 
    
         
            +
                    glm_vec2_muladds(v, NUM2FLT(other), d);
         
     | 
| 
      
 168 
     | 
    
         
            +
                }
         
     | 
| 
      
 169 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 170 
     | 
    
         
            +
            }
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
            static VALUE vec2_max_add(VALUE self, VALUE other)
         
     | 
| 
      
 173 
     | 
    
         
            +
            {
         
     | 
| 
      
 174 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 175 
     | 
    
         
            +
                glm_vec2_maxadd(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 176 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 177 
     | 
    
         
            +
            }
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
            static VALUE vec2_min_add(VALUE self, VALUE other)
         
     | 
| 
      
 180 
     | 
    
         
            +
            {
         
     | 
| 
      
 181 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 182 
     | 
    
         
            +
                glm_vec2_minadd(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 183 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 184 
     | 
    
         
            +
            }
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
            static VALUE vec2_negate_bang(VALUE self)
         
     | 
| 
      
 187 
     | 
    
         
            +
            {
         
     | 
| 
      
 188 
     | 
    
         
            +
                glm_vec2_negate(DATA_PTR(self));
         
     | 
| 
      
 189 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 190 
     | 
    
         
            +
            }
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
            static VALUE vec2_negate(VALUE self)
         
     | 
| 
      
 193 
     | 
    
         
            +
            {
         
     | 
| 
      
 194 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 195 
     | 
    
         
            +
                glm_vec2_negate_to(DATA_PTR(self), d);
         
     | 
| 
      
 196 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 197 
     | 
    
         
            +
            }
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            static VALUE vec2_normalize(VALUE self)
         
     | 
| 
      
 200 
     | 
    
         
            +
            {
         
     | 
| 
      
 201 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 202 
     | 
    
         
            +
                glm_vec2_normalize_to(DATA_PTR(self), d);
         
     | 
| 
      
 203 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 204 
     | 
    
         
            +
            }
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            static VALUE vec2_normalize_bang(VALUE self)
         
     | 
| 
      
 207 
     | 
    
         
            +
            {
         
     | 
| 
      
 208 
     | 
    
         
            +
                glm_vec2_normalize(DATA_PTR(self));
         
     | 
| 
      
 209 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 210 
     | 
    
         
            +
            }
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
            static VALUE vec2_rotate_bang(VALUE self, VALUE angle)
         
     | 
| 
      
 213 
     | 
    
         
            +
            {
         
     | 
| 
      
 214 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 215 
     | 
    
         
            +
                vec2 temp;
         
     | 
| 
      
 216 
     | 
    
         
            +
                glm_vec2_rotate(v, NUM2FLT(angle), v);
         
     | 
| 
      
 217 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 218 
     | 
    
         
            +
            }
         
     | 
| 
      
 219 
     | 
    
         
            +
             
     | 
| 
      
 220 
     | 
    
         
            +
            static VALUE vec2_rotate(VALUE self, VALUE angle)
         
     | 
| 
      
 221 
     | 
    
         
            +
            {
         
     | 
| 
      
 222 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 223 
     | 
    
         
            +
                glm_vec2_rotate(DATA_PTR(self), NUM2FLT(angle), d);
         
     | 
| 
      
 224 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 225 
     | 
    
         
            +
            }
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
            static VALUE vec2_distance(VALUE self, VALUE other)
         
     | 
| 
      
 228 
     | 
    
         
            +
            {
         
     | 
| 
      
 229 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_distance(DATA_PTR(self), DATA_PTR(other)));
         
     | 
| 
      
 230 
     | 
    
         
            +
            }
         
     | 
| 
      
 231 
     | 
    
         
            +
             
     | 
| 
      
 232 
     | 
    
         
            +
            static VALUE vec2_distance_squared(VALUE self, VALUE other)
         
     | 
| 
      
 233 
     | 
    
         
            +
            {
         
     | 
| 
      
 234 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_distance2(DATA_PTR(self), DATA_PTR(other)));
         
     | 
| 
      
 235 
     | 
    
         
            +
            }
         
     | 
| 
      
 236 
     | 
    
         
            +
             
     | 
| 
      
 237 
     | 
    
         
            +
            static VALUE vec2_maxv(VALUE self, VALUE other)
         
     | 
| 
      
 238 
     | 
    
         
            +
            {
         
     | 
| 
      
 239 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 240 
     | 
    
         
            +
                glm_vec2_maxv(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 241 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 242 
     | 
    
         
            +
            }
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
            static VALUE vec2_minv(VALUE self, VALUE other)
         
     | 
| 
      
 245 
     | 
    
         
            +
            {
         
     | 
| 
      
 246 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 247 
     | 
    
         
            +
                glm_vec2_minv(DATA_PTR(self), DATA_PTR(other), d);
         
     | 
| 
      
 248 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 249 
     | 
    
         
            +
            }
         
     | 
| 
      
 250 
     | 
    
         
            +
             
     | 
| 
      
 251 
     | 
    
         
            +
            static VALUE vec2_clamp_bang(VALUE self, VALUE min, VALUE max)
         
     | 
| 
      
 252 
     | 
    
         
            +
            {
         
     | 
| 
      
 253 
     | 
    
         
            +
                glm_vec2_clamp(DATA_PTR(self), NUM2FLT(min), NUM2FLT(max));
         
     | 
| 
      
 254 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 255 
     | 
    
         
            +
            }
         
     | 
| 
      
 256 
     | 
    
         
            +
             
     | 
| 
      
 257 
     | 
    
         
            +
            static VALUE vec2_clamp(VALUE self, VALUE min, VALUE max)
         
     | 
| 
      
 258 
     | 
    
         
            +
            {
         
     | 
| 
      
 259 
     | 
    
         
            +
                return vec2_clamp(vec2_copy(self), min, max);
         
     | 
| 
      
 260 
     | 
    
         
            +
            }
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
            static VALUE vec2_lerp(VALUE self, VALUE other, VALUE weight)
         
     | 
| 
      
 263 
     | 
    
         
            +
            {
         
     | 
| 
      
 264 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 265 
     | 
    
         
            +
                glm_vec2_lerp(DATA_PTR(self), DATA_PTR(other), NUM2FLT(weight), d);
         
     | 
| 
      
 266 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 267 
     | 
    
         
            +
            }
         
     | 
| 
      
 268 
     | 
    
         
            +
             
     | 
| 
      
 269 
     | 
    
         
            +
            static VALUE vec2_lerp_bang(VALUE self, VALUE other, VALUE weight)
         
     | 
| 
      
 270 
     | 
    
         
            +
            {
         
     | 
| 
      
 271 
     | 
    
         
            +
                vec2 temp;
         
     | 
| 
      
 272 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 273 
     | 
    
         
            +
                glm_vec2_lerp(v, DATA_PTR(other), NUM2FLT(weight), temp);
         
     | 
| 
      
 274 
     | 
    
         
            +
                glm_vec2_copy(temp, v);
         
     | 
| 
      
 275 
     | 
    
         
            +
                return self;
         
     | 
| 
      
 276 
     | 
    
         
            +
            }
         
     | 
| 
      
 277 
     | 
    
         
            +
             
     | 
| 
      
 278 
     | 
    
         
            +
            static VALUE vec2_equal(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 279 
     | 
    
         
            +
            {
         
     | 
| 
      
 280 
     | 
    
         
            +
                VALUE other, epsilon;
         
     | 
| 
      
 281 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &other, &epsilon);
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
                if (CLASS_OF(self) != CLASS_OF(other))
         
     | 
| 
      
 284 
     | 
    
         
            +
                    return Qfalse;
         
     | 
| 
      
 285 
     | 
    
         
            +
             
     | 
| 
      
 286 
     | 
    
         
            +
                float *v1 = DATA_PTR(self), *v2 = DATA_PTR(other);
         
     | 
| 
      
 287 
     | 
    
         
            +
                bool result = RTEST(epsilon) ? glm_vec2_eqv_eps(v1, v2) : glm_vec2_eqv(v1, v2);
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
                return RB_BOOL(result);
         
     | 
| 
      
 290 
     | 
    
         
            +
            }
         
     | 
| 
      
 291 
     | 
    
         
            +
             
     | 
| 
      
 292 
     | 
    
         
            +
            static VALUE vec2_all_p(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 293 
     | 
    
         
            +
            {
         
     | 
| 
      
 294 
     | 
    
         
            +
                VALUE value, epsilon;
         
     | 
| 
      
 295 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &value, &epsilon);
         
     | 
| 
      
 296 
     | 
    
         
            +
             
     | 
| 
      
 297 
     | 
    
         
            +
                float *v1 = DATA_PTR(self), v2 = NUM2FLT(value);
         
     | 
| 
      
 298 
     | 
    
         
            +
                bool result = RTEST(epsilon) ? glm_vec2_eq_eps(v1, v2) : glm_vec2_eq(v1, v2);
         
     | 
| 
      
 299 
     | 
    
         
            +
             
     | 
| 
      
 300 
     | 
    
         
            +
                return RB_BOOL(result);
         
     | 
| 
      
 301 
     | 
    
         
            +
            }
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
            static VALUE vec2_max_value(VALUE self)
         
     | 
| 
      
 304 
     | 
    
         
            +
            {
         
     | 
| 
      
 305 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_max(DATA_PTR(self)));
         
     | 
| 
      
 306 
     | 
    
         
            +
            }
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
      
 308 
     | 
    
         
            +
            static VALUE vec2_min_value(VALUE self)
         
     | 
| 
      
 309 
     | 
    
         
            +
            {
         
     | 
| 
      
 310 
     | 
    
         
            +
                return DBL2NUM(glm_vec2_min(DATA_PTR(self)));
         
     | 
| 
      
 311 
     | 
    
         
            +
            }
         
     | 
| 
      
 312 
     | 
    
         
            +
             
     | 
| 
      
 313 
     | 
    
         
            +
            static VALUE vec2_infinite_p(VALUE self)
         
     | 
| 
      
 314 
     | 
    
         
            +
            {
         
     | 
| 
      
 315 
     | 
    
         
            +
                return RB_BOOL(glm_vec2_isinf(DATA_PTR(self)));
         
     | 
| 
      
 316 
     | 
    
         
            +
            }
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
            static VALUE vec2_nan_p(VALUE self)
         
     | 
| 
      
 319 
     | 
    
         
            +
            {
         
     | 
| 
      
 320 
     | 
    
         
            +
                return RB_BOOL(glm_vec2_isnan(DATA_PTR(self)));
         
     | 
| 
      
 321 
     | 
    
         
            +
            }
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
            static VALUE vec2_sqrt(VALUE self)
         
     | 
| 
      
 324 
     | 
    
         
            +
            {
         
     | 
| 
      
 325 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 326 
     | 
    
         
            +
                glm_vec2_sqrt(DATA_PTR(self), d);
         
     | 
| 
      
 327 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 328 
     | 
    
         
            +
            }
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
            static VALUE vec2_abs(VALUE self)
         
     | 
| 
      
 331 
     | 
    
         
            +
            {
         
     | 
| 
      
 332 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 333 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 334 
     | 
    
         
            +
                d[0] = fabsf(v[0]);
         
     | 
| 
      
 335 
     | 
    
         
            +
                d[1] = fabsf(v[1]);
         
     | 
| 
      
 336 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 337 
     | 
    
         
            +
            }
         
     | 
| 
      
 338 
     | 
    
         
            +
             
     | 
| 
      
 339 
     | 
    
         
            +
            static VALUE vec2_sign(VALUE self)
         
     | 
| 
      
 340 
     | 
    
         
            +
            {
         
     | 
| 
      
 341 
     | 
    
         
            +
                float *d = RGSS_VEC2_NEW;
         
     | 
| 
      
 342 
     | 
    
         
            +
                glm_vec2_sign(DATA_PTR(self), d);
         
     | 
| 
      
 343 
     | 
    
         
            +
                return VEC2_WRAP(d);
         
     | 
| 
      
 344 
     | 
    
         
            +
            }
         
     | 
| 
      
 345 
     | 
    
         
            +
             
     | 
| 
      
 346 
     | 
    
         
            +
            static void vec2_create(int argc, VALUE *argv, vec2 v)
         
     | 
| 
      
 347 
     | 
    
         
            +
            {
         
     | 
| 
      
 348 
     | 
    
         
            +
                VALUE a1, a2;
         
     | 
| 
      
 349 
     | 
    
         
            +
                rb_scan_args(argc, argv, "02", &a1, &a2);
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
      
 351 
     | 
    
         
            +
                switch (argc)
         
     | 
| 
      
 352 
     | 
    
         
            +
                {
         
     | 
| 
      
 353 
     | 
    
         
            +
                    case 0:
         
     | 
| 
      
 354 
     | 
    
         
            +
                    {
         
     | 
| 
      
 355 
     | 
    
         
            +
                        glm_vec2_zero(v);
         
     | 
| 
      
 356 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 357 
     | 
    
         
            +
                    }
         
     | 
| 
      
 358 
     | 
    
         
            +
                    case 1:
         
     | 
| 
      
 359 
     | 
    
         
            +
                    {
         
     | 
| 
      
 360 
     | 
    
         
            +
                        if (RB_TYPE_P(a1, T_DATA))
         
     | 
| 
      
 361 
     | 
    
         
            +
                        {
         
     | 
| 
      
 362 
     | 
    
         
            +
                            glm_vec2_copy(DATA_PTR(a1), v);
         
     | 
| 
      
 363 
     | 
    
         
            +
                        }
         
     | 
| 
      
 364 
     | 
    
         
            +
                        else
         
     | 
| 
      
 365 
     | 
    
         
            +
                        {
         
     | 
| 
      
 366 
     | 
    
         
            +
                            glm_vec2_fill(v, NUM2FLT(a1));
         
     | 
| 
      
 367 
     | 
    
         
            +
                        }
         
     | 
| 
      
 368 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 369 
     | 
    
         
            +
                    }
         
     | 
| 
      
 370 
     | 
    
         
            +
                    case 2:
         
     | 
| 
      
 371 
     | 
    
         
            +
                    {
         
     | 
| 
      
 372 
     | 
    
         
            +
                        v[0] = NUM2FLT(a1);    
         
     | 
| 
      
 373 
     | 
    
         
            +
                        v[1] = NUM2FLT(a2);        
         
     | 
| 
      
 374 
     | 
    
         
            +
                        break;
         
     | 
| 
      
 375 
     | 
    
         
            +
                    }
         
     | 
| 
      
 376 
     | 
    
         
            +
                }
         
     | 
| 
      
 377 
     | 
    
         
            +
            }
         
     | 
| 
      
 378 
     | 
    
         
            +
             
     | 
| 
      
 379 
     | 
    
         
            +
            static VALUE vec2_initialize(int argc, VALUE *argv, VALUE self)
         
     | 
| 
      
 380 
     | 
    
         
            +
            {
         
     | 
| 
      
 381 
     | 
    
         
            +
                if (CLASS_OF(self) != rb_cVec2)
         
     | 
| 
      
 382 
     | 
    
         
            +
                    rb_warn("inheriting from %s may result in undefined behavior", rb_class2name(rb_cVec3));
         
     | 
| 
      
 383 
     | 
    
         
            +
             
     | 
| 
      
 384 
     | 
    
         
            +
                vec2_create(argc, argv, DATA_PTR(self));
         
     | 
| 
      
 385 
     | 
    
         
            +
                return Qnil;
         
     | 
| 
      
 386 
     | 
    
         
            +
            }
         
     | 
| 
      
 387 
     | 
    
         
            +
             
     | 
| 
      
 388 
     | 
    
         
            +
            static VALUE vec2_kernel_create(int argc, VALUE *argv, VALUE module)
         
     | 
| 
      
 389 
     | 
    
         
            +
            {
         
     | 
| 
      
 390 
     | 
    
         
            +
                float *v = RGSS_VEC2_NEW;
         
     | 
| 
      
 391 
     | 
    
         
            +
                vec2_create(argc, argv, v);
         
     | 
| 
      
 392 
     | 
    
         
            +
                return VEC2_WRAP(v);
         
     | 
| 
      
 393 
     | 
    
         
            +
            }
         
     | 
| 
      
 394 
     | 
    
         
            +
             
     | 
| 
      
 395 
     | 
    
         
            +
            static VALUE vec2_unitx(VALUE klass)
         
     | 
| 
      
 396 
     | 
    
         
            +
            {
         
     | 
| 
      
 397 
     | 
    
         
            +
                return RGSS_Vec2_New(1.0f, 0.0f);
         
     | 
| 
      
 398 
     | 
    
         
            +
            }
         
     | 
| 
      
 399 
     | 
    
         
            +
             
     | 
| 
      
 400 
     | 
    
         
            +
            static VALUE vec2_unity(VALUE klass)
         
     | 
| 
      
 401 
     | 
    
         
            +
            {
         
     | 
| 
      
 402 
     | 
    
         
            +
                return RGSS_Vec2_New(0.0f, 1.0f);
         
     | 
| 
      
 403 
     | 
    
         
            +
            }
         
     | 
| 
      
 404 
     | 
    
         
            +
             
     | 
| 
      
 405 
     | 
    
         
            +
            static VALUE vec2_inspect(VALUE self)
         
     | 
| 
      
 406 
     | 
    
         
            +
            {
         
     | 
| 
      
 407 
     | 
    
         
            +
                float *v = DATA_PTR(self);
         
     | 
| 
      
 408 
     | 
    
         
            +
                return rb_sprintf("<%f, %f>", v[0], v[1]);
         
     | 
| 
      
 409 
     | 
    
         
            +
            }
         
     | 
| 
      
 410 
     | 
    
         
            +
             
     | 
| 
      
 411 
     | 
    
         
            +
            void RGSS_Init_Vec2(VALUE parent)
         
     | 
| 
      
 412 
     | 
    
         
            +
            {
         
     | 
| 
      
 413 
     | 
    
         
            +
                rb_cVec2 = rb_define_class_under(parent, "Vec2", rb_cObject);
         
     | 
| 
      
 414 
     | 
    
         
            +
                rb_define_alloc_func(rb_cVec2, vec2_alloc);
         
     | 
| 
      
 415 
     | 
    
         
            +
                rb_define_methodm1(rb_cVec2, "initialize", vec2_initialize, -1);
         
     | 
| 
      
 416 
     | 
    
         
            +
                rb_define_methodm1(rb_mKernel, "vec2", vec2_kernel_create, -1);
         
     | 
| 
      
 417 
     | 
    
         
            +
             
     | 
| 
      
 418 
     | 
    
         
            +
                rb_define_const(rb_cVec2, "SIZE", SIZET2NUM(RGSS_VEC2_SIZE));
         
     | 
| 
      
 419 
     | 
    
         
            +
                rb_define_const(rb_cVec2, "ALIGN", SIZET2NUM(RGSS_VEC2_ALIGN));
         
     | 
| 
      
 420 
     | 
    
         
            +
             
     | 
| 
      
 421 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "[]", vec2_get, 1);
         
     | 
| 
      
 422 
     | 
    
         
            +
                rb_define_method2(rb_cVec2, "[]=", vec2_set, 2);
         
     | 
| 
      
 423 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "x", vec2_get_x, 0);
         
     | 
| 
      
 424 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "y", vec2_get_y, 0);
         
     | 
| 
      
 425 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "x=", vec2_set_x, 1);
         
     | 
| 
      
 426 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "y=", vec2_set_y, 1);
         
     | 
| 
      
 427 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "copy", vec2_copy, 0);
         
     | 
| 
      
 428 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "dot", vec2_dot, 1);
         
     | 
| 
      
 429 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "cross", vec2_cross, 1);
         
     | 
| 
      
 430 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "length", vec2_length, 0);
         
     | 
| 
      
 431 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "length_squared", vec2_length_squared, 0);
         
     | 
| 
      
 432 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "add", vec2_add, 1);
         
     | 
| 
      
 433 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "subtract", vec2_sub, 1);
         
     | 
| 
      
 434 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "multiply", vec2_mul, 1);
         
     | 
| 
      
 435 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "divide", vec2_div, 1);
         
     | 
| 
      
 436 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "norm_scale", vec2_norm_scale, 1);
         
     | 
| 
      
 437 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "add_add", vec2_add_add, 1);
         
     | 
| 
      
 438 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "sub_add", vec2_sub_add, 1);
         
     | 
| 
      
 439 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "mul_add", vec2_mul_add, 1);
         
     | 
| 
      
 440 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "max_add", vec2_max_add, 1);
         
     | 
| 
      
 441 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "min_add", vec2_min_add, 1);
         
     | 
| 
      
 442 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "negate", vec2_negate, 0);
         
     | 
| 
      
 443 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "negate!", vec2_negate_bang, 0);
         
     | 
| 
      
 444 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "normalize", vec2_normalize, 0);
         
     | 
| 
      
 445 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "normalize!", vec2_normalize_bang, 0);
         
     | 
| 
      
 446 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "rotate",  vec2_rotate, 1);
         
     | 
| 
      
 447 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "rotate!", vec2_rotate_bang, 1);
         
     | 
| 
      
 448 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "distance",  vec2_distance, 1);
         
     | 
| 
      
 449 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "distance_squared", vec2_distance_squared, 1);
         
     | 
| 
      
 450 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "max", vec2_maxv, 1);
         
     | 
| 
      
 451 
     | 
    
         
            +
                rb_define_method1(rb_cVec2, "min", vec2_minv, 1);
         
     | 
| 
      
 452 
     | 
    
         
            +
                rb_define_method2(rb_cVec2, "clamp", vec2_clamp, 2);
         
     | 
| 
      
 453 
     | 
    
         
            +
                rb_define_method2(rb_cVec2, "clamp!", vec2_clamp_bang, 2);
         
     | 
| 
      
 454 
     | 
    
         
            +
                rb_define_method2(rb_cVec2, "lerp", vec2_lerp, 2);
         
     | 
| 
      
 455 
     | 
    
         
            +
                rb_define_method2(rb_cVec2, "lerp!", vec2_lerp_bang, 2);
         
     | 
| 
      
 456 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "infinite?", vec2_infinite_p, 0);
         
     | 
| 
      
 457 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "nan?", vec2_nan_p, 0);
         
     | 
| 
      
 458 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "sqrt", vec2_sqrt, 0);
         
     | 
| 
      
 459 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "abs", vec2_abs, 0);
         
     | 
| 
      
 460 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "sign", vec2_sign, 0);
         
     | 
| 
      
 461 
     | 
    
         
            +
                rb_define_methodm1(rb_cVec2, "eql?", vec2_equal, -1);
         
     | 
| 
      
 462 
     | 
    
         
            +
                rb_define_methodm1(rb_cVec2, "all?", vec2_all_p, -1);
         
     | 
| 
      
 463 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "max_value", vec2_max_value, 0);
         
     | 
| 
      
 464 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "min_value", vec2_min_value, 0);
         
     | 
| 
      
 465 
     | 
    
         
            +
             
     | 
| 
      
 466 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "inspect", vec2_inspect, 0);
         
     | 
| 
      
 467 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "to_s", vec2_inspect, 0);
         
     | 
| 
      
 468 
     | 
    
         
            +
                rb_define_method0(rb_cVec2, "to_str", vec2_inspect, 0);
         
     | 
| 
      
 469 
     | 
    
         
            +
             
     | 
| 
      
 470 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "dup", "copy");
         
     | 
| 
      
 471 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "magnitude", "length");
         
     | 
| 
      
 472 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "magnitude_squared", "length_squared");
         
     | 
| 
      
 473 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "norm", "length");
         
     | 
| 
      
 474 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "norm2", "length_squared");
         
     | 
| 
      
 475 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "+", "add");
         
     | 
| 
      
 476 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "-", "subtract");
         
     | 
| 
      
 477 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "*", "multiply");
         
     | 
| 
      
 478 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "/", "divide");
         
     | 
| 
      
 479 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "-@", "negate");
         
     | 
| 
      
 480 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "==", "eql?");
         
     | 
| 
      
 481 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "scale", "multiply");
         
     | 
| 
      
 482 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "mix", "lerp");
         
     | 
| 
      
 483 
     | 
    
         
            +
                rb_define_alias(rb_cVec2, "mix!", "lerp!");
         
     | 
| 
      
 484 
     | 
    
         
            +
             
     | 
| 
      
 485 
     | 
    
         
            +
                rb_define_singleton_method0(rb_cVec2, "zero", vec2_zero, 0);
         
     | 
| 
      
 486 
     | 
    
         
            +
                rb_define_singleton_method0(rb_cVec2, "one", vec2_one, 0);
         
     | 
| 
      
 487 
     | 
    
         
            +
                rb_define_singleton_method0(rb_cVec2, "unit_x", vec2_unitx, 0);
         
     | 
| 
      
 488 
     | 
    
         
            +
                rb_define_singleton_method0(rb_cVec2, "unit_y", vec2_unity, 0);
         
     | 
| 
      
 489 
     | 
    
         
            +
            }
         
     |