コード例 #1
0
  public void update() {
    super.update();

    boolean enableDebug = Config.getInstance().isDebug();
    debugLine1.setVisible(enableDebug);
    debugLine2.setVisible(enableDebug);
    debugLine3.setVisible(enableDebug);
    debugLine4.setVisible(enableDebug);

    if (enableDebug) {
      CameraTargetSystem cameraTarget = CoreRegistry.get(CameraTargetSystem.class);
      double memoryUsage =
          ((double) Runtime.getRuntime().totalMemory() - (double) Runtime.getRuntime().freeMemory())
              / 1048576.0;
      Timer timer = CoreRegistry.get(Timer.class);
      debugLine1.setText(
          String.format(
              "fps: %.2f, mem usage: %.2f MB, total mem: %.2f, max mem: %.2f",
              timer.getFps(),
              memoryUsage,
              Runtime.getRuntime().totalMemory() / 1048576.0,
              Runtime.getRuntime().maxMemory() / 1048576.0));
      debugLine2.setText(String.format("%s", cameraTarget.toString()));
      debugLine3.setText(String.format("%s", CoreRegistry.get(WorldRenderer.class)));
      debugLine4.setText(
          String.format(
              "total vus: %s | active threads: %s",
              ChunkTessellator.getVertexArrayUpdateCount(),
              CoreRegistry.get(GameEngine.class).getActiveTaskCount()));
    }
  }
コード例 #2
0
    @Override
    public void run() {
      ChunkMesh[] newMeshes = new ChunkMesh[WorldRendererLwjgl.VERTICAL_SEGMENTS];
      ChunkView chunkView = worldProvider.getLocalView(c.getPos());
      if (chunkView != null) {
        c.setDirty(false);
        for (int seg = 0; seg < WorldRendererLwjgl.VERTICAL_SEGMENTS; seg++) {
          int meshHeight = ChunkConstants.SIZE_Y / WorldRendererLwjgl.VERTICAL_SEGMENTS;
          newMeshes[seg] =
              tessellator.generateMesh(
                  chunkView,
                  c.getPos(),
                  meshHeight,
                  seg * (ChunkConstants.SIZE_Y / WorldRendererLwjgl.VERTICAL_SEGMENTS));
        }

        c.setPendingMesh(newMeshes);
        ChunkMonitor.fireChunkTessellated(c.getPos(), newMeshes);
      }
      chunkUpdateManager.finishedProcessing(c);
      // Clean these up because the task executor holds the object in memory.
      c = null;
      tessellator = null;
      worldProvider = null;
    }