Skip to content

Commit e936019

Browse files
committed
Merge branch 'update'
2 parents fc4c95e + ae79012 commit e936019

File tree

72 files changed

+15453
-9964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+15453
-9964
lines changed

pom.xml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34

45
<!-- Project information -->
@@ -114,12 +115,12 @@
114115

115116
<!-- Project dependencies -->
116117
<dependencies>
117-
<!-- Provided by third-party -->
118+
<!-- Compile -->
118119
<dependency>
119120
<groupId>net.sf.trove4j</groupId>
120121
<artifactId>trove4j</artifactId>
121122
<version>3.0.3</version>
122-
<scope>provided</scope>
123+
<scope>compile</scope>
123124
</dependency>
124125
<!-- Testing only -->
125126
<dependency>
@@ -262,7 +263,8 @@
262263
<artifactId>maven-javadoc-plugin</artifactId>
263264
<version>2.9.1</version>
264265
<configuration>
265-
<bottom><![CDATA[Copyright (c) {project.inceptionYear} <a href="${project.organization.url}" target="_blank">${project.organization.name}</a>. ${project.name} is licensed under <a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License Version 3</a>]]></bottom>
266+
<bottom>
267+
<![CDATA[Copyright (c) {project.inceptionYear} <a href="${project.organization.url}" target="_blank">${project.organization.name}</a>. ${project.name} is licensed under <a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">GNU Lesser General Public License Version 3</a>]]></bottom>
266268
<doctitle><![CDATA[${project.name} ${project.version}+${ciSystem}-b${buildNumber}.git-${commit}]]></doctitle>
267269
<windowtitle>${project.name} Javadocs</windowtitle>
268270
<author>false</author>

src/main/java/org/spout/physics/ReactDefaults.java

Lines changed: 100 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -30,44 +30,104 @@
3030
* Physics engine constants
3131
*/
3232
public class ReactDefaults {
33-
/**
34-
* The machine epsilon. Default: 1.1920929E-7
35-
*/
36-
public static final float MACHINE_EPSILON = 1.1920929E-7f;
37-
/**
38-
* Default internal constant timestep in seconds. Default: 1/60s
39-
*/
40-
public static final float DEFAULT_TIMESTEP = 1f / 60;
41-
/**
42-
* Default restitution coefficient for a rigid body. Default: 0.5
43-
*/
44-
public static final float DEFAULT_RESTITUTION_COEFFICIENT = 0.5f;
45-
/**
46-
* Default friction coefficient for a rigid body. Default: 0.3
47-
*/
48-
public static final float DEFAULT_FRICTION_COEFFICIENT = 0.3f;
49-
/**
50-
* True if the deactivation (sleeping) of inactive bodies is enabled. Default: true
51-
*/
52-
public static final boolean DEACTIVATION_ENABLED = true;
53-
/**
54-
* Object margin for collision detection in cm. Default: 0.04
55-
*/
56-
public static final float OBJECT_MARGIN = 0.04f;
57-
/**
58-
* Distance threshold for two contact points for a valid persistent contact. Default: 0.02
59-
*/
60-
public static final float PERSISTENT_CONTACT_DIST_THRESHOLD = 0.02f;
61-
/**
62-
* Velocity threshold for contact velocity restitution. Default: 1
63-
*/
64-
public static final float RESTITUTION_VELOCITY_THRESHOLD = 1;
65-
/**
66-
* Number of iterations when solving a LCP problem. Default: 15
67-
*/
68-
public static final int DEFAULT_CONSTRAINTS_SOLVER_NB_ITERATIONS = 15;
69-
/**
70-
* The linked phase AABB scaling factor. Default: 2
71-
*/
72-
public static final float LINKED_PHASE_AABB_SCALING = 2;
33+
/**
34+
* The machine epsilon. Default: 1.1920929E-7
35+
*/
36+
public static final float MACHINE_EPSILON = 1.1920929E-7f;
37+
/**
38+
* 2 * Pi constant.
39+
*/
40+
public static final float PI_TIMES_2 = 6.28318530f;
41+
/**
42+
* Default internal constant timestep in seconds. Default: 1/60s
43+
*/
44+
public static final float DEFAULT_TIMESTEP = 1f / 60;
45+
/**
46+
* Default restitution coefficient for a rigid body. Default: 0.5
47+
*/
48+
public static final float DEFAULT_RESTITUTION_COEFFICIENT = 0.5f;
49+
/**
50+
* Default friction coefficient for a rigid body. Default: 0.3
51+
*/
52+
public static final float DEFAULT_FRICTION_COEFFICIENT = 0.3f;
53+
/**
54+
* Default bounciness factor for a rigid body. Default: 0.5
55+
*/
56+
public static final float DEFAULT_BOUNCINESS = 0.5f;
57+
/**
58+
* True if the sleeping technique is enabled. Default: true
59+
*/
60+
public static final boolean SLEEPING_ENABLED = true;
61+
/**
62+
* Object margin for collision detection in meters (for the GJK-EPA Algorithm). Default: 0.04
63+
*/
64+
public static final float OBJECT_MARGIN = 0.04f;
65+
/**
66+
* Distance threshold for two contact points for a valid persistent contact. Default: 0.02
67+
*/
68+
public static final float PERSISTENT_CONTACT_DIST_THRESHOLD = 0.02f;
69+
/**
70+
* Velocity threshold for contact velocity restitution. Default: 1
71+
*/
72+
public static final float RESTITUTION_VELOCITY_THRESHOLD = 1;
73+
/**
74+
* Number of iterations when solving the velocity constraints of the Sequential Impulse technique. Default: 10
75+
*/
76+
public static final int DEFAULT_VELOCITY_SOLVER_NB_ITERATIONS = 10;
77+
/**
78+
* Number of iterations when solving the position constraints of the Sequential Impulse technique. Default: 5
79+
*/
80+
public static final int DEFAULT_POSITION_SOLVER_NB_ITERATIONS = 5;
81+
/**
82+
* Time (in seconds) that a body must stay still to be considered sleeping. Default: 1
83+
*/
84+
public static final float DEFAULT_TIME_BEFORE_SLEEP = 1.0f;
85+
/**
86+
* A body with a linear velocity smaller than the sleep linear velocity (in m/s) might enter sleeping mode. Default: 0.02
87+
*/
88+
public static final float DEFAULT_SLEEP_LINEAR_VELOCITY = 0.02f;
89+
/**
90+
* A body with angular velocity smaller than the sleep angular velocity (in rad/s) might enter sleeping mode. Default: 3pi/180
91+
*/
92+
public static final float DEFAULT_SLEEP_ANGULAR_VELOCITY = (float) (3 * (Math.PI / 180));
93+
/**
94+
* The linked phase AABB scaling factor. Default: 2
95+
*/
96+
public static final float LINKED_PHASE_AABB_SCALING = 2;
97+
98+
/**
99+
* Position correction technique used in the constraint solver (for joints). Default: NON_LINEAR_GAUSS_SEIDEL
100+
* <p/>
101+
* BAUMGARTE: Faster but can be inaccurate in some situations.
102+
* <p/>
103+
* NON_LINEAR_GAUSS_SEIDEL: Slower but more precise. This is the option used by default.
104+
*/
105+
public static enum JointsPositionCorrectionTechnique {
106+
/**
107+
* Faster but can be inaccurate in some situations.
108+
*/
109+
BAUMGARTE_JOINTS,
110+
/**
111+
* Slower but more precise. This is the option used by default.
112+
*/
113+
NON_LINEAR_GAUSS_SEIDEL
114+
}
115+
116+
/**
117+
* Position correction technique used in the contact solver (for contacts). Default: SPLIT_IMPULSES
118+
* <p/>
119+
* BAUMGARTE: Faster but can be inaccurate and can lead to unexpected bounciness in some situations (due to error correction factor being added to the bodies momentum).
120+
* <p/>
121+
* SPLIT_IMPULSES: A bit slower but the error correction factor is not added to the bodies momentum. This is the option used by default.
122+
*/
123+
public static enum ContactsPositionCorrectionTechnique {
124+
/**
125+
* Faster but can be inaccurate and can lead to unexpected bounciness in some situations (due to error correction factor being added to the bodies momentum).
126+
*/
127+
BAUMGARTE_CONTACTS,
128+
/**
129+
* A bit slower but the error correction factor is not added to the bodies momentum. This is the option used by default.
130+
*/
131+
SPLIT_IMPULSES
132+
}
73133
}

src/main/java/org/spout/physics/Utilities.java

Lines changed: 101 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -30,115 +30,115 @@
3030
* This class contains static utilities. It was added for the port to implement some C++ code in Java.
3131
*/
3232
public class Utilities {
33-
/**
34-
* Returns the index of an object in an array, or -1 if it can't be found.
35-
*
36-
* @param array The array to search
37-
* @param object The object to look for
38-
* @return The index, or -1 if the object wasn't found
39-
*/
40-
public static int indexOf(Object[] array, Object object) {
41-
for (int i = 0; i < array.length; i++) {
42-
if (object.equals(array[i])) {
43-
return i;
44-
}
45-
}
46-
return -1;
47-
}
33+
/**
34+
* Returns the index of an object in an array, or -1 if it can't be found.
35+
*
36+
* @param array The array to search
37+
* @param object The object to look for
38+
* @return The index, or -1 if the object wasn't found
39+
*/
40+
public static int indexOf(Object[] array, Object object) {
41+
for (int i = 0; i < array.length; i++) {
42+
if (object.equals(array[i])) {
43+
return i;
44+
}
45+
}
46+
return -1;
47+
}
4848

49-
/**
50-
* Represents a pair of 32 bit integers.
51-
*/
52-
public static class IntPair {
53-
private int first;
54-
private int second;
49+
/**
50+
* Represents a pair of 32 bit integers.
51+
*/
52+
public static class IntPair {
53+
private int first;
54+
private int second;
5555

56-
/**
57-
* Constructs a new int pair with both integers being 0.
58-
*/
59-
public IntPair() {
60-
this(0, 0);
61-
}
56+
/**
57+
* Constructs a new int pair with both integers being 0.
58+
*/
59+
public IntPair() {
60+
this(0, 0);
61+
}
6262

63-
/**
64-
* Constructs a new int pair with the desired value for each member.
65-
*
66-
* @param first The value of the first member
67-
* @param second The value of the second member
68-
*/
69-
public IntPair(int first, int second) {
70-
this.first = first;
71-
this.second = second;
72-
}
63+
/**
64+
* Constructs a new int pair with the desired value for each member.
65+
*
66+
* @param first The value of the first member
67+
* @param second The value of the second member
68+
*/
69+
public IntPair(int first, int second) {
70+
this.first = first;
71+
this.second = second;
72+
}
7373

74-
/**
75-
* Gets the value of the first member.
76-
*
77-
* @return The first member's value
78-
*/
79-
public int getFirst() {
80-
return first;
81-
}
74+
/**
75+
* Gets the value of the first member.
76+
*
77+
* @return The first member's value
78+
*/
79+
public int getFirst() {
80+
return first;
81+
}
8282

83-
/**
84-
* Sets the first member's value.
85-
*
86-
* @param first The value for the first member
87-
*/
88-
public void setFirst(int first) {
89-
this.first = first;
90-
}
83+
/**
84+
* Sets the first member's value.
85+
*
86+
* @param first The value for the first member
87+
*/
88+
public void setFirst(int first) {
89+
this.first = first;
90+
}
9191

92-
/**
93-
* Gets the value of the second member.
94-
*
95-
* @return The second member's value
96-
*/
97-
public int getSecond() {
98-
return second;
99-
}
92+
/**
93+
* Gets the value of the second member.
94+
*
95+
* @return The second member's value
96+
*/
97+
public int getSecond() {
98+
return second;
99+
}
100100

101-
/**
102-
* Sets the second member's value.
103-
*
104-
* @param second The value for the second member
105-
*/
106-
public void setSecond(int second) {
107-
this.second = second;
108-
}
101+
/**
102+
* Sets the second member's value.
103+
*
104+
* @param second The value for the second member
105+
*/
106+
public void setSecond(int second) {
107+
this.second = second;
108+
}
109109

110-
/**
111-
* Swaps both members. First becomes second, second becomes first.
112-
*/
113-
public void swap() {
114-
final int temp = first;
115-
first = second;
116-
second = temp;
117-
}
110+
/**
111+
* Swaps both members. First becomes second, second becomes first.
112+
*/
113+
public void swap() {
114+
final int temp = first;
115+
first = second;
116+
second = temp;
117+
}
118118

119-
@Override
120-
public boolean equals(Object o) {
121-
if (this == o) {
122-
return true;
123-
}
124-
if (!(o instanceof IntPair)) {
125-
return false;
126-
}
127-
final IntPair intPair = (IntPair) o;
128-
if (first != intPair.getFirst()) {
129-
return false;
130-
}
131-
if (second != intPair.getSecond()) {
132-
return false;
133-
}
134-
return true;
135-
}
119+
@Override
120+
public boolean equals(Object o) {
121+
if (this == o) {
122+
return true;
123+
}
124+
if (!(o instanceof IntPair)) {
125+
return false;
126+
}
127+
final IntPair intPair = (IntPair) o;
128+
if (first != intPair.getFirst()) {
129+
return false;
130+
}
131+
if (second != intPair.getSecond()) {
132+
return false;
133+
}
134+
return true;
135+
}
136136

137-
@Override
138-
public int hashCode() {
139-
int result = first;
140-
result = 31 * result + second;
141-
return result;
142-
}
143-
}
137+
@Override
138+
public int hashCode() {
139+
int result = first;
140+
result = 31 * result + second;
141+
return result;
142+
}
143+
}
144144
}

0 commit comments

Comments
 (0)