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.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +8 -0
- data/.mvn/wrapper/maven-wrapper.properties +1 -0
- data/.travis.yml +23 -0
- data/CHANGELOG.md +8 -0
- data/README.md +7 -7
- data/Rakefile +1 -2
- data/lib/box2d.jar +0 -0
- data/lib/pbox2d/version.rb +1 -1
- data/lib/pbox2d.rb +1 -0
- data/pbox2d.gemspec +6 -11
- data/pom.rb +59 -0
- data/pom.xml +82 -73
- data/src/org/jbox2d/JBox2D.gwt.xml +12 -0
- data/src/org/jbox2d/callbacks/ContactAdaptor.java +27 -0
- data/src/org/jbox2d/callbacks/ContactFilter.java +59 -0
- data/src/org/jbox2d/callbacks/ContactImpulse.java +42 -0
- data/src/org/jbox2d/callbacks/ContactListener.java +87 -0
- data/src/org/jbox2d/callbacks/DebugDraw.java +297 -0
- data/src/org/jbox2d/callbacks/DestructionListener.java +53 -0
- data/src/org/jbox2d/callbacks/PairCallback.java +29 -0
- data/src/org/jbox2d/callbacks/ParticleDestructionListener.java +20 -0
- data/src/org/jbox2d/callbacks/ParticleQueryCallback.java +19 -0
- data/src/org/jbox2d/callbacks/ParticleRaycastCallback.java +19 -0
- data/src/org/jbox2d/callbacks/QueryCallback.java +45 -0
- data/src/org/jbox2d/callbacks/RayCastCallback.java +55 -0
- data/src/org/jbox2d/callbacks/TreeCallback.java +42 -0
- data/src/org/jbox2d/callbacks/TreeRayCastCallback.java +44 -0
- data/src/org/jbox2d/collision/AABB.java +338 -0
- data/src/org/jbox2d/collision/Collision.java +1444 -0
- data/src/org/jbox2d/collision/ContactID.java +106 -0
- data/src/org/jbox2d/collision/Distance.java +773 -0
- data/src/org/jbox2d/collision/DistanceInput.java +41 -0
- data/src/org/jbox2d/collision/DistanceOutput.java +43 -0
- data/src/org/jbox2d/collision/Manifold.java +116 -0
- data/src/org/jbox2d/collision/ManifoldPoint.java +104 -0
- data/src/org/jbox2d/collision/RayCastInput.java +47 -0
- data/src/org/jbox2d/collision/RayCastOutput.java +46 -0
- data/src/org/jbox2d/collision/TimeOfImpact.java +526 -0
- data/src/org/jbox2d/collision/WorldManifold.java +200 -0
- data/src/org/jbox2d/collision/broadphase/BroadPhase.java +92 -0
- data/src/org/jbox2d/collision/broadphase/BroadPhaseStrategy.java +88 -0
- data/src/org/jbox2d/collision/broadphase/DefaultBroadPhaseBuffer.java +268 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTree.java +883 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTreeFlatNodes.java +873 -0
- data/src/org/jbox2d/collision/broadphase/DynamicTreeNode.java +54 -0
- data/src/org/jbox2d/collision/broadphase/Pair.java +46 -0
- data/src/org/jbox2d/collision/shapes/ChainShape.java +264 -0
- data/src/org/jbox2d/collision/shapes/CircleShape.java +207 -0
- data/src/org/jbox2d/collision/shapes/EdgeShape.java +254 -0
- data/src/org/jbox2d/collision/shapes/MassData.java +105 -0
- data/src/org/jbox2d/collision/shapes/PolygonShape.java +718 -0
- data/src/org/jbox2d/collision/shapes/Shape.java +136 -0
- data/src/org/jbox2d/collision/shapes/ShapeType.java +32 -0
- data/src/org/jbox2d/common/BufferUtils.java +209 -0
- data/src/org/jbox2d/common/Color3f.java +88 -0
- data/src/org/jbox2d/common/IViewportTransform.java +133 -0
- data/src/org/jbox2d/common/Mat22.java +609 -0
- data/src/org/jbox2d/common/Mat33.java +290 -0
- data/src/org/jbox2d/common/MathUtils.java +335 -0
- data/src/org/jbox2d/common/OBBViewportTransform.java +174 -0
- data/src/org/jbox2d/common/PlatformMathUtils.java +46 -0
- data/src/org/jbox2d/common/RaycastResult.java +37 -0
- data/src/org/jbox2d/common/Rot.java +150 -0
- data/src/org/jbox2d/common/Settings.java +246 -0
- data/src/org/jbox2d/common/Sweep.java +116 -0
- data/src/org/jbox2d/common/Timer.java +46 -0
- data/src/org/jbox2d/common/Transform.java +203 -0
- data/src/org/jbox2d/common/Vec2.java +388 -0
- data/src/org/jbox2d/common/Vec3.java +170 -0
- data/src/org/jbox2d/dynamics/Body.java +1246 -0
- data/src/org/jbox2d/dynamics/BodyDef.java +382 -0
- data/src/org/jbox2d/dynamics/BodyType.java +41 -0
- data/src/org/jbox2d/dynamics/ContactManager.java +293 -0
- data/src/org/jbox2d/dynamics/Filter.java +62 -0
- data/src/org/jbox2d/dynamics/Fixture.java +454 -0
- data/src/org/jbox2d/dynamics/FixtureDef.java +214 -0
- data/src/org/jbox2d/dynamics/FixtureProxy.java +38 -0
- data/src/org/jbox2d/dynamics/Island.java +602 -0
- data/src/org/jbox2d/dynamics/Profile.java +97 -0
- data/src/org/jbox2d/dynamics/SolverData.java +33 -0
- data/src/org/jbox2d/dynamics/TimeStep.java +46 -0
- data/src/org/jbox2d/dynamics/World.java +2075 -0
- data/src/org/jbox2d/dynamics/contacts/ChainAndCircleContact.java +57 -0
- data/src/org/jbox2d/dynamics/contacts/ChainAndPolygonContact.java +57 -0
- data/src/org/jbox2d/dynamics/contacts/CircleContact.java +50 -0
- data/src/org/jbox2d/dynamics/contacts/Contact.java +365 -0
- data/src/org/jbox2d/dynamics/contacts/ContactCreator.java +35 -0
- data/src/org/jbox2d/dynamics/contacts/ContactEdge.java +56 -0
- data/src/org/jbox2d/dynamics/contacts/ContactPositionConstraint.java +49 -0
- data/src/org/jbox2d/dynamics/contacts/ContactRegister.java +31 -0
- data/src/org/jbox2d/dynamics/contacts/ContactSolver.java +1104 -0
- data/src/org/jbox2d/dynamics/contacts/ContactVelocityConstraint.java +60 -0
- data/src/org/jbox2d/dynamics/contacts/EdgeAndCircleContact.java +52 -0
- data/src/org/jbox2d/dynamics/contacts/EdgeAndPolygonContact.java +52 -0
- data/src/org/jbox2d/dynamics/contacts/PolygonAndCircleContact.java +51 -0
- data/src/org/jbox2d/dynamics/contacts/PolygonContact.java +50 -0
- data/src/org/jbox2d/dynamics/contacts/Position.java +31 -0
- data/src/org/jbox2d/dynamics/contacts/Velocity.java +31 -0
- data/src/org/jbox2d/dynamics/joints/ConstantVolumeJoint.java +258 -0
- data/src/org/jbox2d/dynamics/joints/ConstantVolumeJointDef.java +75 -0
- data/src/org/jbox2d/dynamics/joints/DistanceJoint.java +356 -0
- data/src/org/jbox2d/dynamics/joints/DistanceJointDef.java +106 -0
- data/src/org/jbox2d/dynamics/joints/FrictionJoint.java +294 -0
- data/src/org/jbox2d/dynamics/joints/FrictionJointDef.java +78 -0
- data/src/org/jbox2d/dynamics/joints/GearJoint.java +520 -0
- data/src/org/jbox2d/dynamics/joints/GearJointDef.java +58 -0
- data/src/org/jbox2d/dynamics/joints/Jacobian.java +32 -0
- data/src/org/jbox2d/dynamics/joints/Joint.java +235 -0
- data/src/org/jbox2d/dynamics/joints/JointDef.java +65 -0
- data/src/org/jbox2d/dynamics/joints/JointEdge.java +57 -0
- data/src/org/jbox2d/dynamics/joints/JointType.java +28 -0
- data/src/org/jbox2d/dynamics/joints/LimitState.java +28 -0
- data/src/org/jbox2d/dynamics/joints/MotorJoint.java +339 -0
- data/src/org/jbox2d/dynamics/joints/MotorJointDef.java +55 -0
- data/src/org/jbox2d/dynamics/joints/MouseJoint.java +262 -0
- data/src/org/jbox2d/dynamics/joints/MouseJointDef.java +62 -0
- data/src/org/jbox2d/dynamics/joints/PrismaticJoint.java +808 -0
- data/src/org/jbox2d/dynamics/joints/PrismaticJointDef.java +120 -0
- data/src/org/jbox2d/dynamics/joints/PulleyJoint.java +393 -0
- data/src/org/jbox2d/dynamics/joints/PulleyJointDef.java +105 -0
- data/src/org/jbox2d/dynamics/joints/RevoluteJoint.java +554 -0
- data/src/org/jbox2d/dynamics/joints/RevoluteJointDef.java +137 -0
- data/src/org/jbox2d/dynamics/joints/RopeJoint.java +276 -0
- data/src/org/jbox2d/dynamics/joints/RopeJointDef.java +34 -0
- data/src/org/jbox2d/dynamics/joints/WeldJoint.java +424 -0
- data/src/org/jbox2d/dynamics/joints/WeldJointDef.java +85 -0
- data/src/org/jbox2d/dynamics/joints/WheelJoint.java +498 -0
- data/src/org/jbox2d/dynamics/joints/WheelJointDef.java +98 -0
- data/src/org/jbox2d/particle/ParticleBodyContact.java +17 -0
- data/src/org/jbox2d/particle/ParticleColor.java +52 -0
- data/src/org/jbox2d/particle/ParticleContact.java +14 -0
- data/src/org/jbox2d/particle/ParticleDef.java +24 -0
- data/src/org/jbox2d/particle/ParticleGroup.java +154 -0
- data/src/org/jbox2d/particle/ParticleGroupDef.java +62 -0
- data/src/org/jbox2d/particle/ParticleGroupType.java +8 -0
- data/src/org/jbox2d/particle/ParticleSystem.java +2172 -0
- data/src/org/jbox2d/particle/ParticleType.java +28 -0
- data/src/org/jbox2d/particle/StackQueue.java +44 -0
- data/src/org/jbox2d/particle/VoronoiDiagram.java +209 -0
- data/src/org/jbox2d/pooling/IDynamicStack.java +47 -0
- data/src/org/jbox2d/pooling/IOrderedStack.java +57 -0
- data/src/org/jbox2d/pooling/IWorldPool.java +101 -0
- data/src/org/jbox2d/pooling/arrays/FloatArray.java +50 -0
- data/src/org/jbox2d/pooling/arrays/GeneratorArray.java +33 -0
- data/src/org/jbox2d/pooling/arrays/IntArray.java +53 -0
- data/src/org/jbox2d/pooling/arrays/Vec2Array.java +57 -0
- data/src/org/jbox2d/pooling/normal/CircleStack.java +77 -0
- data/src/org/jbox2d/pooling/normal/DefaultWorldPool.java +331 -0
- data/src/org/jbox2d/pooling/normal/MutableStack.java +72 -0
- data/src/org/jbox2d/pooling/normal/OrderedStack.java +73 -0
- data/src/org/jbox2d/pooling/stacks/DynamicIntStack.java +60 -0
- metadata +161 -14
- 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
|
+
}
|