use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class Diamond3iIteratorTest method testThreeDistanceOnlyIteration.
@Test
public void testThreeDistanceOnlyIteration() {
int cc = 0;
for (Vector3ic next : Diamond3iIterable.shell(new Vector3i(), 3).build()) {
assertEquals(3, next.gridDistance(new Vector3i()));
cc++;
}
assertEquals(38, cc);
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class BlockSelectionRenderSystem method renderOverlayForOneBlockSelection.
private void renderOverlayForOneBlockSelection(BlockSelectionComponent blockSelectionComponent, BlockSelectionRenderer selectionRenderer) {
selectionRenderer.beginRenderOverlay();
if (blockSelectionComponent.currentSelection == null) {
if (blockSelectionComponent.startPosition != null) {
selectionRenderer.renderMark(blockSelectionComponent.startPosition);
}
} else {
for (Vector3ic pos : blockSelectionComponent.currentSelection) {
selectionRenderer.renderMark(pos);
}
}
selectionRenderer.endRenderOverlay();
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class RenderableWorldImpl method onChunkLoaded.
@Override
public void onChunkLoaded(Vector3ic chunkCoordinates) {
if (renderableRegion.contains(chunkCoordinates)) {
Chunk chunk = chunkProvider.getChunk(chunkCoordinates);
if (chunk != null) {
chunksInProximityOfCamera.add(chunk);
chunksInProximityOfCamera.sort(new ChunkFrontToBackComparator());
if (lodChunkProvider != null) {
lodChunkProvider.onRealChunkLoaded(chunkCoordinates);
}
} else {
logger.warn("Warning: onChunkLoaded called for a null chunk!");
}
}
for (Vector3ic pos : new BlockRegion(chunkCoordinates).expand(1, 1, 1)) {
Chunk chunk = chunkProvider.getChunk(pos);
if (chunk != null) {
chunk.setDirty(true);
}
}
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class RenderableWorldImpl method pregenerateChunks.
/**
* @return true if pregeneration is complete
*/
@Override
public boolean pregenerateChunks() {
boolean pregenerationIsComplete = true;
chunkProvider.update();
Chunk chunk;
ChunkMesh newMesh;
ChunkView localView;
for (Vector3ic chunkCoordinates : calculateRenderableRegion(renderingConfig.getViewDistance())) {
chunk = chunkProvider.getChunk(chunkCoordinates);
if (chunk == null) {
pregenerationIsComplete = false;
} else if (chunk.isDirty()) {
localView = worldProvider.getLocalView(chunkCoordinates);
if (localView == null) {
continue;
}
chunk.setDirty(false);
newMesh = chunkTessellator.generateMesh(localView);
newMesh.updateMesh();
newMesh.discardData();
if (chunk.hasMesh()) {
chunk.getMesh().dispose();
}
chunk.setMesh(newMesh);
pregenerationIsComplete = false;
break;
}
}
return pregenerationIsComplete;
}
use of org.joml.Vector3ic in project Terasology by MovingBlocks.
the class HeadlessWorldRenderer method updateChunksInProximity.
/**
* Updates the list of chunks around the player.
*
* @param force Forces the update
* @return True if the list was changed
*/
public boolean updateChunksInProximity(boolean force) {
Vector3i newChunkPos = calcCamChunkOffset();
// TODO: This should actually be done based on events from the ChunkProvider on new chunk availability/old chunk removal
boolean chunksCurrentlyPending = false;
if (!newChunkPos.equals(chunkPos) || force || pendingChunks) {
Vector3ic viewingDistance = config.getRendering().getViewDistance().getChunkDistance();
BlockRegion viewRegion = new BlockRegion(newChunkPos).expand(new Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
if (chunksInProximity.size() == 0 || force || pendingChunks) {
// just add all visible chunks
chunksInProximity.clear();
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;
}
}
} else {
BlockRegion oldRegion = new BlockRegion(chunkPos).expand(new Vector3i(viewingDistance.x() / 2, viewingDistance.y() / 2, viewingDistance.z() / 2));
// remove
for (Vector3ic candidateForRemove : viewRegion) {
if (!oldRegion.contains(candidateForRemove)) {
Chunk c = chunkProvider.getChunk(candidateForRemove);
if (c != null) {
chunksInProximity.remove(c);
c.disposeMesh();
}
}
}
// add
for (Vector3ic chunkPosition : viewRegion) {
Chunk c = chunkProvider.getChunk(chunkPosition);
if (c != null && worldProvider.getLocalView(c.getPosition(new Vector3i())) != null) {
chunksInProximity.add(c);
} else {
chunksCurrentlyPending = true;
}
}
}
chunkPos.set(newChunkPos);
pendingChunks = chunksCurrentlyPending;
Collections.sort(chunksInProximity, new ChunkFrontToBackComparator());
return true;
}
return false;
}
Aggregations