Skip to content

Commit

Permalink
Fixing ChunkModel unloading
Browse files Browse the repository at this point in the history
  • Loading branch information
kitskub committed Sep 8, 2014
1 parent 2e37686 commit 052d87b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ChunkReference(Chunk referent) {

public ChunkReference(Point base) {
this.chunk = null;
this.region = new RegionReference(new Point(base.getWorld(), base.getBlockX() >> Region.BLOCKS.BITS, base.getBlockY() >> Region.BLOCKS.BITS, base.getBlockZ() >> Region.BLOCKS.BITS));
this.region = new RegionReference(new Point(base.getWorld(), base.getBlockX() & Region.BLOCKS.MASK, base.getBlockY() & Region.BLOCKS.MASK, base.getBlockZ() & Region.BLOCKS.MASK));
this.base = base;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class FlowRenderer implements Renderer {
private StringModel itpsMonitorModel;
private StringModel positionModel;
private StringModel genCountModel;
private StringModel modelsModel;
private boolean fpsMonitorStarted = false;

private FlowScheduler scheduler;
Expand Down Expand Up @@ -260,7 +261,7 @@ private void addHUD() {
e.printStackTrace();
return;
}
final StringModel sandboxModel = new StringModel(context, graph.getProgram("font"), "FlowEngineFTPSInputPositionWRa0123456789.-: GenCount", ubuntu.deriveFont(Font.PLAIN, 15), windowSize.getX());
final StringModel sandboxModel = new StringModel(context, graph.getProgram("font"), "FlowEngineFTPSInputPositionWRa0123456789.-: GenCountModels", ubuntu.deriveFont(Font.PLAIN, 15), windowSize.getX());
final float aspect = getAspectRatio();
sandboxModel.setPosition(new Vector3f(0.005, .97 * aspect, -0.1));
sandboxModel.setString("Flow Engine - WIP");
Expand Down Expand Up @@ -289,6 +290,11 @@ private void addHUD() {
guiModels.add(genCoModel);
genCountModel = genCoModel;

final StringModel modelModel = sandboxModel.getInstance();
modelModel.setPosition(new Vector3f(0.005, .79 * aspect, -0.1));
guiModels.add(modelModel);
modelsModel = modelModel;

updateHUD();
}

Expand Down Expand Up @@ -333,6 +339,7 @@ private void updateHUD() {
positionModel.setString("Position: " + camera.getPosition().toInt().toString() + " Rotation: " + camera.getRotation().toString());

genCountModel.setString("GenCount: " + RegionGenerator.getGenCount());
modelsModel.setString("Models: " + models.size());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ private void updateChunkModels() {
Set<ChunkReference> removeChunks = new HashSet<>();
toRemove.drainTo(removeChunks);
for (ChunkReference ref : removeChunks) {
final Vector3i position = ref.getBase().getVector().toInt();
final Vector3i blockBase = ref.getBase().getVector().toInt();
final Vector3i position = new Vector3i(blockBase.getX() >> Chunk.BLOCKS.BITS, blockBase.getY() >> Chunk.BLOCKS.BITS, blockBase.getZ() >> Chunk.BLOCKS.BITS);
chunks.remove(position);
final ChunkModel model = chunkModels.remove(position);
if (model == null) continue;
Expand Down

0 comments on commit 052d87b

Please sign in to comment.