Module: Box2D
- Extended by:
- FFI::Library
- Defined in:
- lib/box2d.rb,
lib/box2d_id.rb,
lib/box2d_base.rb,
lib/box2d_main.rb,
lib/box2d_types.rb,
lib/box2d_helper.rb,
lib/box2d_collision.rb,
lib/box2d_id_inline.rb,
lib/box2d_math_functions.rb,
lib/box2d_math_inline_functions.rb
Defined Under Namespace
Classes: AABB, BodyDef, BodyEvents, BodyId, BodyMoveEvent, Capsule, CastOutput, ChainDef, ChainId, ChainSegment, Circle, CollisionPlane, ContactBeginTouchEvent, ContactData, ContactEndTouchEvent, ContactEvents, ContactHitEvent, ContactId, CosSin, Counters, DebugDraw, DistanceInput, DistanceJointDef, DistanceOutput, DynamicTree, ExplosionDef, Filter, FilterJointDef, Hull, JointDef, JointEvent, JointEvents, JointId, Manifold, ManifoldPoint, MassData, Mat22, MotorJointDef, MouseJointDef, Plane, PlaneResult, PlaneSolverResult, Polygon, PrismaticJointDef, Profile, QueryFilter, RayCastInput, RayResult, RevoluteJointDef, Rot, Segment, SegmentDistanceResult, SensorBeginTouchEvent, SensorEndTouchEvent, SensorEvents, ShapeCastInput, ShapeCastPairInput, ShapeDef, ShapeId, ShapeProxy, Simplex, SimplexCache, SimplexVertex, SurfaceMaterial, Sweep, TOIInput, TOIOutput, Transform, TreeNode, TreeNode_Union, TreeStats, Vec2, Version, WeldJointDef, WheelJointDef, WorldDef, WorldId
Constant Summary collapse
- HASH_INIT =
Define/Macro
5381- DEFAULT_CATEGORY_BITS =
Define/Macro
0x0001- BodyType_staticBody =
Enum
0- BodyType_kinematicBody =
1- BodyType_dynamicBody =
2- BodyType_bodyTypeCount =
3- ShapeType_circleShape =
0- ShapeType_capsuleShape =
1- ShapeType_segmentShape =
2- ShapeType_polygonShape =
3- ShapeType_chainSegmentShape =
4- ShapeType_shapeTypeCount =
5- JointType_distanceJoint =
0- JointType_filterJoint =
1- JointType_motorJoint =
2- JointType_mouseJoint =
3- JointType_prismaticJoint =
4- JointType_revoluteJoint =
5- JointType_weldJoint =
6- JointType_wheelJoint =
7- HexColor_colorAliceBlue =
15792383- HexColor_colorAntiqueWhite =
16444375- HexColor_colorAqua =
65535- HexColor_colorAquamarine =
8388564- HexColor_colorAzure =
15794175- HexColor_colorBeige =
16119260- HexColor_colorBisque =
16770244- HexColor_colorBlack =
0- HexColor_colorBlanchedAlmond =
16772045- HexColor_colorBlue =
255- HexColor_colorBlueViolet =
9055202- HexColor_colorBrown =
10824234- HexColor_colorBurlywood =
14596231- HexColor_colorCadetBlue =
6266528- HexColor_colorChartreuse =
8388352- HexColor_colorChocolate =
13789470- HexColor_colorCoral =
16744272- HexColor_colorCornflowerBlue =
6591981- HexColor_colorCornsilk =
16775388- HexColor_colorCrimson =
14423100- HexColor_colorCyan =
65535- HexColor_colorDarkBlue =
139- HexColor_colorDarkCyan =
35723- HexColor_colorDarkGoldenRod =
12092939- HexColor_colorDarkGray =
11119017- HexColor_colorDarkGreen =
25600- HexColor_colorDarkKhaki =
12433259- HexColor_colorDarkMagenta =
9109643- HexColor_colorDarkOliveGreen =
5597999- HexColor_colorDarkOrange =
16747520- HexColor_colorDarkOrchid =
10040012- HexColor_colorDarkRed =
9109504- HexColor_colorDarkSalmon =
15308410- HexColor_colorDarkSeaGreen =
9419919- HexColor_colorDarkSlateBlue =
4734347- HexColor_colorDarkSlateGray =
3100495- HexColor_colorDarkTurquoise =
52945- HexColor_colorDarkViolet =
9699539- HexColor_colorDeepPink =
16716947- HexColor_colorDeepSkyBlue =
49151- HexColor_colorDimGray =
6908265- HexColor_colorDodgerBlue =
2003199- HexColor_colorFireBrick =
11674146- HexColor_colorFloralWhite =
16775920- HexColor_colorForestGreen =
2263842- HexColor_colorFuchsia =
16711935- HexColor_colorGainsboro =
14474460- HexColor_colorGhostWhite =
16316671- HexColor_colorGold =
16766720- HexColor_colorGoldenRod =
14329120- HexColor_colorGray =
8421504- HexColor_colorGreen =
32768- HexColor_colorGreenYellow =
11403055- HexColor_colorHoneyDew =
15794160- HexColor_colorHotPink =
16738740- HexColor_colorIndianRed =
13458524- HexColor_colorIndigo =
4915330- HexColor_colorIvory =
16777200- HexColor_colorKhaki =
15787660- HexColor_colorLavender =
15132410- HexColor_colorLavenderBlush =
16773365- HexColor_colorLawnGreen =
8190976- HexColor_colorLemonChiffon =
16775885- HexColor_colorLightBlue =
11393254- HexColor_colorLightCoral =
15761536- HexColor_colorLightCyan =
14745599- HexColor_colorLightGoldenRodYellow =
16448210- HexColor_colorLightGray =
13882323- HexColor_colorLightGreen =
9498256- HexColor_colorLightPink =
16758465- HexColor_colorLightSalmon =
16752762- HexColor_colorLightSeaGreen =
2142890- HexColor_colorLightSkyBlue =
8900346- HexColor_colorLightSlateGray =
7833753- HexColor_colorLightSteelBlue =
11584734- HexColor_colorLightYellow =
16777184- HexColor_colorLime =
65280- HexColor_colorLimeGreen =
3329330- HexColor_colorLinen =
16445670- HexColor_colorMagenta =
16711935- HexColor_colorMaroon =
8388608- HexColor_colorMediumAquaMarine =
6737322- HexColor_colorMediumBlue =
205- HexColor_colorMediumOrchid =
12211667- HexColor_colorMediumPurple =
9662683- HexColor_colorMediumSeaGreen =
3978097- HexColor_colorMediumSlateBlue =
8087790- HexColor_colorMediumSpringGreen =
64154- HexColor_colorMediumTurquoise =
4772300- HexColor_colorMediumVioletRed =
13047173- HexColor_colorMidnightBlue =
1644912- HexColor_colorMintCream =
16121850- HexColor_colorMistyRose =
16770273- HexColor_colorMoccasin =
1677022916768685128- HexColor_colorOldLace =
16643558- HexColor_colorOlive =
8421376- HexColor_colorOliveDrab =
7048739- HexColor_colorOrange =
16753920- HexColor_colorOrangeRed =
16729344- HexColor_colorOrchid =
14315734- HexColor_colorPaleGoldenRod =
15657130- HexColor_colorPaleGreen =
10025880- HexColor_colorPaleTurquoise =
11529966- HexColor_colorPaleVioletRed =
14381203- HexColor_colorPapayaWhip =
16773077- HexColor_colorPeachPuff =
16767673- HexColor_colorPeru =
13468991- HexColor_colorPink =
16761035- HexColor_colorPlum =
14524637- HexColor_colorPowderBlue =
11591910- HexColor_colorPurple =
8388736- HexColor_colorRebeccaPurple =
6697881- HexColor_colorRed =
16711680- HexColor_colorRosyBrown =
12357519- HexColor_colorRoyalBlue =
4286945- HexColor_colorSaddleBrown =
9127187- HexColor_colorSalmon =
16416882- HexColor_colorSandyBrown =
16032864- HexColor_colorSeaGreen =
3050327- HexColor_colorSeaShell =
16774638- HexColor_colorSienna =
10506797- HexColor_colorSilver =
12632256- HexColor_colorSkyBlue =
8900331- HexColor_colorSlateBlue =
6970061- HexColor_colorSlateGray =
7372944- HexColor_colorSnow =
16775930- HexColor_colorSpringGreen =
65407- HexColor_colorSteelBlue =
4620980- HexColor_colorTan =
13808780- HexColor_colorTeal =
32896- HexColor_colorThistle =
14204888- HexColor_colorTomato =
16737095- HexColor_colorTurquoise =
4251856- HexColor_colorViolet =
15631086- HexColor_colorWheat =
16113331- HexColor_colorWhite =
16777215- HexColor_colorWhiteSmoke =
16119285- HexColor_colorYellow =
16776960- HexColor_colorYellowGreen =
10145074- HexColor_colorBox2DRed =
14430514- HexColor_colorBox2DBlue =
3190463- HexColor_colorBox2DGreen =
9226532- HexColor_colorBox2DYellow =
16772748- NULL_WORLDID =
ID helper
WorldId.new.freeze
- NULL_BODYID =
BodyId.new.freeze
- NULL_SHAPEID =
ShapeId.new.freeze
- NULL_CHAINID =
ChainId.new.freeze
- NULL_JOINTID =
JointId.new.freeze
- VEC2_ZERO =
Math helper
Vec2.new.freeze
- ROT_IDENTITY =
Rot.create_as(1.0, 0.0).freeze
- TRANSFORM_IDENTITY =
Transform.create_as(Vec2.new.freeze, Rot.create_as(1.0, 0.0).freeze).freeze
- MAT22_ZERO =
Mat22.create_as(Vec2.new.freeze, Vec2.new.freeze).freeze
- MAX_POLYGON_VERTICES =
Define/Macro
8- TOIState_toiStateUnknown =
Enum
0- TOIState_toiStateFailed =
1- TOIState_toiStateOverlapped =
2- TOIState_toiStateHit =
3- TOIState_toiStateSeparated =
4- @@box2d_import_done =
false
Class Method Summary collapse
- .id_equals(id1, id2) ⇒ Object
- .id_non_null(id) ⇒ Object
- .id_null(id) ⇒ Object
- .load_lib(libpath, method_naming: :original) ⇒ Object
-
.setup_base_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_collision_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_id_inline_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_id_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_main_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_math_functions_symbols(method_naming: :original) ⇒ Object
Function.
-
.setup_math_inline_functions_symbols(method_naming: :original) ⇒ Object
Function.
- .setup_symbols(method_naming: :original) ⇒ Object
-
.setup_types_symbols(method_naming: :original) ⇒ Object
Function.
Class Method Details
.id_equals(id1, id2) ⇒ Object
26 27 28 |
# File 'lib/box2d_helper.rb', line 26 def self.id_equals(id1, id2) id1.index1 == id2.index1 && id1.world0 == id2.world0 && id1.generation == id2.generation end |
.id_non_null(id) ⇒ Object
22 23 24 |
# File 'lib/box2d_helper.rb', line 22 def self.id_non_null(id) id.index1 != 0 end |
.id_null(id) ⇒ Object
18 19 20 |
# File 'lib/box2d_helper.rb', line 18 def self.id_null(id) id.index1 == 0 end |
.load_lib(libpath, method_naming: :original) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/box2d.rb', line 20 def self.load_lib(libpath, method_naming: :original) unless @@box2d_import_done # Ref.: Using Multiple and Alternate Libraries # https://github.com/ffi/ffi/wiki/Using-Multiple-and-Alternate-Libraries begin lib_paths = [libpath].compact ffi_lib_flags :now, :global ffi_lib *lib_paths setup_symbols(method_naming: method_naming) rescue => error $stderr.puts("[Warning] Failed to load libraries (#{error}).") if output_error end end end |
.setup_base_symbols(method_naming: :original) ⇒ Object
Function
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/box2d_base.rb', line 50 def self.setup_base_symbols(method_naming: :original) entries = [ [:SetAllocator, :b2SetAllocator, [:pointer, :pointer], :void], [:GetByteCount, :b2GetByteCount, [], :int], [:SetAssertFcn, :b2SetAssertFcn, [:pointer], :void], [:GetVersion, :b2GetVersion, [], Version.by_value], [:GetTicks, :b2GetTicks, [], :ulong_long], [:GetMilliseconds, :b2GetMilliseconds, [:ulong_long], :float], [:GetMillisecondsAndReset, :b2GetMillisecondsAndReset, [:pointer], :float], [:Yield, :b2Yield, [], :void], [:Hash, :b2Hash, [:uint, :pointer, :int], :uint], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_collision_symbols(method_naming: :original) ⇒ Object
Function
820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
# File 'lib/box2d_collision.rb', line 820 def self.setup_collision_symbols(method_naming: :original) entries = [ [:IsValidRay, :b2IsValidRay, [:pointer], :bool], [:MakePolygon, :b2MakePolygon, [:pointer, :float], Polygon.by_value], [:MakeOffsetPolygon, :b2MakeOffsetPolygon, [:pointer, Vec2.by_value, Rot.by_value], Polygon.by_value], [:MakeOffsetRoundedPolygon, :b2MakeOffsetRoundedPolygon, [:pointer, Vec2.by_value, Rot.by_value, :float], Polygon.by_value], [:MakeSquare, :b2MakeSquare, [:float], Polygon.by_value], [:MakeBox, :b2MakeBox, [:float, :float], Polygon.by_value], [:MakeRoundedBox, :b2MakeRoundedBox, [:float, :float, :float], Polygon.by_value], [:MakeOffsetBox, :b2MakeOffsetBox, [:float, :float, Vec2.by_value, Rot.by_value], Polygon.by_value], [:MakeOffsetRoundedBox, :b2MakeOffsetRoundedBox, [:float, :float, Vec2.by_value, Rot.by_value, :float], Polygon.by_value], [:TransformPolygon, :b2TransformPolygon, [Transform.by_value, :pointer], Polygon.by_value], [:ComputeCircleMass, :b2ComputeCircleMass, [:pointer, :float], MassData.by_value], [:ComputeCapsuleMass, :b2ComputeCapsuleMass, [:pointer, :float], MassData.by_value], [:ComputePolygonMass, :b2ComputePolygonMass, [:pointer, :float], MassData.by_value], [:ComputeCircleAABB, :b2ComputeCircleAABB, [:pointer, Transform.by_value], AABB.by_value], [:ComputeCapsuleAABB, :b2ComputeCapsuleAABB, [:pointer, Transform.by_value], AABB.by_value], [:ComputePolygonAABB, :b2ComputePolygonAABB, [:pointer, Transform.by_value], AABB.by_value], [:ComputeSegmentAABB, :b2ComputeSegmentAABB, [:pointer, Transform.by_value], AABB.by_value], [:PointInCircle, :b2PointInCircle, [Vec2.by_value, :pointer], :bool], [:PointInCapsule, :b2PointInCapsule, [Vec2.by_value, :pointer], :bool], [:PointInPolygon, :b2PointInPolygon, [Vec2.by_value, :pointer], :bool], [:RayCastCircle, :b2RayCastCircle, [:pointer, :pointer], CastOutput.by_value], [:RayCastCapsule, :b2RayCastCapsule, [:pointer, :pointer], CastOutput.by_value], [:RayCastSegment, :b2RayCastSegment, [:pointer, :pointer, :bool], CastOutput.by_value], [:RayCastPolygon, :b2RayCastPolygon, [:pointer, :pointer], CastOutput.by_value], [:ShapeCastCircle, :b2ShapeCastCircle, [:pointer, :pointer], CastOutput.by_value], [:ShapeCastCapsule, :b2ShapeCastCapsule, [:pointer, :pointer], CastOutput.by_value], [:ShapeCastSegment, :b2ShapeCastSegment, [:pointer, :pointer], CastOutput.by_value], [:ShapeCastPolygon, :b2ShapeCastPolygon, [:pointer, :pointer], CastOutput.by_value], [:ComputeHull, :b2ComputeHull, [:pointer, :int], Hull.by_value], [:ValidateHull, :b2ValidateHull, [:pointer], :bool], [:SegmentDistance, :b2SegmentDistance, [Vec2.by_value, Vec2.by_value, Vec2.by_value, Vec2.by_value], SegmentDistanceResult.by_value], [:ShapeDistance, :b2ShapeDistance, [:pointer, :pointer, :pointer, :int], DistanceOutput.by_value], [:ShapeCast, :b2ShapeCast, [:pointer], CastOutput.by_value], [:MakeProxy, :b2MakeProxy, [:pointer, :int, :float], ShapeProxy.by_value], [:MakeOffsetProxy, :b2MakeOffsetProxy, [:pointer, :int, :float, Vec2.by_value, Rot.by_value], ShapeProxy.by_value], [:GetSweepTransform, :b2GetSweepTransform, [:pointer, :float], Transform.by_value], [:TimeOfImpact, :b2TimeOfImpact, [:pointer], TOIOutput.by_value], [:CollideCircles, :b2CollideCircles, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideCapsuleAndCircle, :b2CollideCapsuleAndCircle, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideSegmentAndCircle, :b2CollideSegmentAndCircle, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollidePolygonAndCircle, :b2CollidePolygonAndCircle, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideCapsules, :b2CollideCapsules, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideSegmentAndCapsule, :b2CollideSegmentAndCapsule, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollidePolygonAndCapsule, :b2CollidePolygonAndCapsule, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollidePolygons, :b2CollidePolygons, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideSegmentAndPolygon, :b2CollideSegmentAndPolygon, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideChainSegmentAndCircle, :b2CollideChainSegmentAndCircle, [:pointer, Transform.by_value, :pointer, Transform.by_value], Manifold.by_value], [:CollideChainSegmentAndCapsule, :b2CollideChainSegmentAndCapsule, [:pointer, Transform.by_value, :pointer, Transform.by_value, :pointer], Manifold.by_value], [:CollideChainSegmentAndPolygon, :b2CollideChainSegmentAndPolygon, [:pointer, Transform.by_value, :pointer, Transform.by_value, :pointer], Manifold.by_value], [:DynamicTree_Create, :b2DynamicTree_Create, [], DynamicTree.by_value], [:DynamicTree_Destroy, :b2DynamicTree_Destroy, [:pointer], :void], [:DynamicTree_CreateProxy, :b2DynamicTree_CreateProxy, [:pointer, AABB.by_value, :ulong_long, :ulong_long], :int], [:DynamicTree_DestroyProxy, :b2DynamicTree_DestroyProxy, [:pointer, :int], :void], [:DynamicTree_MoveProxy, :b2DynamicTree_MoveProxy, [:pointer, :int, AABB.by_value], :void], [:DynamicTree_EnlargeProxy, :b2DynamicTree_EnlargeProxy, [:pointer, :int, AABB.by_value], :void], [:DynamicTree_SetCategoryBits, :b2DynamicTree_SetCategoryBits, [:pointer, :int, :ulong_long], :void], [:DynamicTree_GetCategoryBits, :b2DynamicTree_GetCategoryBits, [:pointer, :int], :ulong_long], [:DynamicTree_Query, :b2DynamicTree_Query, [:pointer, AABB.by_value, :ulong_long, :pointer, :pointer], TreeStats.by_value], [:DynamicTree_RayCast, :b2DynamicTree_RayCast, [:pointer, :pointer, :ulong_long, :pointer, :pointer], TreeStats.by_value], [:DynamicTree_ShapeCast, :b2DynamicTree_ShapeCast, [:pointer, :pointer, :ulong_long, :pointer, :pointer], TreeStats.by_value], [:DynamicTree_GetHeight, :b2DynamicTree_GetHeight, [:pointer], :int], [:DynamicTree_GetAreaRatio, :b2DynamicTree_GetAreaRatio, [:pointer], :float], [:DynamicTree_GetRootBounds, :b2DynamicTree_GetRootBounds, [:pointer], AABB.by_value], [:DynamicTree_GetProxyCount, :b2DynamicTree_GetProxyCount, [:pointer], :int], [:DynamicTree_Rebuild, :b2DynamicTree_Rebuild, [:pointer, :bool], :int], [:DynamicTree_GetByteCount, :b2DynamicTree_GetByteCount, [:pointer], :int], [:DynamicTree_GetUserData, :b2DynamicTree_GetUserData, [:pointer, :int], :ulong_long], [:DynamicTree_GetAABB, :b2DynamicTree_GetAABB, [:pointer, :int], AABB.by_value], [:DynamicTree_Validate, :b2DynamicTree_Validate, [:pointer], :void], [:DynamicTree_ValidateNoEnlarged, :b2DynamicTree_ValidateNoEnlarged, [:pointer], :void], [:SolvePlanes, :b2SolvePlanes, [Vec2.by_value, :pointer, :int], PlaneSolverResult.by_value], [:ClipVector, :b2ClipVector, [Vec2.by_value, :pointer, :int], Vec2.by_value], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_id_inline_symbols(method_naming: :original) ⇒ Object
Function
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/box2d_id_inline.rb', line 25 def self.setup_id_inline_symbols(method_naming: :original) entries = [ [:StoreWorldId, :b2StoreWorldId, [WorldId.by_value], :uint], [:LoadWorldId, :b2LoadWorldId, [:uint], WorldId.by_value], [:StoreBodyId, :b2StoreBodyId, [BodyId.by_value], :ulong_long], [:LoadBodyId, :b2LoadBodyId, [:ulong_long], BodyId.by_value], [:StoreShapeId, :b2StoreShapeId, [ShapeId.by_value], :ulong_long], [:LoadShapeId, :b2LoadShapeId, [:ulong_long], ShapeId.by_value], [:StoreChainId, :b2StoreChainId, [ChainId.by_value], :ulong_long], [:LoadChainId, :b2LoadChainId, [:ulong_long], ChainId.by_value], [:StoreJointId, :b2StoreJointId, [JointId.by_value], :ulong_long], [:LoadJointId, :b2LoadJointId, [:ulong_long], JointId.by_value], [:StoreContactId, :b2StoreContactId, [ContactId.by_value, :pointer], :void], [:LoadContactId, :b2LoadContactId, [:pointer], ContactId.by_value], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_id_symbols(method_naming: :original) ⇒ Object
Function
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/box2d_id.rb', line 151 def self.setup_id_symbols(method_naming: :original) entries = [ ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_main_symbols(method_naming: :original) ⇒ Object
Function
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/box2d_main.rb', line 25 def self.setup_main_symbols(method_naming: :original) entries = [ [:CreateWorld, :b2CreateWorld, [:pointer], WorldId.by_value], [:DestroyWorld, :b2DestroyWorld, [WorldId.by_value], :void], [:World_IsValid, :b2World_IsValid, [WorldId.by_value], :bool], [:World_Step, :b2World_Step, [WorldId.by_value, :float, :int], :void], [:World_Draw, :b2World_Draw, [WorldId.by_value, :pointer], :void], [:World_GetBodyEvents, :b2World_GetBodyEvents, [WorldId.by_value], BodyEvents.by_value], [:World_GetSensorEvents, :b2World_GetSensorEvents, [WorldId.by_value], SensorEvents.by_value], [:World_GetContactEvents, :b2World_GetContactEvents, [WorldId.by_value], ContactEvents.by_value], [:World_GetJointEvents, :b2World_GetJointEvents, [WorldId.by_value], JointEvents.by_value], [:World_OverlapAABB, :b2World_OverlapAABB, [WorldId.by_value, AABB.by_value, QueryFilter.by_value, :pointer, :pointer], TreeStats.by_value], [:World_OverlapShape, :b2World_OverlapShape, [WorldId.by_value, :pointer, QueryFilter.by_value, :pointer, :pointer], TreeStats.by_value], [:World_CastRay, :b2World_CastRay, [WorldId.by_value, Vec2.by_value, Vec2.by_value, QueryFilter.by_value, :pointer, :pointer], TreeStats.by_value], [:World_CastRayClosest, :b2World_CastRayClosest, [WorldId.by_value, Vec2.by_value, Vec2.by_value, QueryFilter.by_value], RayResult.by_value], [:World_CastShape, :b2World_CastShape, [WorldId.by_value, :pointer, Vec2.by_value, QueryFilter.by_value, :pointer, :pointer], TreeStats.by_value], [:World_CastMover, :b2World_CastMover, [WorldId.by_value, :pointer, Vec2.by_value, QueryFilter.by_value], :float], [:World_CollideMover, :b2World_CollideMover, [WorldId.by_value, :pointer, QueryFilter.by_value, :pointer, :pointer], :void], [:World_EnableSleeping, :b2World_EnableSleeping, [WorldId.by_value, :bool], :void], [:World_IsSleepingEnabled, :b2World_IsSleepingEnabled, [WorldId.by_value], :bool], [:World_EnableContinuous, :b2World_EnableContinuous, [WorldId.by_value, :bool], :void], [:World_IsContinuousEnabled, :b2World_IsContinuousEnabled, [WorldId.by_value], :bool], [:World_SetRestitutionThreshold, :b2World_SetRestitutionThreshold, [WorldId.by_value, :float], :void], [:World_GetRestitutionThreshold, :b2World_GetRestitutionThreshold, [WorldId.by_value], :float], [:World_SetHitEventThreshold, :b2World_SetHitEventThreshold, [WorldId.by_value, :float], :void], [:World_GetHitEventThreshold, :b2World_GetHitEventThreshold, [WorldId.by_value], :float], [:World_SetCustomFilterCallback, :b2World_SetCustomFilterCallback, [WorldId.by_value, :pointer, :pointer], :void], [:World_SetPreSolveCallback, :b2World_SetPreSolveCallback, [WorldId.by_value, :pointer, :pointer], :void], [:World_SetGravity, :b2World_SetGravity, [WorldId.by_value, Vec2.by_value], :void], [:World_GetGravity, :b2World_GetGravity, [WorldId.by_value], Vec2.by_value], [:World_Explode, :b2World_Explode, [WorldId.by_value, :pointer], :void], [:World_SetContactTuning, :b2World_SetContactTuning, [WorldId.by_value, :float, :float, :float], :void], [:World_SetMaximumLinearSpeed, :b2World_SetMaximumLinearSpeed, [WorldId.by_value, :float], :void], [:World_GetMaximumLinearSpeed, :b2World_GetMaximumLinearSpeed, [WorldId.by_value], :float], [:World_EnableWarmStarting, :b2World_EnableWarmStarting, [WorldId.by_value, :bool], :void], [:World_IsWarmStartingEnabled, :b2World_IsWarmStartingEnabled, [WorldId.by_value], :bool], [:World_GetAwakeBodyCount, :b2World_GetAwakeBodyCount, [WorldId.by_value], :int], [:World_GetProfile, :b2World_GetProfile, [WorldId.by_value], Profile.by_value], [:World_GetCounters, :b2World_GetCounters, [WorldId.by_value], Counters.by_value], [:World_SetUserData, :b2World_SetUserData, [WorldId.by_value, :pointer], :void], [:World_GetUserData, :b2World_GetUserData, [WorldId.by_value], :pointer], [:World_SetFrictionCallback, :b2World_SetFrictionCallback, [WorldId.by_value, :pointer], :void], [:World_SetRestitutionCallback, :b2World_SetRestitutionCallback, [WorldId.by_value, :pointer], :void], [:World_DumpMemoryStats, :b2World_DumpMemoryStats, [WorldId.by_value], :void], [:World_RebuildStaticTree, :b2World_RebuildStaticTree, [WorldId.by_value], :void], [:World_EnableSpeculative, :b2World_EnableSpeculative, [WorldId.by_value, :bool], :void], [:CreateBody, :b2CreateBody, [WorldId.by_value, :pointer], BodyId.by_value], [:DestroyBody, :b2DestroyBody, [BodyId.by_value], :void], [:Body_IsValid, :b2Body_IsValid, [BodyId.by_value], :bool], [:Body_GetType, :b2Body_GetType, [BodyId.by_value], :int], [:Body_SetType, :b2Body_SetType, [BodyId.by_value, :int], :void], [:Body_SetName, :b2Body_SetName, [BodyId.by_value, :pointer], :void], [:Body_GetName, :b2Body_GetName, [BodyId.by_value], :pointer], [:Body_SetUserData, :b2Body_SetUserData, [BodyId.by_value, :pointer], :void], [:Body_GetUserData, :b2Body_GetUserData, [BodyId.by_value], :pointer], [:Body_GetPosition, :b2Body_GetPosition, [BodyId.by_value], Vec2.by_value], [:Body_GetRotation, :b2Body_GetRotation, [BodyId.by_value], Rot.by_value], [:Body_GetTransform, :b2Body_GetTransform, [BodyId.by_value], Transform.by_value], [:Body_SetTransform, :b2Body_SetTransform, [BodyId.by_value, Vec2.by_value, Rot.by_value], :void], [:Body_GetLocalPoint, :b2Body_GetLocalPoint, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_GetWorldPoint, :b2Body_GetWorldPoint, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_GetLocalVector, :b2Body_GetLocalVector, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_GetWorldVector, :b2Body_GetWorldVector, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_GetLinearVelocity, :b2Body_GetLinearVelocity, [BodyId.by_value], Vec2.by_value], [:Body_GetAngularVelocity, :b2Body_GetAngularVelocity, [BodyId.by_value], :float], [:Body_SetLinearVelocity, :b2Body_SetLinearVelocity, [BodyId.by_value, Vec2.by_value], :void], [:Body_SetAngularVelocity, :b2Body_SetAngularVelocity, [BodyId.by_value, :float], :void], [:Body_SetTargetTransform, :b2Body_SetTargetTransform, [BodyId.by_value, Transform.by_value, :float], :void], [:Body_GetLocalPointVelocity, :b2Body_GetLocalPointVelocity, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_GetWorldPointVelocity, :b2Body_GetWorldPointVelocity, [BodyId.by_value, Vec2.by_value], Vec2.by_value], [:Body_ApplyForce, :b2Body_ApplyForce, [BodyId.by_value, Vec2.by_value, Vec2.by_value, :bool], :void], [:Body_ApplyForceToCenter, :b2Body_ApplyForceToCenter, [BodyId.by_value, Vec2.by_value, :bool], :void], [:Body_ApplyTorque, :b2Body_ApplyTorque, [BodyId.by_value, :float, :bool], :void], [:Body_ApplyLinearImpulse, :b2Body_ApplyLinearImpulse, [BodyId.by_value, Vec2.by_value, Vec2.by_value, :bool], :void], [:Body_ApplyLinearImpulseToCenter, :b2Body_ApplyLinearImpulseToCenter, [BodyId.by_value, Vec2.by_value, :bool], :void], [:Body_ApplyAngularImpulse, :b2Body_ApplyAngularImpulse, [BodyId.by_value, :float, :bool], :void], [:Body_GetMass, :b2Body_GetMass, [BodyId.by_value], :float], [:Body_GetRotationalInertia, :b2Body_GetRotationalInertia, [BodyId.by_value], :float], [:Body_GetLocalCenterOfMass, :b2Body_GetLocalCenterOfMass, [BodyId.by_value], Vec2.by_value], [:Body_GetWorldCenterOfMass, :b2Body_GetWorldCenterOfMass, [BodyId.by_value], Vec2.by_value], [:Body_SetMassData, :b2Body_SetMassData, [BodyId.by_value, MassData.by_value], :void], [:Body_GetMassData, :b2Body_GetMassData, [BodyId.by_value], MassData.by_value], [:Body_ApplyMassFromShapes, :b2Body_ApplyMassFromShapes, [BodyId.by_value], :void], [:Body_SetLinearDamping, :b2Body_SetLinearDamping, [BodyId.by_value, :float], :void], [:Body_GetLinearDamping, :b2Body_GetLinearDamping, [BodyId.by_value], :float], [:Body_SetAngularDamping, :b2Body_SetAngularDamping, [BodyId.by_value, :float], :void], [:Body_GetAngularDamping, :b2Body_GetAngularDamping, [BodyId.by_value], :float], [:Body_SetGravityScale, :b2Body_SetGravityScale, [BodyId.by_value, :float], :void], [:Body_GetGravityScale, :b2Body_GetGravityScale, [BodyId.by_value], :float], [:Body_IsAwake, :b2Body_IsAwake, [BodyId.by_value], :bool], [:Body_SetAwake, :b2Body_SetAwake, [BodyId.by_value, :bool], :void], [:Body_EnableSleep, :b2Body_EnableSleep, [BodyId.by_value, :bool], :void], [:Body_IsSleepEnabled, :b2Body_IsSleepEnabled, [BodyId.by_value], :bool], [:Body_SetSleepThreshold, :b2Body_SetSleepThreshold, [BodyId.by_value, :float], :void], [:Body_GetSleepThreshold, :b2Body_GetSleepThreshold, [BodyId.by_value], :float], [:Body_IsEnabled, :b2Body_IsEnabled, [BodyId.by_value], :bool], [:Body_Disable, :b2Body_Disable, [BodyId.by_value], :void], [:Body_Enable, :b2Body_Enable, [BodyId.by_value], :void], [:Body_SetFixedRotation, :b2Body_SetFixedRotation, [BodyId.by_value, :bool], :void], [:Body_IsFixedRotation, :b2Body_IsFixedRotation, [BodyId.by_value], :bool], [:Body_SetBullet, :b2Body_SetBullet, [BodyId.by_value, :bool], :void], [:Body_IsBullet, :b2Body_IsBullet, [BodyId.by_value], :bool], [:Body_EnableContactEvents, :b2Body_EnableContactEvents, [BodyId.by_value, :bool], :void], [:Body_EnableHitEvents, :b2Body_EnableHitEvents, [BodyId.by_value, :bool], :void], [:Body_GetWorld, :b2Body_GetWorld, [BodyId.by_value], WorldId.by_value], [:Body_GetShapeCount, :b2Body_GetShapeCount, [BodyId.by_value], :int], [:Body_GetShapes, :b2Body_GetShapes, [BodyId.by_value, :pointer, :int], :int], [:Body_GetJointCount, :b2Body_GetJointCount, [BodyId.by_value], :int], [:Body_GetJoints, :b2Body_GetJoints, [BodyId.by_value, :pointer, :int], :int], [:Body_GetContactCapacity, :b2Body_GetContactCapacity, [BodyId.by_value], :int], [:Body_GetContactData, :b2Body_GetContactData, [BodyId.by_value, :pointer, :int], :int], [:Body_ComputeAABB, :b2Body_ComputeAABB, [BodyId.by_value], AABB.by_value], [:CreateCircleShape, :b2CreateCircleShape, [BodyId.by_value, :pointer, :pointer], ShapeId.by_value], [:CreateSegmentShape, :b2CreateSegmentShape, [BodyId.by_value, :pointer, :pointer], ShapeId.by_value], [:CreateCapsuleShape, :b2CreateCapsuleShape, [BodyId.by_value, :pointer, :pointer], ShapeId.by_value], [:CreatePolygonShape, :b2CreatePolygonShape, [BodyId.by_value, :pointer, :pointer], ShapeId.by_value], [:DestroyShape, :b2DestroyShape, [ShapeId.by_value, :bool], :void], [:Shape_IsValid, :b2Shape_IsValid, [ShapeId.by_value], :bool], [:Shape_GetType, :b2Shape_GetType, [ShapeId.by_value], :int], [:Shape_GetBody, :b2Shape_GetBody, [ShapeId.by_value], BodyId.by_value], [:Shape_GetWorld, :b2Shape_GetWorld, [ShapeId.by_value], WorldId.by_value], [:Shape_IsSensor, :b2Shape_IsSensor, [ShapeId.by_value], :bool], [:Shape_SetUserData, :b2Shape_SetUserData, [ShapeId.by_value, :pointer], :void], [:Shape_GetUserData, :b2Shape_GetUserData, [ShapeId.by_value], :pointer], [:Shape_SetDensity, :b2Shape_SetDensity, [ShapeId.by_value, :float, :bool], :void], [:Shape_GetDensity, :b2Shape_GetDensity, [ShapeId.by_value], :float], [:Shape_SetFriction, :b2Shape_SetFriction, [ShapeId.by_value, :float], :void], [:Shape_GetFriction, :b2Shape_GetFriction, [ShapeId.by_value], :float], [:Shape_SetRestitution, :b2Shape_SetRestitution, [ShapeId.by_value, :float], :void], [:Shape_GetRestitution, :b2Shape_GetRestitution, [ShapeId.by_value], :float], [:Shape_SetMaterial, :b2Shape_SetMaterial, [ShapeId.by_value, :int], :void], [:Shape_GetMaterial, :b2Shape_GetMaterial, [ShapeId.by_value], :int], [:Shape_SetSurfaceMaterial, :b2Shape_SetSurfaceMaterial, [ShapeId.by_value, SurfaceMaterial.by_value], :void], [:Shape_GetSurfaceMaterial, :b2Shape_GetSurfaceMaterial, [ShapeId.by_value], SurfaceMaterial.by_value], [:Shape_GetFilter, :b2Shape_GetFilter, [ShapeId.by_value], Filter.by_value], [:Shape_SetFilter, :b2Shape_SetFilter, [ShapeId.by_value, Filter.by_value], :void], [:Shape_EnableSensorEvents, :b2Shape_EnableSensorEvents, [ShapeId.by_value, :bool], :void], [:Shape_AreSensorEventsEnabled, :b2Shape_AreSensorEventsEnabled, [ShapeId.by_value], :bool], [:Shape_EnableContactEvents, :b2Shape_EnableContactEvents, [ShapeId.by_value, :bool], :void], [:Shape_AreContactEventsEnabled, :b2Shape_AreContactEventsEnabled, [ShapeId.by_value], :bool], [:Shape_EnablePreSolveEvents, :b2Shape_EnablePreSolveEvents, [ShapeId.by_value, :bool], :void], [:Shape_ArePreSolveEventsEnabled, :b2Shape_ArePreSolveEventsEnabled, [ShapeId.by_value], :bool], [:Shape_EnableHitEvents, :b2Shape_EnableHitEvents, [ShapeId.by_value, :bool], :void], [:Shape_AreHitEventsEnabled, :b2Shape_AreHitEventsEnabled, [ShapeId.by_value], :bool], [:Shape_TestPoint, :b2Shape_TestPoint, [ShapeId.by_value, Vec2.by_value], :bool], [:Shape_RayCast, :b2Shape_RayCast, [ShapeId.by_value, :pointer], CastOutput.by_value], [:Shape_GetCircle, :b2Shape_GetCircle, [ShapeId.by_value], Circle.by_value], [:Shape_GetSegment, :b2Shape_GetSegment, [ShapeId.by_value], Segment.by_value], [:Shape_GetChainSegment, :b2Shape_GetChainSegment, [ShapeId.by_value], ChainSegment.by_value], [:Shape_GetCapsule, :b2Shape_GetCapsule, [ShapeId.by_value], Capsule.by_value], [:Shape_GetPolygon, :b2Shape_GetPolygon, [ShapeId.by_value], Polygon.by_value], [:Shape_SetCircle, :b2Shape_SetCircle, [ShapeId.by_value, :pointer], :void], [:Shape_SetCapsule, :b2Shape_SetCapsule, [ShapeId.by_value, :pointer], :void], [:Shape_SetSegment, :b2Shape_SetSegment, [ShapeId.by_value, :pointer], :void], [:Shape_SetPolygon, :b2Shape_SetPolygon, [ShapeId.by_value, :pointer], :void], [:Shape_GetParentChain, :b2Shape_GetParentChain, [ShapeId.by_value], ChainId.by_value], [:Shape_GetContactCapacity, :b2Shape_GetContactCapacity, [ShapeId.by_value], :int], [:Shape_GetContactData, :b2Shape_GetContactData, [ShapeId.by_value, :pointer, :int], :int], [:Shape_GetSensorCapacity, :b2Shape_GetSensorCapacity, [ShapeId.by_value], :int], [:Shape_GetSensorOverlaps, :b2Shape_GetSensorOverlaps, [ShapeId.by_value, :pointer, :int], :int], [:Shape_GetAABB, :b2Shape_GetAABB, [ShapeId.by_value], AABB.by_value], [:Shape_GetMassData, :b2Shape_GetMassData, [ShapeId.by_value], MassData.by_value], [:Shape_GetClosestPoint, :b2Shape_GetClosestPoint, [ShapeId.by_value, Vec2.by_value], Vec2.by_value], [:CreateChain, :b2CreateChain, [BodyId.by_value, :pointer], ChainId.by_value], [:DestroyChain, :b2DestroyChain, [ChainId.by_value], :void], [:Chain_GetWorld, :b2Chain_GetWorld, [ChainId.by_value], WorldId.by_value], [:Chain_GetSegmentCount, :b2Chain_GetSegmentCount, [ChainId.by_value], :int], [:Chain_GetSegments, :b2Chain_GetSegments, [ChainId.by_value, :pointer, :int], :int], [:Chain_SetFriction, :b2Chain_SetFriction, [ChainId.by_value, :float], :void], [:Chain_GetFriction, :b2Chain_GetFriction, [ChainId.by_value], :float], [:Chain_SetRestitution, :b2Chain_SetRestitution, [ChainId.by_value, :float], :void], [:Chain_GetRestitution, :b2Chain_GetRestitution, [ChainId.by_value], :float], [:Chain_SetMaterial, :b2Chain_SetMaterial, [ChainId.by_value, :int], :void], [:Chain_GetMaterial, :b2Chain_GetMaterial, [ChainId.by_value], :int], [:Chain_IsValid, :b2Chain_IsValid, [ChainId.by_value], :bool], [:DestroyJoint, :b2DestroyJoint, [JointId.by_value], :void], [:Joint_IsValid, :b2Joint_IsValid, [JointId.by_value], :bool], [:Joint_GetType, :b2Joint_GetType, [JointId.by_value], :int], [:Joint_GetBodyA, :b2Joint_GetBodyA, [JointId.by_value], BodyId.by_value], [:Joint_GetBodyB, :b2Joint_GetBodyB, [JointId.by_value], BodyId.by_value], [:Joint_GetWorld, :b2Joint_GetWorld, [JointId.by_value], WorldId.by_value], [:Joint_SetLocalFrameA, :b2Joint_SetLocalFrameA, [JointId.by_value, Transform.by_value], :void], [:Joint_GetLocalFrameA, :b2Joint_GetLocalFrameA, [JointId.by_value], Transform.by_value], [:Joint_SetLocalFrameB, :b2Joint_SetLocalFrameB, [JointId.by_value, Transform.by_value], :void], [:Joint_GetLocalFrameB, :b2Joint_GetLocalFrameB, [JointId.by_value], Transform.by_value], [:Joint_SetCollideConnected, :b2Joint_SetCollideConnected, [JointId.by_value, :bool], :void], [:Joint_GetCollideConnected, :b2Joint_GetCollideConnected, [JointId.by_value], :bool], [:Joint_SetUserData, :b2Joint_SetUserData, [JointId.by_value, :pointer], :void], [:Joint_GetUserData, :b2Joint_GetUserData, [JointId.by_value], :pointer], [:Joint_WakeBodies, :b2Joint_WakeBodies, [JointId.by_value], :void], [:Joint_GetConstraintForce, :b2Joint_GetConstraintForce, [JointId.by_value], Vec2.by_value], [:Joint_GetConstraintTorque, :b2Joint_GetConstraintTorque, [JointId.by_value], :float], [:Joint_GetLinearSeparation, :b2Joint_GetLinearSeparation, [JointId.by_value], :float], [:Joint_GetAngularSeparation, :b2Joint_GetAngularSeparation, [JointId.by_value], :float], [:Joint_GetConstraintTuning, :b2Joint_GetConstraintTuning, [JointId.by_value, :pointer, :pointer], :void], [:Joint_SetConstraintTuning, :b2Joint_SetConstraintTuning, [JointId.by_value, :float, :float], :void], [:CreateDistanceJoint, :b2CreateDistanceJoint, [WorldId.by_value, :pointer], JointId.by_value], [:DistanceJoint_SetLength, :b2DistanceJoint_SetLength, [JointId.by_value, :float], :void], [:DistanceJoint_GetLength, :b2DistanceJoint_GetLength, [JointId.by_value], :float], [:DistanceJoint_EnableSpring, :b2DistanceJoint_EnableSpring, [JointId.by_value, :bool], :void], [:DistanceJoint_IsSpringEnabled, :b2DistanceJoint_IsSpringEnabled, [JointId.by_value], :bool], [:DistanceJoint_SetSpringHertz, :b2DistanceJoint_SetSpringHertz, [JointId.by_value, :float], :void], [:DistanceJoint_SetSpringDampingRatio, :b2DistanceJoint_SetSpringDampingRatio, [JointId.by_value, :float], :void], [:DistanceJoint_GetSpringHertz, :b2DistanceJoint_GetSpringHertz, [JointId.by_value], :float], [:DistanceJoint_GetSpringDampingRatio, :b2DistanceJoint_GetSpringDampingRatio, [JointId.by_value], :float], [:DistanceJoint_EnableLimit, :b2DistanceJoint_EnableLimit, [JointId.by_value, :bool], :void], [:DistanceJoint_IsLimitEnabled, :b2DistanceJoint_IsLimitEnabled, [JointId.by_value], :bool], [:DistanceJoint_SetLengthRange, :b2DistanceJoint_SetLengthRange, [JointId.by_value, :float, :float], :void], [:DistanceJoint_GetMinLength, :b2DistanceJoint_GetMinLength, [JointId.by_value], :float], [:DistanceJoint_GetMaxLength, :b2DistanceJoint_GetMaxLength, [JointId.by_value], :float], [:DistanceJoint_GetCurrentLength, :b2DistanceJoint_GetCurrentLength, [JointId.by_value], :float], [:DistanceJoint_EnableMotor, :b2DistanceJoint_EnableMotor, [JointId.by_value, :bool], :void], [:DistanceJoint_IsMotorEnabled, :b2DistanceJoint_IsMotorEnabled, [JointId.by_value], :bool], [:DistanceJoint_SetMotorSpeed, :b2DistanceJoint_SetMotorSpeed, [JointId.by_value, :float], :void], [:DistanceJoint_GetMotorSpeed, :b2DistanceJoint_GetMotorSpeed, [JointId.by_value], :float], [:DistanceJoint_SetMaxMotorForce, :b2DistanceJoint_SetMaxMotorForce, [JointId.by_value, :float], :void], [:DistanceJoint_GetMaxMotorForce, :b2DistanceJoint_GetMaxMotorForce, [JointId.by_value], :float], [:DistanceJoint_GetMotorForce, :b2DistanceJoint_GetMotorForce, [JointId.by_value], :float], [:CreateMotorJoint, :b2CreateMotorJoint, [WorldId.by_value, :pointer], JointId.by_value], [:MotorJoint_SetMaxForce, :b2MotorJoint_SetMaxForce, [JointId.by_value, :float], :void], [:MotorJoint_GetMaxForce, :b2MotorJoint_GetMaxForce, [JointId.by_value], :float], [:MotorJoint_SetMaxTorque, :b2MotorJoint_SetMaxTorque, [JointId.by_value, :float], :void], [:MotorJoint_GetMaxTorque, :b2MotorJoint_GetMaxTorque, [JointId.by_value], :float], [:MotorJoint_SetCorrectionFactor, :b2MotorJoint_SetCorrectionFactor, [JointId.by_value, :float], :void], [:MotorJoint_GetCorrectionFactor, :b2MotorJoint_GetCorrectionFactor, [JointId.by_value], :float], [:CreateMouseJoint, :b2CreateMouseJoint, [WorldId.by_value, :pointer], JointId.by_value], [:MouseJoint_SetSpringHertz, :b2MouseJoint_SetSpringHertz, [JointId.by_value, :float], :void], [:MouseJoint_GetSpringHertz, :b2MouseJoint_GetSpringHertz, [JointId.by_value], :float], [:MouseJoint_SetSpringDampingRatio, :b2MouseJoint_SetSpringDampingRatio, [JointId.by_value, :float], :void], [:MouseJoint_GetSpringDampingRatio, :b2MouseJoint_GetSpringDampingRatio, [JointId.by_value], :float], [:MouseJoint_SetMaxForce, :b2MouseJoint_SetMaxForce, [JointId.by_value, :float], :void], [:MouseJoint_GetMaxForce, :b2MouseJoint_GetMaxForce, [JointId.by_value], :float], [:CreateFilterJoint, :b2CreateFilterJoint, [WorldId.by_value, :pointer], JointId.by_value], [:CreatePrismaticJoint, :b2CreatePrismaticJoint, [WorldId.by_value, :pointer], JointId.by_value], [:PrismaticJoint_EnableSpring, :b2PrismaticJoint_EnableSpring, [JointId.by_value, :bool], :void], [:PrismaticJoint_IsSpringEnabled, :b2PrismaticJoint_IsSpringEnabled, [JointId.by_value], :bool], [:PrismaticJoint_SetSpringHertz, :b2PrismaticJoint_SetSpringHertz, [JointId.by_value, :float], :void], [:PrismaticJoint_GetSpringHertz, :b2PrismaticJoint_GetSpringHertz, [JointId.by_value], :float], [:PrismaticJoint_SetSpringDampingRatio, :b2PrismaticJoint_SetSpringDampingRatio, [JointId.by_value, :float], :void], [:PrismaticJoint_GetSpringDampingRatio, :b2PrismaticJoint_GetSpringDampingRatio, [JointId.by_value], :float], [:PrismaticJoint_SetTargetTranslation, :b2PrismaticJoint_SetTargetTranslation, [JointId.by_value, :float], :void], [:PrismaticJoint_GetTargetTranslation, :b2PrismaticJoint_GetTargetTranslation, [JointId.by_value], :float], [:PrismaticJoint_EnableLimit, :b2PrismaticJoint_EnableLimit, [JointId.by_value, :bool], :void], [:PrismaticJoint_IsLimitEnabled, :b2PrismaticJoint_IsLimitEnabled, [JointId.by_value], :bool], [:PrismaticJoint_GetLowerLimit, :b2PrismaticJoint_GetLowerLimit, [JointId.by_value], :float], [:PrismaticJoint_GetUpperLimit, :b2PrismaticJoint_GetUpperLimit, [JointId.by_value], :float], [:PrismaticJoint_SetLimits, :b2PrismaticJoint_SetLimits, [JointId.by_value, :float, :float], :void], [:PrismaticJoint_EnableMotor, :b2PrismaticJoint_EnableMotor, [JointId.by_value, :bool], :void], [:PrismaticJoint_IsMotorEnabled, :b2PrismaticJoint_IsMotorEnabled, [JointId.by_value], :bool], [:PrismaticJoint_SetMotorSpeed, :b2PrismaticJoint_SetMotorSpeed, [JointId.by_value, :float], :void], [:PrismaticJoint_GetMotorSpeed, :b2PrismaticJoint_GetMotorSpeed, [JointId.by_value], :float], [:PrismaticJoint_SetMaxMotorForce, :b2PrismaticJoint_SetMaxMotorForce, [JointId.by_value, :float], :void], [:PrismaticJoint_GetMaxMotorForce, :b2PrismaticJoint_GetMaxMotorForce, [JointId.by_value], :float], [:PrismaticJoint_GetMotorForce, :b2PrismaticJoint_GetMotorForce, [JointId.by_value], :float], [:PrismaticJoint_GetTranslation, :b2PrismaticJoint_GetTranslation, [JointId.by_value], :float], [:PrismaticJoint_GetSpeed, :b2PrismaticJoint_GetSpeed, [JointId.by_value], :float], [:CreateRevoluteJoint, :b2CreateRevoluteJoint, [WorldId.by_value, :pointer], JointId.by_value], [:RevoluteJoint_EnableSpring, :b2RevoluteJoint_EnableSpring, [JointId.by_value, :bool], :void], [:RevoluteJoint_IsSpringEnabled, :b2RevoluteJoint_IsSpringEnabled, [JointId.by_value], :bool], [:RevoluteJoint_SetSpringHertz, :b2RevoluteJoint_SetSpringHertz, [JointId.by_value, :float], :void], [:RevoluteJoint_GetSpringHertz, :b2RevoluteJoint_GetSpringHertz, [JointId.by_value], :float], [:RevoluteJoint_SetSpringDampingRatio, :b2RevoluteJoint_SetSpringDampingRatio, [JointId.by_value, :float], :void], [:RevoluteJoint_GetSpringDampingRatio, :b2RevoluteJoint_GetSpringDampingRatio, [JointId.by_value], :float], [:RevoluteJoint_SetTargetAngle, :b2RevoluteJoint_SetTargetAngle, [JointId.by_value, :float], :void], [:RevoluteJoint_GetTargetAngle, :b2RevoluteJoint_GetTargetAngle, [JointId.by_value], :float], [:RevoluteJoint_GetAngle, :b2RevoluteJoint_GetAngle, [JointId.by_value], :float], [:RevoluteJoint_EnableLimit, :b2RevoluteJoint_EnableLimit, [JointId.by_value, :bool], :void], [:RevoluteJoint_IsLimitEnabled, :b2RevoluteJoint_IsLimitEnabled, [JointId.by_value], :bool], [:RevoluteJoint_GetLowerLimit, :b2RevoluteJoint_GetLowerLimit, [JointId.by_value], :float], [:RevoluteJoint_GetUpperLimit, :b2RevoluteJoint_GetUpperLimit, [JointId.by_value], :float], [:RevoluteJoint_SetLimits, :b2RevoluteJoint_SetLimits, [JointId.by_value, :float, :float], :void], [:RevoluteJoint_EnableMotor, :b2RevoluteJoint_EnableMotor, [JointId.by_value, :bool], :void], [:RevoluteJoint_IsMotorEnabled, :b2RevoluteJoint_IsMotorEnabled, [JointId.by_value], :bool], [:RevoluteJoint_SetMotorSpeed, :b2RevoluteJoint_SetMotorSpeed, [JointId.by_value, :float], :void], [:RevoluteJoint_GetMotorSpeed, :b2RevoluteJoint_GetMotorSpeed, [JointId.by_value], :float], [:RevoluteJoint_GetMotorTorque, :b2RevoluteJoint_GetMotorTorque, [JointId.by_value], :float], [:RevoluteJoint_SetMaxMotorTorque, :b2RevoluteJoint_SetMaxMotorTorque, [JointId.by_value, :float], :void], [:RevoluteJoint_GetMaxMotorTorque, :b2RevoluteJoint_GetMaxMotorTorque, [JointId.by_value], :float], [:CreateWeldJoint, :b2CreateWeldJoint, [WorldId.by_value, :pointer], JointId.by_value], [:WeldJoint_SetLinearHertz, :b2WeldJoint_SetLinearHertz, [JointId.by_value, :float], :void], [:WeldJoint_GetLinearHertz, :b2WeldJoint_GetLinearHertz, [JointId.by_value], :float], [:WeldJoint_SetLinearDampingRatio, :b2WeldJoint_SetLinearDampingRatio, [JointId.by_value, :float], :void], [:WeldJoint_GetLinearDampingRatio, :b2WeldJoint_GetLinearDampingRatio, [JointId.by_value], :float], [:WeldJoint_SetAngularHertz, :b2WeldJoint_SetAngularHertz, [JointId.by_value, :float], :void], [:WeldJoint_GetAngularHertz, :b2WeldJoint_GetAngularHertz, [JointId.by_value], :float], [:WeldJoint_SetAngularDampingRatio, :b2WeldJoint_SetAngularDampingRatio, [JointId.by_value, :float], :void], [:WeldJoint_GetAngularDampingRatio, :b2WeldJoint_GetAngularDampingRatio, [JointId.by_value], :float], [:CreateWheelJoint, :b2CreateWheelJoint, [WorldId.by_value, :pointer], JointId.by_value], [:WheelJoint_EnableSpring, :b2WheelJoint_EnableSpring, [JointId.by_value, :bool], :void], [:WheelJoint_IsSpringEnabled, :b2WheelJoint_IsSpringEnabled, [JointId.by_value], :bool], [:WheelJoint_SetSpringHertz, :b2WheelJoint_SetSpringHertz, [JointId.by_value, :float], :void], [:WheelJoint_GetSpringHertz, :b2WheelJoint_GetSpringHertz, [JointId.by_value], :float], [:WheelJoint_SetSpringDampingRatio, :b2WheelJoint_SetSpringDampingRatio, [JointId.by_value, :float], :void], [:WheelJoint_GetSpringDampingRatio, :b2WheelJoint_GetSpringDampingRatio, [JointId.by_value], :float], [:WheelJoint_EnableLimit, :b2WheelJoint_EnableLimit, [JointId.by_value, :bool], :void], [:WheelJoint_IsLimitEnabled, :b2WheelJoint_IsLimitEnabled, [JointId.by_value], :bool], [:WheelJoint_GetLowerLimit, :b2WheelJoint_GetLowerLimit, [JointId.by_value], :float], [:WheelJoint_GetUpperLimit, :b2WheelJoint_GetUpperLimit, [JointId.by_value], :float], [:WheelJoint_SetLimits, :b2WheelJoint_SetLimits, [JointId.by_value, :float, :float], :void], [:WheelJoint_EnableMotor, :b2WheelJoint_EnableMotor, [JointId.by_value, :bool], :void], [:WheelJoint_IsMotorEnabled, :b2WheelJoint_IsMotorEnabled, [JointId.by_value], :bool], [:WheelJoint_SetMotorSpeed, :b2WheelJoint_SetMotorSpeed, [JointId.by_value, :float], :void], [:WheelJoint_GetMotorSpeed, :b2WheelJoint_GetMotorSpeed, [JointId.by_value], :float], [:WheelJoint_SetMaxMotorTorque, :b2WheelJoint_SetMaxMotorTorque, [JointId.by_value, :float], :void], [:WheelJoint_GetMaxMotorTorque, :b2WheelJoint_GetMaxMotorTorque, [JointId.by_value], :float], [:WheelJoint_GetMotorTorque, :b2WheelJoint_GetMotorTorque, [JointId.by_value], :float], [:Contact_IsValid, :b2Contact_IsValid, [ContactId.by_value], :bool], [:Contact_GetManifold, :b2Contact_GetManifold, [ContactId.by_value], Manifold.by_value], [:Contact_GetShapeIds, :b2Contact_GetShapeIds, [ContactId.by_value, :pointer, :pointer], :void], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_math_functions_symbols(method_naming: :original) ⇒ Object
Function
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/box2d_math_functions.rb', line 144 def self.setup_math_functions_symbols(method_naming: :original) entries = [ [:IsValidFloat, :b2IsValidFloat, [:float], :bool], [:IsValidVec2, :b2IsValidVec2, [Vec2.by_value], :bool], [:IsValidRotation, :b2IsValidRotation, [Rot.by_value], :bool], [:IsValidTransform, :b2IsValidTransform, [Transform.by_value], :bool], [:IsValidAABB, :b2IsValidAABB, [AABB.by_value], :bool], [:IsValidPlane, :b2IsValidPlane, [Plane.by_value], :bool], [:Atan2, :b2Atan2, [:float, :float], :float], [:ComputeCosSin, :b2ComputeCosSin, [:float], CosSin.by_value], [:ComputeRotationBetweenUnitVectors, :b2ComputeRotationBetweenUnitVectors, [Vec2.by_value, Vec2.by_value], Rot.by_value], [:SetLengthUnitsPerMeter, :b2SetLengthUnitsPerMeter, [:float], :void], [:GetLengthUnitsPerMeter, :b2GetLengthUnitsPerMeter, [], :float], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_math_inline_functions_symbols(method_naming: :original) ⇒ Object
Function
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/box2d_math_inline_functions.rb', line 25 def self.setup_math_inline_functions_symbols(method_naming: :original) entries = [ [:MinInt, :b2MinInt, [:int, :int], :int], [:MaxInt, :b2MaxInt, [:int, :int], :int], [:AbsInt, :b2AbsInt, [:int], :int], [:ClampInt, :b2ClampInt, [:int, :int, :int], :int], [:MinFloat, :b2MinFloat, [:float, :float], :float], [:MaxFloat, :b2MaxFloat, [:float, :float], :float], [:AbsFloat, :b2AbsFloat, [:float], :float], [:ClampFloat, :b2ClampFloat, [:float, :float, :float], :float], [:Dot, :b2Dot, [Vec2.by_value, Vec2.by_value], :float], [:Cross, :b2Cross, [Vec2.by_value, Vec2.by_value], :float], [:CrossVS, :b2CrossVS, [Vec2.by_value, :float], Vec2.by_value], [:CrossSV, :b2CrossSV, [:float, Vec2.by_value], Vec2.by_value], [:LeftPerp, :b2LeftPerp, [Vec2.by_value], Vec2.by_value], [:RightPerp, :b2RightPerp, [Vec2.by_value], Vec2.by_value], [:Add, :b2Add, [Vec2.by_value, Vec2.by_value], Vec2.by_value], [:Sub, :b2Sub, [Vec2.by_value, Vec2.by_value], Vec2.by_value], [:Neg, :b2Neg, [Vec2.by_value], Vec2.by_value], [:Lerp, :b2Lerp, [Vec2.by_value, Vec2.by_value, :float], Vec2.by_value], [:Mul, :b2Mul, [Vec2.by_value, Vec2.by_value], Vec2.by_value], [:MulSV, :b2MulSV, [:float, Vec2.by_value], Vec2.by_value], [:MulAdd, :b2MulAdd, [Vec2.by_value, :float, Vec2.by_value], Vec2.by_value], [:MulSub, :b2MulSub, [Vec2.by_value, :float, Vec2.by_value], Vec2.by_value], [:Abs, :b2Abs, [Vec2.by_value], Vec2.by_value], [:Min, :b2Min, [Vec2.by_value, Vec2.by_value], Vec2.by_value], [:Max, :b2Max, [Vec2.by_value, Vec2.by_value], Vec2.by_value], [:Clamp, :b2Clamp, [Vec2.by_value, Vec2.by_value, Vec2.by_value], Vec2.by_value], [:Length, :b2Length, [Vec2.by_value], :float], [:Distance, :b2Distance, [Vec2.by_value, Vec2.by_value], :float], [:Normalize, :b2Normalize, [Vec2.by_value], Vec2.by_value], [:IsNormalized, :b2IsNormalized, [Vec2.by_value], :bool], [:GetLengthAndNormalize, :b2GetLengthAndNormalize, [:pointer, Vec2.by_value], Vec2.by_value], [:NormalizeRot, :b2NormalizeRot, [Rot.by_value], Rot.by_value], [:IntegrateRotation, :b2IntegrateRotation, [Rot.by_value, :float], Rot.by_value], [:LengthSquared, :b2LengthSquared, [Vec2.by_value], :float], [:DistanceSquared, :b2DistanceSquared, [Vec2.by_value, Vec2.by_value], :float], [:MakeRot, :b2MakeRot, [:float], Rot.by_value], [:MakeRotFromUnitVector, :b2MakeRotFromUnitVector, [Vec2.by_value], Rot.by_value], [:IsNormalizedRot, :b2IsNormalizedRot, [Rot.by_value], :bool], [:NLerp, :b2NLerp, [Rot.by_value, Rot.by_value, :float], Rot.by_value], [:ComputeAngularVelocity, :b2ComputeAngularVelocity, [Rot.by_value, Rot.by_value, :float], :float], [:Rot_GetAngle, :b2Rot_GetAngle, [Rot.by_value], :float], [:Rot_GetXAxis, :b2Rot_GetXAxis, [Rot.by_value], Vec2.by_value], [:Rot_GetYAxis, :b2Rot_GetYAxis, [Rot.by_value], Vec2.by_value], [:MulRot, :b2MulRot, [Rot.by_value, Rot.by_value], Rot.by_value], [:InvMulRot, :b2InvMulRot, [Rot.by_value, Rot.by_value], Rot.by_value], [:RelativeAngle, :b2RelativeAngle, [Rot.by_value, Rot.by_value], :float], [:UnwindAngle, :b2UnwindAngle, [:float], :float], [:RotateVector, :b2RotateVector, [Rot.by_value, Vec2.by_value], Vec2.by_value], [:InvRotateVector, :b2InvRotateVector, [Rot.by_value, Vec2.by_value], Vec2.by_value], [:TransformPoint, :b2TransformPoint, [Transform.by_value, Vec2.by_value], Vec2.by_value], [:InvTransformPoint, :b2InvTransformPoint, [Transform.by_value, Vec2.by_value], Vec2.by_value], [:MulTransforms, :b2MulTransforms, [Transform.by_value, Transform.by_value], Transform.by_value], [:InvMulTransforms, :b2InvMulTransforms, [Transform.by_value, Transform.by_value], Transform.by_value], [:MulMV, :b2MulMV, [Mat22.by_value, Vec2.by_value], Vec2.by_value], [:GetInverse22, :b2GetInverse22, [Mat22.by_value], Mat22.by_value], [:Solve22, :b2Solve22, [Mat22.by_value, Vec2.by_value], Vec2.by_value], [:AABB_Contains, :b2AABB_Contains, [AABB.by_value, AABB.by_value], :bool], [:AABB_Center, :b2AABB_Center, [AABB.by_value], Vec2.by_value], [:AABB_Extents, :b2AABB_Extents, [AABB.by_value], Vec2.by_value], [:AABB_Union, :b2AABB_Union, [AABB.by_value, AABB.by_value], AABB.by_value], [:AABB_Overlaps, :b2AABB_Overlaps, [AABB.by_value, AABB.by_value], :bool], [:MakeAABB, :b2MakeAABB, [:pointer, :int, :float], AABB.by_value], [:PlaneSeparation, :b2PlaneSeparation, [Plane.by_value, Vec2.by_value], :float], [:SpringDamper, :b2SpringDamper, [:float, :float, :float, :float, :float], :float], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |
.setup_symbols(method_naming: :original) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/box2d.rb', line 37 def self.setup_symbols(method_naming: :original) setup_base_symbols(method_naming: method_naming) setup_math_functions_symbols(method_naming: method_naming) setup_math_inline_functions_symbols(method_naming: method_naming) setup_id_symbols(method_naming: method_naming) setup_id_inline_symbols(method_naming: method_naming) setup_collision_symbols(method_naming: method_naming) setup_types_symbols(method_naming: method_naming) setup_main_symbols(method_naming: method_naming) end |
.setup_types_symbols(method_naming: :original) ⇒ Object
Function
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
# File 'lib/box2d_types.rb', line 1504 def self.setup_types_symbols(method_naming: :original) entries = [ [:DefaultWorldDef, :b2DefaultWorldDef, [], WorldDef.by_value], [:DefaultBodyDef, :b2DefaultBodyDef, [], BodyDef.by_value], [:DefaultFilter, :b2DefaultFilter, [], Filter.by_value], [:DefaultQueryFilter, :b2DefaultQueryFilter, [], QueryFilter.by_value], [:DefaultSurfaceMaterial, :b2DefaultSurfaceMaterial, [], SurfaceMaterial.by_value], [:DefaultShapeDef, :b2DefaultShapeDef, [], ShapeDef.by_value], [:DefaultChainDef, :b2DefaultChainDef, [], ChainDef.by_value], [:DefaultDistanceJointDef, :b2DefaultDistanceJointDef, [], DistanceJointDef.by_value], [:DefaultMotorJointDef, :b2DefaultMotorJointDef, [], MotorJointDef.by_value], [:DefaultMouseJointDef, :b2DefaultMouseJointDef, [], MouseJointDef.by_value], [:DefaultFilterJointDef, :b2DefaultFilterJointDef, [], FilterJointDef.by_value], [:DefaultPrismaticJointDef, :b2DefaultPrismaticJointDef, [], PrismaticJointDef.by_value], [:DefaultRevoluteJointDef, :b2DefaultRevoluteJointDef, [], RevoluteJointDef.by_value], [:DefaultWeldJointDef, :b2DefaultWeldJointDef, [], WeldJointDef.by_value], [:DefaultWheelJointDef, :b2DefaultWheelJointDef, [], WheelJointDef.by_value], [:DefaultExplosionDef, :b2DefaultExplosionDef, [], ExplosionDef.by_value], [:DefaultDebugDraw, :b2DefaultDebugDraw, [], DebugDraw.by_value], ] entries.each do |entry| api_name = if method_naming == :snake_case 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 snake_case_name.gsub!('vector_3', 'vector3_') if snake_case_name.include?('vector_3') snake_case_name.gsub!('vector_2', 'vector2_') if snake_case_name.include?('vector_2') snake_case_name.chop! if snake_case_name.end_with?('_') snake_case_name.to_sym else entry[0] end attach_function api_name, entry[1], entry[2], entry[3] rescue FFI::NotFoundError => e warn "[Warning] Failed to import #{entry[0]} (#{e})." end end |