raylib-spinel 0.1.0
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/LICENSE.md +16 -0
- data/README.md +135 -0
- data/lib/physac.h +1987 -0
- data/lib/physac_compat.rb +43 -0
- data/lib/physac_ffi.rb +128 -0
- data/lib/raygui.h +6479 -0
- data/lib/raygui_compat.rb +116 -0
- data/lib/raygui_ffi.rb +714 -0
- data/lib/raylib_audio_fields.rb +115 -0
- data/lib/raylib_camera_fields.rb +16 -0
- data/lib/raylib_compat.rb +72 -0
- data/lib/raylib_ffi.rb +4093 -0
- data/lib/raylib_field_index.rb +593 -0
- data/lib/raylib_handles.rb +427 -0
- data/lib/raylib_handles_ffi.rb +255 -0
- data/lib/raylib_include.rb +2414 -0
- data/lib/raylib_model_ref.rb +99 -0
- data/lib/raylib_pointer_fields.rb +153 -0
- data/lib/raylib_ruby.rb +614 -0
- data/lib/raylib_sizes.rb +128 -0
- data/lib/raylib_struct_fields.rb +102 -0
- data/lib/raylib_structs.rb +174 -0
- data/lib/raymath_ffi.rb +1014 -0
- data/lib/rcamera_ffi.rb +113 -0
- data/lib/rl_handle_views.h +83 -0
- data/lib/rlgl_constants.rb +382 -0
- data/lib/rlgl_ffi.rb +1016 -0
- data/raylib-spinel/physac.rb +13 -0
- data/raylib-spinel/raygui.rb +14 -0
- data/raylib-spinel/raymath.rb +15 -0
- data/raylib-spinel/rcamera.rb +15 -0
- data/raylib-spinel/rlgl.rb +13 -0
- data/raylib-spinel.rb +56 -0
- data/raylib.rb +37 -0
- data/spin.toml +21 -0
- metadata +97 -0
data/lib/raylib_sizes.rb
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# raylib_sizes.rb — generated by tools/gen_handle_class_c.py.
|
|
2
|
+
#
|
|
3
|
+
# The gem's `Class.size` (FFI::Struct.size) drives its pointer arithmetic
|
|
4
|
+
# (`font.recs + i * Rectangle.size`, `Color.new(mapPixels + i * Color.size)`, ...).
|
|
5
|
+
# These are the exact C sizes, not hand-maintained numbers.
|
|
6
|
+
|
|
7
|
+
module Raylib
|
|
8
|
+
ffi_lib "raylib"
|
|
9
|
+
ffi_func :rl_Image_sizeof, [], :int
|
|
10
|
+
ffi_func :rl_Texture2D_sizeof, [], :int
|
|
11
|
+
ffi_func :rl_Font_sizeof, [], :int
|
|
12
|
+
ffi_func :rl_GlyphInfo_sizeof, [], :int
|
|
13
|
+
ffi_func :rl_RenderTexture_sizeof, [], :int
|
|
14
|
+
ffi_func :rl_Model_sizeof, [], :int
|
|
15
|
+
ffi_func :rl_Material_sizeof, [], :int
|
|
16
|
+
ffi_func :rl_Mesh_sizeof, [], :int
|
|
17
|
+
ffi_func :rl_Shader_sizeof, [], :int
|
|
18
|
+
ffi_func :rl_ModelAnimation_sizeof, [], :int
|
|
19
|
+
ffi_func :rl_BoneInfo_sizeof, [], :int
|
|
20
|
+
ffi_func :rl_Transform_sizeof, [], :int
|
|
21
|
+
ffi_func :rl_AutomationEvent_sizeof, [], :int
|
|
22
|
+
ffi_func :rl_AutomationEventList_sizeof, [], :int
|
|
23
|
+
ffi_func :rl_Vector2_sizeof, [], :int
|
|
24
|
+
ffi_func :rl_Vector3_sizeof, [], :int
|
|
25
|
+
ffi_func :rl_Vector4_sizeof, [], :int
|
|
26
|
+
ffi_func :rl_Rectangle_sizeof, [], :int
|
|
27
|
+
ffi_func :rl_Color_sizeof, [], :int
|
|
28
|
+
ffi_func :rl_Camera_sizeof, [], :int
|
|
29
|
+
ffi_func :rl_Camera2D_sizeof, [], :int
|
|
30
|
+
ffi_func :rl_BoundingBox_sizeof, [], :int
|
|
31
|
+
ffi_func :rl_Ray_sizeof, [], :int
|
|
32
|
+
ffi_func :rl_RayCollision_sizeof, [], :int
|
|
33
|
+
ffi_func :rl_Matrix_sizeof, [], :int
|
|
34
|
+
ffi_func :rl_NPatchInfo_sizeof, [], :int
|
|
35
|
+
ffi_func :rl_VrDeviceInfo_sizeof, [], :int
|
|
36
|
+
ffi_func :rl_VrStereoConfig_sizeof, [], :int
|
|
37
|
+
ffi_func :rl_FilePathList_sizeof, [], :int
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
module Raylib
|
|
41
|
+
class Image
|
|
42
|
+
def self.size = Raylib.rl_Image_sizeof
|
|
43
|
+
end
|
|
44
|
+
class Texture2D
|
|
45
|
+
def self.size = Raylib.rl_Texture2D_sizeof
|
|
46
|
+
end
|
|
47
|
+
class Font
|
|
48
|
+
def self.size = Raylib.rl_Font_sizeof
|
|
49
|
+
end
|
|
50
|
+
class GlyphInfo
|
|
51
|
+
def self.size = Raylib.rl_GlyphInfo_sizeof
|
|
52
|
+
end
|
|
53
|
+
class RenderTexture
|
|
54
|
+
def self.size = Raylib.rl_RenderTexture_sizeof
|
|
55
|
+
end
|
|
56
|
+
class Model
|
|
57
|
+
def self.size = Raylib.rl_Model_sizeof
|
|
58
|
+
end
|
|
59
|
+
class Material
|
|
60
|
+
def self.size = Raylib.rl_Material_sizeof
|
|
61
|
+
end
|
|
62
|
+
class Mesh
|
|
63
|
+
def self.size = Raylib.rl_Mesh_sizeof
|
|
64
|
+
end
|
|
65
|
+
class Shader
|
|
66
|
+
def self.size = Raylib.rl_Shader_sizeof
|
|
67
|
+
end
|
|
68
|
+
class ModelAnimation
|
|
69
|
+
def self.size = Raylib.rl_ModelAnimation_sizeof
|
|
70
|
+
end
|
|
71
|
+
class BoneInfo
|
|
72
|
+
def self.size = Raylib.rl_BoneInfo_sizeof
|
|
73
|
+
end
|
|
74
|
+
class Transform
|
|
75
|
+
def self.size = Raylib.rl_Transform_sizeof
|
|
76
|
+
end
|
|
77
|
+
class AutomationEvent
|
|
78
|
+
def self.size = Raylib.rl_AutomationEvent_sizeof
|
|
79
|
+
end
|
|
80
|
+
class AutomationEventList
|
|
81
|
+
def self.size = Raylib.rl_AutomationEventList_sizeof
|
|
82
|
+
end
|
|
83
|
+
class Vector2
|
|
84
|
+
def self.size = Raylib.rl_Vector2_sizeof
|
|
85
|
+
end
|
|
86
|
+
class Vector3
|
|
87
|
+
def self.size = Raylib.rl_Vector3_sizeof
|
|
88
|
+
end
|
|
89
|
+
class Vector4
|
|
90
|
+
def self.size = Raylib.rl_Vector4_sizeof
|
|
91
|
+
end
|
|
92
|
+
class Rectangle
|
|
93
|
+
def self.size = Raylib.rl_Rectangle_sizeof
|
|
94
|
+
end
|
|
95
|
+
class Color
|
|
96
|
+
def self.size = Raylib.rl_Color_sizeof
|
|
97
|
+
end
|
|
98
|
+
class Camera
|
|
99
|
+
def self.size = Raylib.rl_Camera_sizeof
|
|
100
|
+
end
|
|
101
|
+
class Camera2D
|
|
102
|
+
def self.size = Raylib.rl_Camera2D_sizeof
|
|
103
|
+
end
|
|
104
|
+
class BoundingBox
|
|
105
|
+
def self.size = Raylib.rl_BoundingBox_sizeof
|
|
106
|
+
end
|
|
107
|
+
class Ray
|
|
108
|
+
def self.size = Raylib.rl_Ray_sizeof
|
|
109
|
+
end
|
|
110
|
+
class RayCollision
|
|
111
|
+
def self.size = Raylib.rl_RayCollision_sizeof
|
|
112
|
+
end
|
|
113
|
+
class Matrix
|
|
114
|
+
def self.size = Raylib.rl_Matrix_sizeof
|
|
115
|
+
end
|
|
116
|
+
class NPatchInfo
|
|
117
|
+
def self.size = Raylib.rl_NPatchInfo_sizeof
|
|
118
|
+
end
|
|
119
|
+
class VrDeviceInfo
|
|
120
|
+
def self.size = Raylib.rl_VrDeviceInfo_sizeof
|
|
121
|
+
end
|
|
122
|
+
class VrStereoConfig
|
|
123
|
+
def self.size = Raylib.rl_VrStereoConfig_sizeof
|
|
124
|
+
end
|
|
125
|
+
class FilePathList
|
|
126
|
+
def self.size = Raylib.rl_FilePathList_sizeof
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Field accessors for the small structs whose writers the generator does not
|
|
4
|
+
# emit (it covers scalars only) plus the gem's names where ours differed
|
|
5
|
+
# (BoneInfo#parent vs our parent_bone_index). Hand-written, so regenerating
|
|
6
|
+
# raylib_ffi.rb cannot drop them.
|
|
7
|
+
module Raylib
|
|
8
|
+
native_struct "Ray", "rl_Ray"
|
|
9
|
+
ffi_func :rl_Ray_position, [:ptr, :ptr], :void
|
|
10
|
+
native_method :position=, [:any], :void, "rl_Ray_set_position"
|
|
11
|
+
ffi_func :rl_Ray_direction, [:ptr, :ptr], :void
|
|
12
|
+
native_method :direction=, [:any], :void, "rl_Ray_set_direction"
|
|
13
|
+
|
|
14
|
+
native_struct "RayCollision", "rl_RayCollision"
|
|
15
|
+
native_method :hit, [], :bool, "rl_m_RayCollision_hit"
|
|
16
|
+
native_method :hit=, [:bool], :bool, "rl_m_RayCollision_set_hit"
|
|
17
|
+
ffi_func :rl_RayCollision_point, [:ptr, :ptr], :void
|
|
18
|
+
native_method :point=, [:any], :void, "rl_RayCollision_set_point"
|
|
19
|
+
ffi_func :rl_RayCollision_normal, [:ptr, :ptr], :void
|
|
20
|
+
native_method :normal=, [:any], :void, "rl_RayCollision_set_normal"
|
|
21
|
+
|
|
22
|
+
native_struct "BoneInfo", "rl_BoneInfo"
|
|
23
|
+
ffi_func :rl_BoneInfo_name, [:ptr], :str
|
|
24
|
+
ffi_func :rl_BoneInfo_set_name, [:ptr, :str], :void
|
|
25
|
+
native_method :parent, [], :int, "rl_m_BoneInfo_parent"
|
|
26
|
+
native_method :parent=, [:int], :int, "rl_m_BoneInfo_set_parent"
|
|
27
|
+
|
|
28
|
+
native_struct "RenderTexture", "rl_RenderTexture"
|
|
29
|
+
native_method :id, [], :int, "rl_m_RenderTexture_id"
|
|
30
|
+
native_method :id=, [:int], :int, "rl_m_RenderTexture_set_id"
|
|
31
|
+
native_method :texture=, [:any], :void, "rl_RenderTexture_set_texture"
|
|
32
|
+
native_method :depth=, [:any], :void, "rl_RenderTexture_set_depth"
|
|
33
|
+
native_struct "Mesh", "rl_Mesh"
|
|
34
|
+
ffi_func :rl_m_Mesh_animVertices, [:ptr], :long
|
|
35
|
+
native_method :animVertices=, [:any], :void, "rl_Mesh_set_animVertices"
|
|
36
|
+
ffi_func :rl_m_Mesh_animNormals, [:ptr], :long
|
|
37
|
+
native_method :animNormals=, [:any], :void, "rl_Mesh_set_animNormals"
|
|
38
|
+
ffi_func :rl_m_Mesh_boneIndices, [:ptr], :long
|
|
39
|
+
native_method :boneIndices=, [:any], :void, "rl_Mesh_set_boneIndices"
|
|
40
|
+
ffi_func :rl_m_Mesh_boneWeights, [:ptr], :long
|
|
41
|
+
native_method :boneWeights=, [:any], :void, "rl_Mesh_set_boneWeights"
|
|
42
|
+
native_method :boneCount, [], :int, "rl_m_Mesh_boneCount"
|
|
43
|
+
native_method :boneCount=, [:int], :int, "rl_m_Mesh_set_boneCount"
|
|
44
|
+
native_method :vaoId, [], :int, "rl_m_Mesh_vaoId"
|
|
45
|
+
native_method :vaoId=, [:int], :int, "rl_m_Mesh_set_vaoId"
|
|
46
|
+
ffi_func :rl_m_Mesh_vboId, [:ptr], :long
|
|
47
|
+
native_method :vboId=, [:any], :void, "rl_Mesh_set_vboId"
|
|
48
|
+
|
|
49
|
+
native_struct "ModelAnimation", "rl_ModelAnimation"
|
|
50
|
+
ffi_func :rl_ModelAnimation_name, [:ptr], :str
|
|
51
|
+
ffi_func :rl_ModelAnimation_set_name, [:ptr, :str], :void
|
|
52
|
+
ffi_func :rl_m_ModelAnimation_keyframePoses, [:ptr], :long
|
|
53
|
+
native_method :keyframePoses=, [:any], :void, "rl_ModelAnimation_set_keyframePoses"
|
|
54
|
+
native_struct "Shader", "rl_Shader"
|
|
55
|
+
ffi_func :rl_m_Shader_locs, [:ptr], :long
|
|
56
|
+
native_method :locs=, [:any], :void, "rl_Shader_set_locs"
|
|
57
|
+
|
|
58
|
+
native_struct "BoundingBox", "rl_BoundingBox"
|
|
59
|
+
native_method :min=, [:any], :void, "rl_BoundingBox_set_min"
|
|
60
|
+
native_method :max=, [:any], :void, "rl_BoundingBox_set_max"
|
|
61
|
+
|
|
62
|
+
native_struct "NPatchInfo", "rl_NPatchInfo"
|
|
63
|
+
ffi_func :rl_NPatchInfo_source, [:ptr, :ptr], :void
|
|
64
|
+
native_method :source=, [:any], :void, "rl_NPatchInfo_set_source"
|
|
65
|
+
|
|
66
|
+
native_struct "FilePathList", "rl_FilePathList"
|
|
67
|
+
ffi_func :rl_m_FilePathList_paths, [:ptr], :long
|
|
68
|
+
native_method :paths=, [:any], :void, "rl_FilePathList_set_paths"
|
|
69
|
+
native_struct "VrDeviceInfo", "rl_VrDeviceInfo"
|
|
70
|
+
ffi_func :rl_m_VrDeviceInfo_lensDistortionValues, [:ptr], :long
|
|
71
|
+
native_method :lensDistortionValues=, [:any], :void, "rl_VrDeviceInfo_set_lensDistortionValues"
|
|
72
|
+
ffi_func :rl_m_VrDeviceInfo_chromaAbCorrection, [:ptr], :long
|
|
73
|
+
native_method :chromaAbCorrection=, [:any], :void, "rl_VrDeviceInfo_set_chromaAbCorrection"
|
|
74
|
+
|
|
75
|
+
native_struct "VrStereoConfig", "rl_VrStereoConfig"
|
|
76
|
+
ffi_func :rl_m_VrStereoConfig_projection, [:ptr], :long
|
|
77
|
+
native_method :projection=, [:any], :void, "rl_VrStereoConfig_set_projection"
|
|
78
|
+
ffi_func :rl_m_VrStereoConfig_viewOffset, [:ptr], :long
|
|
79
|
+
native_method :viewOffset=, [:any], :void, "rl_VrStereoConfig_set_viewOffset"
|
|
80
|
+
ffi_func :rl_m_VrStereoConfig_leftLensCenter, [:ptr], :long
|
|
81
|
+
native_method :leftLensCenter=, [:any], :void, "rl_VrStereoConfig_set_leftLensCenter"
|
|
82
|
+
ffi_func :rl_m_VrStereoConfig_rightLensCenter, [:ptr], :long
|
|
83
|
+
native_method :rightLensCenter=, [:any], :void, "rl_VrStereoConfig_set_rightLensCenter"
|
|
84
|
+
ffi_func :rl_m_VrStereoConfig_leftScreenCenter, [:ptr], :long
|
|
85
|
+
native_method :leftScreenCenter=, [:any], :void, "rl_VrStereoConfig_set_leftScreenCenter"
|
|
86
|
+
ffi_func :rl_m_VrStereoConfig_rightScreenCenter, [:ptr], :long
|
|
87
|
+
native_method :rightScreenCenter=, [:any], :void, "rl_VrStereoConfig_set_rightScreenCenter"
|
|
88
|
+
ffi_func :rl_m_VrStereoConfig_scale, [:ptr], :long
|
|
89
|
+
native_method :scale=, [:any], :void, "rl_VrStereoConfig_set_scale"
|
|
90
|
+
ffi_func :rl_m_VrStereoConfig_scaleIn, [:ptr], :long
|
|
91
|
+
native_method :scaleIn=, [:any], :void, "rl_VrStereoConfig_set_scaleIn"
|
|
92
|
+
|
|
93
|
+
native_struct "AutomationEvent", "rl_AutomationEvent"
|
|
94
|
+
ffi_func :rl_m_AutomationEvent_params, [:ptr], :long
|
|
95
|
+
native_method :params=, [:any], :void, "rl_AutomationEvent_set_params"
|
|
96
|
+
|
|
97
|
+
native_struct "GlyphInfo", "rl_GlyphInfo"
|
|
98
|
+
native_method :image=, [:any], :void, "rl_GlyphInfo_set_image"
|
|
99
|
+
|
|
100
|
+
native_struct "AutomationEventList", "rl_AutomationEventList"
|
|
101
|
+
native_method :events=, [:any], :void, "rl_AutomationEventList_set_events"
|
|
102
|
+
end
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# raylib_structs.rb — the gem's struct factories and helpers on the Spinel path.
|
|
4
|
+
#
|
|
5
|
+
# The MRI gem's struct classes are FFI::Struct subclasses; raylib_helper.rb adds
|
|
6
|
+
# `create`/`copy_from`/`set`/`to_a`, the Color constructors and the `size` class
|
|
7
|
+
# methods. Our classes are Spinel native structs with attribute accessors, so
|
|
8
|
+
# the same names and semantics are reimplemented here. Loaded by raylib.rb
|
|
9
|
+
# (Spinel path only); under MRI the gem provides them. The Color helpers and
|
|
10
|
+
# the Vector2/Rectangle `.create` factories live in raylib_ffi.rb instead, so
|
|
11
|
+
# the `require "raylib-spinel"` entry gets them too.
|
|
12
|
+
#
|
|
13
|
+
# Every numeric argument is coerced with `to_f`/`to_i` (AGENTS B4): with mixed
|
|
14
|
+
# Integer/Float call sites Spinel boxes the parameter, and a raw assignment to a
|
|
15
|
+
# native float field would then read the union payload as garbage.
|
|
16
|
+
module Raylib
|
|
17
|
+
# Quaternion has Vector4's exact layout ({float x,y,z,w}).
|
|
18
|
+
Quaternion = Vector4
|
|
19
|
+
|
|
20
|
+
# The gem's Camera is Camera3D (raylib_main.rb: Camera = Camera3D).
|
|
21
|
+
Camera3D = Camera
|
|
22
|
+
|
|
23
|
+
# Degree/radian conversion (raylib_helper.rb).
|
|
24
|
+
DEG2RAD = 0.017453292519943295
|
|
25
|
+
RAD2DEG = 57.29577951308232
|
|
26
|
+
|
|
27
|
+
class Vector2
|
|
28
|
+
# `.create` lives in raylib_ffi.rb (fill-factory route, both entries).
|
|
29
|
+
def self.copy_from(vec)
|
|
30
|
+
Vector2.create(vec.x, vec.y)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def set(x, y)
|
|
35
|
+
self.x = x.to_f
|
|
36
|
+
self.y = y.to_f
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def add(x, y)
|
|
41
|
+
self.x = x.to_f + self.x
|
|
42
|
+
self.y = y.to_f + self.y
|
|
43
|
+
self
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def add_vector(v)
|
|
47
|
+
self.x = v.x + self.x
|
|
48
|
+
self.y = v.y + self.y
|
|
49
|
+
self
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def to_a
|
|
53
|
+
[x, y]
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class Vector3
|
|
58
|
+
def self.create(x = 0.0, y = 0.0, z = 0.0)
|
|
59
|
+
v = Vector3.new(x.to_f, y.to_f, z.to_f)
|
|
60
|
+
v
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def self.copy_from(vec)
|
|
64
|
+
Vector3.create(vec.x, vec.y, vec.z)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def set(x, y, z)
|
|
69
|
+
self.x = x.to_f
|
|
70
|
+
self.y = y.to_f
|
|
71
|
+
self.z = z.to_f
|
|
72
|
+
self
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def to_a
|
|
76
|
+
[x, y, z]
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class Vector4
|
|
81
|
+
def self.create(x = 0.0, y = 0.0, z = 0.0, w = 0.0)
|
|
82
|
+
v = Vector4.new
|
|
83
|
+
v.x = x.to_f
|
|
84
|
+
v.y = y.to_f
|
|
85
|
+
v.z = z.to_f
|
|
86
|
+
v.w = w.to_f
|
|
87
|
+
v
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.copy_from(vec)
|
|
91
|
+
Vector4.create(vec.x, vec.y, vec.z, vec.w)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def set(x, y, z, w)
|
|
96
|
+
self.x = x.to_f
|
|
97
|
+
self.y = y.to_f
|
|
98
|
+
self.z = z.to_f
|
|
99
|
+
self.w = w.to_f
|
|
100
|
+
self
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def to_a
|
|
104
|
+
[x, y, z, w]
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class Rectangle
|
|
109
|
+
# `.create` lives in raylib_ffi.rb (fill-factory route, both entries).
|
|
110
|
+
def self.copy_from(rec)
|
|
111
|
+
Rectangle.create(rec.x, rec.y, rec.width, rec.height)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def set(x, y, width, height)
|
|
116
|
+
self.x = x.to_f
|
|
117
|
+
self.y = y.to_f
|
|
118
|
+
self.width = width.to_f
|
|
119
|
+
self.height = height.to_f
|
|
120
|
+
self
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Camera#position/.target/.up and the with_* fluent builders, and
|
|
125
|
+
# Camera2D#offset/.target and its with_* builders, live in raylib_ffi.rb
|
|
126
|
+
# next to the native declarations (address-view / C fill shims), so every
|
|
127
|
+
# entry path loads one definition.
|
|
128
|
+
|
|
129
|
+
class BoundingBox
|
|
130
|
+
|
|
131
|
+
# min/max views live in raylib_ffi.rb next to the native declarations.
|
|
132
|
+
|
|
133
|
+
# The gem's factory: create(min_vector, max_vector) or
|
|
134
|
+
# create(min_x, min_y, min_z, max_x, max_y, max_z). The optional tail keeps
|
|
135
|
+
# both arities in one method; the branches read either the vectors or the
|
|
136
|
+
# scalars, so each call site stays typed.
|
|
137
|
+
def self.create(a, b, c = nil, d = nil, e = nil, f = nil)
|
|
138
|
+
bb = BoundingBox.new
|
|
139
|
+
if c.nil?
|
|
140
|
+
bb.min.set(a.x, a.y, a.z)
|
|
141
|
+
bb.max.set(b.x, b.y, b.z)
|
|
142
|
+
else
|
|
143
|
+
bb.with_min(a.to_f, b.to_f, c.to_f)
|
|
144
|
+
bb.with_max(d.to_f, e.to_f, f.to_f)
|
|
145
|
+
end
|
|
146
|
+
bb
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# Transform#t/.r/.s (and the layout names) live in raylib_ffi.rb next to the
|
|
151
|
+
# native declarations, using the address-view form.
|
|
152
|
+
|
|
153
|
+
class Ray
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class RayCollision
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
class Matrix
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# raylib's Vector3ToFloatV/MatrixToFloatV return the raw float arrays (the
|
|
163
|
+
# gem's helpers unwrap [:v].to_a; the field order below is the struct order).
|
|
164
|
+
def self.Vector3ToFloat(vec)
|
|
165
|
+
[vec.x, vec.y, vec.z]
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def self.MatrixToFloat(mat)
|
|
169
|
+
[mat.m0, mat.m4, mat.m8, mat.m12,
|
|
170
|
+
mat.m1, mat.m5, mat.m9, mat.m13,
|
|
171
|
+
mat.m2, mat.m6, mat.m10, mat.m14,
|
|
172
|
+
mat.m3, mat.m7, mat.m11, mat.m15]
|
|
173
|
+
end
|
|
174
|
+
end
|