diff --git a/demo1/.gitignore b/demo1/.gitignore index 7194620..6dad9fb 100644 --- a/demo1/.gitignore +++ b/demo1/.gitignore @@ -26,3 +26,5 @@ buildNumber.properties .factorypath .project .vscode/ + +*.jar diff --git a/demo1/pom.xml b/demo1/pom.xml index f51d7cb..2a751c3 100644 --- a/demo1/pom.xml +++ b/demo1/pom.xml @@ -19,8 +19,8 @@ 0% 0% - 20 - 5 + 2100 + 1000 @@ -38,12 +38,12 @@ nz.ac.massey.javaecs javaecs - 0.9.9-RELEASE_CANDIDATE + 1.0.1 - + + @@ -179,7 +179,7 @@ - + diff --git a/demo1/src/main/java/nz/ac/massey/javaecs/examples/App.java b/demo1/src/main/java/nz/ac/massey/javaecs/examples/App.java index d712bd9..054ed9b 100644 --- a/demo1/src/main/java/nz/ac/massey/javaecs/examples/App.java +++ b/demo1/src/main/java/nz/ac/massey/javaecs/examples/App.java @@ -55,7 +55,7 @@ public final class App { LogUpdateSystem logUpdateSystem = new LogUpdateSystem(gameEngine); gameEngine.registerSystem(LogUpdateSystem.class, logUpdateSystem); - RenderSystem renderSystem = new RenderSystem(gameEngine, 10.); + RenderSystem renderSystem = new RenderSystem(gameEngine, 5.); gameEngine.registerSystem(RenderSystem.class, renderSystem); ExistenceSystem existenceSystem = new ExistenceSystem(gameEngine); @@ -114,7 +114,7 @@ public final class App { gameEngine.addComponent(newEnt, Vec2D.class, new Vec2D(5,5,0)); // Uncomment this block to enable the stress-test (runs 500 square entities, with physics etc.) - /*Random rand = new Random(); + Random rand = new Random(); for (int i = 0; i < 500; i++) { newEnt = gameEngine.createEntity(); double size = 1 + rand.nextDouble(); @@ -125,7 +125,7 @@ public final class App { gameEngine.addComponent(newEnt, Render.class, new Render(BoxRender.class)); gameEngine.addComponent(newEnt, BoxRender.class, new BoxRender(size, size, 30 + rand.nextInt(225), 30 + rand.nextInt(225), 30 + rand.nextInt(225))); gameEngine.addComponent(newEnt, TimedExistence.class, new TimedExistence(25 + rand.nextDouble() * 90)); - }*/ + } /************************************ ** Run init() on the systems ** @@ -146,6 +146,7 @@ public final class App { double frameRate = 1.0 / 144; // 1 second divided by target number of frames boolean exit = false; + Thread.sleep(5000); long startTime = System.nanoTime(); while (!exit){ // Run system updates diff --git a/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/CollisionSystem.java b/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/CollisionSystem.java index a79c80c..2e89951 100644 --- a/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/CollisionSystem.java +++ b/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/CollisionSystem.java @@ -1,14 +1,11 @@ package nz.ac.massey.javaecs.examples.Systems; import java.util.BitSet; -import java.util.HashSet; -import java.util.Set; import nz.ac.massey.javaecs.ECSSystem; import nz.ac.massey.javaecs.Engine; import nz.ac.massey.javaecs.Entity; import nz.ac.massey.javaecs.examples.Components.Collider; -import nz.ac.massey.javaecs.examples.Components.Gravity; import nz.ac.massey.javaecs.examples.Components.RidgidBody; import nz.ac.massey.javaecs.examples.Components.Vec2D; @@ -28,14 +25,13 @@ public class CollisionSystem extends ECSSystem { public void init() { } - // This is a quick & naive physics implementation. Not all collision states are accurately calculated | I'm pretty sure one of the states is set wrong, and sends things flying in the wrong direction - // I also expect it is highly inefficient, though it is able to run it with 500 subscribed entities + // This is a quick & naive physics implementation. + // I expect it is highly inefficient, though it is able to run it with 500 + // subscribed entities // with no major performance issues // Replace this with a proper system as required - I.e. Box2D or etc. @Override public void update(double dt) { - Set processed = new HashSet<>(); - // Gets all items we have collided with for (Entity entity : entities) { Vec2D pos = (Vec2D) gameEngine.getComponentData(entity, Vec2D.class); RidgidBody ridgidBody = (RidgidBody) gameEngine.getComponentData(entity, RidgidBody.class); @@ -43,231 +39,72 @@ public class CollisionSystem extends ECSSystem { if (ridgidBody.mass >= 0) { // Only ignore non-static colliders for (Entity entity2 : entities) { - if (!processed.contains(entity2)) { // If this entity has been added, we've already calc'ed its forces completely - // skip entities that have already been processed - Vec2D otherPos = (Vec2D) gameEngine.getComponentData(entity2, Vec2D.class); - RidgidBody otherRidgidBody = (RidgidBody) gameEngine.getComponentData(entity2, - RidgidBody.class); - Collider otherCollider = (Collider) gameEngine.getComponentData(entity2, Collider.class); + // skip entities that have already been processed + Vec2D otherPos = (Vec2D) gameEngine.getComponentData(entity2, Vec2D.class); + RidgidBody otherRidgidBody = (RidgidBody) gameEngine.getComponentData(entity2, RidgidBody.class); + Collider otherCollider = (Collider) gameEngine.getComponentData(entity2, Collider.class); - if (ridgidBody.mass >= 0 || otherRidgidBody.mass >= 0) { - // Evaluate a collision in the top-left - boolean tlCollide = pos.x > otherPos.x && pos.x < otherPos.x + otherCollider.x - && pos.y > otherPos.y && pos.y < otherPos.y + otherCollider.y; - // Evaluate a collision in the bottom-left - boolean blCollide = pos.x > otherPos.x && pos.x < otherPos.x + otherCollider.x - && pos.y + collider.y > otherPos.y - && pos.y + collider.y < otherPos.y + otherCollider.y; - // Evaluate a collision in the bottom-right - boolean brCollide = pos.x + collider.x > otherPos.x - && pos.x + collider.x < otherPos.x + otherCollider.x - && pos.y + collider.y > otherPos.y - && pos.y + collider.y < otherPos.y + otherCollider.y; - // Evaluate a collision in the top-right - boolean trCollide = pos.x + collider.x > otherPos.x - && pos.x + collider.x < otherPos.x + otherCollider.x - && pos.y > otherPos.y - && pos.y < otherPos.y + otherCollider.y; - if (tlCollide || blCollide || brCollide || trCollide) { - // Get the vels - double totalXVel = Math.abs(ridgidBody.xVel) + Math.abs(otherRidgidBody.xVel); - double totalYVel = Math.abs(ridgidBody.yVel) + Math.abs(otherRidgidBody.yVel); - double xMult = 0; - double yMult = 0; - double multTot = 1; // reflect a force back 100%, (srtabilises) then add any extra in bounce - double totalMass = ridgidBody.mass + otherRidgidBody.mass; - boolean fullEdge = false; - // left-hand collision - if (tlCollide && blCollide) { - fullEdge = true; - pos.x = otherPos.x + otherCollider.x - .00001; - xMult = multTot; - } - // right-hand collision - else if (brCollide && trCollide) { - fullEdge = true; - pos.x = otherPos.x - collider.x + .00001; - xMult = -multTot; - } - // Bottom collision - else if (blCollide && brCollide) { - fullEdge = true; - //pos.y = otherPos.y + otherCollider.y; - pos.y = otherPos.y - collider.y + .00001; - yMult = -multTot; - } - // top collision - else if (trCollide && tlCollide) { - fullEdge = true; - //pos.y = otherPos.y - collider.y; - pos.y = otherPos.y + otherCollider.y -.00001; - yMult = multTot; - } - if(!fullEdge){ - // Not a full edge collision, must evaluate which edge it is (it then gets treated as a full edge) - double deltaXVel = Math.abs(ridgidBody.xVel - otherRidgidBody.xVel); - double deltaYVel = Math.abs(ridgidBody.yVel - otherRidgidBody.yVel); - double deltaMin = 50.; - double incidentThreshold = 0; // 10% of the sum of the velocity - if (trCollide){ - fullEdge = true; - // use the ratio i.e. the angle - // There are 3 cases, the incident angle is less than 45 - // The incident angle is more than 45 - // The incident angle is near 0 or 90 - if(deltaXVel < incidentThreshold || deltaYVel < incidentThreshold){ - // must use cover calc, as it is near stationary - if (otherPos.y - (pos.y + collider.y) >= otherPos.x - (pos.x + collider.x)){ - // vertical cover wins - yMult = multTot; - } - else{ - xMult = -multTot; - } - } - else if (deltaYVel > deltaXVel){ - // Top edge - //if (deltaYVel > deltaMin) pos.y = otherPos.y + otherCollider.y; - yMult = multTot; - } - else{ - - //if (deltaXVel > deltaMin) pos.x = otherPos.x + collider.x; - xMult = -multTot; - } - } - else if (brCollide){ - fullEdge = true; - if(deltaXVel < incidentThreshold || deltaYVel < incidentThreshold){ - // must use cover calc, as it is near stationary - if (pos.y - (otherPos.y + otherCollider.y) >= otherPos.x - (pos.x + collider.x)){ - // vertical cover wins - yMult = -multTot; - } - else{ - xMult = -multTot; - } - } - else if (deltaYVel < deltaXVel){ - //pos.y = otherPos.y + otherCollider.y; - //if (deltaYVel > deltaMin) pos.y = otherPos.y - collider.y; - yMult = -multTot; - } - else{ - //if (deltaXVel > deltaMin) pos.x = otherPos.x - collider.x; - xMult = -multTot; - } - } - else if (blCollide){ - fullEdge = true; - if(deltaXVel < incidentThreshold || deltaYVel < incidentThreshold){ - // must use cover calc, as it is near stationary - if (pos.y - (otherPos.y + otherCollider.y) >= pos.x - (otherPos.x + otherCollider.x)){ - // vertical cover wins - yMult = -multTot; - } - else{ - xMult = multTot; - } - } - else if (deltaYVel > deltaXVel){ - //if (deltaYVel > deltaMin) pos.y = otherPos.y - collider.y; - yMult = -multTot; - } - else{ - //if (deltaXVel > deltaMin) pos.x = otherPos.x + otherCollider.x; - xMult = multTot; - } - } - else{ // top left - fullEdge = true; - if(deltaXVel < incidentThreshold || deltaYVel < incidentThreshold){ - // must use cover calc, as it is near stationary - if (otherPos.y - (pos.y + collider.y) >= pos.x - (otherPos.x + otherCollider.x)){ - // vertical cover wins - yMult = multTot; - } - else{ - xMult = multTot; - } - } - else if (deltaYVel > deltaXVel){ - //if (deltaYVel > deltaMin) pos.y = otherPos.y +otherCollider.y; - yMult = multTot; - } - else { - //if (deltaXVel > deltaMin) pos.x = otherPos.x + otherCollider.x; - xMult = multTot; - } - } - - } - if (fullEdge) { - // Finally, actuate the calculation - // entity 2 is immovable; full acceleration applied to the current entity - - if (otherRidgidBody.mass >= 0){ - // For collisions between dynamic objects, the restoring velocity [rv] is shared between both objects. - // Each object experiences a restoring velocity proportionate to its percentage of the total mass. - // They each recieve an additional force of 'bounce', - // which is the total velocity * total bounciness - // This force is then shared by the mass - double rvX1 = totalXVel * ((totalMass - ridgidBody.mass) / totalMass) * xMult; - double rvY1 = totalYVel * ((totalMass - ridgidBody.mass) / totalMass) * yMult; - double totalBounce = ridgidBody.bounciness * otherRidgidBody.bounciness; - // Restoring forces - ridgidBody.xVel += rvX1; - ridgidBody.yVel += rvY1; - // Additional forces; 'bounce' - double xBounce = rvX1 * ((totalBounce - ridgidBody.bounciness) / totalBounce); - double yBounce = rvY1 * ((totalBounce - ridgidBody.bounciness) / totalBounce); - rvX1 = xBounce * ((totalMass - ridgidBody.mass) / totalMass);// * xMult; - rvY1 = yBounce * ((totalMass - ridgidBody.mass) / totalMass);// * yMult; - // bounce forces - ridgidBody.xVel += rvX1; - ridgidBody.yVel += rvY1; - } - else{ - // For collisions against a fixed object, the restoring velocity (velocity in the direction against the collision vector) [name it 'rv'] - // is at least -1x. This would affix the cardinal velocity to zero, both objects would have a 'bounciness' of zero. - // The bounciness is combined (b = object1 * object2), which gives us the total percent of retained velocity, - // i.e. a factor >= 0 & <= 1. Multiply this factor by rv to get the total restoring velocity - double newXVel = totalXVel * (xMult * (Math.abs(xMult) + (ridgidBody.bounciness * otherRidgidBody.bounciness))); - double newYVel = totalYVel * (yMult * (Math.abs(yMult) + (ridgidBody.bounciness * otherRidgidBody.bounciness))); - ridgidBody.xVel += newXVel; - ridgidBody.yVel += newYVel; - } - } + if (otherRidgidBody.mass < 0) { + // Evaluate a collision in the top-left + boolean tlCollide = pos.x > otherPos.x && pos.x < otherPos.x + otherCollider.x + && pos.y > otherPos.y && pos.y < otherPos.y + otherCollider.y; + // Evaluate a collision in the bottom-left + boolean blCollide = pos.x > otherPos.x && pos.x < otherPos.x + otherCollider.x + && pos.y + collider.y > otherPos.y && pos.y + collider.y < otherPos.y + otherCollider.y; + // Evaluate a collision in the bottom-right + boolean brCollide = pos.x + collider.x > otherPos.x + && pos.x + collider.x < otherPos.x + otherCollider.x && pos.y + collider.y > otherPos.y + && pos.y + collider.y < otherPos.y + otherCollider.y; + // Evaluate a collision in the top-right + boolean trCollide = pos.x + collider.x > otherPos.x + && pos.x + collider.x < otherPos.x + otherCollider.x && pos.y > otherPos.y + && pos.y < otherPos.y + otherCollider.y; + if (tlCollide || blCollide || brCollide || trCollide) { + // Get the vels + double totalXVel = Math.abs(ridgidBody.xVel) + Math.abs(otherRidgidBody.xVel); + double totalYVel = Math.abs(ridgidBody.yVel) + Math.abs(otherRidgidBody.yVel); + double xMult = 0; + double yMult = 0; + double multTot = 1; + boolean fullEdge = false; + // left-hand collision + if (tlCollide && blCollide) { + fullEdge = true; + pos.x = otherPos.x + otherCollider.x; + xMult = multTot; + } + // right-hand collision + else if (brCollide && trCollide) { + fullEdge = true; + pos.x = otherPos.x - collider.x; + xMult = -multTot; + } + // Bottom collision + else if (blCollide && brCollide) { + fullEdge = true; + // pos.y = otherPos.y + otherCollider.y; + pos.y = otherPos.y - collider.y; + yMult = -multTot; + } + // top collision + else if (trCollide && tlCollide) { + fullEdge = true; + // pos.y = otherPos.y - collider.y; + pos.y = otherPos.y + otherCollider.y; + yMult = multTot; + } + if (fullEdge) { + double newXVel = totalXVel * (xMult + * (Math.abs(xMult) + (ridgidBody.bounciness * otherRidgidBody.bounciness))); + double newYVel = totalYVel * (yMult + * (Math.abs(yMult) + (ridgidBody.bounciness * otherRidgidBody.bounciness))); + ridgidBody.xVel += newXVel; + ridgidBody.yVel += newYVel; } } } } - //processed.add(entity); // Add this entity to the already processed ones } - } } - - /** - * Zero degrees is straight up, 90 east -90 (270) = west 180 south - * - * @param xVel - * @param yVel - * @return - */ - public static double calcAngle(double xVel, double yVel) { - if (xVel == 0) { // Div zero; = +- 90 - return yVel < 0 ? 270 : 90; - } else if (xVel < 0 && yVel < 0) { // bottom-left quad (180 - 270) - return 180. + Math.tanh(yVel / xVel); - } else if (xVel < 0) { // Top left quad (270 - 360) - return 360 - Math.tanh(yVel / xVel); - } else if (yVel < 0) { - return 180 - Math.tanh(yVel / xVel); - } else { - return Math.tanh(yVel / xVel); - } - - } - } diff --git a/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java b/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java index 0329934..e5996c8 100644 --- a/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java +++ b/demo1/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java @@ -25,8 +25,8 @@ public class RenderSystem extends ECSSystem{ Engine gameEngine; Thread renderThread; double renderScale; - int screenX = 1024; - int screenY = 1024; + int screenX = 512; + int screenY = 512; public RenderSystem(Engine gameEngine, double renderScale){ this.gameEngine = gameEngine; @@ -46,6 +46,7 @@ public class RenderSystem extends ECSSystem{ @Override public void update(double dt) { + // This approach needs reconsidering, as it creates an excessive amount of objects that Group renderScene = new Group(); for (Entity entity : entities) { if (((Render)gameEngine.getComponentData(entity, Render.class)).renderType == BoxRender.class){ @@ -54,8 +55,8 @@ public class RenderSystem extends ECSSystem{ Rectangle rect = new Rectangle(box.xSize* renderScale, box.ySize * renderScale); rect.setFill(new Color(box.r, box.g, box.b, box.a)); - rect.setX(12 + (vec2d.x * renderScale)); - rect.setY(1012 - (vec2d.y * renderScale) - rect.getHeight()); + rect.setX(6 + (vec2d.x * renderScale)); + rect.setY(506 - (vec2d.y * renderScale) - rect.getHeight()); renderScene.getChildren().add(rect); } else if (((Render)gameEngine.getComponentData(entity, Render.class)).renderType == TextRender.class){ @@ -100,7 +101,7 @@ public class RenderSystem extends ECSSystem{ public void start(Stage primaryStage) throws Exception { // based on the colorful circles sample at https://docs.oracle.com/javase/8/javafx/get-started-tutorial/animation.htm root = new Group(); - Scene scene = new Scene(root, 1024, 1024, Color.BLACK); + Scene scene = new Scene(root, 512, 512, Color.BLACK); primaryStage.setScene(scene); primaryStage.show(); // Signal the renderer is ready diff --git a/demo2/pom.xml b/demo2/pom.xml index 72781cc..ce14d65 100644 --- a/demo2/pom.xml +++ b/demo2/pom.xml @@ -38,7 +38,7 @@ nz.ac.massey.javaecs javaecs - 0.9.9-RELEASE_CANDIDATE + 1.0.1 diff --git a/demo2/src/main/java/nz/ac/massey/javaecs/examples/App.java b/demo2/src/main/java/nz/ac/massey/javaecs/examples/App.java index 98fa768..1176be0 100644 --- a/demo2/src/main/java/nz/ac/massey/javaecs/examples/App.java +++ b/demo2/src/main/java/nz/ac/massey/javaecs/examples/App.java @@ -56,7 +56,7 @@ public class App { ControlSystem controlSystem = new ControlSystem(gameEngine); gameEngine.registerSystem(ControlSystem.class, controlSystem); - RenderSystem renderSystem = new RenderSystem(gameEngine, 10.); + RenderSystem renderSystem = new RenderSystem(gameEngine, 5.); gameEngine.registerSystem(RenderSystem.class, renderSystem); PlayerSystem playerSystem = new PlayerSystem(gameEngine); @@ -100,7 +100,6 @@ public class App { boolean exit = false; long startTime = System.nanoTime(); - int state = 0; while (!exit){ // Run system updates diff --git a/demo2/src/main/java/nz/ac/massey/javaecs/examples/JFXView.java b/demo2/src/main/java/nz/ac/massey/javaecs/examples/JFXView.java index ffdedf1..cd9cd6d 100644 --- a/demo2/src/main/java/nz/ac/massey/javaecs/examples/JFXView.java +++ b/demo2/src/main/java/nz/ac/massey/javaecs/examples/JFXView.java @@ -15,7 +15,7 @@ public class JFXView extends Application { primaryStage.setTitle("JavaECS Demo 2"); App.worldGroup = new Group(); App.worldStage = primaryStage; - Scene scene = new Scene(App.worldGroup, 1024, 1024, Color.BLACK); + Scene scene = new Scene(App.worldGroup, 512, 512, Color.BLACK); primaryStage.setScene(scene); primaryStage.show(); // Notifiy that the renderer is ready diff --git a/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/ControlSystem.java b/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/ControlSystem.java index e042faf..1a2c23e 100644 --- a/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/ControlSystem.java +++ b/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/ControlSystem.java @@ -9,9 +9,7 @@ import javafx.stage.Stage; import nz.ac.massey.javaecs.ECSSystem; import nz.ac.massey.javaecs.Engine; import nz.ac.massey.javaecs.Entity; -import nz.ac.massey.javaecs.examples.Components.Control; import nz.ac.massey.javaecs.examples.Components.Input; -import nz.ac.massey.javaecs.examples.Components.Render; /** diff --git a/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java b/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java index e08ea69..a1d77a7 100644 --- a/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java +++ b/demo2/src/main/java/nz/ac/massey/javaecs/examples/Systems/RenderSystem.java @@ -2,18 +2,12 @@ package nz.ac.massey.javaecs.examples.Systems; import java.util.BitSet; -import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Group; -import javafx.scene.Scene; import javafx.scene.image.ImageView; -import javafx.scene.paint.Color; -import javafx.stage.Stage; import nz.ac.massey.javaecs.ECSSystem; import nz.ac.massey.javaecs.Engine; import nz.ac.massey.javaecs.Entity; -import nz.ac.massey.javaecs.examples.Components.Control; -import nz.ac.massey.javaecs.examples.Components.Input; import nz.ac.massey.javaecs.examples.Components.Render; import nz.ac.massey.javaecs.examples.Components.Sprite; import nz.ac.massey.javaecs.examples.Components.Vec2D; @@ -25,8 +19,8 @@ public class RenderSystem extends ECSSystem { Group renderGroup; Thread renderThread; double renderScale; - int screenX = 1024; - int screenY = 1024; + int screenX = 512; + int screenY = 512; public RenderSystem(Engine gameEngine, double renderScale){ this.gameEngine = gameEngine; diff --git a/perftest/pom.xml b/perftest/pom.xml index 9ce7a7d..01b8e1f 100644 --- a/perftest/pom.xml +++ b/perftest/pom.xml @@ -38,7 +38,7 @@ nz.ac.massey.javaecs javaecs - 0.9.2-PRERELEASE + 1.0.1 diff --git a/perftest/src/main/java/nz/ac/massey/javaecs/examples/App.java b/perftest/src/main/java/nz/ac/massey/javaecs/examples/App.java index 2988d76..2472250 100644 --- a/perftest/src/main/java/nz/ac/massey/javaecs/examples/App.java +++ b/perftest/src/main/java/nz/ac/massey/javaecs/examples/App.java @@ -15,8 +15,9 @@ public final class App { /** * Says hello to the world. * @param args The arguments of the program. + * @throws InterruptedException */ - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { int nEntities = 1_000_000; double startTime = System.nanoTime(); Engine engine = new Engine(nEntities); @@ -41,15 +42,16 @@ public final class App { Entity entity = engine.createEntity(); engine.addComponent(entity, PositionComponent.class, new PositionComponent()); engine.addComponent(entity, DirectionComponent.class, new DirectionComponent()); - if (i % 2 != 0){ engine.addComponent(entity, ComflabulationComponent.class, new ComflabulationComponent()); } + } endTime = System.nanoTime(); System.out.println("Entity creation Time taken: " + (endTime - startTime) / 1e6+ " ms " + "("+ (endTime - startTime) / 1e9 + " seconds )"); - + // Delay as object creation is multithreaded in at least OpenJDK 1.8 - lets use see the single core performance + Thread.sleep(5000); double dt = 1.0f/60.0f; startTime = System.nanoTime(); movementSystem.update(dt); diff --git a/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/ComflabSystem.java b/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/ComflabSystem.java index 59e3303..5c12374 100644 --- a/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/ComflabSystem.java +++ b/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/ComflabSystem.java @@ -23,9 +23,6 @@ public class ComflabSystem extends ECSSystem { } @Override - public void update() { - } - public void update(double dt) { for (Entity entity : entities) { ComflabulationComponent comflab = (ComflabulationComponent)ecs.getComponentData(entity, ComflabulationComponent.class); diff --git a/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/MovementSystem.java b/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/MovementSystem.java index c0626bd..99f414b 100644 --- a/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/MovementSystem.java +++ b/perftest/src/main/java/nz/ac/massey/javaecs/examples/Systems/MovementSystem.java @@ -1,6 +1,5 @@ package nz.ac.massey.javaecs.examples.Systems; -import java.lang.management.ThreadInfo; import java.util.BitSet; import nz.ac.massey.javaecs.ECSSystem; @@ -26,9 +25,6 @@ public class MovementSystem extends ECSSystem { } @Override - public void update() { - } - public void update(double dt) { for (Entity entity : entities) { PositionComponent position = (PositionComponent)ecs.getComponentData(entity, PositionComponent.class);