diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2011-03-18 05:28:14 +0000 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2011-03-18 05:28:14 +0000 |
commit | 8c88c2ea28f2a20edc74d301a3f36264637ce40b (patch) | |
tree | ee65fb96c09db17d83f4fa511ee7fc25007e6ddf /src | |
parent | 02f9894a0ff7950076da6e227356c8f79fb10c98 (diff) |
Don't send objects that can't be sent...
Diffstat (limited to 'src')
-rw-r--r-- | src/common/CollisionDetector.java | 4 | ||||
-rw-r--r-- | src/tesseract/World.java | 6 | ||||
-rw-r--r-- | src/tesseract/objects/Cannon.java | 74 |
3 files changed, 7 insertions, 77 deletions
diff --git a/src/common/CollisionDetector.java b/src/common/CollisionDetector.java index dbe2b15..f193a29 100644 --- a/src/common/CollisionDetector.java +++ b/src/common/CollisionDetector.java @@ -272,8 +272,8 @@ public class CollisionDetector { if (a instanceof Sphere && b instanceof Sphere)
return calculateCollisions((Sphere)a, (Sphere)b);
- /*if (!a.getBounds().intersect(b.getBounds()))
- return EMPTY_COLLISION_LIST;*/
+ if (!a.getBounds().intersect(b.getBounds()))
+ return EMPTY_COLLISION_LIST;
if (a instanceof Particle)
return calculateCollisions((Particle)a, b);
diff --git a/src/tesseract/World.java b/src/tesseract/World.java index 7cc67a4..f03d45a 100644 --- a/src/tesseract/World.java +++ b/src/tesseract/World.java @@ -24,8 +24,10 @@ import javax.vecmath.Point3d; import javax.vecmath.Vector3f; import tesseract.forces.Force; +import tesseract.objects.DyingParticle; import tesseract.objects.Ground; import tesseract.objects.HalfSpace; +import tesseract.objects.ModifyableParticle; import tesseract.objects.Particle; import tesseract.objects.PhysicalObject; import tesseract.objects.blimp.Blimp; @@ -288,7 +290,9 @@ public class World implements Observer { // Side collision, is there a peer? final PeerInformation peer = myPeer.getPeerInDirection(o.getVelocity().x, -o.getVelocity().z); - if (peer != null) { + if (peer != null + && !(o instanceof ModifyableParticle) + && !(o instanceof DyingParticle)) { final CollidableObject sendMe = o; o.rotateForTransmission(myPeer.getPeerInformation(), peer); diff --git a/src/tesseract/objects/Cannon.java b/src/tesseract/objects/Cannon.java deleted file mode 100644 index c1ddce6..0000000 --- a/src/tesseract/objects/Cannon.java +++ /dev/null @@ -1,74 +0,0 @@ -package tesseract.objects;
-
-import javax.media.j3d.IndexedQuadArray;
-import javax.media.j3d.PointArray;
-import javax.media.j3d.Transform3D;
-import javax.vecmath.Point3f;
-import javax.vecmath.Vector3f;
-
-public class Cannon extends PhysicalObject{
-
- public Cannon(Vector3f thePosition, float mass) {
- super(thePosition, mass);
- // TODO Auto-generated constructor stub
- buildShape(14, 7f, 2f, 2f);
- }
-
- private void buildShape(final int theDivisions, final float length,
- final float breechRadius, final float gunThickness) {
- Point3f[] coordinates = new Point3f[theDivisions * 4];
- final float barrelRadius = breechRadius + gunThickness;
- final float arcAngle = (float) (Math.PI * 2.0);
- final float gunDivAngle = 2 * (float) Math.PI / theDivisions;
- Transform3D center = new Transform3D();
-
- for (int i = 0; i < theDivisions; i++) {
- coordinates[i] = new Point3f(breechRadius
- * (float) Math.cos(i * gunDivAngle), 0f, breechRadius
- * (float) Math.sin(i * gunDivAngle));
- }
-
- for (int i = theDivisions; i < theDivisions * 2; i++) {
- coordinates[i] = new Point3f(breechRadius
- * (float) Math.cos(i * gunDivAngle), length, breechRadius
- * (float) Math.sin(i * gunDivAngle));
- }
-
- for (int i = theDivisions * 2; i < theDivisions * 3; i++) {
- coordinates[i] = new Point3f(barrelRadius
- * (float) Math.cos(i * gunDivAngle), 0f, barrelRadius
- * (float) Math.sin(i * gunDivAngle));
- }
-
- for (int i = theDivisions * 3; i < theDivisions * 4; i++) {
- coordinates[i] = new Point3f(barrelRadius
- * (float) Math.cos(i * gunDivAngle), length, barrelRadius
- * (float) Math.sin(i * gunDivAngle));
- }
-
- IndexedQuadArray geometry = new IndexedQuadArray(theDivisions * 4, PointArray.COORDINATES,
- theDivisions * 4);
- int topInsideStop = 0;
- int index = 0;
- for (int i = 0; i < theDivisions; i++) {
- geometry.setCoordinate(index++, coordinates[i]);
- geometry.setCoordinate(index++, coordinates[(theDivisions + i) % (2 * theDivisions)]);
- geometry.setCoordinate(index++, coordinates[(theDivisions + i + 1) % (2 * theDivisions)]);
- geometry.setCoordinate(index++, coordinates[(i + 1) % theDivisions]);
- }
-
- for (int i = theDivisions * 2; i < theDivisions * 3; i++) {
- geometry.setCoordinate(index++, coordinates[i]);
- geometry.setCoordinate(index++, coordinates[(theDivisions + i) % (4 * theDivisions)]);
- geometry.setCoordinate(index++, coordinates[(theDivisions + i + 1) % (4 * theDivisions)]);
- geometry.setCoordinate(index++, coordinates[((i + 1) % theDivisions) + theDivisions * 2]);
- }
-
- for (int i = 0; i < theDivisions; i++) {
- geometry.setCoordinate(index++, coordinates[i]);
- geometry.setCoordinate(index++, coordinates[i + 3 * theDivisions]);
- geometry.setCoordinate(index++, coordinates[(1 + i + 3 * theDivisions) % theDivisions]);
- geometry.setCoordinate(index++, coordinates[(i + 1) % theDivisions]);
- }
- }
-}
|