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
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# physac compat — loaded by raylib-spinel/physac (never by the base entry).
|
|
4
|
+
#
|
|
5
|
+
# The physics shims (rl_PhysicsBodyData_*, rl_PhysicsBodySetEnabled,
|
|
6
|
+
# rl_DestroyPhysicsBody) only exist when lib/physac_ffi.rb is part of the
|
|
7
|
+
# program, so these definitions must not live in raylib_handles.rb: a scene
|
|
8
|
+
# that never loads physac would carry unresolved class-method calls.
|
|
9
|
+
|
|
10
|
+
module Raylib
|
|
11
|
+
# The gem's PhysicsBodyData (FFI::Struct view over the opaque PhysicsBody
|
|
12
|
+
# pointer). Plain Ruby: the producer returns a raw :ptr and the example wraps
|
|
13
|
+
# it with PhysicsBodyData.new(ptr); consumers below accept either form.
|
|
14
|
+
class PhysicsBodyData
|
|
15
|
+
def initialize(ptr, owner = nil)
|
|
16
|
+
@__ptr = ptr
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def __ptr = @__ptr
|
|
20
|
+
|
|
21
|
+
def id = Raylib.rl_PhysicsBodyData_id(@__ptr)
|
|
22
|
+
def enabled = Raylib.rl_PhysicsBodyData_enabled(@__ptr) != 0
|
|
23
|
+
def enabled=(v)
|
|
24
|
+
Raylib.rl_PhysicsBodySetEnabled(@__ptr, v ? 1 : 0)
|
|
25
|
+
end
|
|
26
|
+
def position = Vector2.new(Raylib.rl_PhysicsBodyData_position_addr(@__ptr))
|
|
27
|
+
def velocity = Vector2.new(Raylib.rl_PhysicsBodyData_velocity_addr(@__ptr))
|
|
28
|
+
def force = Vector2.new(Raylib.rl_PhysicsBodyData_force_addr(@__ptr))
|
|
29
|
+
def orient = Raylib.rl_PhysicsBodyData_orient(@__ptr)
|
|
30
|
+
def mass = Raylib.rl_PhysicsBodyData_mass(@__ptr)
|
|
31
|
+
def isGrounded = Raylib.rl_PhysicsBodyData_isGrounded(@__ptr) != 0
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Accepts a PhysicsBodyData view (the gem idiom) or the raw pointer the
|
|
35
|
+
# producers return (physics_demo keeps a raw-pointer list).
|
|
36
|
+
def self.DestroyPhysicsBody(body)
|
|
37
|
+
if body.is_a?(PhysicsBodyData)
|
|
38
|
+
Raylib.rl_DestroyPhysicsBody(body.__ptr)
|
|
39
|
+
else
|
|
40
|
+
Raylib.rl_DestroyPhysicsBody(body)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
data/lib/physac_ffi.rb
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# physac_ffi.rb — physac bindings for Spinel AOT.
|
|
2
|
+
#
|
|
3
|
+
# physac is compiled into lib/physac_adapter.o + lib/physac_impl.o and linked
|
|
4
|
+
# into the physics scene. PhysicsBody is an opaque pointer; body creation takes
|
|
5
|
+
# raw floats (Vector2 by value). Loaded by `require "raylib-spinel/physac"`.
|
|
6
|
+
# Under CRuby the raylib-bindings gem already binds physac.
|
|
7
|
+
|
|
8
|
+
module Raylib
|
|
9
|
+
ffi_lib "raylib"
|
|
10
|
+
# No flags of our own: this TU includes no raylib-family header, and the
|
|
11
|
+
# carried C gets its include paths from [native] pkg_config in spin.toml.
|
|
12
|
+
# The (empty) line stays because the generators anchor their splice on a
|
|
13
|
+
# `ffi_cflags "..."` line being present (tools/generate_physac.py).
|
|
14
|
+
ffi_cflags ""
|
|
15
|
+
|
|
16
|
+
# ====== generated: complete physac API surface ======
|
|
17
|
+
ffi_func :InitPhysics, [], :void
|
|
18
|
+
ffi_func :UpdatePhysics, [], :void
|
|
19
|
+
ffi_func :ResetPhysics, [], :void
|
|
20
|
+
ffi_func :ClosePhysics, [], :void
|
|
21
|
+
ffi_func :SetPhysicsTimeStep, [:double], :void
|
|
22
|
+
ffi_func :SetPhysicsGravity, [:float, :float], :void
|
|
23
|
+
ffi_func :rl_PhysicsShatter, [:ptr, :ptr, :float], :void
|
|
24
|
+
ffi_func :rl_SetPhysicsBodyRotation, [:ptr, :float], :void
|
|
25
|
+
ffi_func :GetPhysicsBodiesCount, [], :int
|
|
26
|
+
ffi_func :GetPhysicsShapeType, [:int], :int
|
|
27
|
+
ffi_func :GetPhysicsShapeVerticesCount, [:int], :int
|
|
28
|
+
|
|
29
|
+
ffi_func :rl_InitPhysics, [], :ptr
|
|
30
|
+
ffi_func :rl_UpdatePhysics1, [], :void
|
|
31
|
+
ffi_func :rl_ResetPhysics, [], :void
|
|
32
|
+
ffi_func :rl_ClosePhysics, [], :void
|
|
33
|
+
ffi_func :rl_SetPhysicsGravity, %i[float float], :void
|
|
34
|
+
ffi_func :rl_SetPhysicsTimeStep, [:double], :void
|
|
35
|
+
ffi_func :rl_CreatePhysicsBodyCircle, %i[float float float float], :ptr
|
|
36
|
+
ffi_func :rl_CreatePhysicsBodyRectangle, %i[float float float float float], :ptr
|
|
37
|
+
ffi_func :rl_CreatePhysicsBodyPolygon, %i[float float float int float], :ptr
|
|
38
|
+
ffi_func :rl_DestroyPhysicsBody, [:ptr], :void
|
|
39
|
+
ffi_func :rl_PhysicsAddForce, %i[ptr float float], :void
|
|
40
|
+
ffi_func :rl_PhysicsAddTorque, %i[ptr float], :void
|
|
41
|
+
ffi_func :rl_GetPhysicsBody, [:int], :ptr
|
|
42
|
+
ffi_func :rl_GetPhysicsBodiesCount, [], :int
|
|
43
|
+
ffi_func :rl_GetPhysicsShapeType, [:int], :int
|
|
44
|
+
ffi_func :rl_GetPhysicsShapeVerticesCount, [:int], :int
|
|
45
|
+
ffi_func :rl_GetPhysicsShapeVertex, %i[ptr int ptr], :void
|
|
46
|
+
ffi_func :rl_PhysicsBodySetEnabled, %i[ptr int], :void
|
|
47
|
+
ffi_func :rl_PhysicsBodyGetEnabled, [:ptr], :int
|
|
48
|
+
ffi_func :rl_PhysicsBodyGetPosY, [:ptr], :float
|
|
49
|
+
ffi_func :rl_PhysicsBodyGetPosX, [:ptr], :float
|
|
50
|
+
ffi_func :rl_PhysicsBodyData_position_addr, [:ptr], :long
|
|
51
|
+
ffi_func :rl_PhysicsBodyData_velocity_addr, [:ptr], :long
|
|
52
|
+
ffi_func :rl_PhysicsBodyData_force_addr, [:ptr], :long
|
|
53
|
+
ffi_func :rl_PhysicsBodyData_id, [:ptr], :int
|
|
54
|
+
ffi_func :rl_PhysicsBodyData_enabled, [:ptr], :int
|
|
55
|
+
ffi_func :rl_PhysicsBodyData_isGrounded, [:ptr], :int
|
|
56
|
+
ffi_func :rl_PhysicsBodyData_orient, [:ptr], :double
|
|
57
|
+
ffi_func :rl_PhysicsBodyData_mass, [:ptr], :double
|
|
58
|
+
|
|
59
|
+
def self.InitPhysics = Raylib.rl_InitPhysics
|
|
60
|
+
def self.UpdatePhysics = Raylib.rl_UpdatePhysics1
|
|
61
|
+
def self.ResetPhysics = Raylib.rl_ResetPhysics
|
|
62
|
+
def self.ClosePhysics = Raylib.rl_ClosePhysics
|
|
63
|
+
def self.SetPhysicsGravity(x, y) = Raylib.rl_SetPhysicsGravity(x, y)
|
|
64
|
+
def self.SetPhysicsTimeStep(delta) = Raylib.rl_SetPhysicsTimeStep(delta)
|
|
65
|
+
def self.CreatePhysicsBodyCircle(pos, radius, density) = Raylib.rl_CreatePhysicsBodyCircle(pos.x, pos.y, radius, density)
|
|
66
|
+
def self.CreatePhysicsBodyRectangle(pos, width, height, density) = Raylib.rl_CreatePhysicsBodyRectangle(pos.x, pos.y, width, height, density)
|
|
67
|
+
def self.CreatePhysicsBodyPolygon(pos, radius, sides, density) = Raylib.rl_CreatePhysicsBodyPolygon(pos.x, pos.y, radius, sides, density)
|
|
68
|
+
def self.PhysicsAddForce(body, force) = Raylib.rl_PhysicsAddForce(body, force.x, force.y)
|
|
69
|
+
def self.PhysicsAddTorque(body, amount) = Raylib.rl_PhysicsAddTorque(body, amount)
|
|
70
|
+
def self.GetPhysicsBody(index) = Raylib.rl_GetPhysicsBody(index)
|
|
71
|
+
def self.GetPhysicsBodiesCount = Raylib.rl_GetPhysicsBodiesCount
|
|
72
|
+
def self.GetPhysicsShapeType(index) = Raylib.rl_GetPhysicsShapeType(index)
|
|
73
|
+
def self.GetPhysicsShapeVerticesCount(index) = Raylib.rl_GetPhysicsShapeVerticesCount(index)
|
|
74
|
+
# gem shape: returns the vertex (a Vector2)
|
|
75
|
+
def self.GetPhysicsShapeVertex(body, vertex)
|
|
76
|
+
out = Vector2.new
|
|
77
|
+
Raylib.rl_GetPhysicsShapeVertex(body, vertex, out)
|
|
78
|
+
out
|
|
79
|
+
end
|
|
80
|
+
def self.PhysicsBodySetEnabled(body, enabled) = Raylib.rl_PhysicsBodySetEnabled(body, enabled)
|
|
81
|
+
def self.PhysicsBodyGetEnabled(body) = Raylib.rl_PhysicsBodyGetEnabled(body)
|
|
82
|
+
def self.PhysicsBodyGetPosY(body) = Raylib.rl_PhysicsBodyGetPosY(body)
|
|
83
|
+
def self.PhysicsBodyGetPosX(body) = Raylib.rl_PhysicsBodyGetPosX(body)
|
|
84
|
+
|
|
85
|
+
PHYSICS_CIRCLE = 0
|
|
86
|
+
PHYSICS_POLYGON = 1
|
|
87
|
+
|
|
88
|
+
# ====== generated: wrappers + constants ======
|
|
89
|
+
def self.PhysicsShatter(body, position, force)
|
|
90
|
+
Raylib.rl_PhysicsShatter(body, position, force)
|
|
91
|
+
end
|
|
92
|
+
def self.SetPhysicsBodyRotation(body, radians)
|
|
93
|
+
Raylib.rl_SetPhysicsBodyRotation(body, radians)
|
|
94
|
+
end
|
|
95
|
+
PHYSAC_MAX_BODIES = 64
|
|
96
|
+
PHYSAC_MAX_MANIFOLDS = 4096
|
|
97
|
+
PHYSAC_MAX_VERTICES = 24
|
|
98
|
+
PHYSAC_DEFAULT_CIRCLE_VERTICES = 24
|
|
99
|
+
PHYSAC_COLLISION_ITERATIONS = 100
|
|
100
|
+
PHYSAC_PENETRATION_ALLOWANCE = 0.05
|
|
101
|
+
PHYSAC_PENETRATION_CORRECTION = 0.4
|
|
102
|
+
PHYSAC_PI = 3.141592653589793
|
|
103
|
+
|
|
104
|
+
# ====== generated: wrappers + constants ======
|
|
105
|
+
|
|
106
|
+
# ====== generated: snake_case aliases (MRI gem naming) ======
|
|
107
|
+
class << self
|
|
108
|
+
alias_method :init_physics, :InitPhysics
|
|
109
|
+
alias_method :update_physics, :UpdatePhysics
|
|
110
|
+
alias_method :reset_physics, :ResetPhysics
|
|
111
|
+
alias_method :close_physics, :ClosePhysics
|
|
112
|
+
alias_method :set_physics_time_step, :SetPhysicsTimeStep
|
|
113
|
+
alias_method :set_physics_gravity, :SetPhysicsGravity
|
|
114
|
+
alias_method :create_physics_body_circle, :CreatePhysicsBodyCircle
|
|
115
|
+
alias_method :create_physics_body_rectangle, :CreatePhysicsBodyRectangle
|
|
116
|
+
alias_method :create_physics_body_polygon, :CreatePhysicsBodyPolygon
|
|
117
|
+
alias_method :destroy_physics_body, :DestroyPhysicsBody
|
|
118
|
+
alias_method :physics_add_force, :PhysicsAddForce
|
|
119
|
+
alias_method :physics_add_torque, :PhysicsAddTorque
|
|
120
|
+
alias_method :physics_shatter, :PhysicsShatter
|
|
121
|
+
alias_method :set_physics_body_rotation, :SetPhysicsBodyRotation
|
|
122
|
+
alias_method :get_physics_body, :GetPhysicsBody
|
|
123
|
+
alias_method :get_physics_bodies_count, :GetPhysicsBodiesCount
|
|
124
|
+
alias_method :get_physics_shape_type, :GetPhysicsShapeType
|
|
125
|
+
alias_method :get_physics_shape_vertices_count, :GetPhysicsShapeVerticesCount
|
|
126
|
+
alias_method :get_physics_shape_vertex, :GetPhysicsShapeVertex
|
|
127
|
+
end
|
|
128
|
+
end
|