mirror of https://github.com/buggins/dlangui.git
dminer optimizations
This commit is contained in:
parent
a66f93d81a
commit
f37fa6970b
|
@ -151,6 +151,7 @@ struct SmallChunk {
|
|||
protected ulong[8] canPassPlanesX; // 64 bytes WEST to EAST
|
||||
protected ulong[8] canPassPlanesY; // 64 bytes DOWN to UP
|
||||
protected ulong[8] canPassPlanesZ; // 64 bytes NORTH to SOUTH
|
||||
|
||||
protected ubyte[6] canPassFromTo; // index is FROM direction, ubyte is DirMask of TO direction; 1 means can pass FROM .. TO
|
||||
//ulong[6][6] canPassFromTo; // 288 bytes
|
||||
SmallChunk * [6] nearChunks;
|
||||
|
@ -1554,7 +1555,7 @@ struct VisibilityCheckIterator {
|
|||
return;
|
||||
// direction test (TODO)
|
||||
int dot = diff.dot(cameraDirection);
|
||||
if (dot < 3000)
|
||||
if (dot < 8000)
|
||||
return;
|
||||
//....
|
||||
// plan visiting
|
||||
|
@ -1618,9 +1619,9 @@ struct VisibilityCheckIterator {
|
|||
this.visitor = visitor;
|
||||
this.cameraDirection = cameraDirection;
|
||||
Vector3d cameraOffset = cameraDirection;
|
||||
cameraOffset.x /= 16;
|
||||
cameraOffset.y /= 16;
|
||||
cameraOffset.z /= 16;
|
||||
cameraOffset.x /= 7;
|
||||
cameraOffset.y /= 7;
|
||||
cameraOffset.z /= 7;
|
||||
this.camPos = startPos - cameraOffset;
|
||||
//if (!startChunk)
|
||||
// return;
|
||||
|
|
|
@ -60,6 +60,13 @@ extern (C) int UIAppMain(string[] args) {
|
|||
return Platform.instance.enterMessageLoop();
|
||||
}
|
||||
|
||||
class ChunkVisitCounter : ChunkVisitor {
|
||||
int count;
|
||||
void visit(World world, SmallChunk * chunk) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
||||
|
||||
import dlangui.graphics.scene.node;
|
||||
|
@ -83,7 +90,6 @@ class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
|||
/// override it
|
||||
_node = node;
|
||||
//Log.d("drawing Miner scene");
|
||||
_chunkIterator.start(_world, _world.camPosition.pos, MAX_VIEW_DISTANCE);
|
||||
//_chunkVisitor.init(_world, MAX_VIEW_DISTANCE, this);
|
||||
_pos = _world.camPosition.pos;
|
||||
_camPosition = _cam.translation;
|
||||
|
@ -96,9 +102,14 @@ class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
|||
camVector.x = cast(int)(_camForwardVector.x * 256);
|
||||
camVector.y = cast(int)(_camForwardVector.y * 256);
|
||||
camVector.z = cast(int)(_camForwardVector.z * 256);
|
||||
ChunkVisitCounter countVisitor = new ChunkVisitCounter();
|
||||
_chunkIterator.start(_world, _world.camPosition.pos, MAX_VIEW_DISTANCE);
|
||||
_chunkIterator.visitVisibleChunks(countVisitor, camVector);
|
||||
long durationNoDraw = currentTimeMillis() - ts;
|
||||
_chunkIterator.start(_world, _world.camPosition.pos, MAX_VIEW_DISTANCE);
|
||||
_chunkIterator.visitVisibleChunks(this, camVector);
|
||||
long duration = currentTimeMillis() - ts;
|
||||
Log.d("drawing of Miner scene finished in ", duration, " ms skipped:", _skippedCount, " drawn:", _drawnCount);
|
||||
Log.d("drawing of Miner scene finished in ", duration, " ms skipped:", _skippedCount, " drawn:", _drawnCount, " duration(noDraw)=", durationNoDraw);
|
||||
}
|
||||
void visit(World world, SmallChunk * chunk) {
|
||||
if (chunk) {
|
||||
|
|
Loading…
Reference in New Issue