reflexion 0.1.7 → 0.1.8
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 +4 -4
- data/.doc/ext/reflex/application.cpp +5 -5
- data/.doc/ext/reflex/body.cpp +167 -0
- data/.doc/ext/reflex/capture_event.cpp +4 -4
- data/.doc/ext/reflex/draw_event.cpp +4 -4
- data/.doc/ext/reflex/event.cpp +4 -4
- data/.doc/ext/reflex/fixture.cpp +101 -0
- data/.doc/ext/reflex/focus_event.cpp +4 -4
- data/.doc/ext/reflex/frame_event.cpp +4 -4
- data/.doc/ext/reflex/image_view.cpp +22 -5
- data/.doc/ext/reflex/key_event.cpp +4 -4
- data/.doc/ext/reflex/native.cpp +6 -0
- data/.doc/ext/reflex/pointer_event.cpp +4 -4
- data/.doc/ext/reflex/reflex.cpp +2 -3
- data/.doc/ext/reflex/scroll_event.cpp +4 -4
- data/.doc/ext/reflex/selector.cpp +4 -4
- data/.doc/ext/reflex/style.cpp +4 -4
- data/.doc/ext/reflex/style_length.cpp +4 -4
- data/.doc/ext/reflex/style_length2.cpp +4 -4
- data/.doc/ext/reflex/style_length4.cpp +4 -4
- data/.doc/ext/reflex/update_event.cpp +4 -4
- data/.doc/ext/reflex/view.cpp +110 -8
- data/.doc/ext/reflex/wheel_event.cpp +4 -4
- data/.doc/ext/reflex/window.cpp +36 -12
- data/README.md +2 -2
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/ext/reflex/application.cpp +8 -8
- data/ext/reflex/body.cpp +181 -0
- data/ext/reflex/capture_event.cpp +4 -4
- data/ext/reflex/draw_event.cpp +4 -4
- data/ext/reflex/event.cpp +4 -4
- data/ext/reflex/fixture.cpp +108 -0
- data/ext/reflex/focus_event.cpp +4 -4
- data/ext/reflex/frame_event.cpp +4 -4
- data/ext/reflex/image_view.cpp +24 -5
- data/ext/reflex/key_event.cpp +4 -4
- data/ext/reflex/native.cpp +6 -0
- data/ext/reflex/pointer_event.cpp +4 -4
- data/ext/reflex/reflex.cpp +2 -3
- data/ext/reflex/scroll_event.cpp +4 -4
- data/ext/reflex/selector.cpp +4 -4
- data/ext/reflex/style.cpp +4 -4
- data/ext/reflex/style_length.cpp +4 -4
- data/ext/reflex/style_length2.cpp +4 -4
- data/ext/reflex/style_length4.cpp +4 -4
- data/ext/reflex/update_event.cpp +4 -4
- data/ext/reflex/view.cpp +126 -12
- data/ext/reflex/wheel_event.cpp +4 -4
- data/ext/reflex/window.cpp +39 -12
- data/include/reflex/bitmap.h +20 -0
- data/include/reflex/body.h +82 -0
- data/include/reflex/bounds.h +20 -0
- data/include/reflex/color.h +20 -0
- data/include/reflex/color_space.h +20 -0
- data/include/reflex/defs.h +5 -1
- data/include/reflex/event.h +16 -25
- data/include/reflex/fixture.h +116 -0
- data/include/reflex/font.h +20 -0
- data/include/reflex/image.h +20 -0
- data/include/reflex/image_view.h +1 -1
- data/include/reflex/matrix.h +20 -0
- data/include/reflex/painter.h +20 -0
- data/include/reflex/point.h +24 -0
- data/include/reflex/ruby/application.h +6 -0
- data/include/reflex/ruby/body.h +41 -0
- data/include/reflex/ruby/event.h +68 -0
- data/include/reflex/ruby/fixture.h +41 -0
- data/include/reflex/ruby/image_view.h +14 -0
- data/include/reflex/ruby/selector.h +14 -0
- data/include/reflex/ruby/style.h +14 -0
- data/include/reflex/ruby/style_length.h +26 -0
- data/include/reflex/ruby/view.h +43 -39
- data/include/reflex/ruby/window.h +27 -21
- data/include/reflex/ruby.h +2 -0
- data/include/reflex/shader.h +20 -0
- data/include/reflex/style.h +2 -3
- data/include/reflex/texture.h +20 -0
- data/include/reflex/view.h +45 -24
- data/include/reflex/window.h +11 -14
- data/include/reflex.h +3 -0
- data/lib/reflex/application.rb +6 -2
- data/lib/reflex/body.rb +17 -0
- data/lib/reflex/fixture.rb +17 -0
- data/lib/reflex/view.rb +16 -1
- data/lib/reflex/window.rb +13 -1
- data/lib/reflex.rb +2 -0
- data/reflex.gemspec +1 -1
- data/samples/bats.rb +4 -3
- data/samples/checker.rb +4 -3
- data/samples/fans.rb +4 -3
- data/samples/fps.rb +5 -3
- data/samples/grid.rb +5 -4
- data/samples/hello.rb +1 -1
- data/samples/image.rb +3 -2
- data/samples/ios/hello/hello/main.cpp +12 -3
- data/samples/ios/hello/hello.xcodeproj/project.pbxproj +376 -123
- data/samples/key.rb +5 -4
- data/samples/layout.rb +3 -2
- data/samples/model.rb +3 -2
- data/samples/osx/hello/hello/main.cpp +12 -3
- data/samples/osx/hello/hello.xcodeproj/project.pbxproj +375 -120
- data/samples/physics.rb +37 -0
- data/samples/repl.rb +3 -2
- data/samples/shader.rb +4 -4
- data/samples/shapes.rb +4 -4
- data/samples/text.rb +6 -4
- data/samples/tree.rb +5 -4
- data/samples/views.rb +3 -2
- data/samples/visuals.rb +1 -2
- data/src/body.cpp +244 -0
- data/src/event.cpp +18 -18
- data/src/fixture.cpp +108 -0
- data/src/image_view.cpp +1 -1
- data/src/ios/native_window.h +2 -0
- data/src/ios/native_window.mm +18 -1
- data/src/ios/opengl_view.mm +8 -0
- data/src/ios/window.mm +24 -3
- data/src/ios/window_data.h +3 -3
- data/src/osx/native_window.mm +17 -1
- data/src/osx/window.mm +24 -3
- data/src/osx/window_data.h +3 -3
- data/src/physics/Box2D/Box2D.h +68 -0
- data/src/physics/Box2D/Collision/Shapes/b2ChainShape.cpp +193 -0
- data/src/physics/Box2D/Collision/Shapes/b2ChainShape.h +105 -0
- data/src/physics/Box2D/Collision/Shapes/b2CircleShape.cpp +99 -0
- data/src/physics/Box2D/Collision/Shapes/b2CircleShape.h +91 -0
- data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.cpp +138 -0
- data/src/physics/Box2D/Collision/Shapes/b2EdgeShape.h +74 -0
- data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.cpp +467 -0
- data/src/physics/Box2D/Collision/Shapes/b2PolygonShape.h +101 -0
- data/src/physics/Box2D/Collision/Shapes/b2Shape.h +101 -0
- data/src/physics/Box2D/Collision/b2BroadPhase.cpp +119 -0
- data/src/physics/Box2D/Collision/b2BroadPhase.h +257 -0
- data/src/physics/Box2D/Collision/b2CollideCircle.cpp +154 -0
- data/src/physics/Box2D/Collision/b2CollideEdge.cpp +698 -0
- data/src/physics/Box2D/Collision/b2CollidePolygon.cpp +239 -0
- data/src/physics/Box2D/Collision/b2Collision.cpp +252 -0
- data/src/physics/Box2D/Collision/b2Collision.h +277 -0
- data/src/physics/Box2D/Collision/b2Distance.cpp +603 -0
- data/src/physics/Box2D/Collision/b2Distance.h +141 -0
- data/src/physics/Box2D/Collision/b2DynamicTree.cpp +778 -0
- data/src/physics/Box2D/Collision/b2DynamicTree.h +289 -0
- data/src/physics/Box2D/Collision/b2TimeOfImpact.cpp +486 -0
- data/src/physics/Box2D/Collision/b2TimeOfImpact.h +58 -0
- data/src/physics/Box2D/Common/b2BlockAllocator.cpp +215 -0
- data/src/physics/Box2D/Common/b2BlockAllocator.h +62 -0
- data/src/physics/Box2D/Common/b2Draw.cpp +44 -0
- data/src/physics/Box2D/Common/b2Draw.h +86 -0
- data/src/physics/Box2D/Common/b2GrowableStack.h +85 -0
- data/src/physics/Box2D/Common/b2Math.cpp +94 -0
- data/src/physics/Box2D/Common/b2Math.h +720 -0
- data/src/physics/Box2D/Common/b2Settings.cpp +44 -0
- data/src/physics/Box2D/Common/b2Settings.h +151 -0
- data/src/physics/Box2D/Common/b2StackAllocator.cpp +83 -0
- data/src/physics/Box2D/Common/b2StackAllocator.h +60 -0
- data/src/physics/Box2D/Common/b2Timer.cpp +101 -0
- data/src/physics/Box2D/Common/b2Timer.h +50 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.cpp +53 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndCircleContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.cpp +53 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ChainAndPolygonContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.cpp +52 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2CircleContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2Contact.cpp +247 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2Contact.h +349 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.cpp +838 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2ContactSolver.h +95 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.cpp +49 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp +49 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.cpp +49 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonAndCircleContact.h +38 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.cpp +52 -0
- data/src/physics/Box2D/Dynamics/Contacts/b2PolygonContact.h +39 -0
- data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.cpp +260 -0
- data/src/physics/Box2D/Dynamics/Joints/b2DistanceJoint.h +169 -0
- data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.cpp +251 -0
- data/src/physics/Box2D/Dynamics/Joints/b2FrictionJoint.h +119 -0
- data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.cpp +419 -0
- data/src/physics/Box2D/Dynamics/Joints/b2GearJoint.h +125 -0
- data/src/physics/Box2D/Dynamics/Joints/b2Joint.cpp +211 -0
- data/src/physics/Box2D/Dynamics/Joints/b2Joint.h +226 -0
- data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.cpp +304 -0
- data/src/physics/Box2D/Dynamics/Joints/b2MotorJoint.h +133 -0
- data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.cpp +222 -0
- data/src/physics/Box2D/Dynamics/Joints/b2MouseJoint.h +129 -0
- data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.cpp +629 -0
- data/src/physics/Box2D/Dynamics/Joints/b2PrismaticJoint.h +196 -0
- data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.cpp +348 -0
- data/src/physics/Box2D/Dynamics/Joints/b2PulleyJoint.h +152 -0
- data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.cpp +502 -0
- data/src/physics/Box2D/Dynamics/Joints/b2RevoluteJoint.h +204 -0
- data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.cpp +241 -0
- data/src/physics/Box2D/Dynamics/Joints/b2RopeJoint.h +114 -0
- data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.cpp +344 -0
- data/src/physics/Box2D/Dynamics/Joints/b2WeldJoint.h +126 -0
- data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.cpp +419 -0
- data/src/physics/Box2D/Dynamics/Joints/b2WheelJoint.h +210 -0
- data/src/physics/Box2D/Dynamics/b2Body.cpp +549 -0
- data/src/physics/Box2D/Dynamics/b2Body.h +860 -0
- data/src/physics/Box2D/Dynamics/b2ContactManager.cpp +296 -0
- data/src/physics/Box2D/Dynamics/b2ContactManager.h +52 -0
- data/src/physics/Box2D/Dynamics/b2Fixture.cpp +303 -0
- data/src/physics/Box2D/Dynamics/b2Fixture.h +345 -0
- data/src/physics/Box2D/Dynamics/b2Island.cpp +539 -0
- data/src/physics/Box2D/Dynamics/b2Island.h +93 -0
- data/src/physics/Box2D/Dynamics/b2TimeStep.h +70 -0
- data/src/physics/Box2D/Dynamics/b2World.cpp +1339 -0
- data/src/physics/Box2D/Dynamics/b2World.h +354 -0
- data/src/physics/Box2D/Dynamics/b2WorldCallbacks.cpp +36 -0
- data/src/physics/Box2D/Dynamics/b2WorldCallbacks.h +155 -0
- data/src/physics/Box2D/Rope/b2Rope.cpp +259 -0
- data/src/physics/Box2D/Rope/b2Rope.h +115 -0
- data/src/style.cpp +2 -2
- data/src/view.cpp +217 -17
- data/src/window.cpp +25 -15
- data/src/world.cpp +206 -0
- data/src/world.h +96 -0
- data/task/box2d.rake +25 -0
- data/test/test_view.rb +5 -5
- metadata +125 -3
data/samples/physics.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
%w[xot rays reflex]
|
5
|
+
.map {|s| File.expand_path "../../../#{s}/lib", __FILE__}
|
6
|
+
.each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
|
7
|
+
|
8
|
+
require 'reflex'
|
9
|
+
|
10
|
+
|
11
|
+
Reflex.start name: "Physics" do |app|
|
12
|
+
Reflex::Window.show title: app.name, frame: [100, 100, 500, 500] do
|
13
|
+
root.set gravity: Reflex::Point.new(0, 9.8), debug: true
|
14
|
+
|
15
|
+
image = Reflex::Image.new(32, 32).paint do |p, img|
|
16
|
+
p.fill :green
|
17
|
+
p.ellipse img.bounds
|
18
|
+
end
|
19
|
+
|
20
|
+
add Reflex::RectShape.new {
|
21
|
+
set color: :blue, frame: [5, 300, 300, 10]
|
22
|
+
body.set static: true
|
23
|
+
}
|
24
|
+
|
25
|
+
10.times do |n|
|
26
|
+
add Reflex::ImageView.new {
|
27
|
+
set image: image, size: image.size, pos: [40 * n, 20 * n]
|
28
|
+
body.set dynamic: true, density: 1
|
29
|
+
}
|
30
|
+
end
|
31
|
+
|
32
|
+
after :draw do |e|
|
33
|
+
e.painter.fill :white
|
34
|
+
e.painter.text "#{e.fps.to_i} FPS", 10, 10
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/samples/repl.rb
CHANGED
data/samples/shader.rb
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
require 'reflex'
|
9
9
|
|
10
10
|
|
11
|
-
Reflex::Window.new do
|
11
|
+
win = Reflex::Window.new do
|
12
12
|
set :title, "Shader Sample"
|
13
13
|
set :frame, 100, 100, 300, 300
|
14
14
|
|
@@ -33,9 +33,9 @@ Reflex::Window.new do
|
|
33
33
|
on :update do
|
34
34
|
redraw
|
35
35
|
end
|
36
|
-
|
37
|
-
show
|
38
36
|
end
|
39
37
|
|
40
38
|
|
41
|
-
Reflex.start name: "Shader Sample"
|
39
|
+
Reflex.start name: "Shader Sample" do
|
40
|
+
win.show
|
41
|
+
end
|
data/samples/shapes.rb
CHANGED
@@ -10,7 +10,7 @@ require 'reflex'
|
|
10
10
|
include Reflex
|
11
11
|
|
12
12
|
|
13
|
-
Window.new do
|
13
|
+
win = Window.new do
|
14
14
|
set title: 'Shape Sample', frame: [100, 100, 500, 400]
|
15
15
|
|
16
16
|
p = painter
|
@@ -22,9 +22,9 @@ Window.new do
|
|
22
22
|
set frame: [32 + 64 * i, 32, 50, 50], color: :gray, border: :white
|
23
23
|
}
|
24
24
|
end
|
25
|
-
|
26
|
-
show
|
27
25
|
end
|
28
26
|
|
29
27
|
|
30
|
-
Reflex.start
|
28
|
+
Reflex.start do
|
29
|
+
win.show
|
30
|
+
end
|
data/samples/text.rb
CHANGED
@@ -11,10 +11,10 @@ require 'reflex'
|
|
11
11
|
lines = File.readlines(__FILE__)
|
12
12
|
|
13
13
|
|
14
|
-
Reflex::Window.new do
|
14
|
+
win = Reflex::Window.new do
|
15
15
|
set title: "Rays/Reflex Text Test", frame: [100, 100, 600, 400]
|
16
16
|
painter.background 0.1
|
17
|
-
painter.font
|
17
|
+
painter.font Reflex::Font.new 'Menlo', 12
|
18
18
|
on :draw do |e|
|
19
19
|
e.painter.push do
|
20
20
|
linenum = "%5d "
|
@@ -31,7 +31,9 @@ Reflex::Window.new do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
34
|
-
show
|
35
34
|
end
|
36
35
|
|
37
|
-
|
36
|
+
|
37
|
+
Reflex.start do
|
38
|
+
win.show
|
39
|
+
end
|
data/samples/tree.rb
CHANGED
data/samples/views.rb
CHANGED
data/samples/visuals.rb
CHANGED
data/src/body.cpp
ADDED
@@ -0,0 +1,244 @@
|
|
1
|
+
#include "reflex/body.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <assert.h>
|
5
|
+
#include <vector>
|
6
|
+
#include <Box2D/Common/b2Math.h>
|
7
|
+
#include <Box2D/Dynamics/b2Body.h>
|
8
|
+
#include <Box2D/Dynamics/b2Fixture.h>
|
9
|
+
#include <Box2D/Collision/Shapes/b2CircleShape.h>
|
10
|
+
#include <Box2D/Collision/Shapes/b2EdgeShape.h>
|
11
|
+
#include <Box2D/Collision/Shapes/b2ChainShape.h>
|
12
|
+
#include <Box2D/Collision/Shapes/b2PolygonShape.h>
|
13
|
+
#include "reflex/exception.h"
|
14
|
+
#include "world.h"
|
15
|
+
|
16
|
+
|
17
|
+
#define PTR ((b2Body*) handle)
|
18
|
+
|
19
|
+
|
20
|
+
namespace Reflex
|
21
|
+
{
|
22
|
+
|
23
|
+
|
24
|
+
Body::Body (Handle h, float scale)
|
25
|
+
: handle(h), scale(scale)
|
26
|
+
{
|
27
|
+
assert(h);
|
28
|
+
}
|
29
|
+
|
30
|
+
Fixture
|
31
|
+
Body::add_box (float width, float height)
|
32
|
+
{
|
33
|
+
assert(PTR);
|
34
|
+
|
35
|
+
b2Vec2 size(width / scale / 2, height / scale / 2);
|
36
|
+
|
37
|
+
b2PolygonShape shape;
|
38
|
+
shape.SetAsBox(size.x, size.y);
|
39
|
+
for (int i = 0; i < 4; ++i)
|
40
|
+
shape.m_vertices[i] += size;
|
41
|
+
|
42
|
+
b2FixtureDef fixture;
|
43
|
+
fixture.shape = &shape;
|
44
|
+
|
45
|
+
return PTR->CreateFixture(&fixture);
|
46
|
+
}
|
47
|
+
|
48
|
+
Fixture
|
49
|
+
Body::add_circle (float size)
|
50
|
+
{
|
51
|
+
assert(PTR);
|
52
|
+
|
53
|
+
float radius = size / scale / 2.f;
|
54
|
+
|
55
|
+
b2CircleShape shape;
|
56
|
+
shape.m_radius = radius;
|
57
|
+
shape.m_p.Set(radius, radius);
|
58
|
+
|
59
|
+
b2FixtureDef fixture;
|
60
|
+
fixture.shape = &shape;
|
61
|
+
|
62
|
+
return PTR->CreateFixture(&fixture);
|
63
|
+
}
|
64
|
+
|
65
|
+
Fixture
|
66
|
+
Body::add_edge (const Point& begin, const Point& end)
|
67
|
+
{
|
68
|
+
assert(PTR);
|
69
|
+
|
70
|
+
b2EdgeShape shape;
|
71
|
+
shape.Set(to_box2d(begin, scale), to_box2d(end, scale));
|
72
|
+
|
73
|
+
b2FixtureDef fixture;
|
74
|
+
fixture.shape = &shape;
|
75
|
+
|
76
|
+
return PTR->CreateFixture(&fixture);
|
77
|
+
}
|
78
|
+
|
79
|
+
Fixture
|
80
|
+
Body::add_edge (const Point* points, size_t size, bool loop)
|
81
|
+
{
|
82
|
+
assert(PTR);
|
83
|
+
|
84
|
+
if (size == 2)
|
85
|
+
return add_edge(points[0], points[1]);
|
86
|
+
|
87
|
+
std::vector<b2Vec2> vecs;
|
88
|
+
vecs.reserve(size);
|
89
|
+
for (size_t i = 0; i < size; ++i)
|
90
|
+
vecs.push_back(to_box2d(points[i], scale));
|
91
|
+
|
92
|
+
b2ChainShape shape;
|
93
|
+
if (loop)
|
94
|
+
shape.CreateLoop(&vecs[0], (int32) size);
|
95
|
+
else
|
96
|
+
shape.CreateChain(&vecs[0], (int32) size);
|
97
|
+
|
98
|
+
b2FixtureDef fixture;
|
99
|
+
fixture.shape = &shape;
|
100
|
+
|
101
|
+
return PTR->CreateFixture(&fixture);
|
102
|
+
}
|
103
|
+
|
104
|
+
Fixture
|
105
|
+
Body::add_polygon (const Point* points, size_t size)
|
106
|
+
{
|
107
|
+
assert(PTR);
|
108
|
+
|
109
|
+
std::vector<b2Vec2> vecs;
|
110
|
+
vecs.reserve(size);
|
111
|
+
for (size_t i = 0; i < size; ++i)
|
112
|
+
vecs.push_back(to_box2d(points[i], scale));
|
113
|
+
|
114
|
+
b2PolygonShape shape;
|
115
|
+
shape.Set(&vecs[0], (int32) size);
|
116
|
+
|
117
|
+
b2FixtureDef fixture;
|
118
|
+
fixture.shape = &shape;
|
119
|
+
|
120
|
+
return PTR->CreateFixture(&fixture);
|
121
|
+
}
|
122
|
+
|
123
|
+
void
|
124
|
+
Body::clear_fixtures ()
|
125
|
+
{
|
126
|
+
assert(PTR);
|
127
|
+
|
128
|
+
b2Fixture* f;
|
129
|
+
while (f = PTR->GetFixtureList())
|
130
|
+
PTR->DestroyFixture(f);
|
131
|
+
}
|
132
|
+
|
133
|
+
Point
|
134
|
+
Body::position () const
|
135
|
+
{
|
136
|
+
assert(PTR);
|
137
|
+
|
138
|
+
return to_point(PTR->GetPosition(), scale);
|
139
|
+
}
|
140
|
+
|
141
|
+
float
|
142
|
+
Body::angle () const
|
143
|
+
{
|
144
|
+
assert(PTR);
|
145
|
+
|
146
|
+
return PTR->GetAngle();
|
147
|
+
}
|
148
|
+
|
149
|
+
void
|
150
|
+
Body::set_static (bool state)
|
151
|
+
{
|
152
|
+
assert(PTR);
|
153
|
+
|
154
|
+
PTR->SetType(state ? b2_staticBody : b2_dynamicBody);
|
155
|
+
}
|
156
|
+
|
157
|
+
bool
|
158
|
+
Body::is_static () const
|
159
|
+
{
|
160
|
+
assert(PTR);
|
161
|
+
|
162
|
+
return PTR->GetType() == b2_staticBody;
|
163
|
+
}
|
164
|
+
|
165
|
+
void
|
166
|
+
Body::set_dynamic (bool state)
|
167
|
+
{
|
168
|
+
assert(PTR);
|
169
|
+
|
170
|
+
PTR->SetType(state ? b2_dynamicBody : b2_staticBody);
|
171
|
+
}
|
172
|
+
|
173
|
+
bool
|
174
|
+
Body::is_dynamic () const
|
175
|
+
{
|
176
|
+
assert(PTR);
|
177
|
+
|
178
|
+
return PTR->GetType() == b2_dynamicBody;
|
179
|
+
}
|
180
|
+
|
181
|
+
void
|
182
|
+
Body::set_density (float density)
|
183
|
+
{
|
184
|
+
iterator first = begin();
|
185
|
+
if (!first)
|
186
|
+
invalid_state_error(__FILE__, __LINE__, "no fixture");
|
187
|
+
|
188
|
+
first->set_density(density);
|
189
|
+
}
|
190
|
+
|
191
|
+
void
|
192
|
+
Body::set_friction (float friction)
|
193
|
+
{
|
194
|
+
iterator first = begin();
|
195
|
+
if (!first)
|
196
|
+
invalid_state_error(__FILE__, __LINE__, "no fixture");
|
197
|
+
|
198
|
+
first->set_friction(friction);
|
199
|
+
}
|
200
|
+
|
201
|
+
void
|
202
|
+
Body::set_restitution (float restitution)
|
203
|
+
{
|
204
|
+
iterator first = begin();
|
205
|
+
if (!first)
|
206
|
+
invalid_state_error(__FILE__, __LINE__, "no fixture");
|
207
|
+
|
208
|
+
first->set_restitution(restitution);
|
209
|
+
}
|
210
|
+
|
211
|
+
Body::iterator
|
212
|
+
Body::begin ()
|
213
|
+
{
|
214
|
+
assert(PTR);
|
215
|
+
|
216
|
+
return Fixture(PTR->GetFixtureList());
|
217
|
+
}
|
218
|
+
|
219
|
+
Body::const_iterator
|
220
|
+
Body::begin () const
|
221
|
+
{
|
222
|
+
assert(PTR);
|
223
|
+
|
224
|
+
return Fixture(PTR->GetFixtureList());
|
225
|
+
}
|
226
|
+
|
227
|
+
Body::iterator
|
228
|
+
Body::end ()
|
229
|
+
{
|
230
|
+
assert(PTR);
|
231
|
+
|
232
|
+
return Fixture(NULL);
|
233
|
+
}
|
234
|
+
|
235
|
+
Body::const_iterator
|
236
|
+
Body::end () const
|
237
|
+
{
|
238
|
+
assert(PTR);
|
239
|
+
|
240
|
+
return Fixture(NULL);
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
}// Reflex
|
data/src/event.cpp
CHANGED
@@ -66,25 +66,25 @@ namespace Reflex
|
|
66
66
|
{
|
67
67
|
}
|
68
68
|
|
69
|
-
|
69
|
+
Point&
|
70
70
|
ScrollEvent::scroll ()
|
71
71
|
{
|
72
|
-
return *(
|
72
|
+
return *(Point*) &scroll_;
|
73
73
|
}
|
74
74
|
|
75
|
-
const
|
75
|
+
const Point&
|
76
76
|
ScrollEvent::scroll () const
|
77
77
|
{
|
78
78
|
return const_cast<ScrollEvent*>(this)->scroll();
|
79
79
|
}
|
80
80
|
|
81
|
-
|
81
|
+
Point&
|
82
82
|
ScrollEvent::delta ()
|
83
83
|
{
|
84
|
-
return *(
|
84
|
+
return *(Point*) &delta_;
|
85
85
|
}
|
86
86
|
|
87
|
-
const
|
87
|
+
const Point&
|
88
88
|
ScrollEvent::delta () const
|
89
89
|
{
|
90
90
|
return const_cast<ScrollEvent*>(this)->delta();
|
@@ -130,7 +130,7 @@ namespace Reflex
|
|
130
130
|
}
|
131
131
|
|
132
132
|
PointerEvent::PointerEvent (
|
133
|
-
Type type, uint pointer_type, const
|
133
|
+
Type type, uint pointer_type, const Point* positions_, size_t size,
|
134
134
|
uint modifiers, uint count, bool drag)
|
135
135
|
: type(type), pointer_type(pointer_type),
|
136
136
|
size(size), modifiers(modifiers), count(count), drag(drag), capture(false)
|
@@ -147,28 +147,28 @@ namespace Reflex
|
|
147
147
|
}
|
148
148
|
}
|
149
149
|
|
150
|
-
|
150
|
+
Point&
|
151
151
|
PointerEvent::position (size_t i)
|
152
152
|
{
|
153
153
|
if (i >= size)
|
154
154
|
index_error(__FILE__, __LINE__);
|
155
155
|
|
156
|
-
return *(
|
156
|
+
return *(Point*) &positions[i];
|
157
157
|
}
|
158
158
|
|
159
|
-
const
|
159
|
+
const Point&
|
160
160
|
PointerEvent::position (size_t i) const
|
161
161
|
{
|
162
162
|
return const_cast<PointerEvent*>(this)->position(i);
|
163
163
|
}
|
164
164
|
|
165
|
-
|
165
|
+
Point&
|
166
166
|
PointerEvent::operator [] (size_t i)
|
167
167
|
{
|
168
168
|
return position(i);
|
169
169
|
}
|
170
170
|
|
171
|
-
const
|
171
|
+
const Point&
|
172
172
|
PointerEvent::operator [] (size_t i) const
|
173
173
|
{
|
174
174
|
return position(i);
|
@@ -186,25 +186,25 @@ namespace Reflex
|
|
186
186
|
{
|
187
187
|
}
|
188
188
|
|
189
|
-
|
189
|
+
Point&
|
190
190
|
WheelEvent::delta ()
|
191
191
|
{
|
192
|
-
return *(
|
192
|
+
return *(Point*) &delta_;
|
193
193
|
}
|
194
194
|
|
195
|
-
const
|
195
|
+
const Point&
|
196
196
|
WheelEvent::delta () const
|
197
197
|
{
|
198
198
|
return const_cast<WheelEvent*>(this)->delta();
|
199
199
|
}
|
200
200
|
|
201
|
-
|
201
|
+
Point&
|
202
202
|
WheelEvent::position ()
|
203
203
|
{
|
204
|
-
return *(
|
204
|
+
return *(Point*) &position_;
|
205
205
|
}
|
206
206
|
|
207
|
-
const
|
207
|
+
const Point&
|
208
208
|
WheelEvent::position () const
|
209
209
|
{
|
210
210
|
return const_cast<WheelEvent*>(this)->position();
|
data/src/fixture.cpp
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#include "reflex/fixture.h"
|
2
|
+
|
3
|
+
|
4
|
+
#include <assert.h>
|
5
|
+
#include <Box2D/Dynamics/b2Fixture.h>
|
6
|
+
|
7
|
+
|
8
|
+
#define PTR ((b2Fixture*) handle)
|
9
|
+
|
10
|
+
|
11
|
+
namespace Reflex
|
12
|
+
{
|
13
|
+
|
14
|
+
|
15
|
+
Fixture::Fixture (Handle h)
|
16
|
+
: handle(h)
|
17
|
+
{
|
18
|
+
}
|
19
|
+
|
20
|
+
Fixture&
|
21
|
+
Fixture::operator = (Handle h)
|
22
|
+
{
|
23
|
+
handle = h;
|
24
|
+
return *this;
|
25
|
+
}
|
26
|
+
|
27
|
+
void
|
28
|
+
Fixture::set_density (float density)
|
29
|
+
{
|
30
|
+
assert(PTR && PTR->GetBody());
|
31
|
+
|
32
|
+
PTR->SetDensity(density);
|
33
|
+
PTR->GetBody()->ResetMassData();
|
34
|
+
}
|
35
|
+
|
36
|
+
float
|
37
|
+
Fixture::density () const
|
38
|
+
{
|
39
|
+
assert(PTR);
|
40
|
+
|
41
|
+
return PTR->GetDensity();
|
42
|
+
}
|
43
|
+
|
44
|
+
void
|
45
|
+
Fixture::set_friction (float friction)
|
46
|
+
{
|
47
|
+
assert(PTR);
|
48
|
+
|
49
|
+
PTR->SetFriction(friction);
|
50
|
+
}
|
51
|
+
|
52
|
+
float
|
53
|
+
Fixture::friction () const
|
54
|
+
{
|
55
|
+
assert(PTR);
|
56
|
+
|
57
|
+
return PTR->GetFriction();
|
58
|
+
}
|
59
|
+
|
60
|
+
void
|
61
|
+
Fixture::set_restitution (float restitution)
|
62
|
+
{
|
63
|
+
assert(PTR);
|
64
|
+
|
65
|
+
PTR->SetRestitution(restitution);
|
66
|
+
}
|
67
|
+
|
68
|
+
float
|
69
|
+
Fixture::restitution () const
|
70
|
+
{
|
71
|
+
assert(PTR);
|
72
|
+
|
73
|
+
return PTR->GetRestitution();
|
74
|
+
}
|
75
|
+
|
76
|
+
Fixture::Handle
|
77
|
+
Fixture::next () const
|
78
|
+
{
|
79
|
+
assert(PTR);
|
80
|
+
|
81
|
+
return PTR->GetNext();
|
82
|
+
}
|
83
|
+
|
84
|
+
Fixture::operator bool () const
|
85
|
+
{
|
86
|
+
return PTR;
|
87
|
+
}
|
88
|
+
|
89
|
+
bool
|
90
|
+
Fixture::operator ! () const
|
91
|
+
{
|
92
|
+
return !operator bool();
|
93
|
+
}
|
94
|
+
|
95
|
+
bool
|
96
|
+
operator == (const Fixture& lhs, const Fixture& rhs)
|
97
|
+
{
|
98
|
+
return lhs.handle == rhs.handle;
|
99
|
+
}
|
100
|
+
|
101
|
+
bool
|
102
|
+
operator != (const Fixture& lhs, const Fixture& rhs)
|
103
|
+
{
|
104
|
+
return !(lhs == rhs);
|
105
|
+
}
|
106
|
+
|
107
|
+
|
108
|
+
}// Reflex
|
data/src/image_view.cpp
CHANGED
data/src/ios/native_window.h
CHANGED
data/src/ios/native_window.mm
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
#include <assert.h>
|
6
|
-
#include
|
6
|
+
#include "reflex/bounds.h"
|
7
7
|
#include "reflex/window.h"
|
8
8
|
#include "reflex/exception.h"
|
9
9
|
#include "event.h"
|
@@ -14,6 +14,16 @@
|
|
14
14
|
#define REF (*pref)
|
15
15
|
|
16
16
|
|
17
|
+
namespace Reflex
|
18
|
+
{
|
19
|
+
|
20
|
+
void update_view_tree (View* v, const UpdateEvent& e);
|
21
|
+
|
22
|
+
void draw_view_tree (View* v, const DrawEvent& e, const Point& offset, const Bounds& clip);
|
23
|
+
|
24
|
+
}// Reflex
|
25
|
+
|
26
|
+
|
17
27
|
static CGRect device_frame ()
|
18
28
|
{
|
19
29
|
return [[UIScreen mainScreen] applicationFrame];
|
@@ -87,6 +97,8 @@ static CGRect device_frame ()
|
|
87
97
|
REF->self->prev_time_update = now;
|
88
98
|
|
89
99
|
REF->on_update(&e);
|
100
|
+
if (!e.is_blocked())
|
101
|
+
Reflex::update_view_tree(REF->root(), e);
|
90
102
|
}
|
91
103
|
|
92
104
|
- (void) draw
|
@@ -115,7 +127,12 @@ static CGRect device_frame ()
|
|
115
127
|
e.bounds.reset(0, 0, b.width, b.height);
|
116
128
|
|
117
129
|
e.painter->begin();
|
130
|
+
e.painter->clear();
|
131
|
+
|
118
132
|
REF->on_draw(&e);
|
133
|
+
if (!e.is_blocked())
|
134
|
+
draw_view_tree(REF->root(), e, 0, REF->frame().dup().move_to(0));
|
135
|
+
|
119
136
|
e.painter->end();
|
120
137
|
}
|
121
138
|
|
data/src/ios/opengl_view.mm
CHANGED
@@ -69,6 +69,14 @@
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
|
72
|
+
- (void) update
|
73
|
+
{
|
74
|
+
NativeWindow* win = (NativeWindow*) self.view.window;
|
75
|
+
if (!win) return;
|
76
|
+
|
77
|
+
[win update];
|
78
|
+
}
|
79
|
+
|
72
80
|
- (void) glkView: (GLKView*) view drawInRect: (CGRect) rect
|
73
81
|
{
|
74
82
|
NativeWindow* win = (NativeWindow*) self.view.window;
|