debug particle cleanup
This commit is contained in:
@@ -23,16 +23,13 @@ import com.seibel.distanthorizons.api.DhApi;
|
||||
import com.seibel.distanthorizons.api.enums.config.EDhApiMcRenderingFadeMode;
|
||||
import com.seibel.distanthorizons.api.enums.rendering.EDhApiRenderPass;
|
||||
import com.seibel.distanthorizons.api.methods.events.abstractEvents.*;
|
||||
import com.seibel.distanthorizons.core.api.external.methods.data.DhApiTerrainDataRepo;
|
||||
import com.seibel.distanthorizons.core.api.internal.rendering.DhRenderState;
|
||||
import com.seibel.distanthorizons.core.file.structure.ClientOnlySaveStructure;
|
||||
import com.seibel.distanthorizons.core.logging.DhLoggerBuilder;
|
||||
import com.seibel.distanthorizons.core.network.messages.MessageRegistry;
|
||||
import com.seibel.distanthorizons.core.pos.DhChunkPos;
|
||||
import com.seibel.distanthorizons.core.render.DhApiRenderProxy;
|
||||
import com.seibel.distanthorizons.core.render.renderer.VanillaFadeRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.LodRenderer;
|
||||
import com.seibel.distanthorizons.core.render.renderer.RenderParams;
|
||||
import com.seibel.distanthorizons.core.render.renderer.*;
|
||||
import com.seibel.distanthorizons.core.util.TimerUtil;
|
||||
import com.seibel.distanthorizons.core.util.objects.Pair;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRenderWrapper;
|
||||
@@ -46,9 +43,7 @@ import com.seibel.distanthorizons.api.enums.rendering.EDhApiRendererMode;
|
||||
import com.seibel.distanthorizons.core.dependencyInjection.SingletonInjector;
|
||||
import com.seibel.distanthorizons.core.level.IServerKeyedClientLevel;
|
||||
import com.seibel.distanthorizons.core.render.glObject.GLProxy;
|
||||
import com.seibel.distanthorizons.core.render.renderer.TestRenderer;
|
||||
import com.seibel.distanthorizons.core.world.AbstractDhWorld;
|
||||
import com.seibel.distanthorizons.core.world.DhClientServerWorld;
|
||||
import com.seibel.distanthorizons.core.world.DhClientWorld;
|
||||
import com.seibel.distanthorizons.core.world.IDhClientWorld;
|
||||
import com.seibel.distanthorizons.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
|
||||
+15
-18
@@ -38,7 +38,6 @@ import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftRen
|
||||
import com.seibel.distanthorizons.core.util.math.Mat4f;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3d;
|
||||
import com.seibel.distanthorizons.core.util.math.Vec3f;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.lwjgl.opengl.GL32;
|
||||
@@ -213,7 +212,7 @@ public class DebugRenderer
|
||||
|
||||
// particle rendering
|
||||
BoxParticle head = null;
|
||||
while ((head = this.particles.poll()) != null && head.isDead(System.nanoTime()))
|
||||
while ((head = this.particles.poll()) != null && head.isDead())
|
||||
{ /* remove dead particles */ }
|
||||
if (head != null)
|
||||
{
|
||||
@@ -311,52 +310,50 @@ public class DebugRenderer
|
||||
public static final class BoxParticle implements Comparable<BoxParticle>
|
||||
{
|
||||
public Box box;
|
||||
public long startTime;
|
||||
public long duration;
|
||||
public long startMsTime;
|
||||
public long durationInMs;
|
||||
public float yChange;
|
||||
|
||||
public BoxParticle(Box box, long startTime, long duration, float yChange)
|
||||
private BoxParticle(Box box, long startMsTime, long durationInMs, float yChange)
|
||||
{
|
||||
this.box = box;
|
||||
this.startTime = startTime;
|
||||
this.duration = duration;
|
||||
this.startMsTime = startMsTime;
|
||||
this.durationInMs = durationInMs;
|
||||
this.yChange = yChange;
|
||||
}
|
||||
|
||||
public BoxParticle(Box box, long nanoSecondDuratoin, float yChange) { this(box, System.nanoTime(), nanoSecondDuratoin, yChange); }
|
||||
|
||||
public BoxParticle(Box box, double secondDuration, float yChange) { this(box, System.nanoTime(), (long) (secondDuration * 1000000000), yChange); }
|
||||
public BoxParticle(Box box, double secondDuration, float yChange) { this(box, System.currentTimeMillis(), (long) (secondDuration * 1_000), yChange); }
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull BoxParticle particle)
|
||||
{
|
||||
return Long.compare(this.startTime + this.duration, particle.startTime + particle.duration);
|
||||
return Long.compare(this.startMsTime + this.durationInMs, particle.startMsTime + particle.durationInMs);
|
||||
}
|
||||
|
||||
public Box getBox()
|
||||
{
|
||||
long now = System.nanoTime();
|
||||
float percent = (now - this.startTime) / (float) this.duration;
|
||||
long nowMs = System.currentTimeMillis();
|
||||
float percent = (nowMs - this.startMsTime) / (float) this.durationInMs;
|
||||
percent = (float) Math.pow(percent, 4);
|
||||
float yDiff = this.yChange * percent;
|
||||
return new Box(new Vec3f(this.box.minPos.x, this.box.minPos.y + yDiff, this.box.minPos.z), new Vec3f(this.box.maxPos.x, this.box.maxPos.y + yDiff, this.box.maxPos.z), this.box.color);
|
||||
}
|
||||
|
||||
public boolean isDead(long time) { return (time - this.startTime) > this.duration; }
|
||||
public boolean isDead() { return (System.currentTimeMillis() - this.startMsTime) > this.durationInMs; }
|
||||
|
||||
}
|
||||
|
||||
public static final class BoxWithLife implements IDebugRenderable, Closeable
|
||||
{
|
||||
public Box box;
|
||||
public BoxParticle particaleOnClose;
|
||||
public BoxParticle particleOnClose;
|
||||
|
||||
|
||||
public BoxWithLife(Box box, long ns, float yChange, Color deathColor)
|
||||
{
|
||||
this.box = box;
|
||||
this.particaleOnClose = new BoxParticle(new Box(box.minPos, box.maxPos, deathColor), -1, ns, yChange);
|
||||
this.particleOnClose = new BoxParticle(new Box(box.minPos, box.maxPos, deathColor), -1, ns, yChange);
|
||||
register(this, null);
|
||||
}
|
||||
|
||||
@@ -366,7 +363,7 @@ public class DebugRenderer
|
||||
public BoxWithLife(Box box, double s, float yChange, Color deathColor)
|
||||
{
|
||||
this.box = box;
|
||||
this.particaleOnClose = new BoxParticle(new Box(box.minPos, box.maxPos, deathColor), s, yChange);
|
||||
this.particleOnClose = new BoxParticle(new Box(box.minPos, box.maxPos, deathColor), s, yChange);
|
||||
}
|
||||
|
||||
public BoxWithLife(Box box, double s, float yChange) { this(box, s, yChange, box.color); }
|
||||
@@ -377,7 +374,7 @@ public class DebugRenderer
|
||||
@Override
|
||||
public void close()
|
||||
{
|
||||
makeParticle(new BoxParticle(this.particaleOnClose.getBox(), System.nanoTime(), this.particaleOnClose.duration, this.particaleOnClose.yChange));
|
||||
makeParticle(new BoxParticle(this.particleOnClose.getBox(), System.nanoTime(), this.particleOnClose.durationInMs, this.particleOnClose.yChange));
|
||||
unregister(this, null);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user