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] canPassPlanesX; // 64 bytes WEST to EAST
|
||||||
protected ulong[8] canPassPlanesY; // 64 bytes DOWN to UP
|
protected ulong[8] canPassPlanesY; // 64 bytes DOWN to UP
|
||||||
protected ulong[8] canPassPlanesZ; // 64 bytes NORTH to SOUTH
|
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
|
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
|
//ulong[6][6] canPassFromTo; // 288 bytes
|
||||||
SmallChunk * [6] nearChunks;
|
SmallChunk * [6] nearChunks;
|
||||||
|
@ -1554,7 +1555,7 @@ struct VisibilityCheckIterator {
|
||||||
return;
|
return;
|
||||||
// direction test (TODO)
|
// direction test (TODO)
|
||||||
int dot = diff.dot(cameraDirection);
|
int dot = diff.dot(cameraDirection);
|
||||||
if (dot < 3000)
|
if (dot < 8000)
|
||||||
return;
|
return;
|
||||||
//....
|
//....
|
||||||
// plan visiting
|
// plan visiting
|
||||||
|
@ -1618,9 +1619,9 @@ struct VisibilityCheckIterator {
|
||||||
this.visitor = visitor;
|
this.visitor = visitor;
|
||||||
this.cameraDirection = cameraDirection;
|
this.cameraDirection = cameraDirection;
|
||||||
Vector3d cameraOffset = cameraDirection;
|
Vector3d cameraOffset = cameraDirection;
|
||||||
cameraOffset.x /= 16;
|
cameraOffset.x /= 7;
|
||||||
cameraOffset.y /= 16;
|
cameraOffset.y /= 7;
|
||||||
cameraOffset.z /= 16;
|
cameraOffset.z /= 7;
|
||||||
this.camPos = startPos - cameraOffset;
|
this.camPos = startPos - cameraOffset;
|
||||||
//if (!startChunk)
|
//if (!startChunk)
|
||||||
// return;
|
// return;
|
||||||
|
|
|
@ -60,6 +60,13 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
return Platform.instance.enterMessageLoop();
|
return Platform.instance.enterMessageLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class ChunkVisitCounter : ChunkVisitor {
|
||||||
|
int count;
|
||||||
|
void visit(World world, SmallChunk * chunk) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
||||||
|
|
||||||
import dlangui.graphics.scene.node;
|
import dlangui.graphics.scene.node;
|
||||||
|
@ -83,7 +90,6 @@ class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
||||||
/// override it
|
/// override it
|
||||||
_node = node;
|
_node = node;
|
||||||
//Log.d("drawing Miner scene");
|
//Log.d("drawing Miner scene");
|
||||||
_chunkIterator.start(_world, _world.camPosition.pos, MAX_VIEW_DISTANCE);
|
|
||||||
//_chunkVisitor.init(_world, MAX_VIEW_DISTANCE, this);
|
//_chunkVisitor.init(_world, MAX_VIEW_DISTANCE, this);
|
||||||
_pos = _world.camPosition.pos;
|
_pos = _world.camPosition.pos;
|
||||||
_camPosition = _cam.translation;
|
_camPosition = _cam.translation;
|
||||||
|
@ -96,9 +102,14 @@ class MinerDrawable : MaterialDrawableObject, ChunkVisitor {
|
||||||
camVector.x = cast(int)(_camForwardVector.x * 256);
|
camVector.x = cast(int)(_camForwardVector.x * 256);
|
||||||
camVector.y = cast(int)(_camForwardVector.y * 256);
|
camVector.y = cast(int)(_camForwardVector.y * 256);
|
||||||
camVector.z = cast(int)(_camForwardVector.z * 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);
|
_chunkIterator.visitVisibleChunks(this, camVector);
|
||||||
long duration = currentTimeMillis() - ts;
|
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) {
|
void visit(World world, SmallChunk * chunk) {
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
|
|
Loading…
Reference in New Issue