This commit is contained in:
Anuken
2020-05-02 23:15:36 -04:00
parent cb6920b8be
commit dd68241d1f
7 changed files with 40 additions and 21 deletions

View File

@@ -41,27 +41,31 @@ public class AsyncLogic{
}
public void begin(){
//sync begin
for(AsyncProcess p : processes){
p.begin();
}
if(Vars.state.isPlaying()){
//sync begin
for(AsyncProcess p : processes){
p.begin();
}
futures.clear();
futures.clear();
//submit all tasks
for(AsyncProcess p : processes){
if(p.shouldProcess()){
futures.add(executor.submit(p::process));
//submit all tasks
for(AsyncProcess p : processes){
if(p.shouldProcess()){
futures.add(executor.submit(p::process));
}
}
}
}
public void end(){
complete();
if(Vars.state.isPlaying()){
complete();
//sync end (flush data)
for(AsyncProcess p : processes){
p.end();
//sync end (flush data)
for(AsyncProcess p : processes){
p.end();
}
}
}

View File

@@ -96,7 +96,7 @@ public class PhysicsProcess implements AsyncProcess{
ref.lastVelocity.set(ref.velocity);
}
physics.step(Core.graphics.getDeltaTime(), 8, 8);
physics.step(Core.graphics.getDeltaTime(), 5, 8);
//get delta vectors
for(PhysicRef ref : refs){
@@ -121,7 +121,7 @@ public class PhysicsProcess implements AsyncProcess{
ref.position.set(entity);
//add delta velocity - this doesn't work very well yet
//entity.vel().add(ref.velocity).sub(ref.lastVelocity);
entity.vel().add(ref.velocity).sub(ref.lastVelocity);
}
}