box2d-bindings 0.1.0-x64-mingw
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ChangeLog +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/lib/box2d.rb +50 -0
- data/lib/box2d_base.rb +95 -0
- data/lib/box2d_collision.rb +832 -0
- data/lib/box2d_collision_inline.rb +47 -0
- data/lib/box2d_helper.rb +67 -0
- data/lib/box2d_id.rb +146 -0
- data/lib/box2d_id_inline.rb +53 -0
- data/lib/box2d_main.rb +337 -0
- data/lib/box2d_math_functions.rb +156 -0
- data/lib/box2d_math_inline_functions.rb +104 -0
- data/lib/box2d_types.rb +1583 -0
- data/lib/libbox2d.dll +0 -0
- metadata +71 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0ee8b757648eafbe65a258a04e611597d61bf16f9195321edf2027767f0c9355
|
4
|
+
data.tar.gz: ca62b982d7f4e3612b840b01b06df2549d3a5d141d995bba3919a8511c3bf4d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8780f8d8cb56ed33e2c72e0b16d9d1284b9f810dbeb2f4097bbe44abd139f1cb16f2ed55fb20cf3f51ce38bedbc2df555872f1f9aeff61c3083841d4106cbd5a
|
7
|
+
data.tar.gz: e9e415647390acf98025b8a489b6bb828ac24a7c4e27035eeb3834f18ceba4f84d1b0440b2872e820790500de5acc3ce5368d317ac563471d9ee5c70f593ac13
|
data/ChangeLog
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
2024-12-29 vaiorabbit <http://twitter.com/vaiorabbit>
|
2
|
+
|
3
|
+
* Added sample_softbody.rb
|
4
|
+
|
5
|
+
2024-12-22 vaiorabbit <http://twitter.com/vaiorabbit>
|
6
|
+
|
7
|
+
* https://github.com/erincatto/box2d/commit/f377034920c42a26cd498c0a0b1b2e9f2b064989
|
8
|
+
|
9
|
+
2024-12-14 vaiorabbit <http://twitter.com/vaiorabbit>
|
10
|
+
|
11
|
+
* https://github.com/erincatto/box2d/commit/f0763aca7d4dfa8f1c19c2c4a9e66fa6e93ea32e
|
12
|
+
|
13
|
+
2024-10-27 vaiorabbit <http://twitter.com/vaiorabbit>
|
14
|
+
|
15
|
+
* https://github.com/erincatto/box2d/commit/87e13e44378afc42598a4f7e8b2d5289982cdda7
|
16
|
+
|
17
|
+
2024-10-14 vaiorabbit <http://twitter.com/vaiorabbit>
|
18
|
+
|
19
|
+
* https://github.com/erincatto/box2d/commit/aee18c76a3c4442b18730097b9660f0fe866e6b1
|
20
|
+
|
21
|
+
2024-10-06 vaiorabbit <http://twitter.com/vaiorabbit>
|
22
|
+
|
23
|
+
* https://github.com/erincatto/box2d/commit/b864f533c3d851d5c7b55fd6fb4bac00466ff854
|
24
|
+
|
25
|
+
2024-09-29 vaiorabbit <http://twitter.com/vaiorabbit>
|
26
|
+
|
27
|
+
* https://github.com/erincatto/box2d/commit/df7373c08a41b7a4ba6edd5d4be200675a948176
|
28
|
+
|
29
|
+
2024-09-22 vaiorabbit <http://twitter.com/vaiorabbit>
|
30
|
+
|
31
|
+
* https://github.com/erincatto/box2d/commit/c56a76daa50726d2e47aad6bb648473ee14d822e
|
32
|
+
|
33
|
+
2024-08-18 vaiorabbit <http://twitter.com/vaiorabbit>
|
34
|
+
|
35
|
+
* make public
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Ruby-Box2D : Box2D bindings for Ruby
|
2
|
+
Copyright (c) 2024-2025 vaiorabbit <http://twitter.com/vaiorabbit>
|
3
|
+
|
4
|
+
This software is provided 'as-is', without any express or implied
|
5
|
+
warranty. In no event will the authors be held liable for any damages
|
6
|
+
arising from the use of this software.
|
7
|
+
|
8
|
+
Permission is granted to anyone to use this software for any purpose,
|
9
|
+
including commercial applications, and to alter it and redistribute it
|
10
|
+
freely, subject to the following restrictions:
|
11
|
+
|
12
|
+
1. The origin of this software must not be misrepresented; you must not
|
13
|
+
claim that you wrote the original software. If you use this software
|
14
|
+
in a product, an acknowledgment in the product documentation would be
|
15
|
+
appreciated but is not required.
|
16
|
+
|
17
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
18
|
+
misrepresented as being the original software.
|
19
|
+
|
20
|
+
3. This notice may not be removed or altered from any source
|
21
|
+
distribution.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
<!-- -*- mode:markdown; coding:utf-8; -*- -->
|
2
|
+
|
3
|
+
# Box2D bindings for Ruby #
|
4
|
+
|
5
|
+
* Created : 2024-08-18
|
6
|
+
* Last modified : 2025-01-01
|
7
|
+
|
8
|
+
Provides Ruby bindings for Box2D
|
9
|
+
* https://box2d.org
|
10
|
+
* https://github.com/erincatto/box2d
|
11
|
+
|
12
|
+
## Features ##
|
13
|
+
|
14
|
+
* Generated semi-automatically
|
15
|
+
* Based on Ruby/FFI ( https://github.com/ffi/ffi )
|
16
|
+
* Pre-built binaries are inside:
|
17
|
+
* Windows (x86_64)
|
18
|
+
* macOS (x86_64, ARM64)
|
19
|
+
* Linux (x86_64, ARM64)
|
20
|
+
|
21
|
+
## License ##
|
22
|
+
|
23
|
+
All shared libraries found in `lib` directory are built on top of Box2D ( https://github.com/erincatto/box2d ) and are available under the MIT License.
|
24
|
+
* https://github.com/erincatto/box2d/blob/main/LICENSE
|
25
|
+
|
26
|
+
All ruby codes here are available under the zlib/libpng License ( http://opensource.org/licenses/Zlib ).
|
27
|
+
|
28
|
+
```
|
29
|
+
Ruby-Box2D : Box2D bindings for Ruby
|
30
|
+
Copyright (c) 2024-2025 vaiorabbit <http://twitter.com/vaiorabbit>
|
31
|
+
|
32
|
+
This software is provided 'as-is', without any express or implied
|
33
|
+
warranty. In no event will the authors be held liable for any damages
|
34
|
+
arising from the use of this software.
|
35
|
+
|
36
|
+
Permission is granted to anyone to use this software for any purpose,
|
37
|
+
including commercial applications, and to alter it and redistribute it
|
38
|
+
freely, subject to the following restrictions:
|
39
|
+
|
40
|
+
1. The origin of this software must not be misrepresented; you must not
|
41
|
+
claim that you wrote the original software. If you use this software
|
42
|
+
in a product, an acknowledgment in the product documentation would be
|
43
|
+
appreciated but is not required.
|
44
|
+
|
45
|
+
2. Altered source versions must be plainly marked as such, and must not be
|
46
|
+
misrepresented as being the original software.
|
47
|
+
|
48
|
+
3. This notice may not be removed or altered from any source
|
49
|
+
distribution.
|
50
|
+
```
|
data/lib/box2d.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Ruby-Box2D : Yet another Box2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/box2d-bindings
|
4
|
+
|
5
|
+
require 'ffi'
|
6
|
+
require_relative 'box2d_base.rb'
|
7
|
+
require_relative 'box2d_math_functions.rb'
|
8
|
+
require_relative 'box2d_math_inline_functions.rb'
|
9
|
+
require_relative 'box2d_id.rb'
|
10
|
+
require_relative 'box2d_id_inline.rb'
|
11
|
+
require_relative 'box2d_collision.rb'
|
12
|
+
require_relative 'box2d_collision_inline.rb'
|
13
|
+
require_relative 'box2d_types.rb'
|
14
|
+
require_relative 'box2d_main.rb'
|
15
|
+
require_relative 'box2d_helper.rb'
|
16
|
+
|
17
|
+
module Box2D
|
18
|
+
extend FFI::Library
|
19
|
+
|
20
|
+
@@box2d_import_done = false
|
21
|
+
def self.load_lib(libpath, method_naming: :original)
|
22
|
+
|
23
|
+
unless @@box2d_import_done
|
24
|
+
# Ref.: Using Multiple and Alternate Libraries
|
25
|
+
# https://github.com/ffi/ffi/wiki/Using-Multiple-and-Alternate-Libraries
|
26
|
+
begin
|
27
|
+
lib_paths = [libpath].compact
|
28
|
+
ffi_lib_flags :now, :global
|
29
|
+
ffi_lib *lib_paths
|
30
|
+
setup_symbols(method_naming: method_naming)
|
31
|
+
rescue => error
|
32
|
+
$stderr.puts("[Warning] Failed to load libraries (#{error}).") if output_error
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.setup_symbols(method_naming: :original)
|
39
|
+
setup_base_symbols(method_naming: method_naming)
|
40
|
+
setup_math_functions_symbols(method_naming: method_naming)
|
41
|
+
setup_math_inline_functions_symbols(method_naming: method_naming)
|
42
|
+
setup_id_symbols(method_naming: method_naming)
|
43
|
+
setup_id_inline_symbols(method_naming: method_naming)
|
44
|
+
setup_collision_symbols(method_naming: method_naming)
|
45
|
+
setup_collision_inline_symbols(method_naming: method_naming)
|
46
|
+
setup_types_symbols(method_naming: method_naming)
|
47
|
+
setup_main_symbols(method_naming: method_naming)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/lib/box2d_base.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# Ruby-Box2D : Yet another Box2D wrapper for Ruby
|
2
|
+
#
|
3
|
+
# * https://github.com/vaiorabbit/box2d-bindings
|
4
|
+
#
|
5
|
+
# [NOTICE] Autogenerated. Do not edit.
|
6
|
+
|
7
|
+
require 'ffi'
|
8
|
+
|
9
|
+
module Box2D
|
10
|
+
extend FFI::Library
|
11
|
+
# Define/Macro
|
12
|
+
|
13
|
+
HASH_INIT = 5381
|
14
|
+
|
15
|
+
# Enum
|
16
|
+
|
17
|
+
|
18
|
+
# Typedef
|
19
|
+
|
20
|
+
typedef :pointer, :b2AllocFcn
|
21
|
+
typedef :pointer, :b2FreeFcn
|
22
|
+
typedef :pointer, :b2AssertFcn
|
23
|
+
|
24
|
+
# Struct
|
25
|
+
|
26
|
+
class Version < FFI::Struct
|
27
|
+
layout(
|
28
|
+
:major, :int,
|
29
|
+
:minor, :int,
|
30
|
+
:revision, :int,
|
31
|
+
)
|
32
|
+
def major = self[:major]
|
33
|
+
def major=(v) self[:major] = v end
|
34
|
+
def minor = self[:minor]
|
35
|
+
def minor=(v) self[:minor] = v end
|
36
|
+
def revision = self[:revision]
|
37
|
+
def revision=(v) self[:revision] = v end
|
38
|
+
def self.create_as(_major_, _minor_, _revision_)
|
39
|
+
instance = Version.new
|
40
|
+
instance[:major] = _major_
|
41
|
+
instance[:minor] = _minor_
|
42
|
+
instance[:revision] = _revision_
|
43
|
+
instance
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Timer < FFI::Struct
|
48
|
+
layout(
|
49
|
+
:start, :long_long,
|
50
|
+
)
|
51
|
+
def start = self[:start]
|
52
|
+
def start=(v) self[:start] = v end
|
53
|
+
def self.create_as(_start_)
|
54
|
+
instance = Timer.new
|
55
|
+
instance[:start] = _start_
|
56
|
+
instance
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# Function
|
62
|
+
|
63
|
+
def self.setup_base_symbols(method_naming: :original)
|
64
|
+
entries = [
|
65
|
+
[:SetAllocator, :b2SetAllocator, [:pointer, :pointer], :void],
|
66
|
+
[:GetByteCount, :b2GetByteCount, [], :int],
|
67
|
+
[:SetAssertFcn, :b2SetAssertFcn, [:pointer], :void],
|
68
|
+
[:InternalAssertFcn, :b2InternalAssertFcn, [:pointer, :pointer, :int], :int],
|
69
|
+
[:GetVersion, :b2GetVersion, [], Version.by_value],
|
70
|
+
[:CreateTimer, :b2CreateTimer, [], Timer.by_value],
|
71
|
+
[:GetTicks, :b2GetTicks, [:pointer], :long_long],
|
72
|
+
[:GetMilliseconds, :b2GetMilliseconds, [:pointer], :float],
|
73
|
+
[:GetMillisecondsAndReset, :b2GetMillisecondsAndReset, [:pointer], :float],
|
74
|
+
[:SleepMilliseconds, :b2SleepMilliseconds, [:int], :void],
|
75
|
+
[:Yield, :b2Yield, [], :void],
|
76
|
+
[:Hash, :b2Hash, [:uint, :pointer, :int], :uint],
|
77
|
+
]
|
78
|
+
entries.each do |entry|
|
79
|
+
api_name = if method_naming == :snake_case
|
80
|
+
snake_case_name = entry[0].to_s.gsub(/([A-Z]+)([A-Z0-9][a-z])/, '\1_\2').gsub(/([a-z\d])([A-Z0-9])/, '\1_\2').downcase
|
81
|
+
snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3')
|
82
|
+
snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2')
|
83
|
+
snake_case_name.chop! if snake_case_name.end_with?('_')
|
84
|
+
snake_case_name.to_sym
|
85
|
+
else
|
86
|
+
entry[0]
|
87
|
+
end
|
88
|
+
attach_function api_name, entry[1], entry[2], entry[3]
|
89
|
+
rescue FFI::NotFoundError => e
|
90
|
+
warn "[Warning] Failed to import #{entry[0]} (#{e})."
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|