joode-devs Mailing List for JOODE
Brought to you by:
arne_m,
t_larkworthy
You can subscribe to this list here.
| 2007 |
Jan
(4) |
Feb
(96) |
Mar
(40) |
Apr
(50) |
May
(15) |
Jun
(27) |
Jul
(27) |
Aug
(15) |
Sep
(7) |
Oct
(8) |
Nov
(6) |
Dec
(45) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
(16) |
May
(3) |
Jun
(11) |
Jul
(1) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2009 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <t_l...@us...> - 2009-02-18 23:57:01
|
Revision: 600
http://joode.svn.sourceforge.net/joode/?rev=600&view=rev
Author: t_larkworthy
Date: 2009-02-18 23:56:56 +0000 (Wed, 18 Feb 2009)
Log Message:
-----------
First steps toward getting jbullet off jstackalloc. So far only the @StaticAlloc s have been converted to static fields.
The rest of Stack.alloc has been diverted to a Stack class authored by me. At the moment it just provides object taken from the object pool when requested. I need to think about the mechanism to release those pooled instances.
Tom
Modified Paths:
--------------
trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionWorld.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CompoundCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConcaveCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConvexAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexPlaneCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexTriangleCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ManifoldResult.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SphereSphereCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkConvexCast.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkPairDetector.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PersistentManifold.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SubsimplexConvexCast.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleRaycastCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/VoronoiSimplexSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BoxShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CollisionShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexHullShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexInternalShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeX.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeZ.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/MinkowskiSumShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvh.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/PolyhedralConvexShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ShapeHull.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/SphereShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StaticPlaneShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StridingMeshInterface.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleMeshShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/UniformScalingShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/AabbUtil2.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/GeometryUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/IDebugDraw.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/QuaternionUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Transform.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/TransformUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullLibrary.java
Added Paths:
-----------
trunk/jbullet/src/net/java/dev/joode/jbullet/utils/
trunk/jbullet/src/net/java/dev/joode/jbullet/utils/Stack.java
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,7 +25,7 @@
import com.bulletphysics.util.ArrayPool;
import com.bulletphysics.util.ObjectPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
/**
* Bullet global settings and constants.
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -30,7 +30,7 @@
import com.bulletphysics.collision.broadphase.AxisSweep3Internal.Handle;
import com.bulletphysics.linearmath.MiscUtil;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.List;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionWorld.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionWorld.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionWorld.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -48,7 +48,7 @@
import com.bulletphysics.linearmath.IDebugDraw;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CompoundCollisionAlgorithm.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CompoundCollisionAlgorithm.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CompoundCollisionAlgorithm.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -33,7 +33,7 @@
import com.bulletphysics.collision.shapes.CompoundShape;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.util.ObjectPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
/**
* CompoundCollisionAlgorithm supports collision between {@link CompoundShape}s and
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConcaveCollisionAlgorithm.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConcaveCollisionAlgorithm.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConcaveCollisionAlgorithm.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -37,7 +37,7 @@
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
import com.bulletphysics.util.ObjectPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.List;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConvexAlgorithm.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConvexAlgorithm.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConvexAlgorithm.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -38,7 +38,7 @@
import com.bulletphysics.collision.shapes.ConvexShape;
import com.bulletphysics.collision.shapes.SphereShape;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.List;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexPlaneCollisionAlgorithm.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexPlaneCollisionAlgorithm.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexPlaneCollisionAlgorithm.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -31,7 +31,7 @@
import com.bulletphysics.collision.shapes.StaticPlaneShape;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.util.ObjectPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.List;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexTriangleCallback.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexTriangleCallback.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexTriangleCallback.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -32,7 +32,7 @@
import com.bulletphysics.collision.shapes.TriangleCallback;
import com.bulletphysics.collision.shapes.TriangleShape;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ManifoldResult.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ManifoldResult.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ManifoldResult.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,7 +29,7 @@
import com.bulletphysics.collision.narrowphase.ManifoldPoint;
import com.bulletphysics.collision.narrowphase.PersistentManifold;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SphereSphereCollisionAlgorithm.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SphereSphereCollisionAlgorithm.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SphereSphereCollisionAlgorithm.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -31,7 +31,7 @@
import com.bulletphysics.collision.shapes.SphereShape;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.util.ObjectPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.List;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkConvexCast.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkConvexCast.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkConvexCast.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.collision.shapes.ConvexShape;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaSolver.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaSolver.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaSolver.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -32,7 +32,7 @@
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
import com.bulletphysics.util.ArrayPool;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkPairDetector.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkPairDetector.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkPairDetector.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,8 +29,7 @@
import com.bulletphysics.linearmath.IDebugDraw;
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
-import cz.advel.stack.StaticAlloc;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
@@ -69,18 +68,33 @@
this.minkowskiA = objectA;
this.minkowskiB = objectB;
}
-
- @StaticAlloc
- public void getClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw, boolean swapResults) {
- Vector3f tmp = Stack.alloc(Vector3f.class);
+ //@StaticAlloc (converted from)
+ static Vector3f tmp = new Vector3f();
+ static Vector3f normalInB = new Vector3f();
+ static Vector3f pointOnA = new Vector3f();
+ static Vector3f pointOnB = new Vector3f();
+ static Transform localTransA = new Transform();
+ static Transform localTransB = new Transform();
+ static Vector3f positionOffset = new Vector3f();
+ static Vector3f seperatingAxisInA = new Vector3f();
+ static Vector3f seperatingAxisInB = new Vector3f();
+ static Vector3f pInA = new Vector3f();
+ static Vector3f qInB = new Vector3f();
+ static Vector3f pWorld = new Vector3f();
+ static Vector3f qWorld = new Vector3f();
+ static Vector3f w = new Vector3f();
+ static Vector3f tmpPointOnA = new Vector3f();
+ static Vector3f tmpPointOnB = new Vector3f();
+ static Vector3f tmpNormalInB = new Vector3f();
+
+ public void getClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw, boolean swapResults) {
+
float distance = 0f;
- Vector3f normalInB = Stack.alloc(Vector3f.class);
normalInB.set(0f, 0f, 0f);
- Vector3f pointOnA = Stack.alloc(Vector3f.class), pointOnB = Stack.alloc(Vector3f.class);
- Transform localTransA = Stack.alloc(input.transformA);
- Transform localTransB = Stack.alloc(input.transformB);
- Vector3f positionOffset = Stack.alloc(Vector3f.class);
+ localTransA.set(input.transformA);
+ localTransB.set(input.transformB);
+
positionOffset.add(localTransA.origin, localTransB.origin);
positionOffset.scale(0.5f);
localTransA.origin.sub(positionOffset);
@@ -116,19 +130,7 @@
simplexSolver.reset();
- Vector3f seperatingAxisInA = Stack.alloc(Vector3f.class);
- Vector3f seperatingAxisInB = Stack.alloc(Vector3f.class);
-
- Vector3f pInA = Stack.alloc(Vector3f.class);
- Vector3f qInB = Stack.alloc(Vector3f.class);
-
- Vector3f pWorld = Stack.alloc(Vector3f.class);
- Vector3f qWorld = Stack.alloc(Vector3f.class);
- Vector3f w = Stack.alloc(Vector3f.class);
-
- Vector3f tmpPointOnA = Stack.alloc(Vector3f.class), tmpPointOnB = Stack.alloc(Vector3f.class);
- Vector3f tmpNormalInB = Stack.alloc(Vector3f.class);
-
+
for (;;) //while (true)
{
seperatingAxisInA.negate(cachedSeparatingAxis);
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PersistentManifold.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PersistentManifold.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PersistentManifold.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.BulletStats;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SubsimplexConvexCast.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SubsimplexConvexCast.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SubsimplexConvexCast.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,7 +29,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleRaycastCallback.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleRaycastCallback.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleRaycastCallback.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,7 +25,7 @@
import com.bulletphysics.collision.shapes.TriangleCallback;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/VoronoiSimplexSolver.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/VoronoiSimplexSolver.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/VoronoiSimplexSolver.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,8 +25,7 @@
import com.bulletphysics.util.ObjectPool;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
-import cz.advel.stack.StaticAlloc;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
@@ -94,8 +93,13 @@
removeVertex(0);
}
- @StaticAlloc
- public boolean updateClosestVectorAndPoints() {
+ //@StaticAlloc convertedFrom
+ static Vector3f tmpUpdate = new Vector3f();
+ static Vector3f nearest = new Vector3f();
+ static Vector3f p = new Vector3f();
+ static Vector3f diff = new Vector3f();
+ static Vector3f v = new Vector3f();
+ public boolean updateClosestVectorAndPoints() {
if (needsUpdate)
{
cachedBC.reset();
@@ -119,19 +123,14 @@
}
case 2:
{
- Vector3f tmp = Stack.alloc(Vector3f.class);
-
+
//closest point origin from line segment
Vector3f from = simplexVectorW[0];
Vector3f to = simplexVectorW[1];
- Vector3f nearest = Stack.alloc(Vector3f.class);
+ p.set(0f, 0f, 0f);
- Vector3f p = Stack.alloc(Vector3f.class);
- p.set(0f, 0f, 0f);
- Vector3f diff = Stack.alloc(Vector3f.class);
diff.sub(p, from);
- Vector3f v = Stack.alloc(Vector3f.class);
v.sub(to, from);
float t = v.dot(diff);
@@ -140,8 +139,8 @@
float dotVV = v.dot(v);
if (t < dotVV) {
t /= dotVV;
- tmp.scale(t, v);
- diff.sub(tmp);
+ tmpUpdate.scale(t, v);
+ diff.sub(tmpUpdate);
cachedBC.usedVertices.usedVertexA = true;
cachedBC.usedVertices.usedVertexB = true;
} else {
@@ -158,16 +157,16 @@
}
cachedBC.setBarycentricCoordinates(1f-t, t, 0f, 0f);
- tmp.scale(t, v);
- nearest.add(from, tmp);
+ tmpUpdate.scale(t, v);
+ nearest.add(from, tmpUpdate);
- tmp.sub(simplexPointsP[1], simplexPointsP[0]);
- tmp.scale(t);
- cachedP1.add(simplexPointsP[0], tmp);
+ tmpUpdate.sub(simplexPointsP[1], simplexPointsP[0]);
+ tmpUpdate.scale(t);
+ cachedP1.add(simplexPointsP[0], tmpUpdate);
- tmp.sub(simplexPointsQ[1], simplexPointsQ[0]);
- tmp.scale(t);
- cachedP2.add(simplexPointsQ[0], tmp);
+ tmpUpdate.sub(simplexPointsQ[1], simplexPointsQ[0]);
+ tmpUpdate.scale(t);
+ cachedP2.add(simplexPointsQ[0], tmpUpdate);
cachedV.sub(cachedP1, cachedP2);
@@ -273,18 +272,24 @@
return cachedValidClosest;
}
- @StaticAlloc
+ //@StaticAlloc (converted from)
+ static Vector3f ab = new Vector3f();
+ static Vector3f ac = new Vector3f();
+ static Vector3f ap = new Vector3f();
+ static Vector3f bp = new Vector3f();
+ static Vector3f cp = new Vector3f();
+ static Vector3f tmp = new Vector3f();
+ static Vector3f tmp1 = new Vector3f();
+ static Vector3f tmp2 = new Vector3f();
+
public boolean closestPtPointTriangle(Vector3f p, Vector3f a, Vector3f b, Vector3f c, SubSimplexClosestResult result) {
result.usedVertices.reset();
// Check if P in vertex region outside A
- Vector3f ab = Stack.alloc(Vector3f.class);
ab.sub(b, a);
- Vector3f ac = Stack.alloc(Vector3f.class);
ac.sub(c, a);
- Vector3f ap = Stack.alloc(Vector3f.class);
ap.sub(p, a);
float d1 = ab.dot(ap);
@@ -299,7 +304,6 @@
}
// Check if P in vertex region outside B
- Vector3f bp = Stack.alloc(Vector3f.class);
bp.sub(p, b);
float d3 = ab.dot(bp);
@@ -327,7 +331,6 @@
}
// Check if P in vertex region outside C
- Vector3f cp = Stack.alloc(Vector3f.class);
cp.sub(p, c);
float d5 = ab.dot(cp);
@@ -358,7 +361,6 @@
if (va <= 0f && (d4 - d3) >= 0f && (d5 - d6) >= 0f) {
float w = (d4 - d3) / ((d4 - d3) + (d5 - d6));
- Vector3f tmp = Stack.alloc(Vector3f.class);
tmp.sub(c, b);
result.closestPointOnSimplex.scaleAdd(w, tmp, b);
@@ -374,9 +376,6 @@
float v = vb * denom;
float w = vc * denom;
- Vector3f tmp1 = Stack.alloc(Vector3f.class);
- Vector3f tmp2 = Stack.alloc(Vector3f.class);
-
tmp1.scale(v, ab);
tmp2.scale(w, ac);
VectorUtil.add(result.closestPointOnSimplex, a, tmp1, tmp2);
@@ -390,21 +389,22 @@
}
/// Test if point p and d lie on opposite sides of plane through abc
- @StaticAlloc
- public static int pointOutsideOfPlane(Vector3f p, Vector3f a, Vector3f b, Vector3f c, Vector3f d)
+ //@StaticAlloc (converted from)
+ static Vector3f tmpPoint = new Vector3f();
+ static Vector3f normal = new Vector3f();
+
+ public static int pointOutsideOfPlane(Vector3f p, Vector3f a, Vector3f b, Vector3f c, Vector3f d)
{
- Vector3f tmp = Stack.alloc(Vector3f.class);
- Vector3f normal = Stack.alloc(Vector3f.class);
normal.sub(b, a);
- tmp.sub(c, a);
- normal.cross(normal, tmp);
+ tmpPoint.sub(c, a);
+ normal.cross(normal, tmpPoint);
- tmp.sub(p, a);
- float signp = tmp.dot(normal); // [AP AB AC]
+ tmpPoint.sub(p, a);
+ float signp = tmpPoint.dot(normal); // [AP AB AC]
- tmp.sub(d, a);
- float signd = tmp.dot(normal); // [AD AB AC]
+ tmpPoint.sub(d, a);
+ float signd = tmpPoint.dot(normal); // [AD AB AC]
//#ifdef CATCH_DEGENERATE_TETRAHEDRON
// #ifdef BT_USE_DOUBLE_PRECISION
@@ -425,13 +425,14 @@
return (signp * signd < 0f)? 1 : 0;
}
- @StaticAlloc
- public boolean closestPtPointTetrahedron(Vector3f p, Vector3f a, Vector3f b, Vector3f c, Vector3f d, SubSimplexClosestResult finalResult) {
+ //@StaticAlloc (converted from)
+
+ static Vector3f tmpClosest = new Vector3f();
+ static Vector3f q = new Vector3f();
+ public boolean closestPtPointTetrahedron(Vector3f p, Vector3f a, Vector3f b, Vector3f c, Vector3f d, SubSimplexClosestResult finalResult) {
SubSimplexClosestResult tempResult = subsimplexResultsPool.get();
tempResult.reset();
try {
- Vector3f tmp = Stack.alloc(Vector3f.class);
- Vector3f q = Stack.alloc(Vector3f.class);
// Start out assuming point inside all halfspaces, so closest to itself
finalResult.closestPointOnSimplex.set(p);
@@ -465,8 +466,8 @@
closestPtPointTriangle(p, a, b, c,tempResult);
q.set(tempResult.closestPointOnSimplex);
- tmp.sub(q, p);
- float sqDist = tmp.dot(tmp);
+ tmpClosest.sub(q, p);
+ float sqDist = tmpClosest.dot(tmpClosest);
// Update best closest point if (squared) distance is less than current best
if (sqDist < bestSqDist) {
bestSqDist = sqDist;
@@ -494,8 +495,8 @@
q.set(tempResult.closestPointOnSimplex);
//convert result bitmask!
- tmp.sub(q, p);
- float sqDist = tmp.dot(tmp);
+ tmpClosest.sub(q, p);
+ float sqDist = tmpClosest.dot(tmpClosest);
if (sqDist < bestSqDist)
{
bestSqDist = sqDist;
@@ -523,8 +524,8 @@
q.set(tempResult.closestPointOnSimplex);
//convert result bitmask!
- tmp.sub(q, p);
- float sqDist = tmp.dot(tmp);
+ tmpClosest.sub(q, p);
+ float sqDist = tmpClosest.dot(tmpClosest);
if (sqDist < bestSqDist)
{
bestSqDist = sqDist;
@@ -551,8 +552,8 @@
closestPtPointTriangle(p, b, d, c,tempResult);
q.set(tempResult.closestPointOnSimplex);
//convert result bitmask!
- tmp.sub(q, p);
- float sqDist = tmp.dot(tmp);
+ tmpClosest.sub(q, p);
+ float sqDist = tmpClosest.dot(tmpClosest);
if (sqDist < bestSqDist)
{
bestSqDist = sqDist;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BoxShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BoxShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BoxShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.linearmath.ScalarUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.util.ObjectPool;
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CollisionShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CollisionShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CollisionShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,7 +25,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,7 +29,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexHullShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexHullShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexHullShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.BulletGlobals;
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexInternalShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexInternalShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexInternalShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeX.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeX.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeX.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -23,7 +23,7 @@
package com.bulletphysics.collision.shapes;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeZ.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeZ.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeZ.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -23,7 +23,7 @@
package com.bulletphysics.collision.shapes;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/MinkowskiSumShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/MinkowskiSumShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/MinkowskiSumShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -26,7 +26,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvh.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvh.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvh.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,7 +29,7 @@
import com.bulletphysics.linearmath.AabbUtil2;
import com.bulletphysics.linearmath.MiscUtil;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
// JAVA NOTE: OptimizedBvh still from 2.66, update it for 2.70b1
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/PolyhedralConvexShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/PolyhedralConvexShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/PolyhedralConvexShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -26,7 +26,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ShapeHull.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ShapeHull.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ShapeHull.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -28,7 +28,7 @@
import com.bulletphysics.linearmath.MiscUtil;
import com.bulletphysics.linearmath.convexhull.*;
import com.bulletphysics.util.IntArrayList;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/SphereShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/SphereShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/SphereShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,7 +25,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StaticPlaneShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StaticPlaneShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StaticPlaneShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.TransformUtil;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StridingMeshInterface.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StridingMeshInterface.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StridingMeshInterface.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -24,7 +24,7 @@
package com.bulletphysics.collision.shapes;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleMeshShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleMeshShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleMeshShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -27,7 +27,7 @@
import com.bulletphysics.linearmath.MatrixUtil;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -26,7 +26,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
import com.bulletphysics.linearmath.VectorUtil;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/UniformScalingShape.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/UniformScalingShape.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/UniformScalingShape.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -25,7 +25,7 @@
import com.bulletphysics.collision.broadphase.BroadphaseNativeType;
import com.bulletphysics.linearmath.Transform;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/AabbUtil2.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/AabbUtil2.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/AabbUtil2.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -23,7 +23,7 @@
package com.bulletphysics.linearmath;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/GeometryUtil.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/GeometryUtil.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/GeometryUtil.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -24,7 +24,7 @@
package com.bulletphysics.linearmath;
import java.util.List;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/IDebugDraw.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/IDebugDraw.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/IDebugDraw.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -23,7 +23,7 @@
package com.bulletphysics.linearmath;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Vector3f;
/**
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/QuaternionUtil.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/QuaternionUtil.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/QuaternionUtil.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -24,7 +24,7 @@
package com.bulletphysics.linearmath;
import com.bulletphysics.BulletGlobals;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Transform.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Transform.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Transform.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -24,8 +24,7 @@
package com.bulletphysics.linearmath;
import com.bulletphysics.collision.shapes.UniformScalingShape;
-import cz.advel.stack.Stack;
-import cz.advel.stack.StaticAlloc;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
@@ -99,9 +98,10 @@
origin.set(vec);
}
- @StaticAlloc
- public void mul(Transform tr1, Transform tr2) {
- Vector3f vec = Stack.alloc(tr2.origin);
+ //@StaticAlloc
+ static Vector3f vec = new Vector3f();
+ public void mul(Transform tr1, Transform tr2) {
+ vec.set(tr2.origin);
tr1.transform(vec);
basis.mul(tr1.basis, tr2.basis);
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/TransformUtil.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/TransformUtil.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/TransformUtil.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -24,8 +24,7 @@
package com.bulletphysics.linearmath;
import com.bulletphysics.BulletGlobals;
-import cz.advel.stack.Stack;
-import cz.advel.stack.StaticAlloc;
+import net.java.dev.joode.jbullet.utils.Stack;
import javax.vecmath.Matrix3f;
import javax.vecmath.Quat4f;
import javax.vecmath.Vector3f;
@@ -63,8 +62,13 @@
}
}
- @StaticAlloc
- public static void integrateTransform(Transform curTrans, Vector3f linvel, Vector3f angvel, float timeStep, Transform predictedTransform) {
+ //@StaticAlloc converted from
+ static Vector3f axis = new Vector3f();
+ static Quat4f dorn = new Quat4f();
+ static Quat4f predictedOrn = new Quat4f();
+ static Quat4f quatTmp = new Quat4f();
+
+ public static void integrateTransform(Transform curTrans, Vector3f linvel, Vector3f angvel, float timeStep, Transform predictedTransform) {
predictedTransform.origin.scaleAdd(timeStep, linvel, curTrans.origin);
// //#define QUATERNION_DERIVATIVE
// #ifdef QUATERNION_DERIVATIVE
@@ -75,7 +79,6 @@
// Exponential map
// google for "Practical Parameterization of Rotations Using the Exponential Map", F. Sebastian Grassia
- Vector3f axis = Stack.alloc(Vector3f.class);
float fAngle = angvel.length();
// limit the angular motion
@@ -91,11 +94,9 @@
// sync(fAngle) = sin(c*fAngle)/t
axis.scale((float) Math.sin(0.5f * fAngle * timeStep) / fAngle, angvel);
}
- Quat4f dorn = Stack.alloc(Quat4f.class);
dorn.set(axis.x, axis.y, axis.z, (float) Math.cos(fAngle * timeStep * 0.5f));
- Quat4f orn0 = curTrans.getRotation(Stack.alloc(Quat4f.class));
+ Quat4f orn0 = curTrans.getRotation(quatTmp);
- Quat4f predictedOrn = Stack.alloc(Quat4f.class);
predictedOrn.mul(dorn, orn0);
predictedOrn.normalize();
// #endif
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullLibrary.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullLibrary.java 2009-02-09 00:08:03 UTC (rev 599)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullLibrary.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -29,7 +29,7 @@
import com.bulletphysics.linearmath.MiscUtil;
import com.bulletphysics.linearmath.VectorUtil;
import com.bulletphysics.util.IntArrayList;
-import cz.advel.stack.Stack;
+import net.java.dev.joode.jbullet.utils.Stack;
import java.util.ArrayList;
import java.util.List;
import javax.vecmath.Vector3f;
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/utils/Stack.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/utils/Stack.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/utils/Stack.java 2009-02-18 23:56:56 UTC (rev 600)
@@ -0,0 +1,59 @@
+package net.java.dev.joode.jbullet.utils;
+
+import com.bulletphysics.util.ObjectPool;
+
+import java.util.HashMap;
+
+/**
+ * JBullet used a clever method for creating temporty variables that were tidied up
+ * after the thread finished executing a method i.e. like putting a variable in the stack in C++.
+ *
+ * This class replaces this functionality so that the instrumentation step that previously
+ * had to be run after compile time can be removed. We assign object from a normal object pool when a method
+ * requests an instance of a class. We record what level of the stack the request was made. We
+ * then tidy release the instance when the thread in no longer at that depth of stack exection.
+ *
+ * As we have no hook in java in which to trigger when a thread leaves a method, we use subsequent
+ * stack allocation requests to monitor the state of the threads current stack level and do the tidying then.
+ *
+ * Ideally we would just replace all the stack.alloc request in the jbullet source to
+ * just use pooling, but thats a big task and prone to introducing bugs so we shall see if we
+ * can do it this way with much less hassle.
+ *
+ * It is likely that some tidying up will never occur, such as when a thread finishes execution.
+ *
+ *
+ * (NOT ETHE ABOVE FUNCTIONALITY HAS NOT BEEN IMPLEMENTED YET, just to keep things working, the stack simply gets an object
+ * of the object pool, which will subsequently be garbage collected normally)
+ *
+ * @author Tom Larkworthy
+ */
+public class Stack {
+ HashMap<Thread, AllocationTable> globalAllocations = new HashMap<Thread, AllocationTable>();
+
+
+ private Stack() { /* compiled code */ }
+
+ public static <T> T alloc(java.lang.Class<T> aClass) {
+
+ return ObjectPool.get(aClass).get();
+ }
+
+ public static <T> T alloc(T t) {
+
+ return ObjectPool.get((Class<T>)t.getClass()).get();
+ }
+
+
+
+ public static void libraryCleanCurrentThread() { /* compiled code */ }
+
+
+ /**
+ * this class is a data container for recording what objects were requested at different
+ * stack levels
+ */
+ private class AllocationTable{
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2009-02-09 00:08:07
|
Revision: 599
http://joode.svn.sourceforge.net/joode/?rev=599&view=rev
Author: t_larkworthy
Date: 2009-02-09 00:08:03 +0000 (Mon, 09 Feb 2009)
Log Message:
-----------
For some reason I keep missing important files on SVN adds. Anyway, I think everything is here now.
JBulletTestingWorld (run through the ant task) now has a JPCT bound sphere moving in response to gravity. Collision functionality NOT tested yet.
Modified Paths:
--------------
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObject.java
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java
trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java
Added Paths:
-----------
trunk/jbullet/lib/ASM3.1/
trunk/jbullet/lib/ASM3.1/asm-all-3.1.jar
trunk/jbullet/lib/JPCT/jpct.jar
trunk/jbullet/lib/JPCT/license.txt
trunk/jbullet/lib/jstackalloc/
trunk/jbullet/lib/jstackalloc/stack-alloc.jar
trunk/jbullet/lib/lwjgl/
trunk/jbullet/lib/lwjgl/jinput.jar
trunk/jbullet/lib/lwjgl/lwjgl.jar
trunk/jbullet/lib/lwjgl/lwjgl_test.jar
trunk/jbullet/lib/lwjgl/lwjgl_util.jar
trunk/jbullet/lib/lwjgl/lwjgl_util_applet.jar
trunk/jbullet/lib/swing-layout/
trunk/jbullet/lib/swing-layout/swing-layout-1.0.3.jar
trunk/jbullet/lib/vecmath/
trunk/jbullet/lib/vecmath/vecmath.jar
Modified: trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObject.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObject.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObject.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -45,7 +45,7 @@
public static final int WANTS_DEACTIVATION = 3;
public static final int DISABLE_DEACTIVATION = 4;
public static final int DISABLE_SIMULATION = 5;
- protected Transform worldTransform = new Transform();
+ public Transform worldTransform = new Transform();
///m_interpolationWorldTransform is used for CCD and interpolation
///it can be either previous or future (predicted) transform
Modified: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -39,6 +39,10 @@
gfxShape.setRotationMatrix(TMP_ROT);
+ System.out.println("TMP.basis = " + TMP.basis);
+ System.out.println("TMP.origin = " + TMP.origin);
+ System.out.println("TMP_ROT = " + TMP_ROT);
+
}
private void convert(Transform tmp, Matrix tmpRot) {
Modified: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -16,6 +16,9 @@
static final Object3D sphere = Primitives.getSphere(20, 1) ;
+ static{
+ sphere.build();
+ }
public Object3D convert(CollisionObject shape) {
CollisionShape rootShape = shape.getRootCollisionShape();
Modified: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -2,6 +2,7 @@
import net.java.dev.joode.World;
import net.java.dev.joode.WorldStepListener;
+import net.java.dev.joode.util.JOODELog;
import net.java.dev.joode.jbullet.JBulletGeomListener;
import net.java.dev.joode.jbullet.JBulletBodyInterface;
import net.java.dev.joode.jbullet.JBulletCollisionWorldAdapter;
@@ -72,7 +73,6 @@
listener.notifyStep(world, 0); //tell the listener to update the dynamic bindings
//add the listener so the scengraph can be dynamically updated
- //space.addGeomListener(listener); NOT NEEDED listener.addAllGeoms automatically adds a listener to the space to catch sub adds
world.addStepListener(listener);
JBulletCollisionWorldAdapter.getAdapter(space).addGeomListener(listener);
}
@@ -118,8 +118,10 @@
JPCTBinding binding = new JPCTBinding(gfxWorld, geom, converter.convert(geom));
if(JBulletBodyInterface.INSTANCE.getBody(geom) != null){
+ JOODELog.debug("creating dynamic binding");
dynamicBindings.put(geom, binding);
}else{
+ JOODELog.debug("creating static binding");
staticBindings.put(geom,binding);
}
Added: trunk/jbullet/lib/ASM3.1/asm-all-3.1.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/ASM3.1/asm-all-3.1.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/JPCT/jpct.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/JPCT/jpct.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/JPCT/license.txt
===================================================================
--- trunk/jbullet/lib/JPCT/license.txt (rev 0)
+++ trunk/jbullet/lib/JPCT/license.txt 2009-02-09 00:08:03 UTC (rev 599)
@@ -0,0 +1,35 @@
+The following is the license that applies to the jPCT API.
+
+/*
+ * Copyright (c) 2002
+ * Helge Foerster. All rights reserved.
+ *
+ * The use of jPCT is free of charge for personal and commercial use.
+ * Redistribution in binary form is permitted provided that the
+ * following conditions are met:
+ *
+ * 1. The class structure and the classes themselves as they are included
+ * in the JAR file that comes with this distribution of jPCT must stay intact.
+ * It is not allowed to decompile the class-files and/or replace the orginal
+ * files with modified versions until this permission is explicitly granted
+ * by the author.
+ * 2. The JAR-file may be decompressed and the class-files may be stored in other
+ * formats/JAR-files as long as 1.) is fulfilled. If jPCT is distributed as part
+ * of another project, it is allowed to obfuscate the class-files together with
+ * the rest of the project-files if you feel that this is required to protect
+ * your intellectual property.
+ * 3. It is not required to mention the use of jPCT in your project, albeit it would
+ * be nice doing so. If you do, it is required to mention the jPCT webpage
+ * at http://www.jpct.net
+ *
+ * THIS SOFTWARE IS PROVIDED 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
+ * PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
\ No newline at end of file
Added: trunk/jbullet/lib/jstackalloc/stack-alloc.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/jstackalloc/stack-alloc.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/lwjgl/jinput.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/lwjgl/jinput.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/lwjgl/lwjgl.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/lwjgl/lwjgl.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/lwjgl/lwjgl_test.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/lwjgl/lwjgl_test.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/lwjgl/lwjgl_util.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/lwjgl/lwjgl_util.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/lwjgl/lwjgl_util_applet.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/lwjgl/lwjgl_util_applet.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/swing-layout/swing-layout-1.0.3.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/swing-layout/swing-layout-1.0.3.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/jbullet/lib/vecmath/vecmath.jar
===================================================================
(Binary files differ)
Property changes on: trunk/jbullet/lib/vecmath/vecmath.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -74,10 +74,21 @@
public Manager(World world) {
this.world = world;
+
+ System.out.println("iterating world bodies");
+ for(Body b = world.getFirstBody(); b!=null;b = b.getNext() ){
+ System.out.println("b = " + b);
+
+ bodyAdded(world, b);
+ }
+ world.addBodyListener(this);
world.addStepListener(this);
+
}
public void updateTransforms(){
+ System.out.println("updateTransforms");
+
for (JBulletJOODEAdapter activeAdapter : activeAdapters) {
activeAdapter.updateWorldTransform();
}
@@ -88,13 +99,15 @@
}
public void bodyAdded(World world, Body body) {
- for (JBulletJOODEAdapter adapter : bodyGeoms.get(body)) {
+ System.out.println("body added");
+
+ for (JBulletJOODEAdapter adapter : getBodyGeoms(body)) {
activeAdapters.add(adapter);
}
}
public void bodyRemoved(World world, Body body) {
- for (JBulletJOODEAdapter adapter : bodyGeoms.get(body)) {
+ for (JBulletJOODEAdapter adapter : getBodyGeoms(body)) {
activeAdapters.remove(adapter);
}
}
@@ -111,6 +124,8 @@
public JBulletJOODEAdapter addShapeToBody(Body body, CollisionObject shape) {
JBulletJOODEAdapter adapter = new JBulletJOODEAdapter(body, shape);
getBodyGeoms(body).add(adapter);
+
+ activeAdapters.add(adapter);
return adapter;
}
@@ -119,7 +134,6 @@
for(int i=0;i<geoms.size();i++){
JBulletJOODEAdapter adapter = geoms.get(i);
if(adapter.getCollisionShape().equals(shape)){
-
activeAdapters.remove(adapter);
geoms.remove(i);
return adapter;
Modified: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -5,15 +5,20 @@
import net.java.dev.joode.geom.Geom;
import net.java.dev.joode.util.Vector3;
import net.java.dev.joode.util.Matrix3;
+import net.java.dev.joode.util.MathUtils;
+import net.java.dev.joode.util.Matrix;
import net.java.dev.joode.Body;
+import org.openmali.vecmath2.Matrix3f;
/**
*/
-public class JBulletJOODEAdapter extends CollisionObject {
+public class JBulletJOODEAdapter {
Body body;
CollisionObject shape;
+
+
public JBulletJOODEAdapter(Body body, CollisionObject shape) {
super();
this.body = body;
@@ -21,10 +26,25 @@
}
public void updateWorldTransform(){
+
+ System.out.println("updateWorldTransform for " + body);
Vector3 pos = body.getPosition();
Matrix3 rot = body.getRotation();
- worldTransform.origin.set(pos.getX(), pos.getY(),pos.getZ());
- worldTransform.basis.set(rot.m);
+ shape.worldTransform.origin.set(pos.getX(), pos.getY(),pos.getZ());
+
+ toVecmathMatrix(rot,shape.worldTransform.basis);
}
+ public CollisionObject getCollisionShape() {
+ return shape;
+ }
+
+ public void toVecmathMatrix(Matrix joode, javax.vecmath.Matrix3f vecmath){
+ for(int i=0;i<3;i++){
+ for(int j=0;j<3;j++){
+ vecmath.setElement(i,j, joode.get(i,j));
+ }
+ }
+
+ }
}
Modified: trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java
===================================================================
--- trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java 2009-02-05 22:59:39 UTC (rev 598)
+++ trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java 2009-02-09 00:08:03 UTC (rev 599)
@@ -11,10 +11,14 @@
import java.util.ArrayList;
import java.awt.*;
+import java.awt.event.KeyListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyAdapter;
import com.bulletphysics.collision.dispatch.*;
import com.bulletphysics.collision.broadphase.SimpleBroadphase;
import com.bulletphysics.collision.shapes.SphereShape;
+import com.bulletphysics.linearmath.Transform;
import com.threed.jpct.*;
import javax.swing.*;
@@ -45,7 +49,13 @@
Camera camera;
+ boolean wireframe = false;
+ float camx = 0;
+ float camy = 0;
+ float camz = 480;
+
+
private ArrayList<Body> movingObjects = new ArrayList<Body>();
private ArrayList<Vector3> originalPositions = new ArrayList<Vector3>();
private ArrayList<Vector3> originalVelocities = new ArrayList<Vector3>();
@@ -99,7 +109,7 @@
}
gfxWorld = new com.threed.jpct.World();
-
+
gfxManager = new JPCTManager(world, space, gfxWorld);
Config.maxPolysVisible = 8192;
@@ -129,19 +139,63 @@
camera.setPosition(new SimpleVector(0, 0, -20));
camera.lookAt(new SimpleVector(0, 0, 0));
+ this.addKeyListener(new KeyAdapter() {
+ public void keyPressed(KeyEvent evt) {
+ if (evt.getKeyCode() == KeyEvent.VK_UP) {
+ camy++;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_DOWN) {
+ camy--;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_LEFT) {
+ camx--;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_RIGHT) {
+ camx++;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_EQUALS) {
+ camz++;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_MINUS) {
+ camz--;
+ }
+ if (evt.getKeyCode() == KeyEvent.VK_W) {
+ wireframe = !wireframe;
+ }
+ camera.setPosition(new SimpleVector(camx, camy, camz));
+ camera.lookAt(new SimpleVector(0, 0, 0));
+ }
+ });
+
}
- public void render(){
+ public void paint(Graphics g) {
+ if (renderBuffer == null) return;
+
gfxWorld.setCameraTo(camera);
- gfxWorld.renderScene(renderBuffer);
- }
+ gfxWorld.renderScene(renderBuffer);
+ renderBuffer.clear(new Color(0, 0, 0));
- public void paint(Graphics g) {
+ if (wireframe) {
+ gfxWorld.drawWireframe(renderBuffer, Color.lightGray);
+ } else {
+ gfxWorld.draw(renderBuffer);
+ }
renderBuffer.display(g);
+
+ g.setColor(Color.white);
+ //g.drawString("fps: "+fps,10,15);
+ g.drawString("polys: " + gfxWorld.getVisibilityList().getSize(), 50, 15);
+
}
- public static void main(String[] args) {
+ public void step(float t){
+ world.step(t);
+ this.repaint();
+ }
+
+ public static void main(String[] args) throws InterruptedException {
JFrame frame = new JFrame();
JBulletTestingWorld testingWorld = new JBulletTestingWorld(true, true);
@@ -149,20 +203,33 @@
frame.add(testingWorld);
frame.setVisible(true);
-
- Body b1= new Body(testingWorld.getDynamicsWorld(), Mass.createSphere(1,1));
+ Body b1 = new Body(testingWorld.getDynamicsWorld(), Mass.createSphere(1, 1));
+
CollisionObject geom = new CollisionObject();
geom.setCollisionShape(new SphereShape(1));
- JBulletBodyInterface.INSTANCE.addShape(geom,b1);
+
+ Transform identity = new Transform();
+ identity.setIdentity();
+
+ geom.setWorldTransform(identity);
+
+ JBulletBodyInterface.INSTANCE.addShape(geom, b1);
+
JBulletCollisionWorldAdapter.getAdapter(
- testingWorld.getCollisionWorld()
+ testingWorld.getCollisionWorld()
).addShape(geom);
testingWorld.addMovingObject(b1);
- testingWorld.render();
+
+ while(true){
+ System.out.println("b1.getPosition() = " + b1.getPosition());
+ testingWorld.step(.1f);
+ Thread.sleep(1000);
+ }
+
}
private World getDynamicsWorld() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2009-02-05 23:00:09
|
Revision: 598
http://joode.svn.sourceforge.net/joode/?rev=598&view=rev
Author: t_larkworthy
Date: 2009-02-05 22:59:39 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Humble beginnings of a merge between JBullet and JOODE (and a JPCT binding as I have to reinvent all that anyway).
Probably doesn't work at the moment, which is why I am working in a subfolder.
Hopefully I can eventually get rid of all JOODE's current broken collision library and replace with JBullet. JBullet uses vector math library, so hopefully we might be able to switch to OpenMali for both the collision library and the dynamics functionality (but thats way off yet
Added Paths:
-----------
trunk/jbullet/JBullet-src/
trunk/jbullet/JBullet-src/com/
trunk/jbullet/JBullet-src/com/bulletphysics/
trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java
trunk/jbullet/JBullet-src/com/bulletphysics/BulletStats.java
trunk/jbullet/JBullet-src/com/bulletphysics/ContactAddedCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/ContactDestroyedCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/ContactProcessedCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3_32.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/BroadphaseInterface.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/BroadphaseNativeType.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/BroadphasePair.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/BroadphaseProxy.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/CollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/CollisionAlgorithmConstructionInfo.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/CollisionFilterGroups.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/DispatchFunc.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/Dispatcher.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/DispatcherInfo.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/HashedOverlappingPairCache.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/OverlapCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/OverlapFilterCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/OverlappingPairCache.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/OverlappingPairCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/SimpleBroadphase.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/SimpleBroadphaseProxy.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionAlgorithmCreateFunc.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionConfiguration.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionDispatcher.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionFlags.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObject.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionObjectType.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CollisionWorld.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/CompoundCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConcaveCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexConvexAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexPlaneCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ConvexTriangleCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/DefaultCollisionConfiguration.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/DefaultNearCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/EmptyAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/ManifoldResult.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/NearCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SimulationIslandManager.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/SphereSphereCollisionAlgorithm.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/UnionFind.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/dispatch/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/ConvexCast.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/ConvexPenetrationDepthSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/DiscreteCollisionDetectorInterface.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkConvexCast.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaPenetrationDepthSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkEpaSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/GjkPairDetector.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/ManifoldPoint.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PersistentManifold.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/PointCollector.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SimplexSolverInterface.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/SubsimplexConvexCast.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleConvexcastCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/TriangleRaycastCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/VoronoiSimplexSolver.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/narrowphase/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BU_Simplex1to4.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BoxShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhSubtreeInfo.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/BvhTriangleMeshShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShapeX.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CapsuleShapeZ.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CollisionShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CompoundShapeChild.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConcaveShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShapeX.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConeShapeZ.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexHullShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexInternalShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ConvexShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeX.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/CylinderShapeZ.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/IndexedMesh.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/InternalTriangleIndexCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/MinkowskiSumShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/NodeOverlapCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvh.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/OptimizedBvhNode.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/PolyhedralConvexShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/QuantizedBvhNodes.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ScalarType.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/ShapeHull.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/SphereShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StaticPlaneShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/StridingMeshInterface.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TraversalMode.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleCallback.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleIndexVertexArray.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleMeshShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/TriangleShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/UniformScalingShape.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/VertexData.java
trunk/jbullet/JBullet-src/com/bulletphysics/collision/shapes/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/AabbUtil2.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/CProfileIterator.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/CProfileManager.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/CProfileNode.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Clock.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/DebugDrawModes.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/DefaultMotionState.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/GeometryUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/IDebugDraw.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/MatrixUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/MiscUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/MotionState.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/QuaternionUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/ScalarUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/Transform.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/TransformUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/VectorUtil.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullDesc.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullFlags.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullLibrary.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/HullResult.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/Int3.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/Int4.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/IntRef.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/PHullResult.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/Tri.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/convexhull/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/linearmath/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/package-info.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/
trunk/jbullet/JBullet-src/com/bulletphysics/util/ArrayPool.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/FloatArrayList.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/IntArrayList.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/ObjectArrayList.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/ObjectPool.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/ObjectStackList.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/StackList.java
trunk/jbullet/JBullet-src/com/bulletphysics/util/package-info.java
Added: trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/BulletGlobals.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,130 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics;
+
+import com.bulletphysics.util.ArrayPool;
+import com.bulletphysics.util.ObjectPool;
+import cz.advel.stack.Stack;
+
+/**
+ * Bullet global settings and constants.
+ *
+ * @author jezek2
+ */
+public class BulletGlobals {
+
+ public static final boolean DEBUG = false;
+
+ public static final float CONVEX_DISTANCE_MARGIN = 0.04f;
+ public static final float FLT_EPSILON = 1.19209290e-07f;
+ public static final float SIMD_EPSILON = FLT_EPSILON;
+
+ public static final float SIMD_2_PI = 6.283185307179586232f;
+ public static final float SIMD_PI = SIMD_2_PI * 0.5f;
+ public static final float SIMD_HALF_PI = SIMD_2_PI * 0.25f;
+ public static final float SIMD_RADS_PER_DEG = SIMD_2_PI / 360f;
+ public static final float SIMD_DEGS_PER_RAD = 360f / SIMD_2_PI;
+ public static final float SIMD_INFINITY = Float.MAX_VALUE;
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ private static ThreadLocal<BulletGlobals> threadLocal = new ThreadLocal<BulletGlobals>() {
+ @Override
+ protected BulletGlobals initialValue() {
+ return new BulletGlobals();
+ }
+ };
+
+ private ContactDestroyedCallback gContactDestroyedCallback;
+ private ContactAddedCallback gContactAddedCallback;
+ private ContactProcessedCallback gContactProcessedCallback;
+
+ private float contactBreakingThreshold = 0.02f;
+ // RigidBody
+ private float deactivationTime = 2f;
+ private boolean disableDeactivation = false;
+
+ public static ContactAddedCallback getContactAddedCallback() {
+ return threadLocal.get().gContactAddedCallback;
+ }
+
+ public static void setContactAddedCallback(ContactAddedCallback callback) {
+ threadLocal.get().gContactAddedCallback = callback;
+ }
+
+ public static ContactDestroyedCallback getContactDestroyedCallback() {
+ return threadLocal.get().gContactDestroyedCallback;
+ }
+
+ public static void setContactDestroyedCallback(ContactDestroyedCallback callback) {
+ threadLocal.get().gContactDestroyedCallback = callback;
+ }
+
+ public static ContactProcessedCallback getContactProcessedCallback() {
+ return threadLocal.get().gContactProcessedCallback;
+ }
+
+ public static void setContactProcessedCallback(ContactProcessedCallback callback) {
+ threadLocal.get().gContactProcessedCallback = callback;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ public static float getContactBreakingThreshold() {
+ return threadLocal.get().contactBreakingThreshold;
+ }
+
+ public static void setContactBreakingThreshold(float threshold) {
+ threadLocal.get().contactBreakingThreshold = threshold;
+ }
+
+ public static float getDeactivationTime() {
+ return threadLocal.get().deactivationTime;
+ }
+
+ public static void setDeactivationTime(float time) {
+ threadLocal.get().deactivationTime = time;
+ }
+
+ public static boolean isDeactivationDisabled() {
+ return threadLocal.get().disableDeactivation;
+ }
+
+ public static void setDeactivationDisabled(boolean disable) {
+ threadLocal.get().disableDeactivation = disable;
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Cleans all current thread specific settings and caches.
+ */
+ public static void cleanCurrentThread() {
+ threadLocal.remove();
+ Stack.libraryCleanCurrentThread();
+ ObjectPool.cleanCurrentThread();
+ ArrayPool.cleanCurrentThread();
+ }
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/BulletStats.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/BulletStats.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/BulletStats.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,106 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics;
+
+import com.bulletphysics.linearmath.CProfileManager;
+import com.bulletphysics.linearmath.Clock;
+import javax.vecmath.Vector3f;
+
+/**
+ * Bullet statistics and profile support.
+ *
+ * @author jezek2
+ */
+public class BulletStats {
+
+ public static int gTotalContactPoints;
+
+ // GjkPairDetector
+ // temp globals, to improve GJK/EPA/penetration calculations
+ public static int gNumDeepPenetrationChecks = 0;
+ public static int gNumGjkChecks = 0;
+ public static int gNumSplitImpulseRecoveries = 0;
+
+ public static int gNumAlignedAllocs;
+ public static int gNumAlignedFree;
+ public static int gTotalBytesAlignedAllocs;
+
+ public static int gPickingConstraintId = 0;
+ public static final Vector3f gOldPickingPos = new Vector3f();
+ public static float gOldPickingDist = 0.f;
+
+ public static int gOverlappingPairs = 0;
+ public static int gRemovePairs = 0;
+ public static int gAddedPairs = 0;
+ public static int gFindPairs = 0;
+
+ public static final Clock gProfileClock = new Clock();
+
+ // JAVA NOTE: added for statistics in applet demo
+ public static long stepSimulationTime;
+ public static long updateTime;
+
+ private static boolean enableProfile = false;
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ public static boolean isProfileEnabled() {
+ return enableProfile;
+ }
+
+ public static void setProfileEnabled(boolean b) {
+ enableProfile = b;
+ }
+
+ public static long profileGetTicks() {
+ long ticks = gProfileClock.getTimeMicroseconds();
+ return ticks;
+ }
+
+ public static float profileGetTickRate() {
+ //return 1000000f;
+ return 1000f;
+ }
+
+ /**
+ * Pushes profile node. Use try/finally block to call {@link #popProfile} method.
+ *
+ * @param name must be {@link String#intern interned} String (not needed for String literals)
+ */
+ public static void pushProfile(String name) {
+ if (enableProfile) {
+ CProfileManager.startProfile(name);
+ }
+ }
+
+ /**
+ * Pops profile node.
+ */
+ public static void popProfile() {
+ if (enableProfile) {
+ CProfileManager.stopProfile();
+ }
+ }
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/ContactAddedCallback.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/ContactAddedCallback.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/ContactAddedCallback.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,41 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics;
+
+import com.bulletphysics.collision.dispatch.CollisionFlags;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.collision.narrowphase.ManifoldPoint;
+
+/**
+ * Called when contact has been created between two collision objects. At least
+ * one of object must have {@link CollisionFlags#CUSTOM_MATERIAL_CALLBACK} flag set.
+ *
+ * @see BulletGlobals#setContactAddedCallback
+ * @author jezek2
+ */
+public interface ContactAddedCallback {
+
+ public boolean contactAdded(ManifoldPoint cp, CollisionObject colObj0, int partId0, int index0, CollisionObject colObj1, int partId1, int index1);
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/ContactDestroyedCallback.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/ContactDestroyedCallback.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/ContactDestroyedCallback.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,36 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics;
+
+/**
+ * Called when contact has been destroyed between two collision objects.
+ *
+ * @see BulletGlobals#setContactDestroyedCallback
+ * @author jezek2
+ */
+public interface ContactDestroyedCallback {
+
+ public boolean contactDestroyed(Object userPersistentData);
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/ContactProcessedCallback.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/ContactProcessedCallback.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/ContactProcessedCallback.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,38 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics;
+
+import com.bulletphysics.collision.narrowphase.ManifoldPoint;
+
+/**
+ * Called when existing contact between two collision objects has been processed.
+ *
+ * @see BulletGlobals#setContactProcessedCallback
+ * @author jezek2
+ */
+public interface ContactProcessedCallback {
+
+ public boolean contactProcessed(ManifoldPoint cp, Object body0, Object body1);
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,167 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * AxisSweep3
+ * Copyright (c) 2006 Simon Hobbs
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics.collision.broadphase;
+
+import javax.vecmath.Vector3f;
+
+/**
+ * AxisSweep3 is an efficient implementation of the 3D axis sweep and prune broadphase.<p>
+ *
+ * It uses arrays rather then lists for storage of the 3 axis. Also it operates using 16 bit
+ * integer coordinates instead of floats. For large worlds and many objects, use {@link AxisSweep3_32}
+ * instead. AxisSweep3_32 has higher precision and allows more than 16384 objects at the cost
+ * of more memory and bit of performance.
+ *
+ * @author jezek2
+ */
+public class AxisSweep3 extends AxisSweep3Internal {
+
+ public AxisSweep3(Vector3f worldAabbMin, Vector3f worldAabbMax) {
+ this(worldAabbMin, worldAabbMax, 16384, null);
+ }
+
+ public AxisSweep3(Vector3f worldAabbMin, Vector3f worldAabbMax, int maxHandles) {
+ this(worldAabbMin, worldAabbMax, maxHandles, null);
+ }
+
+ public AxisSweep3(Vector3f worldAabbMin, Vector3f worldAabbMax, int maxHandles/* = 16384*/, OverlappingPairCache pairCache/* = 0*/) {
+ super(worldAabbMin, worldAabbMax, 0xfffe, 0xffff, maxHandles, pairCache);
+ // 1 handle is reserved as sentinel
+ assert (maxHandles > 1 && maxHandles < 32767);
+ }
+
+ @Override
+ protected EdgeArray createEdgeArray(int size) {
+ return new EdgeArrayImpl(size);
+ }
+
+ @Override
+ protected Handle createHandle() {
+ return new HandleImpl();
+ }
+
+ protected int getMask() {
+ return 0xFFFF;
+ }
+
+ protected static class EdgeArrayImpl extends EdgeArray {
+ private short[] pos;
+ private short[] handle;
+
+ public EdgeArrayImpl(int size) {
+ pos = new short[size];
+ handle = new short[size];
+ }
+
+ @Override
+ public void swap(int idx1, int idx2) {
+ short tmpPos = pos[idx1];
+ short tmpHandle = handle[idx1];
+
+ pos[idx1] = pos[idx2];
+ handle[idx1] = handle[idx2];
+
+ pos[idx2] = tmpPos;
+ handle[idx2] = tmpHandle;
+ }
+
+ @Override
+ public void set(int dest, int src) {
+ pos[dest] = pos[src];
+ handle[dest] = handle[src];
+ }
+
+ @Override
+ public int getPos(int index) {
+ return pos[index] & 0xFFFF;
+ }
+
+ @Override
+ public void setPos(int index, int value) {
+ pos[index] = (short)value;
+ }
+
+ @Override
+ public int getHandle(int index) {
+ return handle[index] & 0xFFFF;
+ }
+
+ @Override
+ public void setHandle(int index, int value) {
+ handle[index] = (short)value;
+ }
+ }
+
+ protected static class HandleImpl extends Handle {
+ private short minEdges0;
+ private short minEdges1;
+ private short minEdges2;
+
+ private short maxEdges0;
+ private short maxEdges1;
+ private short maxEdges2;
+
+ @Override
+ public int getMinEdges(int edgeIndex) {
+ switch (edgeIndex) {
+ default:
+ case 0: return minEdges0 & 0xFFFF;
+ case 1: return minEdges1 & 0xFFFF;
+ case 2: return minEdges2 & 0xFFFF;
+ }
+ }
+
+ @Override
+ public void setMinEdges(int edgeIndex, int value) {
+ switch (edgeIndex) {
+ case 0: minEdges0 = (short)value; break;
+ case 1: minEdges1 = (short)value; break;
+ case 2: minEdges2 = (short)value; break;
+ }
+ }
+
+ @Override
+ public int getMaxEdges(int edgeIndex) {
+ switch (edgeIndex) {
+ default:
+ case 0: return maxEdges0 & 0xFFFF;
+ case 1: return maxEdges1 & 0xFFFF;
+ case 2: return maxEdges2 & 0xFFFF;
+ }
+ }
+
+ @Override
+ public void setMaxEdges(int edgeIndex, int value) {
+ switch (edgeIndex) {
+ case 0: maxEdges0 = (short)value; break;
+ case 1: maxEdges1 = (short)value; break;
+ case 2: maxEdges2 = (short)value; break;
+ }
+ }
+ }
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3Internal.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,705 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * AxisSweep3
+ * Copyright (c) 2006 Simon Hobbs
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics.collision.broadphase;
+
+import com.bulletphysics.BulletStats;
+import com.bulletphysics.collision.broadphase.AxisSweep3Internal.Handle;
+import com.bulletphysics.linearmath.MiscUtil;
+import com.bulletphysics.linearmath.VectorUtil;
+import cz.advel.stack.Stack;
+import java.util.List;
+import javax.vecmath.Vector3f;
+
+/**
+ * AxisSweep3Internal is an internal base class that implements sweep and prune.
+ * Use concrete implementation {@link AxisSweep3} or {@link AxisSweep3_32}.
+ *
+ * @author jezek2
+ */
+public abstract class AxisSweep3Internal implements BroadphaseInterface {
+
+ protected int bpHandleMask;
+ protected int handleSentinel;
+
+ protected final Vector3f worldAabbMin = new Vector3f(); // overall system bounds
+ protected final Vector3f worldAabbMax = new Vector3f(); // overall system bounds
+
+ protected final Vector3f quantize = new Vector3f(); // scaling factor for quantization
+
+ protected int numHandles; // number of active handles
+ protected int maxHandles; // max number of handles
+ protected Handle[] pHandles; // handles pool
+ protected int firstFreeHandle; // free handles list
+
+ protected EdgeArray[] pEdges = new EdgeArray[3]; // edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries)
+
+ protected OverlappingPairCache pairCache;
+
+ // OverlappingPairCallback is an additional optional user callback for adding/removing overlapping pairs, similar interface to OverlappingPairCache.
+ protected OverlappingPairCallback userPairCallback = null;
+
+ protected boolean ownsPairCache = false;
+
+ protected int invalidPair = 0;
+
+ // JAVA NOTE: added
+ protected int mask;
+
+ AxisSweep3Internal(Vector3f worldAabbMin, Vector3f worldAabbMax, int handleMask, int handleSentinel, int userMaxHandles/* = 16384*/, OverlappingPairCache pairCache/*=0*/) {
+ this.bpHandleMask = handleMask;
+ this.handleSentinel = handleSentinel;
+ this.pairCache = pairCache;
+
+ int maxHandles = userMaxHandles + 1; // need to add one sentinel handle
+
+ if (this.pairCache == null) {
+ this.pairCache = new HashedOverlappingPairCache();
+ ownsPairCache = true;
+ }
+
+ //assert(bounds.HasVolume());
+
+ // init bounds
+ this.worldAabbMin.set(worldAabbMin);
+ this.worldAabbMax.set(worldAabbMax);
+
+ Vector3f aabbSize = Stack.alloc(Vector3f.class);
+ aabbSize.sub(this.worldAabbMax, this.worldAabbMin);
+
+ int maxInt = this.handleSentinel;
+
+ quantize.set(maxInt / aabbSize.x, maxInt / aabbSize.y, maxInt / aabbSize.z);
+
+ // allocate handles buffer and put all handles on free list
+ pHandles = new Handle[maxHandles];
+ for (int i=0; i<maxHandles; i++) {
+ pHandles[i] = createHandle();
+ }
+ this.maxHandles = maxHandles;
+ this.numHandles = 0;
+
+ // handle 0 is reserved as the null index, and is also used as the sentinel
+ firstFreeHandle = 1;
+ {
+ for (int i=firstFreeHandle; i<maxHandles; i++) {
+ pHandles[i].setNextFree(i+1);
+ }
+ pHandles[maxHandles - 1].setNextFree(0);
+ }
+
+ {
+ // allocate edge buffers
+ for (int i=0; i<3; i++) {
+ pEdges[i] = createEdgeArray(maxHandles*2);
+ }
+ }
+ //removed overlap management
+
+ // make boundary sentinels
+
+ pHandles[0].clientObject = null;
+
+ for (int axis = 0; axis < 3; axis++) {
+ pHandles[0].setMinEdges(axis, 0);
+ pHandles[0].setMaxEdges(axis, 1);
+
+ pEdges[axis].setPos(0, 0);
+ pEdges[axis].setHandle(0, 0);
+ pEdges[axis].setPos(1, handleSentinel);
+ pEdges[axis].setHandle(1, 0);
+ //#ifdef DEBUG_BROADPHASE
+ //debugPrintAxis(axis);
+ //#endif //DEBUG_BROADPHASE
+ }
+
+ // JAVA NOTE: added
+ mask = getMask();
+ }
+
+ // allocation/deallocation
+ protected int allocHandle() {
+ assert (firstFreeHandle != 0);
+
+ int handle = firstFreeHandle;
+ firstFreeHandle = getHandle(handle).getNextFree();
+ numHandles++;
+
+ return handle;
+ }
+
+ protected void freeHandle(int handle) {
+ assert (handle > 0 && handle < maxHandles);
+
+ getHandle(handle).setNextFree(firstFreeHandle);
+ firstFreeHandle = handle;
+
+ numHandles--;
+ }
+
+ protected boolean testOverlap(int ignoreAxis, Handle pHandleA, Handle pHandleB) {
+ // optimization 1: check the array index (memory address), instead of the m_pos
+
+ for (int axis=0; axis<3; axis++) {
+ if (axis != ignoreAxis) {
+ if (pHandleA.getMaxEdges(axis) < pHandleB.getMinEdges(axis) ||
+ pHandleB.getMaxEdges(axis) < pHandleA.getMinEdges(axis)) {
+ return false;
+ }
+ }
+ }
+
+ //optimization 2: only 2 axis need to be tested (conflicts with 'delayed removal' optimization)
+
+ /*for (int axis = 0; axis < 3; axis++)
+ {
+ if (m_pEdges[axis][pHandleA->m_maxEdges[axis]].m_pos < m_pEdges[axis][pHandleB->m_minEdges[axis]].m_pos ||
+ m_pEdges[axis][pHandleB->m_maxEdges[axis]].m_pos < m_pEdges[axis][pHandleA->m_minEdges[axis]].m_pos)
+ {
+ return false;
+ }
+ }
+ */
+
+ return true;
+ }
+
+ //#ifdef DEBUG_BROADPHASE
+ //void debugPrintAxis(int axis,bool checkCardinality=true);
+ //#endif //DEBUG_BROADPHASE
+
+ protected void quantize(int[] out, Vector3f point, int isMax) {
+ Vector3f clampedPoint = Stack.alloc(point);
+
+ VectorUtil.setMax(clampedPoint, worldAabbMin);
+ VectorUtil.setMin(clampedPoint, worldAabbMax);
+
+ Vector3f v = Stack.alloc(Vector3f.class);
+ v.sub(clampedPoint, worldAabbMin);
+ VectorUtil.mul(v, v, quantize);
+
+ out[0] = (((int)v.x & bpHandleMask) | isMax) & mask;
+ out[1] = (((int)v.y & bpHandleMask) | isMax) & mask;
+ out[2] = (((int)v.z & bpHandleMask) | isMax) & mask;
+ }
+
+ // sorting a min edge downwards can only ever *add* overlaps
+ protected void sortMinDown(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
+ EdgeArray edgeArray = pEdges[axis];
+ int pEdge_idx = edge;
+ int pPrev_idx = pEdge_idx - 1;
+
+ Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));
+
+ while (edgeArray.getPos(pEdge_idx) < edgeArray.getPos(pPrev_idx)) {
+ Handle pHandlePrev = getHandle(edgeArray.getHandle(pPrev_idx));
+
+ if (edgeArray.isMax(pPrev_idx) != 0) {
+ // if previous edge is a maximum check the bounds and add an overlap if necessary
+ if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandlePrev)) {
+ pairCache.addOverlappingPair(pHandleEdge, pHandlePrev);
+ if (userPairCallback != null) {
+ userPairCallback.addOverlappingPair(pHandleEdge, pHandlePrev);
+ //AddOverlap(pEdge->m_handle, pPrev->m_handle);
+ }
+ }
+
+ // update edge reference in other handle
+ pHandlePrev.incMaxEdges(axis);
+ }
+ else {
+ pHandlePrev.incMinEdges(axis);
+ }
+ pHandleEdge.decMinEdges(axis);
+
+ // swap the edges
+ edgeArray.swap(pEdge_idx, pPrev_idx);
+
+ // decrement
+ pEdge_idx--;
+ pPrev_idx--;
+ }
+
+ //#ifdef DEBUG_BROADPHASE
+ //debugPrintAxis(axis);
+ //#endif //DEBUG_BROADPHASE
+ }
+
+ // sorting a min edge upwards can only ever *remove* overlaps
+ protected void sortMinUp(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
+ EdgeArray edgeArray = pEdges[axis];
+ int pEdge_idx = edge;
+ int pNext_idx = pEdge_idx + 1;
+ Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));
+
+ while (edgeArray.getHandle(pNext_idx) != 0 && (edgeArray.getPos(pEdge_idx) >= edgeArray.getPos(pNext_idx))) {
+ Handle pHandleNext = getHandle(edgeArray.getHandle(pNext_idx));
+
+ if (edgeArray.isMax(pNext_idx) != 0) {
+ // if next edge is maximum remove any overlap between the two handles
+ if (updateOverlaps) {
+ Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
+ Handle handle1 = getHandle(edgeArray.getHandle(pNext_idx));
+
+ pairCache.removeOverlappingPair(handle0, handle1, dispatcher);
+ if (userPairCallback != null) {
+ userPairCallback.removeOverlappingPair(handle0, handle1, dispatcher);
+ }
+ }
+
+ // update edge reference in other handle
+ pHandleNext.decMaxEdges(axis);
+ }
+ else {
+ pHandleNext.decMinEdges(axis);
+ }
+ pHandleEdge.incMinEdges(axis);
+
+ // swap the edges
+ edgeArray.swap(pEdge_idx, pNext_idx);
+
+ // increment
+ pEdge_idx++;
+ pNext_idx++;
+ }
+ }
+
+ // sorting a max edge downwards can only ever *remove* overlaps
+ protected void sortMaxDown(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
+ EdgeArray edgeArray = pEdges[axis];
+ int pEdge_idx = edge;
+ int pPrev_idx = pEdge_idx - 1;
+ Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));
+
+ while (edgeArray.getPos(pEdge_idx) < edgeArray.getPos(pPrev_idx)) {
+ Handle pHandlePrev = getHandle(edgeArray.getHandle(pPrev_idx));
+
+ if (edgeArray.isMax(pPrev_idx) == 0) {
+ // if previous edge was a minimum remove any overlap between the two handles
+ if (updateOverlaps) {
+ // this is done during the overlappingpairarray iteration/narrowphase collision
+ Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
+ Handle handle1 = getHandle(edgeArray.getHandle(pPrev_idx));
+ pairCache.removeOverlappingPair(handle0, handle1, dispatcher);
+ if (userPairCallback != null) {
+ userPairCallback.removeOverlappingPair(handle0, handle1, dispatcher);
+ }
+ }
+
+ // update edge reference in other handle
+ pHandlePrev.incMinEdges(axis);
+ }
+ else {
+ pHandlePrev.incMaxEdges(axis);
+ }
+ pHandleEdge.decMaxEdges(axis);
+
+ // swap the edges
+ edgeArray.swap(pEdge_idx, pPrev_idx);
+
+ // decrement
+ pEdge_idx--;
+ pPrev_idx--;
+ }
+
+ //#ifdef DEBUG_BROADPHASE
+ //debugPrintAxis(axis);
+ //#endif //DEBUG_BROADPHASE
+ }
+
+ // sorting a max edge upwards can only ever *add* overlaps
+ protected void sortMaxUp(int axis, int edge, Dispatcher dispatcher, boolean updateOverlaps) {
+ EdgeArray edgeArray = pEdges[axis];
+ int pEdge_idx = edge;
+ int pNext_idx = pEdge_idx + 1;
+ Handle pHandleEdge = getHandle(edgeArray.getHandle(pEdge_idx));
+
+ while (edgeArray.getHandle(pNext_idx) != 0 && (edgeArray.getPos(pEdge_idx) >= edgeArray.getPos(pNext_idx))) {
+ Handle pHandleNext = getHandle(edgeArray.getHandle(pNext_idx));
+
+ if (edgeArray.isMax(pNext_idx) == 0) {
+ // if next edge is a minimum check the bounds and add an overlap if necessary
+ if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandleNext)) {
+ Handle handle0 = getHandle(edgeArray.getHandle(pEdge_idx));
+ Handle handle1 = getHandle(edgeArray.getHandle(pNext_idx));
+ pairCache.addOverlappingPair(handle0, handle1);
+ if (userPairCallback != null) {
+ userPairCallback.addOverlappingPair(handle0, handle1);
+ }
+ }
+
+ // update edge reference in other handle
+ pHandleNext.decMinEdges(axis);
+ }
+ else {
+ pHandleNext.decMaxEdges(axis);
+ }
+ pHandleEdge.incMaxEdges(axis);
+
+ // swap the edges
+ edgeArray.swap(pEdge_idx, pNext_idx);
+
+ // increment
+ pEdge_idx++;
+ pNext_idx++;
+ }
+ }
+
+ public int getNumHandles() {
+ return numHandles;
+ }
+
+ @Override
+ public void calculateOverlappingPairs(Dispatcher dispatcher) {
+ if (pairCache.hasDeferredRemoval()) {
+ List<BroadphasePair> overlappingPairArray = pairCache.getOverlappingPairArray();
+
+ // perform a sort, to find duplicates and to sort 'invalid' pairs to the end
+ MiscUtil.quickSort(overlappingPairArray, BroadphasePair.broadphasePairSortPredicate);
+
+ MiscUtil.resize(overlappingPairArray, overlappingPairArray.size() - invalidPair, BroadphasePair.class);
+ invalidPair = 0;
+
+ int i;
+
+ BroadphasePair previousPair = new BroadphasePair();
+ previousPair.pProxy0 = null;
+ previousPair.pProxy1 = null;
+ previousPair.algorithm = null;
+
+ for (i=0; i<overlappingPairArray.size(); i++) {
+ BroadphasePair pair = overlappingPairArray.get(i);
+
+ boolean isDuplicate = (pair.equals(previousPair));
+
+ previousPair.set(pair);
+
+ boolean needsRemoval = false;
+
+ if (!isDuplicate) {
+ boolean hasOverlap = testAabbOverlap(pair.pProxy0, pair.pProxy1);
+
+ if (hasOverlap) {
+ needsRemoval = false;//callback->processOverlap(pair);
+ }
+ else {
+ needsRemoval = true;
+ }
+ }
+ else {
+ // remove duplicate
+ needsRemoval = true;
+ // should have no algorithm
+ assert (pair.algorithm == null);
+ }
+
+ if (needsRemoval) {
+ pairCache.cleanOverlappingPair(pair, dispatcher);
+
+ // m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
+ // m_overlappingPairArray.pop_back();
+ pair.pProxy0 = null;
+ pair.pProxy1 = null;
+ invalidPair++;
+ BulletStats.gOverlappingPairs--;
+ }
+
+ }
+
+ // if you don't like to skip the invalid pairs in the array, execute following code:
+ //#define CLEAN_INVALID_PAIRS 1
+ //#ifdef CLEAN_INVALID_PAIRS
+
+ // perform a sort, to sort 'invalid' pairs to the end
+ MiscUtil.quickSort(overlappingPairArray, BroadphasePair.broadphasePairSortPredicate);
+
+ MiscUtil.resize(overlappingPairArray, overlappingPairArray.size() - invalidPair, BroadphasePair.class);
+ invalidPair = 0;
+ //#endif//CLEAN_INVALID_PAIRS
+
+ //printf("overlappingPairArray.size()=%d\n",overlappingPairArray.size());
+ }
+ }
+
+ public int addHandle(Vector3f aabbMin, Vector3f aabbMax, Object pOwner, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher, Object multiSapProxy) {
+ // quantize the bounds
+ int[] min = new int[3], max = new int[3];
+ quantize(min, aabbMin, 0);
+ quantize(max, aabbMax, 1);
+
+ // allocate a handle
+ int handle = allocHandle();
+
+ Handle pHandle = getHandle(handle);
+
+ pHandle.uniqueId = handle;
+ //pHandle->m_pOverlaps = 0;
+ pHandle.clientObject = pOwner;
+ pHandle.collisionFilterGroup = collisionFilterGroup;
+ pHandle.collisionFilterMask = collisionFilterMask;
+ pHandle.multiSapParentProxy = multiSapProxy;
+
+ // compute current limit of edge arrays
+ int limit = numHandles * 2;
+
+ // insert new edges just inside the max boundary edge
+ for (int axis = 0; axis < 3; axis++) {
+ pHandles[0].setMaxEdges(axis, pHandles[0].getMaxEdges(axis) + 2);
+
+ pEdges[axis].set(limit + 1, limit - 1);
+
+ pEdges[axis].setPos(limit - 1, min[axis]);
+ pEdges[axis].setHandle(limit - 1, handle);
+
+ pEdges[axis].setPos(limit, max[axis]);
+ pEdges[axis].setHandle(limit, handle);
+
+ pHandle.setMinEdges(axis, limit - 1);
+ pHandle.setMaxEdges(axis, limit);
+ }
+
+ // now sort the new edges to their correct position
+ sortMinDown(0, pHandle.getMinEdges(0), dispatcher, false);
+ sortMaxDown(0, pHandle.getMaxEdges(0), dispatcher, false);
+ sortMinDown(1, pHandle.getMinEdges(1), dispatcher, false);
+ sortMaxDown(1, pHandle.getMaxEdges(1), dispatcher, false);
+ sortMinDown(2, pHandle.getMinEdges(2), dispatcher, true);
+ sortMaxDown(2, pHandle.getMaxEdges(2), dispatcher, true);
+
+ return handle;
+ }
+
+ public void removeHandle(int handle, Dispatcher dispatcher) {
+ Handle pHandle = getHandle(handle);
+
+ // explicitly remove the pairs containing the proxy
+ // we could do it also in the sortMinUp (passing true)
+ // todo: compare performance
+ if (!pairCache.hasDeferredRemoval()) {
+ pairCache.removeOverlappingPairsContainingProxy(pHandle, dispatcher);
+ }
+
+ // compute current limit of edge arrays
+ int limit = numHandles * 2;
+
+ int axis;
+
+ for (axis = 0; axis < 3; axis++) {
+ pHandles[0].setMaxEdges(axis, pHandles[0].getMaxEdges(axis) - 2);
+ }
+
+ // remove the edges by sorting them up to the end of the list
+ for (axis = 0; axis < 3; axis++) {
+ EdgeArray pEdges = this.pEdges[axis];
+ int max = pHandle.getMaxEdges(axis);
+ pEdges.setPos(max, handleSentinel);
+
+ sortMaxUp(axis, max, dispatcher, false);
+
+ int i = pHandle.getMinEdges(axis);
+ pEdges.setPos(i, handleSentinel);
+
+ sortMinUp(axis, i, dispatcher, false);
+
+ pEdges.setHandle(limit - 1, 0);
+ pEdges.setPos(limit - 1, handleSentinel);
+
+ //#ifdef DEBUG_BROADPHASE
+ //debugPrintAxis(axis,false);
+ //#endif //DEBUG_BROADPHASE
+ }
+
+ // free the handle
+ freeHandle(handle);
+ }
+
+ public void updateHandle(int handle, Vector3f aabbMin, Vector3f aabbMax, Dispatcher dispatcher) {
+ Handle pHandle = getHandle(handle);
+
+ // quantize the new bounds
+ int[] min = new int[3], max = new int[3];
+ quantize(min, aabbMin, 0);
+ quantize(max, aabbMax, 1);
+
+ // update changed edges
+ for (int axis = 0; axis < 3; axis++) {
+ int emin = pHandle.getMinEdges(axis);
+ int emax = pHandle.getMaxEdges(axis);
+
+ int dmin = (int) min[axis] - (int) pEdges[axis].getPos(emin);
+ int dmax = (int) max[axis] - (int) pEdges[axis].getPos(emax);
+
+ pEdges[axis].setPos(emin, min[axis]);
+ pEdges[axis].setPos(emax, max[axis]);
+
+ // expand (only adds overlaps)
+ if (dmin < 0) {
+ sortMinDown(axis, emin, dispatcher, true);
+ }
+ if (dmax > 0) {
+ sortMaxUp(axis, emax, dispatcher, true); // shrink (only removes overlaps)
+ }
+ if (dmin > 0) {
+ sortMinUp(axis, emin, dispatcher, true);
+ }
+ if (dmax < 0) {
+ sortMaxDown(axis, emax, dispatcher, true);
+ }
+
+ //#ifdef DEBUG_BROADPHASE
+ //debugPrintAxis(axis);
+ //#endif //DEBUG_BROADPHASE
+ }
+ }
+
+ public Handle getHandle(int index) {
+ return pHandles[index];
+ }
+
+ //public void processAllOverlappingPairs(OverlapCallback callback) {
+ //}
+
+ @Override
+ public BroadphaseProxy createProxy(Vector3f aabbMin, Vector3f aabbMax, BroadphaseNativeType shapeType, Object userPtr, short collisionFilterGroup, short collisionFilterMask, Dispatcher dispatcher, Object multiSapProxy) {
+ int handleId = addHandle(aabbMin, aabbMax, userPtr, collisionFilterGroup, collisionFilterMask, dispatcher, multiSapProxy);
+
+ Handle handle = getHandle(handleId);
+
+ return handle;
+ }
+
+ @Override
+ public void destroyProxy(BroadphaseProxy proxy, Dispatcher dispatcher) {
+ Handle handle = (Handle)proxy;
+ removeHandle(handle.uniqueId, dispatcher);
+ }
+
+ @Override
+ public void setAabb(BroadphaseProxy proxy, Vector3f aabbMin, Vector3f aabbMax, Dispatcher dispatcher) {
+ Handle handle = (Handle) proxy;
+ updateHandle(handle.uniqueId, aabbMin, aabbMax, dispatcher);
+ }
+
+ public boolean testAabbOverlap(BroadphaseProxy proxy0, BroadphaseProxy proxy1) {
+ Handle pHandleA = (Handle)proxy0;
+ Handle pHandleB = (Handle)proxy1;
+
+ // optimization 1: check the array index (memory address), instead of the m_pos
+
+ for (int axis = 0; axis < 3; axis++) {
+ if (pHandleA.getMaxEdges(axis) < pHandleB.getMinEdges(axis) ||
+ pHandleB.getMaxEdges(axis) < pHandleA.getMinEdges(axis)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public OverlappingPairCache getOverlappingPairCache() {
+ return pairCache;
+ }
+
+ public void setOverlappingPairUserCallback(OverlappingPairCallback pairCallback) {
+ userPairCallback = pairCallback;
+ }
+
+ public OverlappingPairCallback getOverlappingPairUserCallback() {
+ return userPairCallback;
+ }
+
+ // getAabb returns the axis aligned bounding box in the 'global' coordinate frame
+ // will add some transform later
+ @Override
+ public void getBroadphaseAabb(Vector3f aabbMin, Vector3f aabbMax) {
+ aabbMin.set(worldAabbMin);
+ aabbMax.set(worldAabbMax);
+ }
+
+ @Override
+ public void printStats() {
+ /*
+ printf("btAxisSweep3.h\n");
+ printf("numHandles = %d, maxHandles = %d\n",m_numHandles,m_maxHandles);
+ printf("aabbMin=%f,%f,%f,aabbMax=%f,%f,%f\n",m_worldAabbMin.getX(),m_worldAabbMin.getY(),m_worldAabbMin.getZ(),
+ m_worldAabbMax.getX(),m_worldAabbMax.getY(),m_worldAabbMax.getZ());
+ */
+ }
+
+ ////////////////////////////////////////////////////////////////////////////
+
+ protected abstract EdgeArray createEdgeArray(int size);
+ protected abstract Handle createHandle();
+ protected abstract int getMask();
+
+ protected static abstract class EdgeArray {
+ public abstract void swap(int idx1, int idx2);
+ public abstract void set(int dest, int src);
+
+ public abstract int getPos(int index);
+ public abstract void setPos(int index, int value);
+
+ public abstract int getHandle(int index);
+ public abstract void setHandle(int index, int value);
+
+ public int isMax(int offset) {
+ return (getPos(offset) & 1);
+ }
+ }
+
+ protected static abstract class Handle extends BroadphaseProxy {
+ public abstract int getMinEdges(int edgeIndex);
+ public abstract void setMinEdges(int edgeIndex, int value);
+
+ public abstract int getMaxEdges(int edgeIndex);
+ public abstract void setMaxEdges(int edgeIndex, int value);
+
+ public void incMinEdges(int edgeIndex) {
+ setMinEdges(edgeIndex, getMinEdges(edgeIndex)+1);
+ }
+
+ public void incMaxEdges(int edgeIndex) {
+ setMaxEdges(edgeIndex, getMaxEdges(edgeIndex)+1);
+ }
+
+ public void decMinEdges(int edgeIndex) {
+ setMinEdges(edgeIndex, getMinEdges(edgeIndex)-1);
+ }
+
+ public void decMaxEdges(int edgeIndex) {
+ setMaxEdges(edgeIndex, getMaxEdges(edgeIndex)-1);
+ }
+
+ public void setNextFree(int next) {
+ setMinEdges(0, next);
+ }
+
+ public int getNextFree() {
+ return getMinEdges(0);
+ }
+ }
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3_32.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3_32.java (rev 0)
+++ trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/AxisSweep3_32.java 2009-02-05 22:59:39 UTC (rev 598)
@@ -0,0 +1,164 @@
+/*
+ * Java port of Bullet (c) 2008 Martin Dvorak <je...@ad...>
+ *
+ * AxisSweep3
+ * Copyright (c) 2006 Simon Hobbs
+ *
+ * Bullet Continuous Collision Detection and Physics Library
+ * Copyright (c) 2003-2008 Erwin Coumans http://www.bulletphysics.com/
+ *
+ * This software is provided 'as-is', without any express or implied warranty.
+ * In no event will the authors be held liable for any damages arising from
+ * the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ */
+
+package com.bulletphysics.collision.broadphase;
+
+import javax.vecmath.Vector3f;
+
+/**
+ * AxisSweep3_32 allows higher precision quantization and more objects compared
+ * to the {@link AxisSweep3} sweep and prune. This comes at the cost of more memory
+ * per handle, and a bit slower performance.
+ *
+ * @author jezek2
+ */
+public class AxisSweep3_32 extends AxisSweep3Internal {
+
+ public AxisSweep3_32(Vector3f worldAabbMin, Vector3f worldAabbMax) {
+ this(worldAabbMin, worldAabbMax, 1500000, null);
+ }
+
+ public AxisSweep3_32(Vector3f worldAabbMin, Vector3f worldAabbMax, int maxHandles) {
+ this(worldAabbMin, worldAabbMax, maxHandles, null);
+ }
+
+ public AxisSweep3_32(Vector3f worldAabbMin, Vector3f worldAabbMax, int maxHandles/* = 1500000*/, OverlappingPairCache pairCache/* = 0*/) {
+ super(worldAabbMin, worldAabbMax, 0xfffffffe, 0x7fffffff, maxHandles, pairCache);
+ // 1 handle is reserved as sentinel
+ assert (maxHandles > 1 && maxHandles < 2147483647);
+ }
+
+ @Override
+ protected EdgeArray createEdgeArray(int size) {
+ return new EdgeArrayImpl(size);
+ }
+
+ @Override
+ protected Handle createHandle() {
+ return new HandleImpl();
+ }
+
+ protected int getMask() {
+ return 0xFFFFFFFF;
+ }
+
+ protected static class EdgeArrayImpl extends EdgeArray {
+ private int[] pos;
+ private int[] handle;
+
+ public EdgeArrayImpl(int size) {
+ pos = new int[size];
+ handle = new int[size];
+ }
+
+ @Override
+ public void swap(int idx1, int idx2) {
+ int tmpPos = pos[idx1];
+ int tmpHandle = handle[idx1];
+
+ pos[idx1] = pos[idx2];
+ handle[idx1] = handle[idx2];
+
+ pos[idx2] = tmpPos;
+ handle[idx2] = tmpHandle;
+ }
+
+ @Override
+ public void set(int dest, int src) {
+ pos[dest] = pos[src];
+ handle[dest] = handle[src];
+ }
+
+ @Override
+ public int getPos(int index) {
+ return pos[index];
+ }
+
+ @Override
+ public void setPos(int index, int value) {
+ pos[index] = value;
+ }
+
+ @Override
+ public int getHandle(int index) {
+ return handle[index];
+ }
+
+ @Override
+ public void setHandle(int index, int value) {
+ handle[index] = value;
+ }
+ }
+
+ protected static class HandleImpl extends Handle {
+ private int minEdges0;
+ private int minEdges1;
+ private int minEdges2;
+
+ private int maxEdges0;
+ private int maxEdges1;
+ private int maxEdges2;
+
+ @Override
+ public int getMinEdges(int edgeIndex) {
+ switch (edgeIndex) {
+ default:
+ case 0: return minEdges0;
+ case 1: return minEdges1;
+ case 2: return minEdges2;
+ }
+ }
+
+ @Override
+ public void setMinEdges(int edgeIndex, int value) {
+ switch (edgeIndex) {
+ case 0: minEdges0 = value; break;
+ case 1: minEdges1 = value; break;
+ case 2: minEdges2 = value; break;
+ }
+ }
+
+ @Override
+ public int getMaxEdges(int edgeIndex) {
+ switch (edgeIndex) {
+ default:
+ case 0: return maxEdges0;
+ case 1: return maxEdges1;
+ case 2: return maxEdges2;
+ }
+ }
+
+ @Override
+ public void setMaxEdges(int edgeIndex, int value) {
+ switch (edgeIndex) {
+ case 0: maxEdges0 = value; break;
+ case 1: maxEdges1 = value; break;
+ case 2: maxEdges2 = value; break;
+ }
+ }
+ }
+
+}
Added: trunk/jbullet/JBullet-src/com/bulletphysics/collision/broadphase/BroadphaseInterface.java
===================================================================
--- trunk/jbullet/JBullet-src/com/bulletp...
[truncated message content] |
|
From: <t_l...@us...> - 2009-02-05 22:49:58
|
Revision: 597
http://joode.svn.sourceforge.net/joode/?rev=597&view=rev
Author: t_larkworthy
Date: 2009-02-05 22:49:48 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Humble beginnings of a merge between JBullet and JOODE (and a JPCT binding as I have to reinvent all that anyway).
Probably doesn't work at the moment, which is why I am working in a subfolder.
Hopefully I can eventually get rid of all JOODE's current broken collision library and replace with JBullet. JBullet uses vector math library, so hopefully we might be able to switch to OpenMali for both the collision library and the dynamics functionality (but thats way off yet
Added Paths:
-----------
trunk/jbullet/src/
trunk/jbullet/src/net/
trunk/jbullet/src/net/java/
trunk/jbullet/src/net/java/dev/
trunk/jbullet/src/net/java/dev/joode/
trunk/jbullet/src/net/java/dev/joode/jbullet/
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionManager.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionWorldAdapter.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletGeomListener.java
trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletBodyInterface.java 2009-02-05 22:49:48 UTC (rev 597)
@@ -0,0 +1,134 @@
+package net.java.dev.joode.jbullet;
+
+import com.bulletphysics.collision.dispatch.CollisionObject;
+
+import java.util.HashMap;
+import java.util.ArrayList;
+
+import net.java.dev.joode.World;
+import net.java.dev.joode.Body;
+import net.java.dev.joode.WorldBodyListener;
+import net.java.dev.joode.WorldStepListener;
+
+/**
+ * This permits CollisionShapes to be associated with bodies
+ */
+public class JBulletBodyInterface {
+
+ //HashMap<World, Autocleaner> cleaners = new HashMap<World,Autocleaner>();
+
+ HashMap<World, Manager> worldManagers = new HashMap<World, Manager>();
+
+ HashMap<CollisionObject, JBulletJOODEAdapter> shapeAdapters
+ = new HashMap<CollisionObject, JBulletJOODEAdapter>();
+
+
+ public static final JBulletBodyInterface INSTANCE = new JBulletBodyInterface();
+ private JBulletBodyInterface(){};
+ public static JBulletBodyInterface getInstance(){return INSTANCE;}
+
+
+ public void addShape(CollisionObject shape, Body body){
+ JBulletJOODEAdapter adapter = getManager(body.getWorld()).addShapeToBody(body, shape);
+ shapeAdapters.put(shape, adapter);
+ }
+
+ public void removeShape(CollisionObject shape, Body body){
+ JBulletJOODEAdapter adapter = getManager(body.getWorld()).removeShapeFromBody(body, shape);
+ if(adapter!= null) shapeAdapters.remove(shape);
+ }
+
+
+
+ private Manager getManager(World world){
+ Manager manager = worldManagers.get(world);
+ if(manager== null){
+ manager = new Manager(world);
+ worldManagers.put(world, manager);
+ }
+ return manager;
+ }
+
+ public Body getBody(CollisionObject shape) {
+ JBulletJOODEAdapter adapter = shapeAdapters.get(shape);
+ if(adapter != null) return adapter.body;
+ return null;
+ }
+
+
+ /**
+ * This manages 2 types of functionality
+ * 1. associating native JBullet collision shaped to bodies (and updating them when the world steps)
+ *
+ * 2. adding the (body associated) collision shapes to collision worlds
+ */
+ public class Manager implements WorldStepListener, WorldBodyListener{
+ World world;
+ ArrayList<JBulletJOODEAdapter> activeAdapters
+ = new ArrayList<JBulletJOODEAdapter>();
+
+ HashMap<Body, ArrayList<JBulletJOODEAdapter>> bodyGeoms
+ = new HashMap<Body, ArrayList<JBulletJOODEAdapter>>();
+
+
+
+ public Manager(World world) {
+ this.world = world;
+ world.addStepListener(this);
+ }
+
+ public void updateTransforms(){
+ for (JBulletJOODEAdapter activeAdapter : activeAdapters) {
+ activeAdapter.updateWorldTransform();
+ }
+ }
+
+ public void notifyStep(World world, float t) {
+ updateTransforms();
+ }
+
+ public void bodyAdded(World world, Body body) {
+ for (JBulletJOODEAdapter adapter : bodyGeoms.get(body)) {
+ activeAdapters.add(adapter);
+ }
+ }
+
+ public void bodyRemoved(World world, Body body) {
+ for (JBulletJOODEAdapter adapter : bodyGeoms.get(body)) {
+ activeAdapters.remove(adapter);
+ }
+ }
+
+ public ArrayList<JBulletJOODEAdapter> getBodyGeoms(Body body){
+ ArrayList<JBulletJOODEAdapter> ret = bodyGeoms.get(body);
+ if(ret == null){
+ ret = new ArrayList<JBulletJOODEAdapter>();
+ bodyGeoms.put(body, ret);
+ }
+ return ret;
+ }
+
+ public JBulletJOODEAdapter addShapeToBody(Body body, CollisionObject shape) {
+ JBulletJOODEAdapter adapter = new JBulletJOODEAdapter(body, shape);
+ getBodyGeoms(body).add(adapter);
+ return adapter;
+ }
+
+ public JBulletJOODEAdapter removeShapeFromBody(Body body,CollisionObject shape) {
+ ArrayList<JBulletJOODEAdapter> geoms = getBodyGeoms(body);
+ for(int i=0;i<geoms.size();i++){
+ JBulletJOODEAdapter adapter = geoms.get(i);
+ if(adapter.getCollisionShape().equals(shape)){
+
+ activeAdapters.remove(adapter);
+ geoms.remove(i);
+ return adapter;
+ }
+ }
+ return null;
+ }
+ }
+
+
+
+}
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionManager.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionManager.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionManager.java 2009-02-05 22:49:48 UTC (rev 597)
@@ -0,0 +1,252 @@
+package net.java.dev.joode.jbullet;
+
+import net.java.dev.joode.force.WorldForce;
+import net.java.dev.joode.collision.SurfaceParameters;
+import net.java.dev.joode.collision.Contact;
+import net.java.dev.joode.collision.CollisionListener;
+import net.java.dev.joode.collision.collider.Colliders;
+import net.java.dev.joode.joint.JointGroupID;
+import net.java.dev.joode.joint.JointContact;
+import net.java.dev.joode.joint.Joint;
+import net.java.dev.joode.util.JOODELog;
+import net.java.dev.joode.util.Vector3;
+import net.java.dev.joode.geom.Geom;
+import net.java.dev.joode.World;
+import net.java.dev.joode.Body;
+import net.java.dev.joode.SimState;
+import net.java.dev.joode.ClonedReferences;
+
+import java.util.ArrayList;
+
+import com.bulletphysics.collision.dispatch.CollisionWorld;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.collision.dispatch.NearCallback;
+import com.bulletphysics.collision.dispatch.CollisionDispatcher;
+import com.bulletphysics.collision.narrowphase.ManifoldPoint;
+import com.bulletphysics.collision.broadphase.BroadphasePair;
+import com.bulletphysics.collision.broadphase.DispatcherInfo;
+import com.bulletphysics.ContactAddedCallback;
+import com.bulletphysics.ContactProcessedCallback;
+import com.bulletphysics.BulletGlobals;
+
+/**
+ * A collision manager for adapting JBullets awsome collision engine.
+ * Instntiate the CollisionManager with a setup world and CollisionWorld
+ * Do not use Body.add(Geom) because that's ODE's standard collision functionality
+ *
+ * This collision manager temporarily overwrites BulletCglobals.ContactProcessedCallback's
+ * value during operation.
+ * @author Tom Larkworthy
+ */
+public class JBulletCollisionManager extends WorldForce {
+
+
+ private World world;
+ private CollisionWorld space;
+
+ private SurfaceParameters params;
+
+ private int numContacts = 0;
+
+ private Contact[] contactBuffer;
+
+ private JointGroupID contactGroup = new JointGroupID();
+
+ private JointContact[] jointContacts;
+
+
+ private boolean ignoreStaticContacts;
+ private final int MAX_CONTACTS;
+
+ private final ArrayList<CollisionListener> listeners = new ArrayList<CollisionListener>();
+
+ CollisionCallback callback;
+ /**
+ * Creates and setups a collision manager for JBullet collision functionality.
+ *
+ */
+ public JBulletCollisionManager(World world, CollisionWorld space, SurfaceParameters defaultSurfaceParameters, boolean ignoreStaticContacts, int MAX_CONTACTS) {
+ super(world);
+
+ this.params = defaultSurfaceParameters;
+ callback = new CollisionCallback();
+ this.MAX_CONTACTS = MAX_CONTACTS;
+ this.ignoreStaticContacts = ignoreStaticContacts;
+
+ contactBuffer = new Contact[MAX_CONTACTS];
+ jointContacts = new JointContact[MAX_CONTACTS];
+ for (int i = 0; i < MAX_CONTACTS; i++) {
+ this.contactBuffer[i] = new Contact(defaultSurfaceParameters, null);
+ this.jointContacts[i] = new JointContact(world, null);
+ }
+
+ setup(world, space);
+ }
+
+ /**
+ * Changes the world and space this CollisionManager is listening to.
+ *
+ * @param world
+ * @param space
+ */
+ public void setup(World world, CollisionWorld space) {
+ if (this.world != null) world.removeForce(this);
+ this.world = world;
+ this.space = space;
+
+ world.addForce(this);
+ }
+
+ private void reset() {
+ this.numContacts = 0;
+ //not really, but sounds bad no?
+ this.contactGroup.clear();
+ this.world.removeJointContacts();
+
+ //reset all vars and surface parameters
+ for (int i = 0; i < MAX_CONTACTS; i++) {
+ this.contactBuffer[i].init();
+ this.contactBuffer[i].setSurfaceParameters(this.params);
+ }
+ }
+
+ private JointContact getFreeContact() {
+ for (int i = 0; i < MAX_CONTACTS; i++) {
+ if (!this.jointContacts[i].getFlag(Joint.FLAG_JOINT_INGROUP)) {
+ return this.jointContacts[i];
+ }
+ }
+
+ return null;
+ }
+
+
+ private void applyContacts() {
+ for (int i = 0; i < numContacts; i++) {
+ final Contact contact = contactBuffer[i];
+ final Geom geom1 = contact.getGeom1();
+ final Geom geom2 = contact.getGeom2();
+ final Body body1 = geom1.getBody();
+ final Body body2 = geom2.getBody();
+
+ JointContact cj = getFreeContact();
+ assert cj != null;
+ cj.setWorld(this.world);
+ cj.setContact(contact);
+
+ if (!notifyCollision(cj))
+ continue;
+
+ this.world.addJoint(cj);
+ //JOODELog.debug("cj = ", cj);
+ this.contactGroup.add(cj);
+ //JOODELog.debug(contactBuffer[i]);
+ if ((body1 != null) || (body2 != null)) {
+ //correct for deep collisions (if you so choose)
+ /*
+ norm.set(cj.contact.normal);
+ norm.scale(cj.contact.depth);
+
+ cj.contact.g1.pos.add(norm.m[0], norm.m[1], norm.m[2]);
+ */
+
+ cj.attach(body1, body2);
+ }
+
+ }
+ }
+
+ public int getContactCount() {
+ return numContacts;
+ }
+
+ public Contact getContact(int i) {
+ return contactBuffer[i];
+ }
+
+ private void step() {
+ for (int j = 0; j < listeners.size(); j++) {
+ listeners.get(j).reset();
+ }
+ this.reset();
+
+ //we use the contact proccess callback to get notified of contacts,
+ //so we will store the old value, and assign out callback before
+ //starting the collision detection proccess
+ //we then restore the old value of the callback
+ ContactProcessedCallback prev = BulletGlobals.getContactProcessedCallback();
+ BulletGlobals.setContactProcessedCallback(callback);
+ space.performDiscreteCollisionDetection();
+ BulletGlobals.setContactProcessedCallback(prev);
+ applyContacts();
+ }
+
+ private boolean notifyCollision(JointContact cj) {
+ for (int j = 0; j < listeners.size(); j++) {
+ if (!listeners.get(j).allowCollision(cj)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void prepare(float t) {
+ step();
+ }
+
+ /**
+ * no forces are actually applied. This force just recalculates the collisions for a world.
+ * It is upto the constraint solver to work out how they affect the world.
+ *
+ * @param body
+ * @param t
+ * @param faccPassback
+ * @param taccPassback
+ */
+ @Override
+ public void applyForce(Body body, float t, Vector3 faccPassback, Vector3 taccPassback) {
+
+ }
+
+ /**
+ * Adds a collision listener. The collision listener has the power of veto, and can alter the
+ * contact parameters before the contact is added to the world.
+ *
+ * @param l
+ */
+ public void addCollisionListener(CollisionListener l) {
+ listeners.add(l);
+ }
+
+ /**
+ * Removes a collision listener
+ *
+ * @param l
+ */
+ public void removeCollisionListener(CollisionListener l) {
+ listeners.remove(l);
+ }
+
+ public SimState cloneState(ClonedReferences util) {
+ return null;
+ }
+
+ public void setDefaultCollisionParameters(SurfaceParameters params) {
+ this.params = params;
+ for (int i = 0; i < MAX_CONTACTS; i++) {
+ this.contactBuffer[i].setSurfaceParameters(params);
+ }
+ }
+
+
+ public class CollisionCallback implements ContactProcessedCallback {
+
+ public boolean contactProcessed(ManifoldPoint cp, Object body0, Object body1) {
+
+ System.out.println("callback");
+
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+ }
+}
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionWorldAdapter.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionWorldAdapter.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletCollisionWorldAdapter.java 2009-02-05 22:49:48 UTC (rev 597)
@@ -0,0 +1,75 @@
+package net.java.dev.joode.jbullet;
+
+import com.bulletphysics.collision.dispatch.CollisionWorld;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.collision.shapes.CollisionShape;
+
+import java.util.HashMap;
+import java.util.WeakHashMap;
+import java.util.ArrayList;
+
+/**
+ */
+public class JBulletCollisionWorldAdapter {
+
+ static WeakHashMap<CollisionWorld, JBulletCollisionWorldAdapter> adapters = new WeakHashMap<CollisionWorld, JBulletCollisionWorldAdapter>();
+
+
+ ArrayList<JBulletGeomListener> listeners = new ArrayList<JBulletGeomListener>();
+
+ CollisionWorld world;
+
+ public static JBulletCollisionWorldAdapter getAdapter(CollisionWorld world){
+ JBulletCollisionWorldAdapter adapter = adapters.get(world);
+
+ if(adapter == null){
+ adapter = new JBulletCollisionWorldAdapter(world);
+ adapters.put(world, adapter);
+ }
+ return adapter;
+ }
+
+ private JBulletCollisionWorldAdapter(CollisionWorld world) {
+ this.world = world;
+ }
+
+
+ /**
+ * @param shape
+ */
+ public void addShape(CollisionObject shape){
+ world.addCollisionObject(shape);
+
+ notifyGeomAdded(shape, world);
+ }
+
+ /**
+ * @param shape
+ */
+ public void removeShape(CollisionObject shape){
+ world.removeCollisionObject(shape);
+
+ notifyGeomRemoved(shape, world);
+ }
+
+
+
+ private void notifyGeomAdded(CollisionObject geom, CollisionWorld space) {
+ for (JBulletGeomListener listener : listeners) {
+ listener.geomAdded(geom, space);
+ }
+ }
+ private void notifyGeomRemoved(CollisionObject geom, CollisionWorld space) {
+ for (JBulletGeomListener listener : listeners) {
+ listener.geomRemoved(geom, space);
+ }
+ }
+ public void addGeomListener(JBulletGeomListener l){
+ listeners.add(l);
+ }
+ public void removeGeomListener(JBulletGeomListener l){
+ listeners.remove(l);
+ }
+
+
+}
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletGeomListener.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletGeomListener.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletGeomListener.java 2009-02-05 22:49:48 UTC (rev 597)
@@ -0,0 +1,14 @@
+package net.java.dev.joode.jbullet;
+
+import com.bulletphysics.collision.dispatch.CollisionWorld;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.collision.shapes.CollisionShape;
+import net.java.dev.joode.Body;
+
+/**
+ */
+public interface JBulletGeomListener {
+
+ void geomAdded(CollisionObject geom, CollisionWorld space);
+ void geomRemoved(CollisionObject geom, CollisionWorld space);
+}
Added: trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java
===================================================================
--- trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java (rev 0)
+++ trunk/jbullet/src/net/java/dev/joode/jbullet/JBulletJOODEAdapter.java 2009-02-05 22:49:48 UTC (rev 597)
@@ -0,0 +1,30 @@
+package net.java.dev.joode.jbullet;
+
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.collision.shapes.CollisionShape;
+import net.java.dev.joode.geom.Geom;
+import net.java.dev.joode.util.Vector3;
+import net.java.dev.joode.util.Matrix3;
+import net.java.dev.joode.Body;
+
+/**
+ */
+public class JBulletJOODEAdapter extends CollisionObject {
+ Body body;
+ CollisionObject shape;
+
+
+ public JBulletJOODEAdapter(Body body, CollisionObject shape) {
+ super();
+ this.body = body;
+ this.shape = shape;
+ }
+
+ public void updateWorldTransform(){
+ Vector3 pos = body.getPosition();
+ Matrix3 rot = body.getRotation();
+ worldTransform.origin.set(pos.getX(), pos.getY(),pos.getZ());
+ worldTransform.basis.set(rot.m);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2009-02-01 17:56:53
|
Revision: 596
http://joode.svn.sourceforge.net/joode/?rev=596&view=rev
Author: t_larkworthy
Date: 2009-02-01 17:56:48 +0000 (Sun, 01 Feb 2009)
Log Message:
-----------
Humble beginnings of a merge between JBullet and JOODE (and a JPCT binding as I have to reinvent all that anyway).
Probably doesn't work at the moment, which is why I am working in a subfolder.
Hopefully I can eventually get rid of all JOODE's current broken collision library and replace with JBullet. JBullet uses vector math library, so hopefully we might be able to switch to OpenMali for both the collision library and the dynamics functionality (but thats way off yet
Added Paths:
-----------
trunk/jbullet/
trunk/jbullet/JPCTbinding/
trunk/jbullet/JPCTbinding/net/
trunk/jbullet/JPCTbinding/net/java/
trunk/jbullet/JPCTbinding/net/java/dev/
trunk/jbullet/JPCTbinding/net/java/dev/joode/
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java
trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java
trunk/jbullet/build.xml
trunk/jbullet/lib/
trunk/jbullet/lib/JPCT/
trunk/jbullet/test/
trunk/jbullet/test/net/
trunk/jbullet/test/net/java/
trunk/jbullet/test/net/java/dev/
trunk/jbullet/test/net/java/dev/joode/
trunk/jbullet/test/net/java/dev/joode/jbullet/
trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java
Added: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java (rev 0)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTBinding.java 2009-02-01 17:56:48 UTC (rev 596)
@@ -0,0 +1,57 @@
+package net.java.dev.joode.jpct;
+
+import net.java.dev.joode.Body;
+import com.bulletphysics.collision.shapes.CollisionShape;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+import com.bulletphysics.linearmath.Transform;
+import com.threed.jpct.Object3D;
+import com.threed.jpct.World;
+import com.threed.jpct.Matrix;
+
+/**
+ */
+public class JPCTBinding {
+ public static final Transform TMP = new Transform();
+ public static final Matrix TMP_ROT = new Matrix();
+
+ CollisionObject collisionObject;
+ Object3D gfxShape;
+ World gfxWorld;
+
+ int objectIndex;
+
+ public JPCTBinding(World gfxWorld, CollisionObject collisionObject, Object3D gfxShape) {
+ this.gfxWorld = gfxWorld;
+ this.collisionObject = collisionObject;
+ this.gfxShape = gfxShape;
+
+ objectIndex = gfxWorld.addObject(gfxShape);
+
+ update();
+ }
+
+ public void update() {
+ collisionObject.getWorldTransform(TMP);
+
+ gfxShape.translate(TMP.origin.x, TMP.origin.y, TMP.origin.z);
+
+ convert(TMP, TMP_ROT);
+
+ gfxShape.setRotationMatrix(TMP_ROT);
+
+ }
+
+ private void convert(Transform tmp, Matrix tmpRot) {
+ for(int i=0;i<3;i++){
+ for(int j=0;j<3;j++){
+ tmpRot.set(i,j,tmp.basis.getElement(i,j));
+ }
+ }
+ }
+
+ public void destroy() {
+ gfxWorld.removeObject(objectIndex);
+ }
+
+
+}
Added: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java (rev 0)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTConverter.java 2009-02-01 17:56:48 UTC (rev 596)
@@ -0,0 +1,30 @@
+package net.java.dev.joode.jpct;
+
+import com.threed.jpct.Object3D;
+import com.threed.jpct.Primitives;
+import com.bulletphysics.collision.shapes.CollisionShape;
+import com.bulletphysics.collision.shapes.SphereShape;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+
+/**
+ */
+public class JPCTConverter {
+
+ public static final int SPHERE_SLICES = 5;
+ public static final int SPHERE_STACKS = 5;
+
+ static final Object3D sphere = Primitives.getSphere(20, 1) ;
+
+
+
+ public Object3D convert(CollisionObject shape) {
+ CollisionShape rootShape = shape.getRootCollisionShape();
+
+ if(rootShape instanceof SphereShape){
+ return new Object3D(sphere);
+ }
+
+
+ throw new UnsupportedOperationException();
+ }
+}
Added: trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java
===================================================================
--- trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java (rev 0)
+++ trunk/jbullet/JPCTbinding/net/java/dev/joode/jpct/JPCTManager.java 2009-02-01 17:56:48 UTC (rev 596)
@@ -0,0 +1,137 @@
+package net.java.dev.joode.jpct;
+
+import net.java.dev.joode.World;
+import net.java.dev.joode.WorldStepListener;
+import net.java.dev.joode.jbullet.JBulletGeomListener;
+import net.java.dev.joode.jbullet.JBulletBodyInterface;
+import net.java.dev.joode.jbullet.JBulletCollisionWorldAdapter;
+
+import java.util.HashMap;
+
+import com.bulletphysics.collision.shapes.CollisionShape;
+import com.bulletphysics.collision.dispatch.CollisionWorld;
+import com.bulletphysics.collision.dispatch.CollisionObject;
+
+public class JPCTManager {
+ com.threed.jpct.World gfxWorld;
+ CollisionWorld space;
+ World world;
+
+ JPCTConverter converter = new JPCTConverter();
+
+ /**
+ * bindings for geometry that changes every world step
+ */
+ public HashMap<CollisionObject, JPCTBinding> dynamicBindings = new HashMap<CollisionObject, JPCTBinding>();
+ /**
+ * bindings for geometry that does not change
+ */
+ HashMap<CollisionObject, JPCTBinding> staticBindings = new HashMap<CollisionObject, JPCTBinding>();
+
+ final Listener listener = new Listener();
+
+ /**
+ *
+ * @param world the world which contains the bodies
+ * @param space the space which new geometries will have representations generated for
+ * @param bg the managed branch group that graphical representations will be added to
+ */
+ public JPCTManager(World world, CollisionWorld space, com.threed.jpct.World bg) {
+
+ reinitalize(bg, world,space);
+ }
+
+ /**
+ * reinitializes the graphical system. All previous bindings are removed, and the system is setup
+ * from scratch with a new world
+ * @param gfxSpace
+ * @param space
+ * @param world
+ */
+ public void reinitalize(com.threed.jpct.World gfxSpace, World world, CollisionWorld space) {
+ synchronized(dynamicBindings){
+ if(this.world != null) this.world.removeStepListener(listener);
+ if(this.space != null) JBulletCollisionWorldAdapter.getAdapter(this.space).removeGeomListener(listener);
+
+ //detach all the previous bindings from their scenegraph
+ for (JPCTBinding binding : dynamicBindings.values()) {
+ binding.destroy();
+ }
+ for (JPCTBinding binding : staticBindings.values()) {
+ binding.destroy();
+ }
+ staticBindings.clear();
+ dynamicBindings.clear();
+
+ //assign our new value objects
+ this.gfxWorld = gfxSpace;
+ this.space = space;
+ this.world = world;
+
+
+ listener.notifyStep(world, 0); //tell the listener to update the dynamic bindings
+
+ //add the listener so the scengraph can be dynamically updated
+ //space.addGeomListener(listener); NOT NEEDED listener.addAllGeoms automatically adds a listener to the space to catch sub adds
+ world.addStepListener(listener);
+ JBulletCollisionWorldAdapter.getAdapter(space).addGeomListener(listener);
+ }
+ }
+
+
+
+
+ public com.threed.jpct.World getScene() {
+ return gfxWorld;
+ }
+
+ public CollisionWorld getSpace() {
+ return space;
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+
+ /**
+ * private class that listens to the relevant objects for events. Made private to avoid publically declaring
+ * methods that shold not be used by the user in the enclosing class.
+ */
+ private class Listener implements JBulletGeomListener, WorldStepListener {
+ //CollisionWorld space;
+
+ /**
+ * updates all bindding values
+ * @param w
+ * @param t
+ */
+ public void notifyStep(World w, float t) {
+ synchronized(dynamicBindings){
+ for (JPCTBinding binding : dynamicBindings.values()) {
+ binding.update();
+ }
+ }
+ }
+
+ public void geomAdded(CollisionObject geom, CollisionWorld space) {
+ JPCTBinding binding = new JPCTBinding(gfxWorld, geom, converter.convert(geom));
+
+ if(JBulletBodyInterface.INSTANCE.getBody(geom) != null){
+ dynamicBindings.put(geom, binding);
+ }else{
+ staticBindings.put(geom,binding);
+ }
+
+ }
+
+ public void geomRemoved(CollisionObject geom, CollisionWorld space) {
+ JPCTBinding binding = dynamicBindings.remove(geom);
+ if(binding!= null) binding.destroy();
+ else{
+ binding = staticBindings.remove(geom);
+ if(binding!=null) binding.destroy();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/jbullet/build.xml
===================================================================
--- trunk/jbullet/build.xml (rev 0)
+++ trunk/jbullet/build.xml 2009-02-01 17:56:48 UTC (rev 596)
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="JOODE-JBullet" default="default" basedir=".">
+ <description >
+ Manages the intergration of JOODE and JBullet,
+ JBullet uses JStackAlloc, which means after compilation the class
+ files need to be instrumented, *SO* you need to make sure the
+ ANT environment has a references to jstackalloc.jar in the lib
+ directory
+ </description>
+ <property name="src" location="src"/>
+ <property name="test-src" location="test"/>
+ <property name="jbullet-src" location="JBullet-src"/>
+ <property name="joode-src" location="../src"/>
+ <property name="JPCTbinding-src" location="JPCTbinding"/>
+
+ <property name="build" location="classes"/>
+ <property name="dist" location="dist"/>
+
+ <path id="lib">
+ <fileset dir="lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ <fileset dir="../lib">
+ <include name="**/*.jar"/>
+ </fileset>
+ </path>
+
+
+ <target name="instrument-classes" depends="init, compile">
+ <taskdef name="instrument-stack"
+ classname="cz.advel.stack.instrument.InstrumentationTask"
+ classpathref="lib" classpath="${build}">
+ </taskdef>
+
+ <instrument-stack dest="${build}" packageName="com.bulletphysics" isolated="true">
+ <fileset dir="${build}" includes="**/*.class"/>
+ </instrument-stack>
+ </target>
+
+ <target name="init">
+ <mkdir dir="${build}"/>
+ </target>
+ <target name="clean">
+ <delete dir="${build}"/>
+ </target>
+
+ <target name="compile" depends="init">
+ <javac classpathref="lib" destdir="${build}">
+ <src >
+ <dirset dir="${src}"/>
+ <dirset dir="${jbullet-src}"/>
+ <dirset dir="${joode-src}"/>
+ <dirset dir="${test-src}"/>
+ <dirset dir="${JPCTbinding-src}"/>
+ </src>
+ </javac>
+ </target>
+
+
+
+ <target name="run-JBulletTestingWorld" depends="instrument-classes">
+ <java fork="true"
+ classpathref="lib"
+ classpath="${build}"
+ classname="net.java.dev.joode.jbullet.JBulletTestingWorld"/>
+ </target>
+</project>
\ No newline at end of file
Added: trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java
===================================================================
--- trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java (rev 0)
+++ trunk/jbullet/test/net/java/dev/joode/jbullet/JBulletTestingWorld.java 2009-02-01 17:56:48 UTC (rev 596)
@@ -0,0 +1,175 @@
+package net.java.dev.joode.jbullet;
+
+import net.java.dev.joode.World;
+import net.java.dev.joode.Body;
+import net.java.dev.joode.Mass;
+import net.java.dev.joode.jpct.JPCTManager;
+import net.java.dev.joode.force.NewtonGravity;
+import net.java.dev.joode.util.Vector3;
+import net.java.dev.joode.util.Matrix3;
+import net.java.dev.joode.collision.SurfaceParameters;
+
+import java.util.ArrayList;
+import java.awt.*;
+
+import com.bulletphysics.collision.dispatch.*;
+import com.bulletphysics.collision.broadphase.SimpleBroadphase;
+import com.bulletphysics.collision.shapes.SphereShape;
+import com.threed.jpct.*;
+
+import javax.swing.*;
+
+/**
+ */
+public class JBulletTestingWorld extends JPanel {
+ public static final int MAX_CONTACTS = 10000;
+
+ //private final net.java.dev.joode.test.FPSStatistics fps;
+
+ private World world;
+
+ CollisionConfiguration collisionConfig = new DefaultCollisionConfiguration();
+ private CollisionWorld space = new CollisionWorld(
+ new CollisionDispatcher(collisionConfig),
+ new SimpleBroadphase(),
+ collisionConfig);
+
+ JPCTManager gfxManager;
+ com.threed.jpct.World gfxWorld;
+
+ private JBulletCollisionManager collMgr = null;
+
+ private SurfaceParameters surfaceParams = null;
+
+ FrameBuffer renderBuffer;
+
+ Camera camera;
+
+
+ private ArrayList<Body> movingObjects = new ArrayList<Body>();
+ private ArrayList<Vector3> originalPositions = new ArrayList<Vector3>();
+ private ArrayList<Vector3> originalVelocities = new ArrayList<Vector3>();
+ private ArrayList<Matrix3> originalRotations = new ArrayList<Matrix3>();
+
+ protected void addMovingObject(Body body) {
+ movingObjects.add(body);
+ originalPositions.add(new Vector3(body.getPosition()));
+ originalVelocities.add(new Vector3(body.getLinearVel()));
+ originalRotations.add(new Matrix3(body.getRotation()));
+ }
+
+ protected void resetMovingObjects() {
+ for (int i = 0; i < movingObjects.size(); i++) {
+ final Body body = movingObjects.get(i);
+
+ body.setPosition(originalPositions.get(i));
+ body.setLinearVel(originalVelocities.get(i));
+ body.setAngularVel(0f, 0f, 0f);
+ body.setRotation(originalRotations.get(i));
+ }
+ }
+
+ /*
+ private void createInfoHUD(Sized2iRO canvasSize) {
+ HUD hud = new HUD(canvasSize, 800f);
+
+ Label infoLabel = new Label(hud.getResX() - 20f, 40f,
+ "Press SPACE to reset the scene.",
+ new Font("Monospace", Font.PLAIN, 20),
+ Colorf.WHITE,
+ TextAlignment.TOP_LEFT
+ );
+ //hud.addWidget(infoLabel, 10f, hud.getResY() - infoLabel.getHeight());
+ hud.addWidget(infoLabel, 10f, 530f);
+
+ addHUD(hud);
+ } */
+
+ public JBulletTestingWorld(boolean gravity, boolean collisions) {
+
+ this.world = new World();
+
+ if (gravity) {
+ new NewtonGravity(world, new Vector3(0f, -9.81f, 0f));
+ }
+
+ if (collisions) {
+ this.surfaceParams = new SurfaceParameters(10f);
+ this.collMgr = new JBulletCollisionManager(world, space, surfaceParams, false, MAX_CONTACTS);
+ }
+
+ gfxWorld = new com.threed.jpct.World();
+
+ gfxManager = new JPCTManager(world, space, gfxWorld);
+
+ Config.maxPolysVisible = 8192;
+
+ Config.linearDiv = 1100;
+ Config.lightDiscardDistance = 1450;
+
+ gfxWorld.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);
+
+ Config.isIndoor = false;
+
+ Config.farPlane = 3500;
+ Config.collideOffset = 500;
+
+ com.threed.jpct.World.setDefaultThread(Thread.currentThread());
+
+ renderBuffer = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_NORMAL);
+ renderBuffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
+ renderBuffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
+ renderBuffer.optimizeBufferAccess();
+
+ gfxWorld.setAmbientLight(50, 50, 50);
+
+ gfxWorld.addLight(new SimpleVector(500, 100, 200), 30, 30, 20);
+
+ camera = gfxWorld.getCamera();
+ camera.setPosition(new SimpleVector(0, 0, -20));
+ camera.lookAt(new SimpleVector(0, 0, 0));
+
+ }
+
+ public void render(){
+ gfxWorld.setCameraTo(camera);
+ gfxWorld.renderScene(renderBuffer);
+ }
+
+
+ public void paint(Graphics g) {
+ renderBuffer.display(g);
+ }
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame();
+
+ JBulletTestingWorld testingWorld = new JBulletTestingWorld(true, true);
+
+ frame.add(testingWorld);
+
+ frame.setVisible(true);
+
+ Body b1= new Body(testingWorld.getDynamicsWorld(), Mass.createSphere(1,1));
+
+ CollisionObject geom = new CollisionObject();
+ geom.setCollisionShape(new SphereShape(1));
+ JBulletBodyInterface.INSTANCE.addShape(geom,b1);
+ JBulletCollisionWorldAdapter.getAdapter(
+ testingWorld.getCollisionWorld()
+ ).addShape(geom);
+
+
+ testingWorld.addMovingObject(b1);
+
+ testingWorld.render();
+ }
+
+ private World getDynamicsWorld() {
+ return world;
+ }
+
+ private CollisionWorld getCollisionWorld() {
+ return space;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-12-11 15:29:48
|
Revision: 595
http://joode.svn.sourceforge.net/joode/?rev=595&view=rev
Author: t_larkworthy
Date: 2008-12-11 15:29:43 +0000 (Thu, 11 Dec 2008)
Log Message:
-----------
Bug fix:-
getGeoms was returning nothing. Works now.
PS last HashSpace fix only fixed one tiny problem with that class
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/space/octtree/OctTreeNode.java
Modified: trunk/src/java/net/java/dev/joode/space/octtree/OctTreeNode.java
===================================================================
--- trunk/src/java/net/java/dev/joode/space/octtree/OctTreeNode.java 2008-12-11 15:14:55 UTC (rev 594)
+++ trunk/src/java/net/java/dev/joode/space/octtree/OctTreeNode.java 2008-12-11 15:29:43 UTC (rev 595)
@@ -70,7 +70,7 @@
}
public void getGeoms(Set<Geom> geoms){
- geoms.addAll(geoms);
+ geoms.addAll(this.geoms);
if(left!=null)
left.getGeoms(geoms);
if(right!=null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-12-11 15:14:59
|
Revision: 594
http://joode.svn.sourceforge.net/joode/?rev=594&view=rev
Author: t_larkworthy
Date: 2008-12-11 15:14:55 +0000 (Thu, 11 Dec 2008)
Log Message:
-----------
Bug fix:-
-POSATIVE_INFINITY change to +NEGATIVE_IFINITY
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/space/HashSpace.java
Modified: trunk/src/java/net/java/dev/joode/space/HashSpace.java
===================================================================
--- trunk/src/java/net/java/dev/joode/space/HashSpace.java 2008-08-14 20:12:49 UTC (rev 593)
+++ trunk/src/java/net/java/dev/joode/space/HashSpace.java 2008-12-11 15:14:55 UTC (rev 594)
@@ -73,9 +73,9 @@
// size/2 < q <= size
// where q is the maximum AABB dimension.
private static int findLevel(float[] bounds) {
- if (bounds[0] <= -Float.POSITIVE_INFINITY || bounds[1] >= Float.POSITIVE_INFINITY ||
- bounds[2] <= -Float.POSITIVE_INFINITY || bounds[3] >= Float.POSITIVE_INFINITY ||
- bounds[4] <= -Float.POSITIVE_INFINITY || bounds[5] >= Float.POSITIVE_INFINITY) {
+ if (bounds[0] <= Float.NEGATIVE_INFINITY || bounds[1] >= Float.POSITIVE_INFINITY ||
+ bounds[2] <= Float.NEGATIVE_INFINITY || bounds[3] >= Float.POSITIVE_INFINITY ||
+ bounds[4] <= Float.NEGATIVE_INFINITY || bounds[5] >= Float.POSITIVE_INFINITY) {
return Integer.MAX_VALUE;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qu...@us...> - 2008-08-14 20:12:54
|
Revision: 593
http://joode.svn.sourceforge.net/joode/?rev=593&view=rev
Author: qudus
Date: 2008-08-14 20:12:49 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
Fixed Trimesh-Sphere collider.
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/collision/collider/TriMeshSphereCollider.java
Modified: trunk/src/java/net/java/dev/joode/collision/collider/TriMeshSphereCollider.java
===================================================================
--- trunk/src/java/net/java/dev/joode/collision/collider/TriMeshSphereCollider.java 2008-08-14 19:52:48 UTC (rev 592)
+++ trunk/src/java/net/java/dev/joode/collision/collider/TriMeshSphereCollider.java 2008-08-14 20:12:49 UTC (rev 593)
@@ -133,7 +133,7 @@
//contact.depth = dis is set above
//Find Face plane point
contact.setNormal(normal);
- //contact.normal.scale(-1);
+ contact.getNormal().scale(-1);
//Find point projection on plane
contact.setPosition(normal);
//contact.pos.scale(-contact.depth);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qu...@us...> - 2008-08-14 19:52:56
|
Revision: 592
http://joode.svn.sourceforge.net/joode/?rev=592&view=rev
Author: qudus
Date: 2008-08-14 19:52:48 +0000 (Thu, 14 Aug 2008)
Log Message:
-----------
New Xith jars.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/math/openmali.jar
trunk/lib/xith3d.jar
trunk/src/java/net/java/dev/joode/collision/collider/RayBoxCollider.java
trunk/src/java/net/java/dev/joode/geom/Circle.java
trunk/src/test/net/java/dev/joode/test/TestingWorld.java
trunk/src/test/net/java/dev/joode/test/collision/TriMeshSphereCollisionTest2.java
trunk/src/test/net/java/dev/joode/test/xith/XithConverter.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/CollisionDropTest.java
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-07-06 11:33:52 UTC (rev 591)
+++ trunk/lib/xith3d.jar 2008-08-14 19:52:48 UTC (rev 592)
@@ -1,373 +1,464 @@
-PK |
|
From: <qu...@us...> - 2008-07-06 11:33:55
|
Revision: 591
http://joode.svn.sourceforge.net/joode/?rev=591&view=rev
Author: qudus
Date: 2008-07-06 04:33:52 -0700 (Sun, 06 Jul 2008)
Log Message:
-----------
Added the necessary methods to AMotorTest, that are needed to run the test through the testlauncher.
Modified Paths:
--------------
trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java
trunk/src/test/net/java/dev/joode/test/xith/XithManager.java
Modified: trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java 2008-06-30 15:36:52 UTC (rev 590)
+++ trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java 2008-07-06 11:33:52 UTC (rev 591)
@@ -77,9 +77,13 @@
}
-
-
- public static void main(String[] args) {
- new AMotorVelocityTest(null).begin();
+
+ public static void runTest(CanvasConstructionInfo canvasInfo) {
+ AMotorVelocityTest test = new AMotorVelocityTest(canvasInfo);
+ test.begin();
}
+
+ public static void main(String[] args) throws Exception {
+ runTest(null);
+ }
}
Modified: trunk/src/test/net/java/dev/joode/test/xith/XithManager.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/xith/XithManager.java 2008-06-30 15:36:52 UTC (rev 590)
+++ trunk/src/test/net/java/dev/joode/test/xith/XithManager.java 2008-07-06 11:33:52 UTC (rev 591)
@@ -3,7 +3,6 @@
import net.java.dev.joode.space.Space;
import net.java.dev.joode.space.GeomListener;
import net.java.dev.joode.geom.Geom;
-import net.java.dev.joode.util.PosRot;
import net.java.dev.joode.World;
import net.java.dev.joode.WorldStepListener;
@@ -15,33 +14,37 @@
import org.xith3d.scenegraph.TransformGroup;
/**
- * A simple scengraph manager. This class updates a branch group automatically in response to new
- * geometry object being added to a world, and to the world being stepped.
- *
- * A replacement of XithBindingManager. On setup an object of this class is provided with a branch group, a world and a space.
- * The object then listens for construction and destruction events of geoms in the provided space, and creates and destroys
- * relevant Xith representations on the BranchGroup.
- * The class also listens for world step events, updating the relevant XithGeometry each iteration
- *
+ * A simple scengraph manager. This class updates a branch group automatically
+ * in response to new geometry object being added to a world, and to the world
+ * being stepped.
+ *
+ * A replacement of XithBindingManager. On setup an object of this class is
+ * provided with a branch group, a world and a space.
+ * The object then listens for construction and destruction events of geoms in
+ * the provided space, and creates and destroys relevant Xith representations on
+ * the BranchGroup.
+ * The class also listens for world step events, updating the relevant
+ * XithGeometry each iteration.
+ *
* @author Tom Larkworthy
*/
public class XithManager {
- BranchGroup bg;
- Space space;
- World world;
+ private BranchGroup bg;
+ private Space space;
+ private World world;
- XithConverter converter = new XithConverter();
+ private XithConverter converter = new XithConverter();
/**
* bindings for geometry that changes every world step
*/
- HashMap<Geom, XithBinding> dynamicBindings = new HashMap<Geom, XithBinding>();
+ private final HashMap<Geom, XithBinding> dynamicBindings = new HashMap<Geom, XithBinding>();
/**
* bindings for geometry that does not change
*/
- HashMap<Geom, TransformGroup> staticBindings = new HashMap<Geom, TransformGroup>();
+ private final HashMap<Geom, TransformGroup> staticBindings = new HashMap<Geom, TransformGroup>();
- final Listener listener = new Listener();
+ private final Listener listener = new Listener();
/**
*
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-30 15:36:55
|
Revision: 590
http://joode.svn.sourceforge.net/joode/?rev=590&view=rev
Author: t_larkworthy
Date: 2008-06-30 08:36:52 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
Bug fix. Dynamic bindings did not tidy up afterthemselves properly when a geom was removed. If the same geom was added back to the space, a reused custom subscene would find it was still conencted to the previous (now defunct) TransformGroup. A complication to the situation was that TransformGroups sometimes get concatinated together to represent GeomTransform offsets to custom scene graph visuals. So to do a full tidy up required a bit of tagging of TransformGroups that represent GeomOffsets
Modified Paths:
--------------
trunk/src/test/net/java/dev/joode/test/xith/XithConverter.java
trunk/src/test/net/java/dev/joode/test/xith/XithManager.java
Modified: trunk/src/test/net/java/dev/joode/test/xith/XithConverter.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/xith/XithConverter.java 2008-06-18 02:05:38 UTC (rev 589)
+++ trunk/src/test/net/java/dev/joode/test/xith/XithConverter.java 2008-06-30 15:36:52 UTC (rev 590)
@@ -38,12 +38,14 @@
final Matrix4f intermediate = new Matrix4f();
+ public static final String OFFSET_GEOM = "Xith Transform Offset Geom";
+
private static float rndFloat(float min, float max) {
return min + rnd.nextFloat() * (max - min);
}
private static boolean texInit = false;
- private static Texture getTexture(String name) {
+ public static Texture getTexture(String name) {
if (!texInit) {
ResourceLocator resLoc = ResourceLocator.create("res/");
resLoc.createAndAddTSL();
@@ -135,7 +137,7 @@
if(geomAppearance.getSceneSubtree() != null){
//if a custom subtree is defined, then use that over anything else
- result.addChild(geomAppearance.getSceneSubtree());
+ result.addChild(geomAppearance.getSceneSubtree());
}else if (geom instanceof Sphere) {
Sphere sphere = (Sphere) geom;
@@ -277,6 +279,9 @@
result.addChild(geomGFX);
+ //we flag the transform group as an offset transform group
+ result.setUserData(OFFSET_GEOM, new Object());
+
}else{
System.err.println("unrecognized shape for XithConverter: " + geom.getClass().getName());
}
Modified: trunk/src/test/net/java/dev/joode/test/xith/XithManager.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/xith/XithManager.java 2008-06-18 02:05:38 UTC (rev 589)
+++ trunk/src/test/net/java/dev/joode/test/xith/XithManager.java 2008-06-30 15:36:52 UTC (rev 590)
@@ -61,36 +61,83 @@
* @param world
*/
public void reinitalize(BranchGroup bg, World world, Space space) {
- //detach all the previous bindings from their scenegraph
- for (XithBinding binding : dynamicBindings.values()) {
- binding.transform.detach();
- }
- for (TransformGroup tg : staticBindings.values()) {
- tg.detach();
- }
- staticBindings.clear();
- dynamicBindings.clear();
+ synchronized(dynamicBindings){
+ //detach all the previous bindings from their scenegraph
+ for (XithBinding binding : dynamicBindings.values()) {
+ removeBinding(binding);
- //remove the listener from the previous value objects
- if(this.space != null){
- this.space.removeGeomListener(listener);
+
+ }
+ for (TransformGroup tg : staticBindings.values()) {
+ tg.removeAllChildren();
+ tg.detach();
+ }
+ staticBindings.clear();
+ dynamicBindings.clear();
+
+ //remove the listener from the previous value objects
+ if(this.space != null){
+ this.space.removeGeomListener(listener);
+ }
+ if(this.world != null)
+ {
+ this.world.removeStepListener(listener);
+ }
+ //assign our new value objects
+ this.bg = bg;
+ this.space = space;
+ this.world = world;
+
+ listener.addAllGeoms(space); //add the new geoms
+
+ listener.notifyStep(world, 0); //tell the listener to update the dynamic bindings
+
+ //add the listener so the scengraph can be dynamically updated
+ //space.addGeomListener(listener); NOT NEEDED listener.addAllGeoms automatically adds a listener to the space to catch sub adds
+ world.addStepListener(listener);
}
- if(this.world != null)
- {
- this.world.removeStepListener(listener);
- }
- //assign our new value objects
- this.bg = bg;
- this.space = space;
- this.world = world;
+ }
- listener.addAllGeoms(space); //add the new geoms
- //add the listener so the scengraph can be dynamically updated
- //space.addGeomListener(listener); NOT NEEDED listener.addAllGeoms automatically adds a listener to the space to catch sub adds
- world.addStepListener(listener);
+
+
+ public BranchGroup getScene() {
+ return bg;
}
+ public Space getSpace() {
+ return space;
+ }
+
+ public World getWorld() {
+ return world;
+ }
+
+ private void removeBinding(XithBinding binding) {
+ //we have a problem that the binding may point to Transform group representing
+ //a GeomTransform, which in turn then is connected to a custom subtree
+ //we need to ensure that the user supplied custom subtree is neatly pruned
+ //from any parent, which in one case is a Transform group generated from
+ //a GeomTransform. In this case, pruning the children of the TransformGroup
+ //will only detach the GeomTransform to its child geomTransform representing
+ //the GeomTransform, the custom subtree will remain connected to an automatically
+ //generate Transformnode which can cause problems later.
+ //so we need to check for a flag indicating the TransformGroup represents an
+ //GeomTransform so we can prun one level deeper
+ //in this case it shoulld only have one child which should also be a TransformGroup
+ if(binding.transform.getUserData(XithConverter.OFFSET_GEOM) != null){
+ for(int i=0;i<binding.transform.numChildren(); i++) {
+ assert i==0;
+ assert binding.transform.getChild(i) instanceof TransformGroup;
+
+ ((TransformGroup)binding.transform.getChild(i)).removeAllChildren();
+ }
+ }
+
+ binding.transform.removeAllChildren();
+ binding.transform.detach();
+ }
+
/**
* private class that listens to the relevant objects for events. Made private to avoid publically declaring
* methods that shold not be used by the user in the enclosing class.
@@ -121,9 +168,12 @@
synchronized(dynamicBindings){
binding = dynamicBindings.remove(g);
}
- bg.removeChild(binding.transform);
+ removeBinding(binding);
+
+
} else {
TransformGroup view = staticBindings.remove(g);
+ view.removeAllChildren();
bg.removeChild(view);
}
}
@@ -137,6 +187,7 @@
* @param space
*/
private void addAllGeoms(Space space) {
+ System.out.println("AddAllGeoms");
List<Geom> geoms = new ArrayList<Geom>();
space.getGeoms(geoms);
for (int i = 0; i < geoms.size(); i++) {
@@ -157,6 +208,8 @@
* @param space
*/
private void removeAllGeoms(Space space) {
+ System.out.println("removeAllGeoms");
+
space.removeGeomListener(this);
List<Geom> geoms = new ArrayList<Geom>();
space.getGeoms(geoms);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-18 02:05:42
|
Revision: 589
http://joode.svn.sourceforge.net/joode/?rev=589&view=rev
Author: t_larkworthy
Date: 2008-06-17 19:05:38 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
Bug fixes and tidies to get previous test working
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
Modified: trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
===================================================================
--- trunk/src/java/net/java/dev/joode/joint/JointAMotor.java 2008-06-18 02:04:15 UTC (rev 588)
+++ trunk/src/java/net/java/dev/joode/joint/JointAMotor.java 2008-06-18 02:05:38 UTC (rev 589)
@@ -17,10 +17,10 @@
int [] rel = new int[3]; // what the axes are relative to (global,b1,b2)
Vector3 [] axis = new Vector3[3]; // three axes
JointLimitMotor [] limot = new JointLimitMotor[3]; // limit+motor info for axes
- Vector3 angle; // user-supplied angles for axes
+ Vector3 angle = new Vector3(); // user-supplied angles for axes
// these vectors are used for calculating euler angles
- Vector3 reference1; // original axis[2], relative to body 1
- Vector3 reference2; // original axis[0], relative to body 2
+ Vector3 reference1 = new Vector3(); // original axis[2], relative to body 1
+ Vector3 reference2 = new Vector3(); // original axis[0], relative to body 2
public static final int MODE_USER=1;
@@ -31,6 +31,11 @@
int i;
JointAMotor j = this;
+ for(i=0;i<3;i++){
+ axis[i] = new Vector3();
+
+ }
+
j.num = 0;
j.mode = MODE_USER;
for (i=0; i<3; i++) {
@@ -170,6 +175,7 @@
// compute the axes and angles, if in euler mode
if (this.mode == MODE_EULER) {
Vector3 []ax = new Vector3[3];
+ for(int i=0;i<3;i++) ax[i] = new Vector3();
this.amotorComputeGlobalAxes (ax);
this.amotorComputeEulerAngles (ax);
}
@@ -189,6 +195,10 @@
JointAMotor joint = this;
// compute the axes (if not global)
Vector3 [] ax = new Vector3[3];
+ for(i=0;i<3;i++){
+ ax[i] = new Vector3();
+ }
+
this.amotorComputeGlobalAxes (ax);
// in euler angle mode we do not actually constrain the angular velocity
@@ -231,7 +241,7 @@
return null;
}
-void dJointSetAMotorNumAxes (int num)
+public void dJointSetAMotorNumAxes (int num)
{
JointAMotor joint = this;
assert(num >= 0 && num <= 3);
@@ -246,7 +256,7 @@
}
-void dJointSetAMotorAxis (int anum, int rel,
+public void dJointSetAMotorAxis (int anum, int rel,
float x, float y, float z)
{
JointAMotor joint = this;
@@ -293,7 +303,7 @@
}
-void dJointSetAMotorAngle (int anum,
+public void dJointSetAMotorAngle (int anum,
float angle)
{
JointAMotor joint = this;
@@ -320,7 +330,7 @@
} */
-void dJointSetAMotorMode (int mode)
+public void dJointSetAMotorMode (int mode)
{
JointAMotor joint = this;
@@ -332,7 +342,7 @@
}
-int dJointGetAMotorNumAxes ()
+public int dJointGetAMotorNumAxes ()
{
JointAMotor joint = this;
@@ -340,7 +350,7 @@
}
-void dJointGetAMotorAxis (int anum,
+public void dJointGetAMotorAxis (int anum,
Vector3 result)
{
JointAMotor joint = this;
@@ -370,7 +380,7 @@
}
-int dJointGetAMotorAxisRel (int anum)
+public int dJointGetAMotorAxisRel (int anum)
{
JointAMotor joint = this;
@@ -381,7 +391,7 @@
}
-float dJointGetAMotorAngle (int anum)
+public float dJointGetAMotorAngle (int anum)
{
JointAMotor joint = this;
@@ -405,7 +415,7 @@
} */
-void dJointAddAMotorTorques (float torque1, float torque2, float torque3)
+public void dJointAddAMotorTorques (float torque1, float torque2, float torque3)
{
JointAMotor joint = this;
@@ -435,6 +445,11 @@
if (joint.getBody(1) != null)
joint.getBody(1).addTorque (-axes[0].m[0], -axes[0].m[1], -axes[0].m[2]);
}
+
+
+ public JointLimitMotor getLimitMotor(int axis){
+ return limot[axis];
+ }
}
//****************************************************************************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-18 02:04:17
|
Revision: 588
http://joode.svn.sourceforge.net/joode/?rev=588&view=rev
Author: t_larkworthy
Date: 2008-06-17 19:04:15 -0700 (Tue, 17 Jun 2008)
Log Message:
-----------
Tests the setVelocity method of the AMotor, done via limit motors.
This test underlines the current poor syntax of the AMotor class. Work needs to be done on the AMotor to reduce gc and genrally get it into java standards.
The test seems to work though. Although little is known as to how it should behave. One would assume that if ODE was working then so is this.
Added Paths:
-----------
trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java
Added: trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java (rev 0)
+++ trunk/src/test/net/java/dev/joode/test/joint/AMotorVelocityTest.java 2008-06-18 02:04:15 UTC (rev 588)
@@ -0,0 +1,85 @@
+package net.java.dev.joode.test.joint;
+
+import net.java.dev.joode.test.JOODETestDescription;
+import net.java.dev.joode.test.TestingWorld;
+import net.java.dev.joode.joint.JointAMotor;
+import net.java.dev.joode.joint.JointBall;
+import net.java.dev.joode.Body;
+import org.xith3d.render.config.CanvasConstructionInfo;
+
+@JOODETestDescription
+ (
+ fulltext = {
+ "creates two bodies, one atacked to the worl via a ball joint",
+ "and another attached to the first via a ball joint",
+ "the relative velocities are controlled with AMotors via the limit motors"},
+ authors = {"Tom Larkworthy" }
+ )
+public class AMotorVelocityTest extends TestingWorld {
+ JointAMotor a1, a2;
+
+
+ public AMotorVelocityTest(CanvasConstructionInfo canvasInfo) {
+ super(false, false, canvasInfo);
+
+ Body b1 = super.createGraphicalBody(10);
+ b1.setPosition(-50, 0, 0);
+
+ JointBall jb1 = new JointBall(getWorld());
+
+ jb1.setAnchor1(0, 50, 0);
+ jb1.setAnchor2(-50, 50, 0);
+ jb1.attach(b1, null);
+
+
+ a1 = new JointAMotor(getWorld());
+ a1.attach(b1, null);
+
+ a1.dJointSetAMotorNumAxes(3);
+
+ a1.dJointSetAMotorAxis(0, 0, 1, 0, 0);
+ a1.dJointSetAMotorAxis(1, 0, 0, 1, 0);
+ a1.dJointSetAMotorAxis(2, 0, 0, 0, 1);
+
+ a1.getLimitMotor(0).setMaxForce(10000);
+ a1.getLimitMotor(1).setMaxForce(10000);
+ a1.getLimitMotor(2).setMaxForce(10000);
+
+ a1.getLimitMotor(0).setVelocity(1);
+ a1.getLimitMotor(1).setVelocity(1);
+ a1.getLimitMotor(2).setVelocity(1);
+
+
+ Body b2 = super.createGraphicalBody(10);
+ b2.setPosition(50, 0, 0);
+
+ JointBall jb2 = new JointBall(getWorld());
+
+ jb2.setAnchor1(0, 50, 0);
+ jb2.setAnchor2(0,0,0);
+ jb2.attach(b2, b1);
+
+
+ a2 = new JointAMotor(getWorld());
+ a2.attach(b2, null);
+
+ a2.dJointSetAMotorNumAxes(3);
+
+ a2.dJointSetAMotorMode(JointAMotor.MODE_EULER);
+
+ a2.getLimitMotor(0).setMaxForce(10000);
+ a2.getLimitMotor(1).setMaxForce(10000);
+ a2.getLimitMotor(2).setMaxForce(10000);
+
+ a2.getLimitMotor(0).setVelocity(1);
+ a2.getLimitMotor(1).setVelocity(1);
+ a2.getLimitMotor(2).setVelocity(1);
+
+
+ }
+
+
+ public static void main(String[] args) {
+ new AMotorVelocityTest(null).begin();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qu...@us...> - 2008-06-15 16:47:50
|
Revision: 587
http://joode.svn.sourceforge.net/joode/?rev=587&view=rev
Author: qudus
Date: 2008-06-15 09:47:48 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
Fixed incompilability.
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
Modified: trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
===================================================================
--- trunk/src/java/net/java/dev/joode/joint/JointAMotor.java 2008-06-15 15:34:17 UTC (rev 586)
+++ trunk/src/java/net/java/dev/joode/joint/JointAMotor.java 2008-06-15 16:47:48 UTC (rev 587)
@@ -10,6 +10,8 @@
*/
public class JointAMotor extends Joint{
+ private static final long serialVersionUID = 4099538059695749627L;
+
int num; // number of axes (0..3)
int mode; // a dAMotorXXX constant
int [] rel = new int[3]; // what the axes are relative to (global,b1,b2)
@@ -160,7 +162,7 @@
}
}
-
+ @Override
public void getInfo1(Info1 info) {
info.m = 0;
info.nub = 0;
@@ -175,12 +177,13 @@
// see if we're powered or at a joint limit for each axis
for (int i=0; i < this.num; i++) {
if (this.limot[i].testRotationalLimit (this.angle.m[i]) ||
- this.limot[i].fmax > 0) {
+ this.limot[i].getMaxForce() > 0) {
info.m++;
}
}
}
+ @Override
public void getInfo2(Info2 info) {
int i;
JointAMotor joint = this;
@@ -248,8 +251,8 @@
{
JointAMotor joint = this;
assert(anum >= 0 && anum <= 2 && rel >= 0 && rel <= 2);
- assert(!(joint.getBody(1)==null&& ((joint.flags & Joint.FLAG_JOINT_REVERSE) != 0) && rel == 1)):"no first body, can't set axis rel=1";
- assert(!(joint.getBody(1)==null && !((joint.flags & Joint.FLAG_JOINT_REVERSE) != 0) && rel == 2)):"no second body, can't set axis rel=2";
+ assert(!(joint.getBody(1)==null && joint.getFlag(Joint.FLAG_JOINT_REVERSE) && rel == 1)):"no first body, can't set axis rel=1";
+ assert(!(joint.getBody(1)==null && !joint.getFlag(Joint.FLAG_JOINT_REVERSE) && rel == 2)):"no second body, can't set axis rel=2";
if (anum < 0) anum = 0;
if (anum > 2) anum = 2;
@@ -410,7 +413,7 @@
if (joint.num == 0)
return;
- assert((joint.flags & Joint.FLAG_JOINT_REVERSE) ==0 ): "dJointAddAMotorTorques not yet implemented for reverse AMotor joints";
+ assert(!joint.getFlag(Joint.FLAG_JOINT_REVERSE)): "dJointAddAMotorTorques not yet implemented for reverse AMotor joints";
amotorComputeGlobalAxes (axes);
axes[0].m[0] *= torque1;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-15 15:34:22
|
Revision: 586
http://joode.svn.sourceforge.net/joode/?rev=586&view=rev
Author: t_larkworthy
Date: 2008-06-15 08:34:17 -0700 (Sun, 15 Jun 2008)
Log Message:
-----------
Translated ODE JointAMotor code to JOODE. Will write test soon.
Added Paths:
-----------
trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
Added: trunk/src/java/net/java/dev/joode/joint/JointAMotor.java
===================================================================
--- trunk/src/java/net/java/dev/joode/joint/JointAMotor.java (rev 0)
+++ trunk/src/java/net/java/dev/joode/joint/JointAMotor.java 2008-06-15 15:34:17 UTC (rev 586)
@@ -0,0 +1,861 @@
+package net.java.dev.joode.joint;
+
+import net.java.dev.joode.SimState;
+import net.java.dev.joode.ClonedReferences;
+import net.java.dev.joode.World;
+import net.java.dev.joode.util.Vector3;
+import net.java.dev.joode.util.MathUtils;
+
+/**
+ */
+public class JointAMotor extends Joint{
+
+ int num; // number of axes (0..3)
+ int mode; // a dAMotorXXX constant
+ int [] rel = new int[3]; // what the axes are relative to (global,b1,b2)
+ Vector3 [] axis = new Vector3[3]; // three axes
+ JointLimitMotor [] limot = new JointLimitMotor[3]; // limit+motor info for axes
+ Vector3 angle; // user-supplied angles for axes
+ // these vectors are used for calculating euler angles
+ Vector3 reference1; // original axis[2], relative to body 1
+ Vector3 reference2; // original axis[0], relative to body 2
+
+
+ public static final int MODE_USER=1;
+ public static final int MODE_EULER=0;
+
+ public JointAMotor(World world) {
+ super(world);
+ int i;
+ JointAMotor j = this;
+
+ j.num = 0;
+ j.mode = MODE_USER;
+ for (i=0; i<3; i++) {
+ j.rel[i] = 0;
+ j.axis[i].setZero();
+ j.limot[i] = new JointLimitMotor (world);
+ j.angle.m[i] = 0;
+ }
+ j.reference1.setZero();
+ j.reference2.setZero();
+ }
+
+ void amotorComputeGlobalAxes (Vector3 [] ax)
+
+ {
+ JointAMotor joint = this;
+ if (joint.mode == MODE_EULER) {
+ // special handling for euler mode
+ MathUtils.dMULTIPLY0_331 (ax[0],joint.getBody(0).getRotation(),joint.axis[0]);
+ if (joint.getBody(1) != null) {
+ MathUtils.dMULTIPLY0_331 (ax[2],joint.getBody(1).getRotation(),joint.axis[2]);
+ }
+ else {
+ ax[2].m[0] = joint.axis[2].m[0];
+ ax[2].m[1] = joint.axis[2].m[1];
+ ax[2].m[2] = joint.axis[2].m[2];
+ }
+ ax[2].cross(ax[0], ax[1]);
+
+ ax[1].normalize();
+ }
+ else {
+ for (int i=0; i < joint.num; i++) {
+ if (joint.rel[i] == 1) {
+ // relative to b1
+ MathUtils.dMULTIPLY0_331 (ax[i],joint.getBody(0).getRotation(),joint.axis[i]);
+ }
+ else if (joint.rel[i] == 2) {
+ // relative to b2
+ if (joint.getBody(1)!=null) { // jds: don't assert, just ignore
+ MathUtils.dMULTIPLY0_331 (ax[i],joint.getBody(1).getRotation(),joint.axis[i]);
+ }
+ }
+ else {
+ // global - just copy it
+ ax[i].m[0] = joint.axis[i].m[0];
+ ax[i].m[1] = joint.axis[i].m[1];
+ ax[i].m[2] = joint.axis[i].m[2];
+ }
+ }
+ }
+ }
+
+ void amotorComputeEulerAngles (Vector3 []ax)
+ {
+ JointAMotor joint = this;
+ // assumptions:
+ // global axes already calculated -. ax
+ // axis[0] is relative to body 1 -. global ax[0]
+ // axis[2] is relative to body 2 -. global ax[2]
+ // ax[1] = ax[2] x ax[0]
+ // original ax[0] and ax[2] are perpendicular
+ // reference1 is perpendicular to ax[0] (in body 1 frame)
+ // reference2 is perpendicular to ax[2] (in body 2 frame)
+ // all ax[] and reference vectors are unit length
+
+ // calculate references in global frame
+ Vector3 ref1 = new Vector3(),ref2=new Vector3();
+ MathUtils.dMULTIPLY0_331 (ref1,joint.getBody(0).getRotation(),joint.reference1);
+ if (joint.getBody(1)!=null) {
+ MathUtils.dMULTIPLY0_331 (ref2,joint.getBody(1).getRotation(),joint.reference2);
+ }
+ else {
+ ref2.m[0] = joint.reference2.m[0];
+ ref2.m[1] = joint.reference2.m[1];
+ ref2.m[2] = joint.reference2.m[2];
+ }
+
+ // get q perpendicular to both ax[0] and ref1, get first euler angle
+ Vector3 q = new Vector3();
+ ax[0].cross(ref1, q);
+
+ joint.angle.m[0] = (float) -Math.atan2 (ax[2].dot(q),ax[2].dot(ref1));
+
+ // get q perpendicular to both ax[0] and ax[1], get second euler angle
+ ax[0].cross(ax[1], q);
+ joint.angle.m[1] = (float) -Math.atan2 (ax[2].dot(ax[0]),ax[2].dot(q));
+
+ // get q perpendicular to both ax[1] and ax[2], get third euler angle
+ ax[1].cross(ax[2], q);
+ joint.angle.m[2] =(float) -Math.atan2 (ref2.dot(ax[1]),ref2.dot(q));
+ }
+
+ /** set the reference vectors as follows:
+ / * reference1 = current axis[2] relative to body 1
+ / * reference2 = current axis[0] relative to body 2
+ / this assumes that:
+ / * axis[0] is relative to body 1
+ / * axis[2] is relative to body 2
+ */
+ void amotorSetEulerReferenceVectors ()
+ {
+ JointAMotor j = this;
+ if (j.getBody(0)!=null && j.getBody(1)!=null) {
+ Vector3 r = new Vector3(); // axis[2] and axis[0] in global coordinates
+ MathUtils.dMULTIPLY0_331 (r,j.getBody(1).getRotation(),j.axis[2]);
+ MathUtils.dMULTIPLY1_331 (j.reference1,j.getBody(0).getRotation(),r);
+ MathUtils.dMULTIPLY0_331 (r,j.getBody(0).getRotation(),j.axis[0]);
+ MathUtils.dMULTIPLY1_331 (j.reference2,j.getBody(1).getRotation(),r);
+ }
+
+ else { // jds
+ // else if (j.node[0].body) {
+ // dMULTIPLY1_331 (j.reference1,j.node[0].body.R,j.axis[2]);
+ // dMULTIPLY0_331 (j.reference2,j.node[0].body.R,j.axis[0]);
+
+ // We want to handle angular motors attached to passive geoms
+ Vector3 r = new Vector3(); // axis[2] and axis[0] in global coordinates
+ r.m[0] = j.axis[2].m[0];
+ r.m[1] = j.axis[2].m[1];
+ r.m[2] = j.axis[2].m[2];
+ r.m[3] = j.axis[2].m[3];
+ MathUtils.dMULTIPLY1_331 (j.reference1,j.getBody(0).getRotation(),r);
+ MathUtils.dMULTIPLY0_331 (r,j.getBody(0).getRotation(),j.axis[0]);
+ j.reference2.m[0] += r.m[0];
+ j.reference2.m[1] += r.m[1];
+ j.reference2.m[2] += r.m[2];
+ j.reference2.m[3] += r.m[3];
+ }
+ }
+
+
+ public void getInfo1(Info1 info) {
+ info.m = 0;
+ info.nub = 0;
+
+ // compute the axes and angles, if in euler mode
+ if (this.mode == MODE_EULER) {
+ Vector3 []ax = new Vector3[3];
+ this.amotorComputeGlobalAxes (ax);
+ this.amotorComputeEulerAngles (ax);
+ }
+
+ // see if we're powered or at a joint limit for each axis
+ for (int i=0; i < this.num; i++) {
+ if (this.limot[i].testRotationalLimit (this.angle.m[i]) ||
+ this.limot[i].fmax > 0) {
+ info.m++;
+ }
+ }
+ }
+
+ public void getInfo2(Info2 info) {
+ int i;
+ JointAMotor joint = this;
+ // compute the axes (if not global)
+ Vector3 [] ax = new Vector3[3];
+ this.amotorComputeGlobalAxes (ax);
+
+ // in euler angle mode we do not actually constrain the angular velocity
+ // along the axes axis[0] and axis[2] (although we do use axis[1]) :
+ //
+ // to get constrain w2-w1 along ...not
+ // ------ --------------------- ------
+ // d(angle[0])/dt = 0 ax[1] x ax[2] ax[0]
+ // d(angle[1])/dt = 0 ax[1]
+ // d(angle[2])/dt = 0 ax[0] x ax[1] ax[2]
+ //
+ // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0.
+ // to prove the result for angle[0], write the expression for angle[0] from
+ // GetInfo1 then take the derivative. to prove this for angle[2] it is
+ // easier to take the euler rate expression for d(angle[2])/dt with respect
+ // to the components of w and set that to 0.
+
+ Vector3 [] axptr = new Vector3[3];
+ axptr[0] = ax[0];
+ axptr[1] = ax[1];
+ axptr[2] = ax[2];
+
+ Vector3 ax0_cross_ax1 = new Vector3();
+ Vector3 ax1_cross_ax2 = new Vector3();
+ if (joint.mode == MODE_EULER) {
+ ax[0].cross(ax[2], ax0_cross_ax1);
+ axptr[2] = ax0_cross_ax1;
+ ax[1].cross(ax[2], ax1_cross_ax2);
+ axptr[0] = ax1_cross_ax2;
+ }
+
+ int row=0;
+ for (i=0; i < joint.num; i++) {
+ if(joint.limot[i].addLimot (joint,info,row,axptr[i],true))
+ row ++;
+ }
+ }
+
+ public SimState cloneState(ClonedReferences util) {
+ return null;
+ }
+
+void dJointSetAMotorNumAxes (int num)
+{
+ JointAMotor joint = this;
+ assert(num >= 0 && num <= 3);
+ if (joint.mode == MODE_EULER) {
+ joint.num = 3;
+ }
+ else {
+ if (num < 0) num = 0;
+ if (num > 3) num = 3;
+ joint.num = num;
+ }
+}
+
+
+void dJointSetAMotorAxis (int anum, int rel,
+ float x, float y, float z)
+{
+ JointAMotor joint = this;
+ assert(anum >= 0 && anum <= 2 && rel >= 0 && rel <= 2);
+ assert(!(joint.getBody(1)==null&& ((joint.flags & Joint.FLAG_JOINT_REVERSE) != 0) && rel == 1)):"no first body, can't set axis rel=1";
+ assert(!(joint.getBody(1)==null && !((joint.flags & Joint.FLAG_JOINT_REVERSE) != 0) && rel == 2)):"no second body, can't set axis rel=2";
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+
+ // adjust rel to match the internal body order
+ if (joint.getBody(1)==null && rel==2) rel = 1;
+
+ joint.rel[anum] = rel;
+
+ // x,y,z is always in global coordinates regardless of rel, so we may have
+ // to convert it to be relative to a body
+ Vector3 r = new Vector3();
+ r.m[0] = x;
+ r.m[1] = y;
+ r.m[2] = z;
+ r.m[3] = 0;
+ if (rel > 0) {
+ if (rel==1) {
+ MathUtils.dMULTIPLY1_331 (joint.axis[anum],joint.getBody(0).getRotation(),r);
+ }
+ else {
+ // don't assert; handle the case of attachment to a bodiless geom
+ if (joint.getBody(1)!=null) { // jds
+ MathUtils.dMULTIPLY1_331(joint.axis[anum],joint.getBody(1).getRotation(),r);
+ }
+ else {
+ joint.axis[anum].m[0] = r.m[0]; joint.axis[anum].m[1] = r.m[1];
+ joint.axis[anum].m[2] = r.m[2]; joint.axis[anum].m[3] = r.m[3];
+ }
+ }
+ }
+ else {
+ joint.axis[anum].m[0] = r.m[0];
+ joint.axis[anum].m[1] = r.m[1];
+ joint.axis[anum].m[2] = r.m[2];
+ }
+ joint.axis[anum].normalize();
+ if (joint.mode == MODE_EULER) amotorSetEulerReferenceVectors ();
+}
+
+
+void dJointSetAMotorAngle (int anum,
+ float angle)
+{
+ JointAMotor joint = this;
+ assert(anum >= 0 && anum < 3);
+ if (joint.mode == MODE_USER) {
+ if (anum < 0) anum = 0;
+ if (anum > 3) anum = 3;
+ joint.angle.m[anum] = angle;
+ }
+}
+
+
+ /*
+void dJointSetAMotorParam (int parameter,
+ float value)
+{
+ JointAMotor joint = this;
+
+ int anum = parameter >> 8;
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ parameter &= 0xff;
+ joint.limot[anum].setBounce (parameter, value);
+} */
+
+
+void dJointSetAMotorMode (int mode)
+{
+ JointAMotor joint = this;
+
+ joint.mode = mode;
+ if (joint.mode == MODE_EULER) {
+ joint.num = 3;
+ amotorSetEulerReferenceVectors ();
+ }
+}
+
+
+int dJointGetAMotorNumAxes ()
+{
+ JointAMotor joint = this;
+
+ return joint.num;
+}
+
+
+void dJointGetAMotorAxis (int anum,
+ Vector3 result)
+{
+ JointAMotor joint = this;
+
+ assert(anum >= 0 && anum < 3);
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ if (joint.rel[anum] > 0) {
+ if (joint.rel[anum]==1) {
+ MathUtils.dMULTIPLY0_331 (result,joint.getBody(0).getRotation(),joint.axis[anum]);
+ }
+ else {
+ if (joint.getBody(1)!=null) { // jds
+ MathUtils.dMULTIPLY0_331 (result,joint.getBody(1).getRotation(),joint.axis[anum]);
+ }
+ else {
+ result.m[0] = joint.axis[anum].m[0]; result.m[1] = joint.axis[anum].m[1];
+ result.m[2] = joint.axis[anum].m[2]; result.m[3] = joint.axis[anum].m[3];
+ }
+ }
+ }
+ else {
+ result.m[0] = joint.axis[anum].m[0];
+ result.m[1] = joint.axis[anum].m[1];
+ result.m[2] = joint.axis[anum].m[2];
+ }
+}
+
+
+int dJointGetAMotorAxisRel (int anum)
+{
+ JointAMotor joint = this;
+
+ assert(anum >= 0 && anum < 3);
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ return joint.rel[anum];
+}
+
+
+float dJointGetAMotorAngle (int anum)
+{
+ JointAMotor joint = this;
+
+ assert(anum >= 0 && anum < 3);
+ if (anum < 0) anum = 0;
+ if (anum > 3) anum = 3;
+ return joint.angle.m[anum];
+}
+
+
+/*
+float dJointGetAMotorParam (int parameter)
+{
+ JointAMotor joint = this;
+
+ int anum = parameter >> 8;
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ parameter &= 0xff;
+ return joint.limot[anum].get (parameter);
+} */
+
+
+void dJointAddAMotorTorques (float torque1, float torque2, float torque3)
+{
+ JointAMotor joint = this;
+
+ Vector3 [] axes = new Vector3[3];
+
+ if (joint.num == 0)
+ return;
+ assert((joint.flags & Joint.FLAG_JOINT_REVERSE) ==0 ): "dJointAddAMotorTorques not yet implemented for reverse AMotor joints";
+
+ amotorComputeGlobalAxes (axes);
+ axes[0].m[0] *= torque1;
+ axes[0].m[1] *= torque1;
+ axes[0].m[2] *= torque1;
+ if (joint.num >= 2) {
+ axes[0].m[0] += axes[1].m[0] * torque2;
+ axes[0].m[1] += axes[1].m[1] * torque2;
+ axes[0].m[2] += axes[1].m[2] * torque2;
+ if (joint.num >= 3) {
+ axes[0].m[0] += axes[2].m[0] * torque3;
+ axes[0].m[1] += axes[2].m[1] * torque3;
+ axes[0].m[2] += axes[2].m[2] * torque3;
+ }
+ }
+
+ if (joint.getBody(0) != null)
+ joint.getBody(0).addTorque (axes[0].m[0],axes[0].m[1],axes[0].m[2]);
+ if (joint.getBody(1) != null)
+ joint.getBody(1).addTorque (-axes[0].m[0], -axes[0].m[1], -axes[0].m[2]);
+}
+}
+
+ //****************************************************************************
+// angular motor
+
+
+ /*
+static void amotorInit (dxJointAMotor *j)
+{
+ int i;
+ j->num = 0;
+ j->mode = MODE_USER;
+ for (i=0; i<3; i++) {
+ j->rel[i] = 0;
+ dSetZero (j->axis[i],4);
+ j->limot[i].init (j->world);
+ j->angle[i] = 0;
+ }
+ dSetZero (j->reference1,4);
+ dSetZero (j->reference2,4);
+}
+
+
+// compute the 3 axes in global coordinates
+
+static void amotorComputeGlobalAxes (dVector3 ax[3])
+{
+ if (joint->mode == MODE_EULER) {
+ // special handling for euler mode
+ MathUtils.dMULTIPLY0_331 (ax[0],joint->node[0].body->R,joint->axis[0]);
+ if (joint->node[1].body) {
+ MathUtils.dMULTIPLY0_331 (ax[2],joint->node[1].body->R,joint->axis[2]);
+ }
+ else {
+ ax[2][0] = joint->axis[2][0];
+ ax[2][1] = joint->axis[2][1];
+ ax[2][2] = joint->axis[2][2];
+ }
+ dCROSS (ax[1],=,ax[2],ax[0]);
+ dNormalize3 (ax[1]);
+ }
+ else {
+ for (int i=0; i < joint->num; i++) {
+ if (joint->rel[i] == 1) {
+ // relative to b1
+ MathUtils.dMULTIPLY0_331 (ax[i],joint->node[0].body->R,joint->axis[i]);
+ }
+ else if (joint->rel[i] == 2) {
+ // relative to b2
+ if (joint->node[1].body) { // jds: don't assert, just ignore
+ MathUtils.dMULTIPLY0_331 (ax[i],joint->node[1].body->R,joint->axis[i]);
+ }
+ }
+ else {
+ // global - just copy it
+ ax[i][0] = joint->axis[i][0];
+ ax[i][1] = joint->axis[i][1];
+ ax[i][2] = joint->axis[i][2];
+ }
+ }
+ }
+}
+
+
+static void amotorComputeEulerAngles (dVector3 ax[3])
+{
+ // assumptions:
+ // global axes already calculated --> ax
+ // axis[0] is relative to body 1 --> global ax[0]
+ // axis[2] is relative to body 2 --> global ax[2]
+ // ax[1] = ax[2] x ax[0]
+ // original ax[0] and ax[2] are perpendicular
+ // reference1 is perpendicular to ax[0] (in body 1 frame)
+ // reference2 is perpendicular to ax[2] (in body 2 frame)
+ // all ax[] and reference vectors are unit length
+
+ // calculate references in global frame
+ dVector3 ref1,ref2;
+ MathUtils.dMULTIPLY0_331 (ref1,joint->node[0].body->R,joint->reference1);
+ if (joint->node[1].body) {
+ MathUtils.dMULTIPLY0_331 (ref2,joint->node[1].body->R,joint->reference2);
+ }
+ else {
+ ref2[0] = joint->reference2[0];
+ ref2[1] = joint->reference2[1];
+ ref2[2] = joint->reference2[2];
+ }
+
+ // get q perpendicular to both ax[0] and ref1, get first euler angle
+ dVector3 q;
+ dCROSS (q,=,ax[0],ref1);
+ joint->angle[0] = -dAtan2 (dDOT(ax[2],q),dDOT(ax[2],ref1));
+
+ // get q perpendicular to both ax[0] and ax[1], get second euler angle
+ dCROSS (q,=,ax[0],ax[1]);
+ joint->angle[1] = -dAtan2 (dDOT(ax[2],ax[0]),dDOT(ax[2],q));
+
+ // get q perpendicular to both ax[1] and ax[2], get third euler angle
+ dCROSS (q,=,ax[1],ax[2]);
+ joint->angle[2] = -dAtan2 (dDOT(ref2,ax[1]), dDOT(ref2,q));
+}
+
+
+// set the reference vectors as follows:
+// * reference1 = current axis[2] relative to body 1
+// * reference2 = current axis[0] relative to body 2
+// this assumes that:
+// * axis[0] is relative to body 1
+// * axis[2] is relative to body 2
+
+static void amotorSetEulerReferenceVectors (dxJointAMotor *j)
+{
+ if (j->node[0].body && j->node[1].body) {
+ dVector3 r; // axis[2] and axis[0] in global coordinates
+ MathUtils.dMULTIPLY0_331 (r,j->node[1].body->R,j->axis[2]);
+ dMULTIPLY1_331 (j->reference1,j->node[0].body->R,r);
+ MathUtils.dMULTIPLY0_331 (r,j->node[0].body->R,j->axis[0]);
+ dMULTIPLY1_331 (j->reference2,j->node[1].body->R,r);
+ }
+
+ else { // jds
+ // else if (j->node[0].body) {
+ // dMULTIPLY1_331 (j->reference1,j->node[0].body->R,j->axis[2]);
+ // MathUtils.dMULTIPLY0_331 (j->reference2,j->node[0].body->R,j->axis[0]);
+
+ // We want to handle angular motors attached to passive geoms
+ dVector3 r; // axis[2] and axis[0] in global coordinates
+ r[0] = j->axis[2][0]; r[1] = j->axis[2][1]; r[2] = j->axis[2][2]; r[3] = j->axis[2][3];
+ dMULTIPLY1_331 (j->reference1,j->node[0].body->R,r);
+ MathUtils.dMULTIPLY0_331 (r,j->node[0].body->R,j->axis[0]);
+ j->reference2[0] += r[0]; j->reference2[1] += r[1];
+ j->reference2[2] += r[2]; j->reference2[3] += r[3];
+ }
+}
+
+
+static void amotorGetInfo1 (dxJointAMotor *j, dxJoint::Info1 *info)
+{
+ info->m = 0;
+ info->nub = 0;
+
+ // compute the axes and angles, if in euler mode
+ if (j->mode == MODE_EULER) {
+ dVector3 ax[3];
+ amotorComputeGlobalAxes (j,ax);
+ amotorComputeEulerAngles (j,ax);
+ }
+
+ // see if we're powered or at a joint limit for each axis
+ for (int i=0; i < j->num; i++) {
+ if (j->limot[i].testRotationalLimit (j->angle[i]) ||
+ j->limot[i].fmax > 0) {
+ info->m++;
+ }
+ }
+}
+
+
+static void amotorGetInfo2 (dxJoint::Info2 *info)
+{
+ int i;
+
+ // compute the axes (if not global)
+ dVector3 ax[3];
+ amotorComputeGlobalAxes (joint,ax);
+
+ // in euler angle mode we do not actually constrain the angular velocity
+ // along the axes axis[0] and axis[2] (although we do use axis[1]) :
+ //
+ // to get constrain w2-w1 along ...not
+ // ------ --------------------- ------
+ // d(angle[0])/dt = 0 ax[1] x ax[2] ax[0]
+ // d(angle[1])/dt = 0 ax[1]
+ // d(angle[2])/dt = 0 ax[0] x ax[1] ax[2]
+ //
+ // constraining w2-w1 along an axis 'a' means that a'*(w2-w1)=0.
+ // to prove the result for angle[0], write the expression for angle[0] from
+ // GetInfo1 then take the derivative. to prove this for angle[2] it is
+ // easier to take the euler rate expression for d(angle[2])/dt with respect
+ // to the components of w and set that to 0.
+
+ dVector3 *axptr[3];
+ axptr[0] = &ax[0];
+ axptr[1] = &ax[1];
+ axptr[2] = &ax[2];
+
+ dVector3 ax0_cross_ax1;
+ dVector3 ax1_cross_ax2;
+ if (joint->mode == MODE_EULER) {
+ dCROSS (ax0_cross_ax1,=,ax[0],ax[1]);
+ axptr[2] = &ax0_cross_ax1;
+ dCROSS (ax1_cross_ax2,=,ax[1],ax[2]);
+ axptr[0] = &ax1_cross_ax2;
+ }
+
+ int row=0;
+ for (i=0; i < joint->num; i++) {
+ row += joint->limot[i].addLimot (joint,info,row,*(axptr[i]),1);
+ }
+}
+
+
+void dJointSetAMotorNumAxes (int num)
+{
+ assert(joint && num >= 0 && num <= 3);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ if (joint->mode == MODE_EULER) {
+ joint->num = 3;
+ }
+ else {
+ if (num < 0) num = 0;
+ if (num > 3) num = 3;
+ joint->num = num;
+ }
+}
+
+
+void dJointSetAMotorAxis (int anum, int rel,
+ dReal x, dReal y, dReal z)
+{
+ assert(joint && anum >= 0 && anum <= 2 && rel >= 0 && rel <= 2);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ assert(!(!joint->node[1].body && (joint->flags & dJOINT_REVERSE) && rel == 1),"no first body, can't set axis rel=1");
+ assert(!(!joint->node[1].body && !(joint->flags & dJOINT_REVERSE) && rel == 2),"no second body, can't set axis rel=2");
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+
+ // adjust rel to match the internal body order
+ if (!joint->node[1].body && rel==2) rel = 1;
+
+ joint->rel[anum] = rel;
+
+ // x,y,z is always in global coordinates regardless of rel, so we may have
+ // to convert it to be relative to a body
+ dVector3 r;
+ r[0] = x;
+ r[1] = y;
+ r[2] = z;
+ r[3] = 0;
+ if (rel > 0) {
+ if (rel==1) {
+ dMULTIPLY1_331 (joint->axis[anum],joint->node[0].body->R,r);
+ }
+ else {
+ // don't assert; handle the case of attachment to a bodiless geom
+ if (joint->node[1].body) { // jds
+ dMULTIPLY1_331 (joint->axis[anum],joint->node[1].body->R,r);
+ }
+ else {
+ joint->axis[anum][0] = r[0]; joint->axis[anum][1] = r[1];
+ joint->axis[anum][2] = r[2]; joint->axis[anum][3] = r[3];
+ }
+ }
+ }
+ else {
+ joint->axis[anum][0] = r[0];
+ joint->axis[anum][1] = r[1];
+ joint->axis[anum][2] = r[2];
+ }
+ dNormalize3 (joint->axis[anum]);
+ if (joint->mode == MODE_EULER) amotorSetEulerReferenceVectors (joint);
+}
+
+
+void dJointSetAMotorAngle (int anum,
+ dReal angle)
+{
+ assert(joint && anum >= 0 && anum < 3);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ if (joint->mode == MODE_USER) {
+ if (anum < 0) anum = 0;
+ if (anum > 3) anum = 3;
+ joint->angle[anum] = angle;
+ }
+}
+
+
+void dJointSetAMotorParam (int parameter,
+ dReal value)
+{
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ int anum = parameter >> 8;
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ parameter &= 0xff;
+ joint->limot[anum].set (parameter, value);
+}
+
+
+void dJointSetAMotorMode (int mode)
+{
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ joint->mode = mode;
+ if (joint->mode == MODE_EULER) {
+ joint->num = 3;
+ amotorSetEulerReferenceVectors (joint);
+ }
+}
+
+
+int dJointGetAMotorNumAxes ()
+{
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ return joint->num;
+}
+
+
+void dJointGetAMotorAxis (int anum,
+ dVector3 result)
+{
+ assert(joint && anum >= 0 && anum < 3);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ if (joint->rel[anum] > 0) {
+ if (joint->rel[anum]==1) {
+ MathUtils.dMULTIPLY0_331 (result,joint->node[0].body->R,joint->axis[anum]);
+ }
+ else {
+ if (joint->node[1].body) { // jds
+ MathUtils.dMULTIPLY0_331 (result,joint->node[1].body->R,joint->axis[anum]);
+ }
+ else {
+ result[0] = joint->axis[anum][0]; result[1] = joint->axis[anum][1];
+ result[2] = joint->axis[anum][2]; result[3] = joint->axis[anum][3];
+ }
+ }
+ }
+ else {
+ result[0] = joint->axis[anum][0];
+ result[1] = joint->axis[anum][1];
+ result[2] = joint->axis[anum][2];
+ }
+}
+
+
+int dJointGetAMotorAxisRel (int anum)
+{
+ assert(joint && anum >= 0 && anum < 3);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ return joint->rel[anum];
+}
+
+
+dReal dJointGetAMotorAngle (int anum)
+{
+ assert(joint && anum >= 0 && anum < 3);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ if (anum < 0) anum = 0;
+ if (anum > 3) anum = 3;
+ return joint->angle[anum];
+}
+
+
+dReal dJointGetAMotorAngleRate (int anum)
+{
+ // @@@
+ dDebug (0,"not yet implemented");
+ return 0;
+}
+
+
+dReal dJointGetAMotorParam (int parameter)
+{
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ int anum = parameter >> 8;
+ if (anum < 0) anum = 0;
+ if (anum > 2) anum = 2;
+ parameter &= 0xff;
+ return joint->limot[anum].get (parameter);
+}
+
+
+int dJointGetAMotorMode ()
+{
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+ return joint->mode;
+}
+
+
+void dJointAddAMotorTorques (dReal torque1, dReal torque2, dReal torque3)
+{
+ dVector3 axes[3];
+ assert(joint);
+ assert(joint->vtable == &__damotor_vtable,"joint is not an amotor");
+
+ if (joint->num == 0)
+ return;
+ assert((joint->flags & dJOINT_REVERSE) == 0, "dJointAddAMotorTorques not yet implemented for reverse AMotor joints");
+
+ amotorComputeGlobalAxes (joint,axes);
+ axes[0][0] *= torque1;
+ axes[0][1] *= torque1;
+ axes[0][2] *= torque1;
+ if (joint->num >= 2) {
+ axes[0][0] += axes[1][0] * torque2;
+ axes[0][1] += axes[1][1] * torque2;
+ axes[0][2] += axes[1][2] * torque2;
+ if (joint->num >= 3) {
+ axes[0][0] += axes[2][0] * torque3;
+ axes[0][1] += axes[2][1] * torque3;
+ axes[0][2] += axes[2][2] * torque3;
+ }
+ }
+
+ if (joint->node[0].body != 0)
+ dBodyAddTorque (joint->node[0].body,axes[0][0],axes[0][1],axes[0][2]);
+ if (joint->node[1].body != 0)
+ dBodyAddTorque(joint->node[1].body, -axes[0][0], -axes[0][1], -axes[0][2]);
+}
+
+
+dxJoint::Vtable __damotor_vtable = {
+ sizeof(dxJointAMotor),
+ (dxJoint::init_fn*) amotorInit,
+ (dxJoint::getInfo1_fn*) amotorGetInfo1,
+ (dxJoint::getInfo2_fn*) amotorGetInfo2,
+ dJointTypeAMotor};
+}
+*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-14 12:39:04
|
Revision: 585
http://joode.svn.sourceforge.net/joode/?rev=585&view=rev
Author: t_larkworthy
Date: 2008-06-14 05:39:01 -0700 (Sat, 14 Jun 2008)
Log Message:
-----------
Added overloaded setAxis and setAnchor(Vector3) versions
Modified Paths:
--------------
trunk/src/java/net/java/dev/joode/joint/JointHinge.java
Modified: trunk/src/java/net/java/dev/joode/joint/JointHinge.java
===================================================================
--- trunk/src/java/net/java/dev/joode/joint/JointHinge.java 2008-06-14 01:51:26 UTC (rev 584)
+++ trunk/src/java/net/java/dev/joode/joint/JointHinge.java 2008-06-14 12:39:01 UTC (rev 585)
@@ -54,6 +54,7 @@
public final void setAnchor1(Vector3 anchor) {
this.anchor1.set(anchor);
}
+
/**
* @return the bodyRelAnchor measured relative to body 1
@@ -77,6 +78,10 @@
public final Vector3 getAnchor2() {
return anchor2;
}
+
+ public final void setAnchor(Vector3 axis){
+ setAnchor(axis.getX(), axis.getY(), axis.getZ());
+ }
public final void setAxis1(Vector3 axis) {
this.axis1.set(axis);
@@ -237,23 +242,27 @@
JointUtils.setAnchors(this, x, y, z, anchor1, anchor2);
this.hingeComputeInitialRelativeRotation();//todo
}
-
+
public final void getAbsAnchor(Vector3 anchor) {
JointUtils.getAnchor(this, anchor, this.anchor1);
}
-
+
public final void setAxis(float x, float y, float z) {
// dUASSERT(joint,"bad joint argument");
// dUASSERT(joint.vtable == &__dhinge_vtable,"joint is not a hinge");
JointUtils.setAxes(this, x, y, z, axis1, axis2);
this.hingeComputeInitialRelativeRotation(); //todo
}
-
- /**
- * Sets qrel to the current orientation of body 0 relative to
+
+ public final void setAxis(Vector3 axis){
+ setAxis(axis.getX(), axis.getY(), axis.getZ());
+ }
+
+ /**
+ * Sets qrel to the current orientation of body 0 relative to
* either body 1 or the environment. More precisely, qrel is
* the initial rotation from body 1 coordinates to body 0
- * coordinates.
+ * coordinates.
*/
private void hingeComputeInitialRelativeRotation() {
if (getBody(0) != null) {
@@ -267,24 +276,24 @@
}
}
}
-
+
/**
* Gets the hinge angle. The angle is measured between the two
* bodies, or between the body and the static environment. Zero
* corresponds to the angle at the time {@link #setAnchor(float, float, float)}
* or {@link #setAxis(float, float, float)} was last called.
- *
+ *
* @return the hinge angle, in radians
*/
public float getHingeAngle() {
return getHingeAngle( getBody(0), getBody(1), axis1, qrel );
}
-
+
public static float getHingeAngle( Body body1, Body body2, Vector3 axis, Quaternion q_initial ) {
// get qrel = relative rotation between the two bodies
Quaternion qrel = new Quaternion();
if (body2 != null) {
- // Compute
+ // Compute
// qrel <- inv(q1) * q2 * inv(q_initial)
Quaternion qa = new Quaternion( body1.getQuaternion() );
qa.invert();
@@ -301,10 +310,10 @@
q_initial.mul( body1.getQuaternion(), qrel );
qrel.invert();
}
-
+
return getHingeAngleFromRelativeQuat(qrel, axis);
}
-
+
public static float getHingeAngleFromRelativeQuat(Quaternion qrel,
Vector3 axis) {
// the angle between the two bodies is extracted from the quaternion
@@ -335,7 +344,7 @@
// points "away" from the direction of the hinge (motor) axis (i.e. more
// than 90 degrees) then use -q instead of q. this represents the same
// rotation, but results in the cos(theta/2) value being sign inverted.
-
+
// extract the angle from the quaternion. cost2 = cos(theta/2),
// sint2 = |sin(theta/2)|
float cost2 = qrel.m[0];
@@ -345,19 +354,19 @@
float theta = (qrel_axis >= 0) ? (float)(2 * Math.atan2(sint2, cost2)) : // if u points in direction of axis
(float)(2 * Math.atan2(sint2, -cost2)); // if u points in
// opposite direction
-
+
// the angle we get will be between 0..2*pi, but we want to return
// angles
// between -pi..pi
if (theta > Math.PI)
theta -= 2 * Math.PI;
-
+
// the angle we've just extracted has the wrong sign
theta = -theta;
-
+
return theta;
}
-
+
public JointHinge cloneState(ClonedReferences util) {
JointHinge clone = new JointHinge();
partialCloneJoint(clone, util);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <t_l...@us...> - 2008-06-14 01:51:30
|
Revision: 584
http://joode.svn.sourceforge.net/joode/?rev=584&view=rev
Author: t_larkworthy
Date: 2008-06-13 18:51:26 -0700 (Fri, 13 Jun 2008)
Log Message:
-----------
A sample application that shows how two dice can be dropped onto a plane and read.
Added Paths:
-----------
trunk/src/examples/net/java/dev/joode/examples/Dice.java
Added: trunk/src/examples/net/java/dev/joode/examples/Dice.java
===================================================================
--- trunk/src/examples/net/java/dev/joode/examples/Dice.java (rev 0)
+++ trunk/src/examples/net/java/dev/joode/examples/Dice.java 2008-06-14 01:51:26 UTC (rev 584)
@@ -0,0 +1,246 @@
+package net.java.dev.joode.examples;
+
+import org.xith3d.loop.InputAdapterRenderLoop;
+import org.xith3d.scenegraph.BranchGroup;
+import org.xith3d.base.Xith3DEnvironment;
+import org.xith3d.render.Canvas3DFactory;
+import org.xith3d.render.Canvas3D;
+import org.openmali.vecmath2.Tuple3f;
+import org.openmali.vecmath2.Vector3f;
+import org.jagatoo.input.InputSystem;
+import org.jagatoo.input.InputSystemException;
+import org.jagatoo.input.devices.components.Key;
+import org.jagatoo.input.events.KeyPressedEvent;
+import net.java.dev.joode.World;
+import net.java.dev.joode.Body;
+import net.java.dev.joode.Mass;
+import net.java.dev.joode.force.NewtonGravity;
+import net.java.dev.joode.force.BodyDamper;
+import net.java.dev.joode.test.xith.XithManager;
+import net.java.dev.joode.collision.CollisionManager;
+import net.java.dev.joode.collision.SurfaceParameters;
+import net.java.dev.joode.util.Vector3;
+import net.java.dev.joode.util.Matrix3;
+import net.java.dev.joode.geom.Box;
+import net.java.dev.joode.geom.Plane;
+import net.java.dev.joode.space.Space;
+import net.java.dev.joode.space.SimpleSpace;
+
+/**
+ * Application that rolls two dice.
+ *
+ * Although this uses Xith as the renderer, another renderer could be used,
+ * the important bits for the application are the world object, the bodies, the Box's and the plane.
+ * An external renderer would take the bodies positions and orientations each step
+ *
+ */
+public class Dice extends InputAdapterRenderLoop {
+
+ World w;
+ Space s;
+ Box b1, b2;
+ Body d1,d2;
+ Plane ground;
+
+
+ public static final int SETTLE_TIME = 10;
+
+ int d1SettleCount = SETTLE_TIME;
+ int d2SettleCount = SETTLE_TIME;
+
+ Vector3 d1PrevPos = new Vector3();
+ Vector3 d2PrevPos = new Vector3();
+
+
+ int d1Value = -1;
+ int d2Value = -1;
+
+
+
+
+
+ public Dice(){
+ s = new SimpleSpace(null); //create a simple collision space
+ w = new World(); //create a rigid body dynamics container
+
+ w.setGlobalERP(.9f); //we will not tolerate errors!
+ w.setGlobalCFM(.01f); //we will enforce constraints hard
+
+ Mass diceMass = Mass.createBox(1,2,2,2);
+
+ d1 = new Body(w, diceMass); //create two rigid bodies
+ d2 = new Body(w, diceMass);
+
+ new BodyDamper(d1, 10,.1f);
+ new BodyDamper(d2, 10,.1f);
+
+ b1 = new Box(s, 2,2,2); //create the two collision geometries in the collision space s
+ b2 = new Box(s, 2,2,2);
+
+
+ d1.addGeom(b1);//equivelent ways of tieing the collision geometries to physics objects
+ b2.setBody(d2);
+
+ ground = new Plane(s, //create a ground collision plane for the dice to bounce upon
+ new Vector3(0.0f, 1.0f, 0.0f), // normal of the Plane shows up
+ new Vector3(0.0f, 0.0f, 0.0f)); // Plane goes through (0|0|0)
+
+
+ SurfaceParameters collisionParameters = new SurfaceParameters(10);
+
+ collisionParameters.setBounce(1);//we will setup collisions to be a little bouncy
+ collisionParameters.addModeFlag(SurfaceParameters.CONTACT_BOUNCE);
+
+ CollisionManager collisionManager = new CollisionManager(w,s, collisionParameters,true,8);
+
+ new NewtonGravity(w, 0,-9.81f,0);
+
+ dropDice();
+
+ setupXith(w,s);
+ }
+
+ @Override
+ /**
+ * called every iteration of the gfx frame automatically by xith
+ */
+ protected void prepareNextFrame(long gameTime, long frameTime, TimingMode timingMode) {
+ super.prepareNextFrame(gameTime, frameTime, timingMode);
+ w.step(.1f);
+
+ if(d1Value == -1){
+ if( Vector3.epsilonEquals(d1PrevPos, d1.getPosition(), .1f)){
+ d1SettleCount--;
+ }else{
+ d1SettleCount = SETTLE_TIME;
+ d1PrevPos.set(d1.getPosition());
+ d1Value = -1;
+ }
+
+ if(d1SettleCount == 0){
+ d1Value = settledFace(d1.getRotation()); //work out the value of the face from the rotation matrix
+
+ d1.disable(); //disable the body to stop it shaking around from dynamics errors
+
+ System.out.println("d1Value = " + d1Value);
+ }
+ }
+
+ if(d2Value == -1){
+ if(Vector3.epsilonEquals(d2PrevPos, d2.getPosition(), .1f)){
+ d2SettleCount--;
+ }else{
+ d2SettleCount = SETTLE_TIME;
+ d2PrevPos.set(d2.getPosition());
+ d2Value = -1;
+
+ }
+
+ if(d2SettleCount == 0){
+ d2Value = settledFace(d2.getRotation());
+ d2.disable(); //disable the body to stop it shaking around from dynamics errors
+
+ System.out.println("d2Value = " + d2Value);
+ }
+ }
+
+
+ }
+
+ private int settledFace(Matrix3 rotation) {
+ //to determine which face is left upwards, we need to find which
+ //axis of the rotation matrix is pointint up i.e. (0,1,0)
+ //so we will just measure the angle between each of matrices
+ //axis and its negative axis against (0,1,0) with a dot product and find the minimum
+
+ Vector3 up = new Vector3(0,1,0);
+ Vector3 column = new Vector3();
+
+ float min = Float.MAX_VALUE;
+ int value = 0;
+
+ for(int i=0;i<3;i++){
+ rotation.getColumn(i,column);
+ column.normalize();
+
+ float cosAngle = column.dot(up);
+
+ if(cosAngle < min){value = i+1;min = cosAngle;}
+ }
+
+ //instead of negating the matrix columns for the remaining 3 axis, we
+ //can jsut dot against the opposite of up
+ up.negate();
+ for(int i=0;i<3;i++){
+ rotation.getColumn(i,column);
+ column.normalize();
+ float cosAngle = column.dot(up);
+ if(cosAngle < min){value = i+4;min = cosAngle;}
+ }
+
+ return value;
+ }
+
+ private void setupXith(World w,Space s) {
+
+ try {
+ // first we'll setup Xith (we want to show our results somehow, right?)
+ Tuple3f eyePosition = new Vector3f(0 , 10.0f, -10 );
+ Tuple3f viewFocus = new Vector3f( 0.0f, 0.0f, 0.0f );
+ Tuple3f vecUp = new Vector3f( 0.0f, 1.0f, 0.0f );
+
+ Xith3DEnvironment env = new Xith3DEnvironment( eyePosition, viewFocus, vecUp, this );
+
+ Canvas3D canvas = Canvas3DFactory.createWindowed( 800, 600, "Example 1" );
+
+ InputSystem.getInstance().registerNewKeyboardAndMouse( canvas.getPeer());
+
+ BranchGroup bg = new BranchGroup();
+
+ env.addPerspectiveBranch(bg);
+
+ env.addCanvas( canvas );
+
+ XithManager graphicsManager = new XithManager(w,s, bg);
+
+ this.begin();
+ } catch (InputSystemException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void dropDice() {
+ d1Value = -1; //indicate the values of the dice are now unkown
+ d2Value = -1;
+
+ d1.enable();//ensure the body dynamics are enabled
+ d2.enable();
+
+
+ d1.setRotation(Matrix3.setRandomRotationMatrix(new Matrix3()));
+ d2.setRotation(Matrix3.setRandomRotationMatrix(new Matrix3()));
+
+ d1.setPosition(5,10,0);
+ d2.setPosition(-5,10,0);
+
+ d1.setLinearVel(-10,0,0);
+ d2.setLinearVel( 10,0,0);
+ }
+
+ @Override
+ public void onKeyPressed(KeyPressedEvent e, Key key) {
+ switch (key.getKeyID())
+ {
+ case SPACE:
+ dropDice();
+ break;
+ case ESCAPE:
+ this.end();
+ break;
+ }
+ }
+
+ public static void main(String[] args) {
+ new Dice();
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <qu...@us...> - 2008-06-10 19:45:23
|
Revision: 583
http://joode.svn.sourceforge.net/joode/?rev=583&view=rev
Author: qudus
Date: 2008-06-10 12:45:17 -0700 (Tue, 10 Jun 2008)
Log Message:
-----------
New Xith3D jars.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/xith3d.jar
trunk/src/xpal/org/xith3d/physics/simulation/joode/JoodeBody.java
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-06-04 21:43:32 UTC (rev 582)
+++ trunk/lib/xith3d.jar 2008-06-10 19:45:17 UTC (rev 583)
@@ -1,13 +1,13 @@
-PK |
|
From: <qu...@us...> - 2008-06-04 21:43:38
|
Revision: 582
http://joode.svn.sourceforge.net/joode/?rev=582&view=rev
Author: qudus
Date: 2008-06-04 14:43:32 -0700 (Wed, 04 Jun 2008)
Log Message:
-----------
Fixed Anchors to be correctly read out of a HingeJoint.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/xith3d.jar
trunk/src/java/net/java/dev/joode/joint/JointHinge.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/JoodeJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeBallJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeFixedJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeHinge2Joint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeHingeJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeSliderJoint.java
Removed Paths:
-------------
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeJointBase.java
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-06-03 18:39:42 UTC (rev 581)
+++ trunk/lib/xith3d.jar 2008-06-04 21:43:32 UTC (rev 582)
@@ -1,4 +1,4 @@
-PK |
|
From: <qu...@us...> - 2008-06-03 18:39:48
|
Revision: 581
http://joode.svn.sourceforge.net/joode/?rev=581&view=rev
Author: qudus
Date: 2008-06-03 11:39:42 -0700 (Tue, 03 Jun 2008)
Log Message:
-----------
New Xith3D jars.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/xith3d.jar
trunk/src/xpal/org/xith3d/physics/simulation/joode/JoodeBody.java
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-06-01 18:45:18 UTC (rev 580)
+++ trunk/lib/xith3d.jar 2008-06-03 18:39:42 UTC (rev 581)
@@ -1,13 +1,13 @@
-PK |
|
From: <qu...@us...> - 2008-06-01 18:45:25
|
Revision: 580
http://joode.svn.sourceforge.net/joode/?rev=580&view=rev
Author: qudus
Date: 2008-06-01 11:45:18 -0700 (Sun, 01 Jun 2008)
Log Message:
-----------
Fixed Joints to return an ro-instance of their positions/anchors/etc.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/math/openmali.jar
trunk/lib/xith3d.jar
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeBallJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeFixedJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeHinge2Joint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeHingeJoint.java
trunk/src/xpal/org/xith3d/physics/simulation/joode/joints/JoodeSliderJoint.java
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/math/openmali.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-05-20 18:42:19 UTC (rev 579)
+++ trunk/lib/xith3d.jar 2008-06-01 18:45:18 UTC (rev 580)
@@ -1,13 +1,13 @@
-PK |
|
From: <qu...@us...> - 2008-05-20 18:42:23
|
Revision: 579
http://joode.svn.sourceforge.net/joode/?rev=579&view=rev
Author: qudus
Date: 2008-05-20 11:42:19 -0700 (Tue, 20 May 2008)
Log Message:
-----------
New Xith3D jars.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/math/openmali.jar
trunk/lib/xith3d.jar
trunk/src/test/net/java/dev/joode/test/TestingWorld.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/PhysicRotationTest.java
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/math/openmali.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-05-10 00:27:22 UTC (rev 578)
+++ trunk/lib/xith3d.jar 2008-05-20 18:42:19 UTC (rev 579)
@@ -1,66 +1,61 @@
-PK |
|
From: <qu...@us...> - 2008-05-10 00:27:25
|
Revision: 578
http://joode.svn.sourceforge.net/joode/?rev=578&view=rev
Author: qudus
Date: 2008-05-09 17:27:22 -0700 (Fri, 09 May 2008)
Log Message:
-----------
New Xith3D jars.
Modified Paths:
--------------
trunk/lib/jagatoo.jar
trunk/lib/xith3d.jar
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-05-07 00:07:03 UTC (rev 577)
+++ trunk/lib/xith3d.jar 2008-05-10 00:27:22 UTC (rev 578)
@@ -1,47 +1,66 @@
-PK |
|
From: <qu...@us...> - 2008-05-07 00:07:12
|
Revision: 577
http://joode.svn.sourceforge.net/joode/?rev=577&view=rev
Author: qudus
Date: 2008-05-06 17:07:03 -0700 (Tue, 06 May 2008)
Log Message:
-----------
New Xith3D jars and necessary code ports.
Modified Paths:
--------------
trunk/.classpath
trunk/contrib/src/test/net/java/dev/joode/metamorphic3D/Display.java
trunk/lib/jagatoo.jar
trunk/lib/xith3d.jar
trunk/src/examples/net/java/dev/joode/examples/Example1.java
trunk/src/examples/net/java/dev/joode/examples/Example2.java
trunk/src/test/net/java/dev/joode/test/TestingWorld.java
trunk/src/test/net/java/dev/joode/test/xith/XithConnection.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/BoxDropTest.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/CollisionDropTest.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/CollisionsTest.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/HingeJointTest.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/HingeJointTest2.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/PhysicRotationTest.java
trunk/src/xpal/org/xith3d/physics/joode/test/xpal/RayCollisionTest.java
Removed Paths:
-------------
trunk/lib/hial/
Modified: trunk/.classpath
===================================================================
--- trunk/.classpath 2008-04-21 18:14:44 UTC (rev 576)
+++ trunk/.classpath 2008-05-07 00:07:03 UTC (rev 577)
@@ -1,26 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/java"/>
- <classpathentry kind="src" path="src/examples"/>
- <classpathentry kind="src" path="src/xpal"/>
- <classpathentry kind="src" path="src/test"/>
- <classpathentry kind="src" path="contrib/src/java"/>
- <classpathentry kind="src" path="contrib/src/test"/>
- <classpathentry kind="lib" path="lib/junit.jar"/>
- <classpathentry kind="lib" path="lib/jagatoo.jar" sourcepath="/jagatoo/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="lib/xith3d.jar" sourcepath="/xith3d/src"/>
- <classpathentry kind="lib" path="lib/hial/hial.jar"/>
- <classpathentry kind="lib" path="lib/jogl/jogl.jar">
- <attributes>
- <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="joode/lib/jogl/linux-i586"/>
- </attributes>
- </classpathentry>
<classpathentry kind="lib" path="lib/math/openmali.jar" sourcepath="/openmali/src"/>
+ <classpathentry kind="lib" path="lib/jagatoo.jar" sourcepath="/jagatoo/src"/>
<classpathentry kind="lib" path="lib/gluegen/gluegen-rt.jar">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="joode/lib/gluegen/linux-i586"/>
</attributes>
</classpathentry>
+ <classpathentry kind="lib" path="lib/jogl/jogl.jar">
+ <attributes>
+ <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="joode/lib/jogl/linux-i586"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="lib" path="lib/xith3d.jar" sourcepath="/xith3d/src"/>
+ <classpathentry kind="lib" path="lib/junit.jar"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/examples"/>
+ <classpathentry kind="src" path="src/xpal"/>
+ <classpathentry kind="src" path="src/test"/>
+ <classpathentry kind="src" path="contrib/src/java"/>
+ <classpathentry kind="src" path="contrib/src/test"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
Modified: trunk/contrib/src/test/net/java/dev/joode/metamorphic3D/Display.java
===================================================================
--- trunk/contrib/src/test/net/java/dev/joode/metamorphic3D/Display.java 2008-04-21 18:14:44 UTC (rev 576)
+++ trunk/contrib/src/test/net/java/dev/joode/metamorphic3D/Display.java 2008-05-07 00:07:03 UTC (rev 577)
@@ -1,5 +1,6 @@
package net.java.dev.joode.metamorphic3D;
+import org.xith3d.loop.CanvasFPSListener;
import org.xith3d.loop.InputAdapterRenderLoop;
import org.xith3d.render.Canvas3D;
import org.xith3d.render.Canvas3DFactory;
@@ -8,6 +9,14 @@
import org.xith3d.scenegraph.BranchGroup;
import org.xith3d.scenegraph.DirectionalLight;
import org.xith3d.base.Xith3DEnvironment;
+import org.jagatoo.input.InputSystem;
+import org.jagatoo.input.InputSystemException;
+import org.jagatoo.input.devices.components.Key;
+import org.jagatoo.input.devices.components.MouseButton;
+import org.jagatoo.input.devices.components.MouseButtons;
+import org.jagatoo.input.events.KeyPressedEvent;
+import org.jagatoo.input.events.KeyReleasedEvent;
+import org.jagatoo.input.events.MouseButtonReleasedEvent;
import org.openmali.vecmath2.Tuple3f;
import org.openmali.vecmath2.Vector3f;
import org.openmali.vecmath2.Colorf;
@@ -17,11 +26,6 @@
import net.java.dev.joode.space.SimpleSpace;
import net.java.dev.joode.space.Space;
import net.java.dev.joode.test.xith.XithManager;
-import net.jtank.input.KeyPressedEvent;
-import net.jtank.input.KeyReleasedEvent;
-import net.jtank.input.KeyCode;
-import net.jtank.input.MouseCode;
-import net.jtank.input.MouseReleasedEvent;
/**
* @author Tom Larkworthy
@@ -44,68 +48,61 @@
@Override
- public void onKeyPressed(KeyPressedEvent e) {
- switch (e.getKeyCode())
+ public void onKeyPressed(KeyPressedEvent e, Key key) {
+ switch (key.getKeyID())
{
- case KeyCode.VK_RIGHT:
+ case RIGHT:
break;
- case KeyCode.VK_LEFT:
+ case LEFT:
break;
- case KeyCode.VK_UP:
+ case UP:
break;
- case KeyCode.VK_DOWN:
+ case DOWN:
break;
}
}
@Override
- public void onKeyReleased(KeyReleasedEvent e)
+ public void onKeyReleased(KeyReleasedEvent e, Key key)
{
- switch (e.getKeyCode())
+ switch (key.getKeyID())
{
- case KeyCode.VK_ESCAPE:
+ case ESCAPE:
this.end();
break;
}
}
@Override
- public void onMouseButtonReleased(MouseReleasedEvent e)
+ public void onMouseButtonReleased(MouseButtonReleasedEvent e, MouseButton button)
{
- switch (e.getButton())
+ if (button == MouseButtons.LEFT_BUTTON)
{
- case MouseCode.LEFT_BUTTON:
- this.end();
- break;
+ this.end();
}
}
- @Override
- protected void onFPSCountIntervalHit(float fps)
- {
- super.onFPSCountIntervalHit( fps );
-
- canvas.setTitle( "Example 1, FPS: " + (int)fps );
- }
-
public Display() {
- super( 128f );
-
-
+ super(120f);
-
// first we'll setup Xith (we want to show our results somehow, right?)
Tuple3f eyePosition = new Vector3f( 0, 3, 10);
Tuple3f viewFocus = new Vector3f( 0.0f, 0.0f, 0.0f );
Tuple3f vecUp = new Vector3f( 0.0f, 1.0f, 0.0f );
-
+
env = new Xith3DEnvironment( eyePosition, viewFocus, vecUp, this );
-
+
canvas = Canvas3DFactory.createWindowed( 800, 600, DisplayMode.getDefaultBPP(), FSAA.OFF, "Self-Reconfiguring Robot Simulator");
- this.getInputManager().registerKeyboardAndMouse( canvas );
-
+ this.addFPSListener(new CanvasFPSListener( canvas));
+
+ try {
+ InputSystem.getInstance().registerNewKeyboardAndMouse(canvas.getPeer());
+ } catch ( InputSystemException ise ) {
+ ise.printStackTrace();
+ }
+
BranchGroup bg = new BranchGroup();
env.addPerspectiveBranch(bg);
@@ -141,7 +138,7 @@
* Starts the example
* @param args
*/
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception {
new Display();
}
}
Modified: trunk/lib/jagatoo.jar
===================================================================
(Binary files differ)
Modified: trunk/lib/xith3d.jar
===================================================================
--- trunk/lib/xith3d.jar 2008-04-21 18:14:44 UTC (rev 576)
+++ trunk/lib/xith3d.jar 2008-05-07 00:07:03 UTC (rev 577)
@@ -1,67 +1,73 @@
-PK |
|
From: <t_l...@us...> - 2008-04-21 18:14:46
|
Revision: 576
http://joode.svn.sourceforge.net/joode/?rev=576&view=rev
Author: t_larkworthy
Date: 2008-04-21 11:14:44 -0700 (Mon, 21 Apr 2008)
Log Message:
-----------
Prevented the physics stepping more than 20 times in one frame render step (though it will still catch up over time)
Modified Paths:
--------------
trunk/src/test/net/java/dev/joode/test/TestingWorld.java
Modified: trunk/src/test/net/java/dev/joode/test/TestingWorld.java
===================================================================
--- trunk/src/test/net/java/dev/joode/test/TestingWorld.java 2008-04-21 18:06:54 UTC (rev 575)
+++ trunk/src/test/net/java/dev/joode/test/TestingWorld.java 2008-04-21 18:14:44 UTC (rev 576)
@@ -180,7 +180,8 @@
//final long stepSize = 5000L;
final long stepSize = 10000L;
- while (stepAccumulator >= stepSize) {
+ int maxSteps = 20;
+ while (stepAccumulator >= stepSize && maxSteps-- > 0) {
if (quickSteps == 0) {
world.step(stepSize / 1e6f);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|