pbox2d 0.6.0-java → 0.8.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +8 -0
  3. data/.mvn/wrapper/maven-wrapper.properties +1 -0
  4. data/.travis.yml +23 -0
  5. data/CHANGELOG.md +8 -0
  6. data/README.md +7 -7
  7. data/Rakefile +1 -2
  8. data/lib/box2d.jar +0 -0
  9. data/lib/pbox2d/version.rb +1 -1
  10. data/lib/pbox2d.rb +1 -0
  11. data/pbox2d.gemspec +6 -11
  12. data/pom.rb +59 -0
  13. data/pom.xml +82 -73
  14. data/src/org/jbox2d/JBox2D.gwt.xml +12 -0
  15. data/src/org/jbox2d/callbacks/ContactAdaptor.java +27 -0
  16. data/src/org/jbox2d/callbacks/ContactFilter.java +59 -0
  17. data/src/org/jbox2d/callbacks/ContactImpulse.java +42 -0
  18. data/src/org/jbox2d/callbacks/ContactListener.java +87 -0
  19. data/src/org/jbox2d/callbacks/DebugDraw.java +297 -0
  20. data/src/org/jbox2d/callbacks/DestructionListener.java +53 -0
  21. data/src/org/jbox2d/callbacks/PairCallback.java +29 -0
  22. data/src/org/jbox2d/callbacks/ParticleDestructionListener.java +20 -0
  23. data/src/org/jbox2d/callbacks/ParticleQueryCallback.java +19 -0
  24. data/src/org/jbox2d/callbacks/ParticleRaycastCallback.java +19 -0
  25. data/src/org/jbox2d/callbacks/QueryCallback.java +45 -0
  26. data/src/org/jbox2d/callbacks/RayCastCallback.java +55 -0
  27. data/src/org/jbox2d/callbacks/TreeCallback.java +42 -0
  28. data/src/org/jbox2d/callbacks/TreeRayCastCallback.java +44 -0
  29. data/src/org/jbox2d/collision/AABB.java +338 -0
  30. data/src/org/jbox2d/collision/Collision.java +1444 -0
  31. data/src/org/jbox2d/collision/ContactID.java +106 -0
  32. data/src/org/jbox2d/collision/Distance.java +773 -0
  33. data/src/org/jbox2d/collision/DistanceInput.java +41 -0
  34. data/src/org/jbox2d/collision/DistanceOutput.java +43 -0
  35. data/src/org/jbox2d/collision/Manifold.java +116 -0
  36. data/src/org/jbox2d/collision/ManifoldPoint.java +104 -0
  37. data/src/org/jbox2d/collision/RayCastInput.java +47 -0
  38. data/src/org/jbox2d/collision/RayCastOutput.java +46 -0
  39. data/src/org/jbox2d/collision/TimeOfImpact.java +526 -0
  40. data/src/org/jbox2d/collision/WorldManifold.java +200 -0
  41. data/src/org/jbox2d/collision/broadphase/BroadPhase.java +92 -0
  42. data/src/org/jbox2d/collision/broadphase/BroadPhaseStrategy.java +88 -0
  43. data/src/org/jbox2d/collision/broadphase/DefaultBroadPhaseBuffer.java +268 -0
  44. data/src/org/jbox2d/collision/broadphase/DynamicTree.java +883 -0
  45. data/src/org/jbox2d/collision/broadphase/DynamicTreeFlatNodes.java +873 -0
  46. data/src/org/jbox2d/collision/broadphase/DynamicTreeNode.java +54 -0
  47. data/src/org/jbox2d/collision/broadphase/Pair.java +46 -0
  48. data/src/org/jbox2d/collision/shapes/ChainShape.java +264 -0
  49. data/src/org/jbox2d/collision/shapes/CircleShape.java +207 -0
  50. data/src/org/jbox2d/collision/shapes/EdgeShape.java +254 -0
  51. data/src/org/jbox2d/collision/shapes/MassData.java +105 -0
  52. data/src/org/jbox2d/collision/shapes/PolygonShape.java +718 -0
  53. data/src/org/jbox2d/collision/shapes/Shape.java +136 -0
  54. data/src/org/jbox2d/collision/shapes/ShapeType.java +32 -0
  55. data/src/org/jbox2d/common/BufferUtils.java +209 -0
  56. data/src/org/jbox2d/common/Color3f.java +88 -0
  57. data/src/org/jbox2d/common/IViewportTransform.java +133 -0
  58. data/src/org/jbox2d/common/Mat22.java +609 -0
  59. data/src/org/jbox2d/common/Mat33.java +290 -0
  60. data/src/org/jbox2d/common/MathUtils.java +335 -0
  61. data/src/org/jbox2d/common/OBBViewportTransform.java +174 -0
  62. data/src/org/jbox2d/common/PlatformMathUtils.java +46 -0
  63. data/src/org/jbox2d/common/RaycastResult.java +37 -0
  64. data/src/org/jbox2d/common/Rot.java +150 -0
  65. data/src/org/jbox2d/common/Settings.java +246 -0
  66. data/src/org/jbox2d/common/Sweep.java +116 -0
  67. data/src/org/jbox2d/common/Timer.java +46 -0
  68. data/src/org/jbox2d/common/Transform.java +203 -0
  69. data/src/org/jbox2d/common/Vec2.java +388 -0
  70. data/src/org/jbox2d/common/Vec3.java +170 -0
  71. data/src/org/jbox2d/dynamics/Body.java +1246 -0
  72. data/src/org/jbox2d/dynamics/BodyDef.java +382 -0
  73. data/src/org/jbox2d/dynamics/BodyType.java +41 -0
  74. data/src/org/jbox2d/dynamics/ContactManager.java +293 -0
  75. data/src/org/jbox2d/dynamics/Filter.java +62 -0
  76. data/src/org/jbox2d/dynamics/Fixture.java +454 -0
  77. data/src/org/jbox2d/dynamics/FixtureDef.java +214 -0
  78. data/src/org/jbox2d/dynamics/FixtureProxy.java +38 -0
  79. data/src/org/jbox2d/dynamics/Island.java +602 -0
  80. data/src/org/jbox2d/dynamics/Profile.java +97 -0
  81. data/src/org/jbox2d/dynamics/SolverData.java +33 -0
  82. data/src/org/jbox2d/dynamics/TimeStep.java +46 -0
  83. data/src/org/jbox2d/dynamics/World.java +2075 -0
  84. data/src/org/jbox2d/dynamics/contacts/ChainAndCircleContact.java +57 -0
  85. data/src/org/jbox2d/dynamics/contacts/ChainAndPolygonContact.java +57 -0
  86. data/src/org/jbox2d/dynamics/contacts/CircleContact.java +50 -0
  87. data/src/org/jbox2d/dynamics/contacts/Contact.java +365 -0
  88. data/src/org/jbox2d/dynamics/contacts/ContactCreator.java +35 -0
  89. data/src/org/jbox2d/dynamics/contacts/ContactEdge.java +56 -0
  90. data/src/org/jbox2d/dynamics/contacts/ContactPositionConstraint.java +49 -0
  91. data/src/org/jbox2d/dynamics/contacts/ContactRegister.java +31 -0
  92. data/src/org/jbox2d/dynamics/contacts/ContactSolver.java +1104 -0
  93. data/src/org/jbox2d/dynamics/contacts/ContactVelocityConstraint.java +60 -0
  94. data/src/org/jbox2d/dynamics/contacts/EdgeAndCircleContact.java +52 -0
  95. data/src/org/jbox2d/dynamics/contacts/EdgeAndPolygonContact.java +52 -0
  96. data/src/org/jbox2d/dynamics/contacts/PolygonAndCircleContact.java +51 -0
  97. data/src/org/jbox2d/dynamics/contacts/PolygonContact.java +50 -0
  98. data/src/org/jbox2d/dynamics/contacts/Position.java +31 -0
  99. data/src/org/jbox2d/dynamics/contacts/Velocity.java +31 -0
  100. data/src/org/jbox2d/dynamics/joints/ConstantVolumeJoint.java +258 -0
  101. data/src/org/jbox2d/dynamics/joints/ConstantVolumeJointDef.java +75 -0
  102. data/src/org/jbox2d/dynamics/joints/DistanceJoint.java +356 -0
  103. data/src/org/jbox2d/dynamics/joints/DistanceJointDef.java +106 -0
  104. data/src/org/jbox2d/dynamics/joints/FrictionJoint.java +294 -0
  105. data/src/org/jbox2d/dynamics/joints/FrictionJointDef.java +78 -0
  106. data/src/org/jbox2d/dynamics/joints/GearJoint.java +520 -0
  107. data/src/org/jbox2d/dynamics/joints/GearJointDef.java +58 -0
  108. data/src/org/jbox2d/dynamics/joints/Jacobian.java +32 -0
  109. data/src/org/jbox2d/dynamics/joints/Joint.java +235 -0
  110. data/src/org/jbox2d/dynamics/joints/JointDef.java +65 -0
  111. data/src/org/jbox2d/dynamics/joints/JointEdge.java +57 -0
  112. data/src/org/jbox2d/dynamics/joints/JointType.java +28 -0
  113. data/src/org/jbox2d/dynamics/joints/LimitState.java +28 -0
  114. data/src/org/jbox2d/dynamics/joints/MotorJoint.java +339 -0
  115. data/src/org/jbox2d/dynamics/joints/MotorJointDef.java +55 -0
  116. data/src/org/jbox2d/dynamics/joints/MouseJoint.java +262 -0
  117. data/src/org/jbox2d/dynamics/joints/MouseJointDef.java +62 -0
  118. data/src/org/jbox2d/dynamics/joints/PrismaticJoint.java +808 -0
  119. data/src/org/jbox2d/dynamics/joints/PrismaticJointDef.java +120 -0
  120. data/src/org/jbox2d/dynamics/joints/PulleyJoint.java +393 -0
  121. data/src/org/jbox2d/dynamics/joints/PulleyJointDef.java +105 -0
  122. data/src/org/jbox2d/dynamics/joints/RevoluteJoint.java +554 -0
  123. data/src/org/jbox2d/dynamics/joints/RevoluteJointDef.java +137 -0
  124. data/src/org/jbox2d/dynamics/joints/RopeJoint.java +276 -0
  125. data/src/org/jbox2d/dynamics/joints/RopeJointDef.java +34 -0
  126. data/src/org/jbox2d/dynamics/joints/WeldJoint.java +424 -0
  127. data/src/org/jbox2d/dynamics/joints/WeldJointDef.java +85 -0
  128. data/src/org/jbox2d/dynamics/joints/WheelJoint.java +498 -0
  129. data/src/org/jbox2d/dynamics/joints/WheelJointDef.java +98 -0
  130. data/src/org/jbox2d/particle/ParticleBodyContact.java +17 -0
  131. data/src/org/jbox2d/particle/ParticleColor.java +52 -0
  132. data/src/org/jbox2d/particle/ParticleContact.java +14 -0
  133. data/src/org/jbox2d/particle/ParticleDef.java +24 -0
  134. data/src/org/jbox2d/particle/ParticleGroup.java +154 -0
  135. data/src/org/jbox2d/particle/ParticleGroupDef.java +62 -0
  136. data/src/org/jbox2d/particle/ParticleGroupType.java +8 -0
  137. data/src/org/jbox2d/particle/ParticleSystem.java +2172 -0
  138. data/src/org/jbox2d/particle/ParticleType.java +28 -0
  139. data/src/org/jbox2d/particle/StackQueue.java +44 -0
  140. data/src/org/jbox2d/particle/VoronoiDiagram.java +209 -0
  141. data/src/org/jbox2d/pooling/IDynamicStack.java +47 -0
  142. data/src/org/jbox2d/pooling/IOrderedStack.java +57 -0
  143. data/src/org/jbox2d/pooling/IWorldPool.java +101 -0
  144. data/src/org/jbox2d/pooling/arrays/FloatArray.java +50 -0
  145. data/src/org/jbox2d/pooling/arrays/GeneratorArray.java +33 -0
  146. data/src/org/jbox2d/pooling/arrays/IntArray.java +53 -0
  147. data/src/org/jbox2d/pooling/arrays/Vec2Array.java +57 -0
  148. data/src/org/jbox2d/pooling/normal/CircleStack.java +77 -0
  149. data/src/org/jbox2d/pooling/normal/DefaultWorldPool.java +331 -0
  150. data/src/org/jbox2d/pooling/normal/MutableStack.java +72 -0
  151. data/src/org/jbox2d/pooling/normal/OrderedStack.java +73 -0
  152. data/src/org/jbox2d/pooling/stacks/DynamicIntStack.java +60 -0
  153. metadata +161 -14
  154. data/lib/jbox2d-library-2.3.1-SNAPSHOT.jar +0 -0
@@ -0,0 +1,154 @@
1
+ package org.jbox2d.particle;
2
+
3
+ import org.jbox2d.common.Transform;
4
+ import org.jbox2d.common.Vec2;
5
+
6
+ public class ParticleGroup {
7
+
8
+ ParticleSystem m_system;
9
+ int m_firstIndex;
10
+ int m_lastIndex;
11
+ int m_groupFlags;
12
+ float m_strength;
13
+ ParticleGroup m_prev;
14
+ ParticleGroup m_next;
15
+
16
+ int m_timestamp;
17
+ float m_mass;
18
+ float m_inertia;
19
+ final Vec2 m_center = new Vec2();
20
+ final Vec2 m_linearVelocity = new Vec2();
21
+ float m_angularVelocity;
22
+ final Transform m_transform = new Transform();
23
+
24
+ boolean m_destroyAutomatically;
25
+ boolean m_toBeDestroyed;
26
+ boolean m_toBeSplit;
27
+
28
+ Object m_userData;
29
+
30
+ public ParticleGroup() {
31
+ // m_system = null;
32
+ m_firstIndex = 0;
33
+ m_lastIndex = 0;
34
+ m_groupFlags = 0;
35
+ m_strength = 1.0f;
36
+
37
+ m_timestamp = -1;
38
+ m_mass = 0;
39
+ m_inertia = 0;
40
+ m_angularVelocity = 0;
41
+ m_transform.setIdentity();
42
+
43
+ m_destroyAutomatically = true;
44
+ m_toBeDestroyed = false;
45
+ m_toBeSplit = false;
46
+ }
47
+
48
+ public ParticleGroup getNext() {
49
+ return m_next;
50
+ }
51
+
52
+ public int getParticleCount() {
53
+ return m_lastIndex - m_firstIndex;
54
+ }
55
+
56
+ public int getBufferIndex() {
57
+ return m_firstIndex;
58
+ }
59
+
60
+ public int getGroupFlags() {
61
+ return m_groupFlags;
62
+ }
63
+
64
+ public void setGroupFlags(int flags) {
65
+ m_groupFlags = flags;
66
+ }
67
+
68
+ public float getMass() {
69
+ updateStatistics();
70
+ return m_mass;
71
+ }
72
+
73
+ public float getInertia() {
74
+ updateStatistics();
75
+ return m_inertia;
76
+ }
77
+
78
+ public Vec2 getCenter() {
79
+ updateStatistics();
80
+ return m_center;
81
+ }
82
+
83
+ public Vec2 getLinearVelocity() {
84
+ updateStatistics();
85
+ return m_linearVelocity;
86
+ }
87
+
88
+ public float getAngularVelocity() {
89
+ updateStatistics();
90
+ return m_angularVelocity;
91
+ }
92
+
93
+ public Transform getTransform() {
94
+ return m_transform;
95
+ }
96
+
97
+ public Vec2 getPosition() {
98
+ return m_transform.p;
99
+ }
100
+
101
+ public float getAngle() {
102
+ return m_transform.q.getAngle();
103
+ }
104
+
105
+ public Object getUserData() {
106
+ return m_userData;
107
+ }
108
+
109
+ public void setUserData(Object data) {
110
+ m_userData = data;
111
+ }
112
+
113
+
114
+
115
+ public void updateStatistics() {
116
+ if (m_timestamp != m_system.m_timestamp) {
117
+ float m = m_system.getParticleMass();
118
+ m_mass = 0;
119
+ m_center.setZero();
120
+ m_linearVelocity.setZero();
121
+ for (int i = m_firstIndex; i < m_lastIndex; i++) {
122
+ m_mass += m;
123
+ Vec2 pos = m_system.m_positionBuffer.data[i];
124
+ m_center.x += m * pos.x;
125
+ m_center.y += m * pos.y;
126
+ Vec2 vel = m_system.m_velocityBuffer.data[i];
127
+ m_linearVelocity.x += m * vel.x;
128
+ m_linearVelocity.y += m * vel.y;
129
+ }
130
+ if (m_mass > 0) {
131
+ m_center.x *= 1 / m_mass;
132
+ m_center.y *= 1 / m_mass;
133
+ m_linearVelocity.x *= 1 / m_mass;
134
+ m_linearVelocity.y *= 1 / m_mass;
135
+ }
136
+ m_inertia = 0;
137
+ m_angularVelocity = 0;
138
+ for (int i = m_firstIndex; i < m_lastIndex; i++) {
139
+ Vec2 pos = m_system.m_positionBuffer.data[i];
140
+ Vec2 vel = m_system.m_velocityBuffer.data[i];
141
+ float px = pos.x - m_center.x;
142
+ float py = pos.y - m_center.y;
143
+ float vx = vel.x - m_linearVelocity.x;
144
+ float vy = vel.y - m_linearVelocity.y;
145
+ m_inertia += m * (px * px + py * py);
146
+ m_angularVelocity += m * (px * vy - py * vx);
147
+ }
148
+ if (m_inertia > 0) {
149
+ m_angularVelocity *= 1 / m_inertia;
150
+ }
151
+ m_timestamp = m_system.m_timestamp;
152
+ }
153
+ }
154
+ }
@@ -0,0 +1,62 @@
1
+ package org.jbox2d.particle;
2
+
3
+ import org.jbox2d.collision.shapes.Shape;
4
+ import org.jbox2d.common.Vec2;
5
+
6
+ /**
7
+ * A particle group definition holds all the data needed to construct a particle group. You can
8
+ * safely re-use these definitions.
9
+ */
10
+ public class ParticleGroupDef {
11
+
12
+ /** The particle-behavior flags. */
13
+ public int flags;
14
+
15
+ /** The group-construction flags. */
16
+ public int groupFlags;
17
+
18
+ /**
19
+ * The world position of the group. Moves the group's shape a distance equal to the value of
20
+ * position.
21
+ */
22
+ public final Vec2 position = new Vec2();
23
+
24
+ /**
25
+ * The world angle of the group in radians. Rotates the shape by an angle equal to the value of
26
+ * angle.
27
+ */
28
+ public float angle;
29
+
30
+ /** The linear velocity of the group's origin in world co-ordinates. */
31
+ public final Vec2 linearVelocity = new Vec2();
32
+
33
+ /** The angular velocity of the group. */
34
+ public float angularVelocity;
35
+
36
+ /** The color of all particles in the group. */
37
+ public ParticleColor color;
38
+
39
+ /**
40
+ * The strength of cohesion among the particles in a group with flag b2_elasticParticle or
41
+ * b2_springParticle.
42
+ */
43
+ public float strength;
44
+
45
+ /** Shape containing the particle group. */
46
+ public Shape shape;
47
+
48
+ /** If true, destroy the group automatically after its last particle has been destroyed. */
49
+ public boolean destroyAutomatically;
50
+
51
+ /** Use this to store application-specific group data. */
52
+ public Object userData;
53
+
54
+ public ParticleGroupDef() {
55
+ flags = 0;
56
+ groupFlags = 0;
57
+ angle = 0;
58
+ angularVelocity = 0;
59
+ strength = 1;
60
+ destroyAutomatically = true;
61
+ }
62
+ }
@@ -0,0 +1,8 @@
1
+ package org.jbox2d.particle;
2
+
3
+ public class ParticleGroupType {
4
+ /** resists penetration */
5
+ public static final int b2_solidParticleGroup = 1 << 0;
6
+ /** keeps its shape */
7
+ public static final int b2_rigidParticleGroup = 1 << 1;
8
+ }