3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * CapsuleShapeX represents a capsule around the X axis.
28 | *
29 | * The total height is height+2*radius
, so the height is just the
30 | * height between the center of each "sphere" of the capsule caps.
31 | *
32 | * @author jezek2
33 | */
34 | public class CapsuleShapeX extends CapsuleShape {
35 |
36 | public CapsuleShapeX(float radius, float height) {
37 | upAxis = 0;
38 | implicitShapeDimensions.set(0.5f * height, radius, radius);
39 | }
40 |
41 | @Override
42 | public String getName() {
43 | return "CapsuleX";
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/CapsuleShapeZ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * CapsuleShapeZ represents a capsule around the Z axis.
28 | *
29 | * The total height is height+2*radius
, so the height is just the
30 | * height between the center of each "sphere" of the capsule caps.
31 | *
32 | * @author jezek2
33 | */
34 | public class CapsuleShapeZ extends CapsuleShape {
35 |
36 | public CapsuleShapeZ(float radius, float height) {
37 | upAxis = 2;
38 | implicitShapeDimensions.set(radius, radius, 0.5f * height);
39 | }
40 |
41 | @Override
42 | public String getName() {
43 | return "CapsuleZ";
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/CompoundShapeChild.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
27 | import com.bulletphysics.linearmath.Transform;
28 |
29 | /**
30 | * Compound shape child.
31 | *
32 | * @author jezek2
33 | */
34 | public class CompoundShapeChild {
35 |
36 | public final Transform transform = new Transform();
37 | public CollisionShape childShape;
38 | public BroadphaseNativeType childShapeType;
39 | public float childMargin;
40 |
41 | @Override
42 | public boolean equals(Object obj) {
43 | if (obj == null || !(obj instanceof CompoundShapeChild)) return false;
44 | CompoundShapeChild child = (CompoundShapeChild)obj;
45 | return transform.equals(child.transform) &&
46 | childShape == child.childShape &&
47 | childShapeType == child.childShapeType &&
48 | childMargin == child.childMargin;
49 | }
50 |
51 | @Override
52 | public int hashCode() {
53 | int hash = 7;
54 | hash = 19 * hash + transform.hashCode();
55 | hash = 19 * hash + childShape.hashCode();
56 | hash = 19 * hash + childShapeType.hashCode();
57 | hash = 19 * hash + Float.floatToIntBits(childMargin);
58 | return hash;
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/ConcaveShape.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * ConcaveShape class provides an interface for non-moving (static) concave shapes.
30 | *
31 | * @author jezek2
32 | */
33 | public abstract class ConcaveShape extends CollisionShape {
34 |
35 | protected float collisionMargin = 0f;
36 |
37 | public abstract void processAllTriangles(TriangleCallback callback, Vector3f aabbMin, Vector3f aabbMax);
38 |
39 | public float getMargin() {
40 | return collisionMargin;
41 | }
42 |
43 | public void setMargin(float margin) {
44 | this.collisionMargin = margin;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/ConeShapeX.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * ConeShape implements a cone shape, around the X axis.
28 | *
29 | * @author jezek2
30 | */
31 | public class ConeShapeX extends ConeShape {
32 |
33 | public ConeShapeX(float radius, float height) {
34 | super(radius, height);
35 | setConeUpIndex(0);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/ConeShapeZ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * ConeShape implements a cone shape, around the Z axis.
28 | *
29 | * @author jezek2
30 | */
31 | public class ConeShapeZ extends ConeShape {
32 |
33 | public ConeShapeZ(float radius, float height) {
34 | super(radius, height);
35 | setConeUpIndex(2);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/ConvexShape.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import com.bulletphysics.linearmath.Transform;
27 | import javax.vecmath.Vector3f;
28 |
29 | /**
30 | * ConvexShape is an abstract shape class. It describes general convex shapes
31 | * using the {@link #localGetSupportingVertex localGetSupportingVertex} interface
32 | * used in combination with GJK or ConvexCast.
33 | *
34 | * @author jezek2
35 | */
36 | public abstract class ConvexShape extends CollisionShape {
37 |
38 | public static final int MAX_PREFERRED_PENETRATION_DIRECTIONS = 10;
39 |
40 | public abstract Vector3f localGetSupportingVertex(Vector3f vec, Vector3f out);
41 |
42 | //#ifndef __SPU__
43 | public abstract Vector3f localGetSupportingVertexWithoutMargin(Vector3f vec, Vector3f out);
44 |
45 | //notice that the vectors should be unit length
46 | public abstract void batchedUnitVectorGetSupportingVertexWithoutMargin(Vector3f[] vectors, Vector3f[] supportVerticesOut, int numVectors);
47 | //#endif
48 |
49 | public abstract void getAabbSlow(Transform t, Vector3f aabbMin, Vector3f aabbMax);
50 |
51 | public abstract void setLocalScaling(Vector3f scaling);
52 |
53 | public abstract Vector3f getLocalScaling(Vector3f out);
54 |
55 | public abstract void setMargin(float margin);
56 |
57 | public abstract float getMargin();
58 |
59 | public abstract int getNumPreferredPenetrationDirections();
60 |
61 | public abstract void getPreferredPenetrationDirection(int index, Vector3f penetrationVector);
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/CylinderShapeX.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import cz.advel.stack.Stack;
27 | import javax.vecmath.Vector3f;
28 |
29 | /**
30 | * Cylinder shape around the X axis.
31 | *
32 | * @author jezek2
33 | */
34 | public class CylinderShapeX extends CylinderShape {
35 |
36 | public CylinderShapeX(Vector3f halfExtents) {
37 | super(halfExtents, false);
38 | upAxis = 0;
39 | recalcLocalAabb();
40 | }
41 |
42 | @Override
43 | public Vector3f localGetSupportingVertexWithoutMargin(Vector3f vec, Vector3f out) {
44 | return cylinderLocalSupportX(getHalfExtentsWithoutMargin(Stack.alloc(Vector3f.class)), vec, out);
45 | }
46 |
47 | @Override
48 | public void batchedUnitVectorGetSupportingVertexWithoutMargin(Vector3f[] vectors, Vector3f[] supportVerticesOut, int numVectors) {
49 | for (int i = 0; i < numVectors; i++) {
50 | cylinderLocalSupportX(getHalfExtentsWithoutMargin(Stack.alloc(Vector3f.class)), vectors[i], supportVerticesOut[i]);
51 | }
52 | }
53 |
54 | @Override
55 | public float getRadius() {
56 | return getHalfExtentsWithMargin(Stack.alloc(Vector3f.class)).y;
57 | }
58 |
59 | @Override
60 | public String getName() {
61 | return "CylinderX";
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/CylinderShapeZ.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import cz.advel.stack.Stack;
27 | import javax.vecmath.Vector3f;
28 |
29 | /**
30 | * Cylinder shape around the Z axis.
31 | *
32 | * @author jezek2
33 | */
34 | public class CylinderShapeZ extends CylinderShape {
35 |
36 | public CylinderShapeZ(Vector3f halfExtents) {
37 | super(halfExtents, false);
38 | upAxis = 2;
39 | recalcLocalAabb();
40 | }
41 |
42 | @Override
43 | public Vector3f localGetSupportingVertexWithoutMargin(Vector3f vec, Vector3f out) {
44 | return cylinderLocalSupportZ(getHalfExtentsWithoutMargin(Stack.alloc(Vector3f.class)), vec, out);
45 | }
46 |
47 | @Override
48 | public void batchedUnitVectorGetSupportingVertexWithoutMargin(Vector3f[] vectors, Vector3f[] supportVerticesOut, int numVectors) {
49 | for (int i = 0; i < numVectors; i++) {
50 | cylinderLocalSupportZ(getHalfExtentsWithoutMargin(Stack.alloc(Vector3f.class)), vectors[i], supportVerticesOut[i]);
51 | }
52 | }
53 |
54 | @Override
55 | public float getRadius() {
56 | return getHalfExtentsWithMargin(Stack.alloc(Vector3f.class)).x;
57 | }
58 |
59 | @Override
60 | public String getName() {
61 | return "CylinderZ";
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/IndexedMesh.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import java.nio.ByteBuffer;
27 |
28 | /**
29 | * IndexedMesh indexes into existing vertex and index arrays, in a similar way to
30 | * OpenGL's glDrawElements. Instead of the number of indices, we pass the number
31 | * of triangles.
32 | *
33 | * @author jezek2
34 | */
35 | public class IndexedMesh {
36 |
37 | public int numTriangles;
38 | public ByteBuffer triangleIndexBase;
39 | public int triangleIndexStride;
40 | public int numVertices;
41 | public ByteBuffer vertexBase;
42 | public int vertexStride;
43 | // The index type is set when adding an indexed mesh to the
44 | // TriangleIndexVertexArray, do not set it manually
45 | public ScalarType indexType;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/InternalTriangleIndexCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * Callback for internal processing of triangles.
30 | *
31 | * @see StridingMeshInterface#internalProcessAllTriangles
32 | * @author jezek2
33 | */
34 | public abstract class InternalTriangleIndexCallback {
35 |
36 | public abstract void internalProcessTriangleIndex(Vector3f[] triangle, int partId, int triangleIndex);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/NodeOverlapCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * Callback for operating with {@link OptimizedBvh}.
28 | *
29 | * @author jezek2
30 | */
31 | public abstract class NodeOverlapCallback {
32 |
33 | public abstract void processNode(int subPart, int triangleIndex);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/OptimizedBvhNode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import java.io.Serializable;
27 | import javax.vecmath.Vector3f;
28 |
29 | /**
30 | * OptimizedBvhNode contains both internal and leaf node information.
31 | *
32 | * @author jezek2
33 | */
34 | public class OptimizedBvhNode implements Serializable {
35 |
36 | private static final long serialVersionUID = 1L;
37 |
38 | public final Vector3f aabbMinOrg = new Vector3f();
39 | public final Vector3f aabbMaxOrg = new Vector3f();
40 |
41 | public int escapeIndex;
42 |
43 | // for child nodes
44 | public int subPart;
45 | public int triangleIndex;
46 |
47 | public void set(OptimizedBvhNode n) {
48 | aabbMinOrg.set(n.aabbMinOrg);
49 | aabbMaxOrg.set(n.aabbMaxOrg);
50 | escapeIndex = n.escapeIndex;
51 | subPart = n.subPart;
52 | triangleIndex = n.triangleIndex;
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/ScalarType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * Scalar type, used when accessing triangle mesh data.
28 | *
29 | * @author jezek2
30 | */
31 | public enum ScalarType {
32 | FLOAT,
33 | DOUBLE,
34 | INTEGER,
35 | SHORT,
36 | FIXEDPOINT88
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/TraversalMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | /**
27 | * Traversal mode for {@link OptimizedBvh}.
28 | *
29 | * @author jezek2
30 | */
31 | public enum TraversalMode {
32 | STACKLESS,
33 | STACKLESS_CACHE_FRIENDLY,
34 | RECURSIVE
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/TriangleCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * TriangleCallback provides a callback for each overlapping triangle when calling
30 | * processAllTriangles.
31 | *
32 | * This callback is called by processAllTriangles for all {@link ConcaveShape} derived
33 | * classes, such as {@link BvhTriangleMeshShape}, {@link StaticPlaneShape} and
34 | * {@link HeightfieldTerrainShape}.
35 | *
36 | * @author jezek2
37 | */
38 | public abstract class TriangleCallback {
39 |
40 | public abstract void processTriangle(Vector3f[] triangle, int partId, int triangleIndex);
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/VertexData.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.collision.shapes;
25 |
26 | import com.bulletphysics.linearmath.VectorUtil;
27 | import javax.vecmath.Tuple3f;
28 | import javax.vecmath.Vector3f;
29 |
30 | /**
31 | * Allows accessing vertex data.
32 | *
33 | * @author jezek2
34 | */
35 | public abstract class VertexData {
36 |
37 | public abstract int getVertexCount();
38 |
39 | public abstract int getIndexCount();
40 |
41 | public abstract T getVertex(int idx, T out);
42 |
43 | public abstract void setVertex(int idx, float x, float y, float z);
44 |
45 | public void setVertex(int idx, Tuple3f t) {
46 | setVertex(idx, t.x, t.y, t.z);
47 | }
48 |
49 | public abstract int getIndex(int idx);
50 |
51 | public void getTriangle(int firstIndex, Vector3f scale, Vector3f[] triangle) {
52 | for (int i=0; i<3; i++) {
53 | getVertex(getIndex(firstIndex+i), triangle[i]);
54 | VectorUtil.mul(triangle[i], triangle[i], scale);
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/collision/shapes/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Collision shapes.
26 | */
27 | package com.bulletphysics.collision.shapes;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/demos/applet/Light.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Software OpenGL-like 3D renderer (c) 2008 Martin Dvorak
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty.
5 | * In no event will the authors be held liable for any damages arising from
6 | * the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | package com.bulletphysics.demos.applet;
22 |
23 | import javax.vecmath.Vector4f;
24 |
25 | /**
26 | *
27 | * @author jezek2
28 | */
29 | public class Light {
30 |
31 | public boolean enabled = false;
32 | public final Vector4f ambient = new Vector4f(0f, 0f, 0f, 1f);
33 | public final Vector4f diffuse = new Vector4f(1f, 1f, 1f, 1f);
34 | public final Vector4f specular = new Vector4f(1f, 1f, 1f, 1f);
35 | public final Vector4f position = new Vector4f(0f, 0f, 1f, 0f);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/demos/applet/LookUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty.
5 | * In no event will the authors be held liable for any damages arising from
6 | * the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | package com.bulletphysics.demos.applet;
22 |
23 | import java.awt.Graphics2D;
24 | import java.awt.RenderingHints;
25 | import java.awt.Toolkit;
26 | import javax.swing.UIManager;
27 |
28 | /**
29 | *
30 | * @author jezek2
31 | */
32 | public class LookUtil {
33 |
34 | private static Object oldAA = null;
35 |
36 | public static void pushAntialias(Graphics2D g2) {
37 | oldAA = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
38 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
39 | }
40 |
41 | public static void popAntialias(Graphics2D g2) {
42 | g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAA);
43 | oldAA = null;
44 | }
45 |
46 | public static boolean isXP() {
47 | if (isWindows()) {
48 | Boolean b = (Boolean)Toolkit.getDefaultToolkit().getDesktopProperty("win.xpstyle.themeActive");
49 | if (b != null && b) return true;
50 | }
51 |
52 | return false;
53 | }
54 |
55 | public static boolean isWindows() {
56 | Object laf = UIManager.getLookAndFeel();
57 | if (laf.getClass().getName().equals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel")) {
58 | return true;
59 | }
60 | return false;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/demos/applet/Span.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Software OpenGL-like 3D renderer (c) 2008 Martin Dvorak
3 | *
4 | * This software is provided 'as-is', without any express or implied warranty.
5 | * In no event will the authors be held liable for any damages arising from
6 | * the use of this software.
7 | *
8 | * Permission is granted to anyone to use this software for any purpose,
9 | * including commercial applications, and to alter it and redistribute it
10 | * freely, subject to the following restrictions:
11 | *
12 | * 1. The origin of this software must not be misrepresented; you must not
13 | * claim that you wrote the original software. If you use this software
14 | * in a product, an acknowledgment in the product documentation would be
15 | * appreciated but is not required.
16 | * 2. Altered source versions must be plainly marked as such, and must not be
17 | * misrepresented as being the original software.
18 | * 3. This notice may not be removed or altered from any source distribution.
19 | */
20 |
21 | package com.bulletphysics.demos.applet;
22 |
23 | /**
24 | *
25 | * @author jezek2
26 | */
27 | class Span {
28 |
29 | public int x1, x2;
30 | public float z1, z2;
31 | public short c1r, c1g, c1b;
32 | public short c2r, c2g, c2b;
33 |
34 | public Span prev, next;
35 |
36 | public void set(Span s) {
37 | x1 = s.x1;
38 | x2 = s.x2;
39 | z1 = s.z1;
40 | z2 = s.z2;
41 | c1r = s.c1r;
42 | c1g = s.c1g;
43 | c1b = s.c1b;
44 | c2r = s.c2r;
45 | c2g = s.c2g;
46 | c2b = s.c2b;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/demos/bsp/BspConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.demos.bsp;
25 |
26 | import com.bulletphysics.util.ObjectArrayList;
27 | import java.io.BufferedReader;
28 | import java.io.IOException;
29 | import java.io.InputStream;
30 | import java.io.InputStreamReader;
31 | import javax.vecmath.Vector3f;
32 |
33 | /**
34 | *
35 | * @author jezek2
36 | */
37 | public abstract class BspConverter {
38 |
39 | public void convertBsp(InputStream in) throws IOException {
40 | BufferedReader r = new BufferedReader(new InputStreamReader(in, "UTF-8"));
41 | String s;
42 |
43 | ObjectArrayList vertices = new ObjectArrayList();
44 | while ((s = r.readLine()) != null) {
45 | int count = Integer.parseInt(s);
46 | vertices.clear();
47 | for (int i=0; i vertices);
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/demos/bsp/exporter.diff:
--------------------------------------------------------------------------------
1 | --- BspDemo.cpp.orig 2007-12-10 03:18:38.000000000 +0100
2 | +++ BspDemo.cpp 2008-01-26 10:53:19.497747800 +0100
3 | @@ -48,16 +48,26 @@
4 | class BspToBulletConverter : public BspConverter
5 | {
6 | BspDemo* m_demoApp;
7 | + FILE *f;
8 |
9 | public:
10 |
11 | BspToBulletConverter(BspDemo* demoApp)
12 | :m_demoApp(demoApp)
13 | {
14 | + f = fopen("_export_bsp_", "wb");
15 | }
16 |
17 | + virtual ~BspToBulletConverter() {
18 | + fclose(f);
19 | + }
20 | +
21 | virtual void addConvexVerticesCollider(btAlignedObjectArray& vertices, bool isEntity, const btVector3& entityTargetLocation)
22 | {
23 | + fprintf(f, "%d\n", vertices.size());
24 | + for (int i=0; i
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.demos.opengl;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | public class FastFormat {
31 |
32 | private static final char[] DIGITS = "0123456789".toCharArray();
33 |
34 | public static void append(StringBuilder b, int i) {
35 | if (i < 0) {
36 | b.append('-');
37 | i = Math.abs(i);
38 | }
39 |
40 | int digit = 1000000000;
41 | boolean first = true;
42 | while (digit >= 1) {
43 | int v = (i/digit);
44 | if (v != 0 || !first) {
45 | b.append(DIGITS[v]);
46 | first = false;
47 | }
48 | i -= v*digit;
49 | digit /= 10;
50 | }
51 |
52 | if (first) b.append('0');
53 | }
54 |
55 | public static void append(StringBuilder b, float f) {
56 | append(b, f, 2);
57 | }
58 |
59 | public static void append(StringBuilder b, float f, int fracDigits) {
60 | int mult = 10*fracDigits;
61 | int val = Math.round(f*mult);
62 | append(b, val / mult);
63 | b.append('.');
64 | append(b, Math.abs(val % mult));
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/ActionInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics;
25 |
26 | import com.bulletphysics.collision.dispatch.CollisionWorld;
27 | import com.bulletphysics.linearmath.IDebugDraw;
28 |
29 | /**
30 | * Basic interface to allow actions such as vehicles and characters to be
31 | * updated inside a {@link DynamicsWorld}.
32 | *
33 | * @author tomrbryn
34 | */
35 | public abstract class ActionInterface {
36 |
37 | public abstract void updateAction(CollisionWorld collisionWorld, float deltaTimeStep);
38 |
39 | public abstract void debugDraw(IDebugDraw debugDrawer);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/DynamicsWorldType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics;
25 |
26 | /**
27 | * Dynamics world type.
28 | *
29 | * @author jezek2
30 | */
31 | public enum DynamicsWorldType {
32 | SIMPLE_DYNAMICS_WORLD,
33 | DISCRETE_DYNAMICS_WORLD,
34 | CONTINUOUS_DYNAMICS_WORLD
35 | }
36 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/InternalTickCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics;
25 |
26 | /**
27 | * Callback called for each internal tick.
28 | *
29 | * @see DynamicsWorld#setInternalTickCallback
30 | * @author jezek2
31 | */
32 | public abstract class InternalTickCallback {
33 |
34 | public abstract void internalTick(DynamicsWorld world, float timeStep);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/ConstraintSolver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | import com.bulletphysics.collision.broadphase.Dispatcher;
27 | import com.bulletphysics.collision.dispatch.CollisionObject;
28 | import com.bulletphysics.collision.narrowphase.PersistentManifold;
29 | import com.bulletphysics.linearmath.IDebugDraw;
30 | import com.bulletphysics.util.ObjectArrayList;
31 |
32 | /**
33 | * Abstract class for constraint solvers.
34 | *
35 | * @author jezek2
36 | */
37 | public abstract class ConstraintSolver {
38 |
39 | //protected final BulletStack stack = BulletStack.get();
40 |
41 | public void prepareSolve (int numBodies, int numManifolds) {}
42 |
43 | /**
44 | * Solve a group of constraints.
45 | */
46 | public abstract float solveGroup(ObjectArrayList bodies, int numBodies, ObjectArrayList manifold, int manifold_offset, int numManifolds, ObjectArrayList constraints, int constraints_offset, int numConstraints, ContactSolverInfo info, IDebugDraw debugDrawer/*, btStackAlloc* stackAlloc*/, Dispatcher dispatcher);
47 |
48 | public void allSolved(ContactSolverInfo info, IDebugDraw debugDrawer/*, btStackAlloc* stackAlloc*/) {}
49 |
50 | /**
51 | * Clear internal cached data and reset random seed.
52 | */
53 | public abstract void reset();
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/ContactConstraintEnum.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | /**
27 | * TODO: name
28 | *
29 | * @author jezek2
30 | */
31 | enum ContactConstraintEnum {
32 | DEFAULT_CONTACT_SOLVER_TYPE,
33 | CONTACT_SOLVER_TYPE1,
34 | CONTACT_SOLVER_TYPE2,
35 | USER_CONTACT_SOLVER_TYPE1,
36 | MAX_CONTACT_SOLVER_TYPES
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/ContactSolverFunc.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | import com.bulletphysics.collision.narrowphase.ManifoldPoint;
27 | import com.bulletphysics.dynamics.RigidBody;
28 |
29 | /**
30 | * Contact solving function.
31 | *
32 | * @author jezek2
33 | */
34 | public abstract class ContactSolverFunc {
35 |
36 | public abstract float resolveContact(RigidBody body1, RigidBody body2, ManifoldPoint contactPoint, ContactSolverInfo info);
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/ContactSolverInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | /**
27 | * Current state of contact solver.
28 | *
29 | * @author jezek2
30 | */
31 | public class ContactSolverInfo {
32 |
33 | public float tau = 0.6f;
34 | public float damping = 1f;
35 | public float friction = 0.3f;
36 | public float timeStep;
37 | public float restitution = 0f;
38 | public int numIterations = 10;
39 | public float maxErrorReduction = 20f;
40 | public float sor = 1.3f;
41 | public float erp = 0.2f; // used as Baumgarte factor
42 | public float erp2 = 0.1f; // used in Split Impulse
43 | public boolean splitImpulse = false;
44 | public float splitImpulsePenetrationThreshold = -0.02f;
45 | public float linearSlop = 0f;
46 | public float warmstartingFactor = 0.85f;
47 |
48 | public int solverMode = SolverMode.SOLVER_RANDMIZE_ORDER | SolverMode.SOLVER_CACHE_FRIENDLY | SolverMode.SOLVER_USE_WARMSTARTING;
49 |
50 | public ContactSolverInfo() {
51 | }
52 |
53 | public ContactSolverInfo(ContactSolverInfo g) {
54 | tau = g.tau;
55 | damping = g.damping;
56 | friction = g.friction;
57 | timeStep = g.timeStep;
58 | restitution = g.restitution;
59 | numIterations = g.numIterations;
60 | maxErrorReduction = g.maxErrorReduction;
61 | sor = g.sor;
62 | erp = g.erp;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/SolverConstraint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * 1D constraint along a normal axis between bodyA and bodyB. It can be combined
30 | * to solve contact and friction constraints.
31 | *
32 | * @author jezek2
33 | */
34 | public class SolverConstraint {
35 |
36 | public final Vector3f relpos1CrossNormal = new Vector3f();
37 | public final Vector3f contactNormal = new Vector3f();
38 |
39 | public final Vector3f relpos2CrossNormal = new Vector3f();
40 | public final Vector3f angularComponentA = new Vector3f();
41 |
42 | public final Vector3f angularComponentB = new Vector3f();
43 |
44 | public float appliedPushImpulse;
45 |
46 | public float appliedImpulse;
47 | public int solverBodyIdA;
48 | public int solverBodyIdB;
49 |
50 | public float friction;
51 | public float restitution;
52 | public float jacDiagABInv;
53 | public float penetration;
54 |
55 | public SolverConstraintType constraintType;
56 | public int frictionIndex;
57 | public Object originalContactPoint;
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/SolverConstraintType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | /**
27 | * Solver constraint type.
28 | *
29 | * @author jezek2
30 | */
31 | public enum SolverConstraintType {
32 | SOLVER_CONTACT_1D,
33 | SOLVER_FRICTION_1D
34 | }
35 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/SolverMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | /**
27 | * Solver flags.
28 | *
29 | * @author jezek2
30 | */
31 | public class SolverMode {
32 |
33 | public static final int SOLVER_RANDMIZE_ORDER = 1;
34 | public static final int SOLVER_FRICTION_SEPARATE = 2;
35 | public static final int SOLVER_USE_WARMSTARTING = 4;
36 | public static final int SOLVER_CACHE_FRIENDLY = 8;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/TypedConstraintType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.constraintsolver;
25 |
26 | /**
27 | * Typed constraint type.
28 | *
29 | * @author jezek2
30 | */
31 | public enum TypedConstraintType {
32 | POINT2POINT_CONSTRAINT_TYPE,
33 | HINGE_CONSTRAINT_TYPE,
34 | CONETWIST_CONSTRAINT_TYPE,
35 | D6_CONSTRAINT_TYPE,
36 | VEHICLE_CONSTRAINT_TYPE,
37 | SLIDER_CONSTRAINT_TYPE
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/constraintsolver/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Constraints and solvers.
26 | */
27 | package com.bulletphysics.dynamics.constraintsolver;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * DynamicsWorld and RigidBody.
26 | */
27 | package com.bulletphysics.dynamics;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/vehicle/DefaultVehicleRaycaster.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.vehicle;
25 |
26 | import com.bulletphysics.collision.dispatch.CollisionWorld.ClosestRayResultCallback;
27 | import com.bulletphysics.dynamics.DynamicsWorld;
28 | import com.bulletphysics.dynamics.RigidBody;
29 | import javax.vecmath.Vector3f;
30 |
31 | /**
32 | * Default implementation of {@link VehicleRaycaster}.
33 | *
34 | * @author jezek2
35 | */
36 | public class DefaultVehicleRaycaster extends VehicleRaycaster {
37 |
38 | protected DynamicsWorld dynamicsWorld;
39 |
40 | public DefaultVehicleRaycaster(DynamicsWorld world) {
41 | this.dynamicsWorld = world;
42 | }
43 |
44 | public Object castRay(Vector3f from, Vector3f to, VehicleRaycasterResult result) {
45 | //RayResultCallback& resultCallback;
46 |
47 | ClosestRayResultCallback rayCallback = new ClosestRayResultCallback(from, to);
48 |
49 | dynamicsWorld.rayTest(from, to, rayCallback);
50 |
51 | if (rayCallback.hasHit()) {
52 | RigidBody body = RigidBody.upcast(rayCallback.collisionObject);
53 | if (body != null && body.hasContactResponse()) {
54 | result.hitPointInWorld.set(rayCallback.hitPointWorld);
55 | result.hitNormalInWorld.set(rayCallback.hitNormalWorld);
56 | result.hitNormalInWorld.normalize();
57 | result.distFraction = rayCallback.closestHitFraction;
58 | return body;
59 | }
60 | }
61 | return null;
62 | }
63 |
64 | }
65 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/vehicle/VehicleRaycaster.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.vehicle;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * VehicleRaycaster is provides interface for between vehicle simulation and raycasting.
30 | *
31 | * @author jezek2
32 | */
33 | public abstract class VehicleRaycaster {
34 |
35 | public abstract Object castRay(Vector3f from, Vector3f to, VehicleRaycasterResult result);
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/vehicle/VehicleRaycasterResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.vehicle;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | * Vehicle raycaster result.
30 | *
31 | * @author jezek2
32 | */
33 | public class VehicleRaycasterResult {
34 |
35 | public final Vector3f hitPointInWorld = new Vector3f();
36 | public final Vector3f hitNormalInWorld = new Vector3f();
37 | public float distFraction = -1f;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/vehicle/VehicleTuning.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.vehicle;
25 |
26 | /**
27 | * Vehicle tuning parameters.
28 | *
29 | * @author jezek2
30 | */
31 | public class VehicleTuning {
32 |
33 | public float suspensionStiffness = 5.88f;
34 | public float suspensionCompression = 0.83f;
35 | public float suspensionDamping = 0.88f;
36 | public float maxSuspensionTravelCm = 500f;
37 | public float frictionSlip = 10.5f;
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/dynamics/vehicle/WheelInfoConstructionInfo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.dynamics.vehicle;
25 |
26 | import javax.vecmath.Vector3f;
27 |
28 | /**
29 | *
30 | * @author jezek2
31 | */
32 | public class WheelInfoConstructionInfo {
33 |
34 | public final Vector3f chassisConnectionCS = new Vector3f();
35 | public final Vector3f wheelDirectionCS = new Vector3f();
36 | public final Vector3f wheelAxleCS = new Vector3f();
37 | public float suspensionRestLength;
38 | public float maxSuspensionTravelCm;
39 | public float wheelRadius;
40 |
41 | public float suspensionStiffness;
42 | public float wheelsDampingCompression;
43 | public float wheelsDampingRelaxation;
44 | public float frictionSlip;
45 | public boolean bIsFrontWheel;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/GImpactMassUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | import javax.vecmath.Vector3f;
31 |
32 | /**
33 | *
34 | * @author jezek2
35 | */
36 | class GImpactMassUtil {
37 |
38 | public static Vector3f get_point_inertia(Vector3f point, float mass, Vector3f out) {
39 | float x2 = point.x * point.x;
40 | float y2 = point.y * point.y;
41 | float z2 = point.z * point.z;
42 | out.set(mass * (y2 + z2), mass * (x2 + z2), mass * (x2 + y2));
43 | return out;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/GImpactTriangleCallback.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | import com.bulletphysics.collision.dispatch.CollisionObject;
31 | import com.bulletphysics.collision.shapes.TriangleCallback;
32 | import javax.vecmath.Vector3f;
33 |
34 | /**
35 | *
36 | * @author jezek2
37 | */
38 | class GImpactTriangleCallback extends TriangleCallback {
39 |
40 | public GImpactCollisionAlgorithm algorithm;
41 | public CollisionObject body0;
42 | public CollisionObject body1;
43 | public GImpactShapeInterface gimpactshape0;
44 | public boolean swapped;
45 | public float margin;
46 |
47 | public void processTriangle(Vector3f[] triangle, int partId, int triangleIndex) {
48 | TriangleShapeEx tri1 = new TriangleShapeEx(triangle[0], triangle[1], triangle[2]);
49 | tri1.setMargin(margin);
50 | if (swapped) {
51 | algorithm.setPart0(partId);
52 | algorithm.setFace0(triangleIndex);
53 | }
54 | else {
55 | algorithm.setPart1(partId);
56 | algorithm.setFace1(triangleIndex);
57 | }
58 | algorithm.gimpact_vs_shape(body0, body1, gimpactshape0, tri1, swapped);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/Pair.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | /**
31 | * Overlapping pair.
32 | *
33 | * @author jezek2
34 | */
35 | class Pair {
36 |
37 | public int index1;
38 | public int index2;
39 |
40 | public Pair() {
41 | }
42 |
43 | public Pair(int index1, int index2) {
44 | this.index1 = index1;
45 | this.index2 = index2;
46 | }
47 |
48 | public Pair(Pair p) {
49 | index1 = p.index1;
50 | index2 = p.index2;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/PairSet.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | /**
31 | *
32 | * @author jezek2
33 | */
34 | class PairSet {
35 |
36 | private Pair[] array;
37 | private int size = 0;
38 |
39 | public PairSet() {
40 | array = new Pair[32];
41 | for (int i=0; i= size) throw new IndexOutOfBoundsException();
56 | return array[index];
57 | }
58 |
59 | @SuppressWarnings("unchecked")
60 | private void expand() {
61 | Pair[] newArray = new Pair[array.length << 1];
62 | for (int i=array.length; i
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | /**
31 | *
32 | * @author jezek2
33 | */
34 | enum PlaneIntersectionType {
35 | BACK_PLANE,
36 | COLLIDE_PLANE,
37 | FRONT_PLANE
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/PlaneShape.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | import com.bulletphysics.collision.shapes.StaticPlaneShape;
31 | import com.bulletphysics.linearmath.Transform;
32 | import com.bulletphysics.linearmath.VectorUtil;
33 | import cz.advel.stack.Stack;
34 | import javax.vecmath.Vector3f;
35 | import javax.vecmath.Vector4f;
36 |
37 | /**
38 | *
39 | * @author jezek2
40 | */
41 | class PlaneShape {
42 |
43 | public static void get_plane_equation(StaticPlaneShape shape, Vector4f equation) {
44 | Vector3f tmp = Stack.alloc(Vector3f.class);
45 | equation.set(shape.getPlaneNormal(tmp));
46 | equation.w = shape.getPlaneConstant();
47 | }
48 |
49 | public static void get_plane_equation_transformed(StaticPlaneShape shape, Transform trans, Vector4f equation) {
50 | get_plane_equation(shape, equation);
51 |
52 | Vector3f tmp = Stack.alloc(Vector3f.class);
53 |
54 | trans.basis.getRow(0, tmp);
55 | float x = VectorUtil.dot3(tmp, equation);
56 | trans.basis.getRow(1, tmp);
57 | float y = VectorUtil.dot3(tmp, equation);
58 | trans.basis.getRow(2, tmp);
59 | float z = VectorUtil.dot3(tmp, equation);
60 |
61 | float w = VectorUtil.dot3(trans.origin, equation) + equation.w;
62 |
63 | equation.set(x, y, z, w);
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/PrimitiveManagerBase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | import com.bulletphysics.extras.gimpact.BoxCollision.AABB;
31 |
32 | /**
33 | * Prototype Base class for primitive classification.
34 | *
35 | * This class is a wrapper for primitive collections.
36 | *
37 | * This tells relevant info for the Bounding Box set classes, which take care of space classification.
38 | *
39 | * This class can manage Compound shapes and trimeshes, and if it is managing trimesh then the
40 | * Hierarchy Bounding Box classes will take advantage of primitive Vs Box overlapping tests for
41 | * getting optimal results and less Per Box compairisons.
42 | *
43 | * @author jezek2
44 | */
45 | abstract class PrimitiveManagerBase {
46 |
47 | /**
48 | * Determines if this manager consist on only triangles, which special case will be optimized.
49 | */
50 | public abstract boolean is_trimesh();
51 |
52 | public abstract int get_primitive_count();
53 |
54 | public abstract void get_primitive_box(int prim_index, AABB primbox);
55 |
56 | /**
57 | * Retrieves only the points of the triangle, and the collision margin.
58 | */
59 | public abstract void get_primitive_triangle(int prim_index, PrimitiveTriangle triangle);
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/ShapeType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | /**
31 | *
32 | * @author jezek2
33 | */
34 | enum ShapeType {
35 | COMPOUND_SHAPE,
36 | TRIMESH_SHAPE_PART,
37 | TRIMESH_SHAPE
38 | }
39 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/TetrahedronShapeEx.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * This source file is part of GIMPACT Library.
5 | *
6 | * For the latest info, see http://gimpact.sourceforge.net/
7 | *
8 | * Copyright (c) 2007 Francisco Leon Najera. C.C. 80087371.
9 | * email: projectileman@yahoo.com
10 | *
11 | * This software is provided 'as-is', without any express or implied warranty.
12 | * In no event will the authors be held liable for any damages arising from
13 | * the use of this software.
14 | *
15 | * Permission is granted to anyone to use this software for any purpose,
16 | * including commercial applications, and to alter it and redistribute it
17 | * freely, subject to the following restrictions:
18 | *
19 | * 1. The origin of this software must not be misrepresented; you must not
20 | * claim that you wrote the original software. If you use this software
21 | * in a product, an acknowledgment in the product documentation would be
22 | * appreciated but is not required.
23 | * 2. Altered source versions must be plainly marked as such, and must not be
24 | * misrepresented as being the original software.
25 | * 3. This notice may not be removed or altered from any source distribution.
26 | */
27 |
28 | package com.bulletphysics.extras.gimpact;
29 |
30 | import com.bulletphysics.collision.shapes.BU_Simplex1to4;
31 | import javax.vecmath.Vector3f;
32 |
33 | /**
34 | * Helper class for tetrahedrons.
35 | *
36 | * @author jezek2
37 | */
38 | class TetrahedronShapeEx extends BU_Simplex1to4 {
39 |
40 | public TetrahedronShapeEx() {
41 | numVertices = 4;
42 | for (int i = 0; i < numVertices; i++) {
43 | vertices[i] = new Vector3f();
44 | }
45 | }
46 |
47 | public void setVertices(Vector3f v0, Vector3f v1, Vector3f v2, Vector3f v3) {
48 | vertices[0].set(v0);
49 | vertices[1].set(v1);
50 | vertices[2].set(v2);
51 | vertices[3].set(v3);
52 | recalcLocalAabb();
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/extras/gimpact/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Provides support for moving concave triangle meshes.
26 | */
27 | package com.bulletphysics.extras.gimpact;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/Clock.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath;
25 |
26 | /**
27 | * Clock is a portable basic clock that measures accurate time in seconds, use for profiling.
28 | *
29 | * @author jezek2
30 | */
31 | public class Clock {
32 |
33 | private long startTime;
34 |
35 | /**
36 | * Creates a new clock and resets it.
37 | */
38 | public Clock() {
39 | reset();
40 | }
41 |
42 | /**
43 | * Resets clock by setting start time to current.
44 | */
45 | public void reset() {
46 | startTime = System.nanoTime();
47 | }
48 |
49 | /**
50 | * Returns the time in milliseconds since the last call to reset or since the Clock was created.
51 | */
52 | public long getTimeMilliseconds() {
53 | return (System.nanoTime() - startTime) / 1000000L;
54 | }
55 |
56 | /**
57 | * Returns the time in microseconds since the last call to reset or since the Clock was created.
58 | */
59 | public long getTimeMicroseconds() {
60 | return (System.nanoTime() - startTime) / 1000L;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/DebugDrawModes.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath;
25 |
26 | /**
27 | * Debug draw modes, used by demo framework.
28 | *
29 | * @author jezek2
30 | */
31 | public class DebugDrawModes {
32 |
33 | public static final int NO_DEBUG = 0;
34 | public static final int DRAW_WIREFRAME = 1;
35 | public static final int DRAW_AABB = 2;
36 | public static final int DRAW_FEATURES_TEXT = 4;
37 | public static final int DRAW_CONTACT_POINTS = 8;
38 | public static final int NO_DEACTIVATION = 16;
39 | public static final int NO_HELP_TEXT = 32;
40 | public static final int DRAW_TEXT = 64;
41 | public static final int PROFILE_TIMINGS = 128;
42 | public static final int ENABLE_SAT_COMPARISON = 256;
43 | public static final int DISABLE_BULLET_LCP = 512;
44 | public static final int ENABLE_CCD = 1024;
45 | public static final int MAX_DEBUG_DRAW_MODE = 1025;
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/MotionState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath;
25 |
26 | /**
27 | * MotionState allows the dynamics world to synchronize the updated world transforms
28 | * with graphics. For optimizations, potentially only moving objects get synchronized
29 | * (using {@link #setWorldTransform setWorldTransform} method).
30 | *
31 | * @author jezek2
32 | */
33 | public abstract class MotionState {
34 |
35 | /**
36 | * Returns world transform.
37 | */
38 | public abstract Transform getWorldTransform(Transform out);
39 |
40 | /**
41 | * Sets world transform. This method is called by JBullet whenever an active
42 | * object represented by this MotionState is moved or rotated.
43 | */
44 | public abstract void setWorldTransform(Transform worldTrans);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/ScalarUtil.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath;
25 |
26 | import com.bulletphysics.BulletGlobals;
27 |
28 | /**
29 | * Utility functions for scalars (floats).
30 | *
31 | * @author jezek2
32 | */
33 | public class ScalarUtil {
34 |
35 | public static float fsel(float a, float b, float c) {
36 | return a >= 0 ? b : c;
37 | }
38 |
39 | public static boolean fuzzyZero(float x) {
40 | return Math.abs(x) < BulletGlobals.FLT_EPSILON;
41 | }
42 |
43 | public static float atan2Fast(float y, float x) {
44 | float coeff_1 = BulletGlobals.SIMD_PI / 4.0f;
45 | float coeff_2 = 3.0f * coeff_1;
46 | float abs_y = Math.abs(y);
47 | float angle;
48 | if (x >= 0.0f) {
49 | float r = (x - abs_y) / (x + abs_y);
50 | angle = coeff_1 - coeff_1 * r;
51 | }
52 | else {
53 | float r = (x + abs_y) / (abs_y - x);
54 | angle = coeff_2 - coeff_1 * r;
55 | }
56 | return (y < 0.0f) ? -angle : angle;
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/HullFlags.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | /**
27 | * Flags that affects convex hull generation, used in {@link HullDesc#flags}.
28 | *
29 | * @author jezek2
30 | */
31 | public class HullFlags {
32 |
33 | public static int TRIANGLES = 1 << 0; // report results as triangles, not polygons.
34 | public static int REVERSE_ORDER = 1 << 1; // reverse order of the triangle indices.
35 | public static int DEFAULT = TRIANGLES;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/HullResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | import com.bulletphysics.util.IntArrayList;
27 | import com.bulletphysics.util.ObjectArrayList;
28 | import javax.vecmath.Vector3f;
29 |
30 | /**
31 | * Contains resulting polygonal representation.
32 | *
33 | * Depending on the {@link #polygons} flag, array of indices consists of:
34 | * for triangles: indices are array indexes into the vertex list
35 | * for polygons: indices are in the form (number of points in face) (p1, p2, p3, ...)
36 | *
37 | * @author jezek2
38 | */
39 | public class HullResult {
40 |
41 | /** True if indices represents polygons, false indices are triangles. */
42 | public boolean polygons = true;
43 |
44 | /** Number of vertices in the output hull. */
45 | public int numOutputVertices = 0;
46 |
47 | /** Array of vertices. */
48 | public final ObjectArrayList outputVertices = new ObjectArrayList();
49 |
50 | /** Number of faces produced. */
51 | public int numFaces = 0;
52 |
53 | /** Total number of indices. */
54 | public int numIndices = 0;
55 |
56 | /** Array of indices. */
57 | public final IntArrayList indices = new IntArrayList();
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/Int3.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | class Int3 {
31 |
32 | public int x, y, z;
33 |
34 | public Int3() {
35 | }
36 |
37 | public Int3(int x, int y, int z) {
38 | this.x = x;
39 | this.y = y;
40 | this.z = z;
41 | }
42 |
43 | public Int3(Int3 i) {
44 | x = i.x;
45 | y = i.y;
46 | z = i.z;
47 | }
48 |
49 | public void set(int x, int y, int z) {
50 | this.x = x;
51 | this.y = y;
52 | this.z = z;
53 | }
54 |
55 | public void set(Int3 i) {
56 | x = i.x;
57 | y = i.y;
58 | z = i.z;
59 | }
60 |
61 | public int getCoord(int coord) {
62 | switch (coord) {
63 | case 0: return x;
64 | case 1: return y;
65 | default: return z;
66 | }
67 | }
68 |
69 | public void setCoord(int coord, int value) {
70 | switch (coord) {
71 | case 0: x = value; break;
72 | case 1: y = value; break;
73 | case 2: z = value; break;
74 | }
75 | }
76 |
77 | public boolean equals(Int3 i) {
78 | return (x == i.x && y == i.y && z == i.z);
79 | }
80 |
81 | public IntRef getRef(final int coord) {
82 | return new IntRef() {
83 | @Override
84 | public int get() {
85 | return getCoord(coord);
86 | }
87 |
88 | @Override
89 | public void set(int value) {
90 | setCoord(coord, value);
91 | }
92 | };
93 | }
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/Int4.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | class Int4 {
31 |
32 | public int x, y, z, w;
33 |
34 | public Int4() {
35 | }
36 |
37 | public Int4(int x, int y, int z, int w) {
38 | this.x = x;
39 | this.y = y;
40 | this.z = z;
41 | this.w = w;
42 | }
43 |
44 | public void set(int x, int y, int z, int w) {
45 | this.x = x;
46 | this.y = y;
47 | this.z = z;
48 | this.w = w;
49 | }
50 |
51 | public int getCoord(int coord) {
52 | switch (coord) {
53 | case 0: return x;
54 | case 1: return y;
55 | case 2: return z;
56 | default: return w;
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/IntRef.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | abstract class IntRef {
31 |
32 | public abstract int get();
33 |
34 | public abstract void set(int value);
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/PHullResult.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | import com.bulletphysics.util.IntArrayList;
27 | import com.bulletphysics.util.ObjectArrayList;
28 | import javax.vecmath.Vector3f;
29 |
30 | /**
31 | *
32 | * @author jezek2
33 | */
34 | class PHullResult {
35 |
36 | public int vcount = 0;
37 | public int indexCount = 0;
38 | public int faceCount = 0;
39 | public ObjectArrayList vertices = null;
40 | public IntArrayList indices = new IntArrayList();
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/Tri.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.linearmath.convexhull;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | class Tri extends Int3 {
31 |
32 | public Int3 n = new Int3();
33 | public int id;
34 | public int vmax;
35 | public float rise;
36 |
37 | public Tri(int a, int b, int c) {
38 | super(a, b, c);
39 | n.set(-1, -1, -1);
40 | vmax = -1;
41 | rise = 0f;
42 | }
43 |
44 | private static int er = -1;
45 |
46 | private static IntRef erRef = new IntRef() {
47 | @Override
48 | public int get() {
49 | return er;
50 | }
51 |
52 | @Override
53 | public void set(int value) {
54 | er = value;
55 | }
56 | };
57 |
58 | public IntRef neib(int a, int b) {
59 | for (int i = 0; i < 3; i++) {
60 | int i1 = (i + 1) % 3;
61 | int i2 = (i + 2) % 3;
62 |
63 | if (getCoord(i) == a && getCoord(i1) == b) {
64 | return n.getRef(i2);
65 | }
66 | if (getCoord(i) == b && getCoord(i1) == a) {
67 | return n.getRef(i2);
68 | }
69 | }
70 | assert (false);
71 | return erRef;
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/convexhull/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Stan Melax Convex Hull Computation
5 | * Copyright (c) 2008 Stan Melax http://www.melax.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Convex Hull library for converting point clouds to polygonal representation.
26 | */
27 | package com.bulletphysics.linearmath.convexhull;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/linearmath/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Vector math library.
26 | */
27 | package com.bulletphysics.linearmath;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Contains global variables and callbacks.
26 | */
27 | package com.bulletphysics;
28 |
29 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/util/FloatArrayList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.util;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | public class FloatArrayList {
31 |
32 | private float[] array = new float[16];
33 | private int size;
34 |
35 | public void add(float value) {
36 | if (size == array.length) {
37 | expand();
38 | }
39 |
40 | array[size++] = value;
41 | }
42 |
43 | private void expand() {
44 | float[] newArray = new float[array.length << 1];
45 | System.arraycopy(array, 0, newArray, 0, array.length);
46 | array = newArray;
47 | }
48 |
49 | public float remove(int index) {
50 | if (index >= size) throw new IndexOutOfBoundsException();
51 | float old = array[index];
52 | System.arraycopy(array, index+1, array, index, size - index - 1);
53 | size--;
54 | return old;
55 | }
56 |
57 | public float get(int index) {
58 | if (index >= size) throw new IndexOutOfBoundsException();
59 | return array[index];
60 | }
61 |
62 | public void set(int index, float value) {
63 | if (index >= size) throw new IndexOutOfBoundsException();
64 | array[index] = value;
65 | }
66 |
67 | public int size() {
68 | return size;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/util/IntArrayList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.util;
25 |
26 | /**
27 | *
28 | * @author jezek2
29 | */
30 | public class IntArrayList {
31 |
32 | private int[] array = new int[16];
33 | private int size;
34 |
35 | public void add(int value) {
36 | if (size == array.length) {
37 | expand();
38 | }
39 |
40 | array[size++] = value;
41 | }
42 |
43 | private void expand() {
44 | int[] newArray = new int[array.length << 1];
45 | System.arraycopy(array, 0, newArray, 0, array.length);
46 | array = newArray;
47 | }
48 |
49 | public int remove(int index) {
50 | if (index >= size) throw new IndexOutOfBoundsException();
51 | int old = array[index];
52 | System.arraycopy(array, index+1, array, index, size - index - 1);
53 | size--;
54 | return old;
55 | }
56 |
57 | public int get(int index) {
58 | if (index >= size) throw new IndexOutOfBoundsException();
59 | return array[index];
60 | }
61 |
62 | public void set(int index, int value) {
63 | if (index >= size) throw new IndexOutOfBoundsException();
64 | array[index] = value;
65 | }
66 |
67 | public int size() {
68 | return size;
69 | }
70 |
71 | public void clear() {
72 | size = 0;
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/util/ObjectStackList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | package com.bulletphysics.util;
25 |
26 | /**
27 | * Stack-based object pool for arbitrary objects, returning not supported.
28 | *
29 | * @author jezek2
30 | */
31 | public class ObjectStackList extends StackList {
32 |
33 | private Class cls;
34 |
35 | public ObjectStackList(Class cls) {
36 | super(false);
37 | this.cls = cls;
38 | }
39 |
40 | @Override
41 | protected T create() {
42 | try {
43 | return cls.newInstance();
44 | }
45 | catch (InstantiationException e) {
46 | throw new IllegalStateException(e);
47 | }
48 | catch (IllegalAccessException e) {
49 | throw new IllegalStateException(e);
50 | }
51 | }
52 |
53 | @Override
54 | protected void copy(T dest, T src) {
55 | throw new UnsupportedOperationException();
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/com/bulletphysics/util/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Java port of Bullet (c) 2008 Martin Dvorak
3 | *
4 | * Bullet Continuous Collision Detection and Physics Library
5 | * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
6 | *
7 | * This software is provided 'as-is', without any express or implied warranty.
8 | * In no event will the authors be held liable for any damages arising from
9 | * the use of this software.
10 | *
11 | * Permission is granted to anyone to use this software for any purpose,
12 | * including commercial applications, and to alter it and redistribute it
13 | * freely, subject to the following restrictions:
14 | *
15 | * 1. The origin of this software must not be misrepresented; you must not
16 | * claim that you wrote the original software. If you use this software
17 | * in a product, an acknowledgment in the product documentation would be
18 | * appreciated but is not required.
19 | * 2. Altered source versions must be plainly marked as such, and must not be
20 | * misrepresented as being the original software.
21 | * 3. This notice may not be removed or altered from any source distribution.
22 | */
23 |
24 | /**
25 | * Java-specific utility classes.
26 | */
27 | package com.bulletphysics.util;
28 |
29 |
--------------------------------------------------------------------------------