diff --git a/dlangui-msvc.visualdproj b/dlangui-msvc.visualdproj
index cccdbf5d..2d70681e 100644
--- a/dlangui-msvc.visualdproj
+++ b/dlangui-msvc.visualdproj
@@ -339,7 +339,7 @@
0
0
0
- 1
+ 0
0
0
0
diff --git a/examples/d3d/d3d-msvc.visualdproj b/examples/d3d/d3d-msvc.visualdproj
index ed3b2e9b..7a816e91 100644
--- a/examples/d3d/d3d-msvc.visualdproj
+++ b/examples/d3d/d3d-msvc.visualdproj
@@ -44,7 +44,7 @@
0
0
0
- 2.043
+ 2
0
0
0
diff --git a/examples/d3d/src/d3d.d b/examples/d3d/src/d3d.d
index dad1b47e..f4e8f429 100644
--- a/examples/d3d/src/d3d.d
+++ b/examples/d3d/src/d3d.d
@@ -122,13 +122,18 @@ class UiWidget : VerticalLayout {
}
World w = new World();
- for (int x = -100; x < 100; x++)
- for (int z = -100; z < 100; z++)
+ for (int x = -1000; x < 1000; x++)
+ for (int z = -1000; z < 1000; z++)
w.setCell(x, 10, z, 1);
- Position position = Position(Vector3d(0, 13, 0), Vector3d(0, 1, 0));
+ w.setCell(0, 11, 10, 2);
+ w.setCell(5, 11, 15, 2);
+ Position position = Position(Vector3d(0, 13, 0), Vector3d(0, 0, 1));
CellVisitor visitor = new TestVisitor();
Log.d("Testing cell visitor");
+ long ts = currentTimeMillis;
w.visitVisibleCells(position, visitor);
+ long duration = currentTimeMillis - ts;
+ Log.d("DiamondVisitor finished in ", duration, " ms");
destroy(w);
}
@@ -211,14 +216,14 @@ class UiWidget : VerticalLayout {
}
class TestVisitor : CellVisitor {
- void newDirection(ref Position camPosition) {
- Log.d("TestVisitor.newDirection");
- }
- void visitFace(World world, ref Position camPosition, Vector3d pos, cell_t cell, Dir face) {
- Log.d("TestVisitor.visitFace ", pos, " cell=", cell, " face=", face);
- }
+ //void newDirection(ref Position camPosition) {
+ // Log.d("TestVisitor.newDirection");
+ //}
+ //void visitFace(World world, ref Position camPosition, Vector3d pos, cell_t cell, Dir face) {
+ // Log.d("TestVisitor.visitFace ", pos, " cell=", cell, " face=", face);
+ //}
void visit(World world, ref Position camPosition, Vector3d pos, cell_t cell, int visibleFaces) {
- Log.d("TestVisitor.visit ", pos, " cell=", cell);
+ //Log.d("TestVisitor.visit ", pos, " cell=", cell);
}
}
diff --git a/examples/d3d/src/dminer/core/blocks.d b/examples/d3d/src/dminer/core/blocks.d
index 7531b897..4e51add2 100644
--- a/examples/d3d/src/dminer/core/blocks.d
+++ b/examples/d3d/src/dminer/core/blocks.d
@@ -66,15 +66,15 @@ public:
// block type definitions
-__gshared BlockDef BLOCK_DEFS[256];
+__gshared BlockDef[256] BLOCK_DEFS;
// faster check for block->canPass()
-__gshared bool BLOCK_TYPE_CAN_PASS[256];
+__gshared bool[256] BLOCK_TYPE_CAN_PASS;
// faster check for block->isOpaque()
-__gshared bool BLOCK_TYPE_OPAQUE[256];
+__gshared bool[256] BLOCK_TYPE_OPAQUE;
// faster check for block->isVisible()
-__gshared bool BLOCK_TYPE_VISIBLE[256];
+__gshared bool[256] BLOCK_TYPE_VISIBLE;
// faster check for block->isVisible()
-__gshared bool BLOCK_TERRAIN_SMOOTHING[256];
+__gshared bool[256] BLOCK_TERRAIN_SMOOTHING;
/// registers new block type
void registerBlockType(BlockDef def) {
diff --git a/examples/d3d/src/dminer/core/minetypes.d b/examples/d3d/src/dminer/core/minetypes.d
index dc2970c0..c2e5af8a 100644
--- a/examples/d3d/src/dminer/core/minetypes.d
+++ b/examples/d3d/src/dminer/core/minetypes.d
@@ -265,7 +265,7 @@ public:
newsize <<= 1;
_data.length = newsize;
for (int i = oldsize; i < newsize; i++)
- _data[i] = T.init;
+ _data.ptr[i] = T.init;
_data.assumeSafeAppend();
}
}
@@ -275,29 +275,29 @@ public:
/// append single item by ref
void append(ref const T value) {
if (_length >= _data.length)
- reserve(_data.length == 0 ? 64 : _data.length * 2 - _length);
- _data[_length++] = value;
+ reserve(cast(int)(_data.length == 0 ? 64 : _data.length * 2 - _length));
+ _data.ptr[_length++] = value;
}
/// append single item by value
void append(T value) {
if (_length >= _data.length)
- reserve(_data.length == 0 ? 64 : _data.length * 2 - _length);
- _data[_length++] = value;
+ reserve(cast(int)(_data.length == 0 ? 64 : _data.length * 2 - _length));
+ _data.ptr[_length++] = value;
}
/// append single item w/o check
void appendNoCheck(ref const T value) {
- _data[_length++] = value;
+ _data.ptr[_length++] = value;
}
/// append single item w/o check
void appendNoCheck(T value) {
- _data[_length++] = value;
+ _data.ptr[_length++] = value;
}
/// appends same value several times, return pointer to appended items
T* append(ref const T value, int count) {
reserve(count);
int startLen = _length;
for (int i = 0; i < count; i++)
- _data[_length++] = value;
+ _data.ptr[_length++] = value;
return _data.ptr + startLen;
}
/// appends same value several times, return pointer to appended items
@@ -305,20 +305,20 @@ public:
reserve(count);
int startLen = _length;
for (int i = 0; i < count; i++)
- _data[_length++] = value;
+ _data.ptr[_length++] = value;
return _data.ptr + startLen;
}
void clear() {
_length = 0;
}
T get(int index) {
- return _data[index];
+ return _data.ptr[index];
}
void set(int index, T value) {
- _data[index] = value;
+ _data.ptr[index] = value;
}
ref T opIndex(int index) {
- return _data[index];
+ return _data.ptr[index];
}
}
@@ -439,7 +439,7 @@ public:
T get(int x, int y) {
if (x < -_size || x >= _size || y < -_size || y >= _size)
return null;
- return _data[calcIndex(x, y)];
+ return _data.ptr[calcIndex(x, y)];
}
void set(int x, int y, T v) {
if (x < -_size || x >= _size || y < -_size || y >= _size) {
@@ -453,9 +453,9 @@ public:
resize(newSizeShift);
}
int index = calcIndex(x, y);
- if (_data[index])
- destroy(_data[index]);
- _data[index] = v;
+ if (_data.ptr[index])
+ destroy(_data.ptr[index]);
+ _data.ptr[index] = v;
}
~this() {
foreach(ref v; _data)
@@ -710,20 +710,20 @@ struct Direction {
/// returns number of bits to store integer
int bitsFor(int n) {
- int res;
- for (res = 0; n > 0; res++)
- n >>= 1;
- return res;
+ int res;
+ for (res = 0; n > 0; res++)
+ n >>= 1;
+ return res;
}
/// returns 0 for 0, 1 for negatives, 2 for positives
int mySign(int n) {
- if (n > 0)
- return 1;
- else if (n < 0)
- return -1;
- else
- return 0;
+ if (n > 0)
+ return 1;
+ else if (n < 0)
+ return -1;
+ else
+ return 0;
}
immutable ulong RANDOM_MULTIPLIER = ((cast(ulong)1 << 48) - 1);
@@ -748,11 +748,11 @@ struct Random {
int nextInt(int n);
}
-const Vector3d DIRECTION_VECTORS[6] = [
- Vector3d(0, 0, -1),
- Vector3d(0, 0, 1),
- Vector3d(-1, 0, 0),
- Vector3d(1, 0, 0),
- Vector3d(0, 1, 0),
- Vector3d(0, -1, 0)
+const Vector3d[6] DIRECTION_VECTORS = [
+ Vector3d(0, 0, -1),
+ Vector3d(0, 0, 1),
+ Vector3d(-1, 0, 0),
+ Vector3d(1, 0, 0),
+ Vector3d(0, 1, 0),
+ Vector3d(0, -1, 0)
];
diff --git a/examples/d3d/src/dminer/core/world.d b/examples/d3d/src/dminer/core/world.d
index b6c4a1d3..fcb94c1d 100644
--- a/examples/d3d/src/dminer/core/world.d
+++ b/examples/d3d/src/dminer/core/world.d
@@ -20,22 +20,22 @@ immutable int CHUNK_DY_MASK = (CHUNK_DY - 1);
// Layer is 256x16x16 CHUNK_DY layers = CHUNK_DY * (CHUNK_DX_SHIFT x CHUNK_DX_SHIFT) cells
struct ChunkLayer {
private:
- cell_t cells[CHUNK_DX * CHUNK_DX];
+ cell_t[CHUNK_DX * CHUNK_DX] cells;
public:
cell_t* ptr(int x, int z) {
- return &cells[(z << CHUNK_DX_SHIFT) + x];
+ return &cells.ptr[(z << CHUNK_DX_SHIFT) + x];
}
cell_t get(int x, int z) {
- return cells[(z << CHUNK_DX_SHIFT) + x];
+ return cells.ptr[(z << CHUNK_DX_SHIFT) + x];
}
void set(int x, int z, cell_t cell) {
- cells[(z << CHUNK_DX_SHIFT) + x] = cell;
+ cells.ptr[(z << CHUNK_DX_SHIFT) + x] = cell;
}
}
struct Chunk {
private:
- ChunkLayer * layers[CHUNK_DY];
+ ChunkLayer*[CHUNK_DY] layers;
int bottomLayer = - 1;
int topLayer = -1;
public:
@@ -62,10 +62,10 @@ public:
}
void set(int x, int y, int z, cell_t cell) {
int layerIndex = y & CHUNK_DY_MASK;
- ChunkLayer * layer = layers[layerIndex];
+ ChunkLayer * layer = layers.ptr[layerIndex];
if (!layer) {
layer = new ChunkLayer();
- layers[layerIndex] = layer;
+ layers.ptr[layerIndex] = layer;
if (topLayer == -1 || topLayer < layerIndex)
topLayer = layerIndex;
if (bottomLayer == -1 || bottomLayer > layerIndex)
@@ -155,8 +155,7 @@ public:
Chunk * p;
if (lastChunkX == chunkx && lastChunkZ == chunkz) {
p = lastChunk;
- }
- else {
+ } else {
p = chunks.get(chunkx, chunkz);
lastChunkX = chunkx;
lastChunkZ = chunkz;
@@ -181,34 +180,34 @@ public:
}
interface CellVisitor {
- void newDirection(ref Position camPosition);
- void visitFace(World world, ref Position camPosition, Vector3d pos, cell_t cell, Dir face);
+ //void newDirection(ref Position camPosition);
+ //void visitFace(World world, ref Position camPosition, Vector3d pos, cell_t cell, Dir face);
void visit(World world, ref Position camPosition, Vector3d pos, cell_t cell, int visibleFaces);
}
struct DiamondVisitor {
- int maxDist;
- int maxDistBits;
- int dist;
- World world;
- Position * position;
- Vector3d pos0;
- CellVisitor visitor;
- CellArray visited;
- cell_t * visited_ptr;
- Vector3dArray oldcells;
- Vector3dArray newcells;
- ubyte visitedOccupied;
- ubyte visitedEmpty;
- int m0;
- int m0mask;
- void init(World w, Position * pos, CellVisitor v) {
+ int maxDist;
+ int maxDistBits;
+ int dist;
+ World world;
+ Position * position;
+ Vector3d pos0;
+ CellVisitor visitor;
+ CellArray visited;
+ cell_t * visited_ptr;
+ Vector3dArray oldcells;
+ Vector3dArray newcells;
+ ubyte visitedOccupied;
+ ubyte visitedEmpty;
+ int m0;
+ int m0mask;
+ void init(World w, Position * pos, CellVisitor v) {
world = w;
position = pos;
visitor = v;
pos0 = position.pos;
}
- void visitCell(Vector3d v) {
+ void visitCell(Vector3d v) {
//CRLog::trace("visitCell(%d %d %d) dist=%d", v.x, v.y, v.z, myAbs(v.x) + myAbs(v.y) + myAbs(v.z));
//int occupied = visitedOccupied;
@@ -288,7 +287,7 @@ struct DiamondVisitor {
newcells.clear();
visitedOccupied += 2;
visitedEmpty += 2;
- //CRLog::trace("dist: %d cells: %d", dist, oldcells.length());
+ //CRLog::trace("dist: %d cells: %d", dist, oldcells.length());
for (int i = 0; i < oldcells.length(); i++) {
Vector3d pt = oldcells[i];
int sx = mySign(pt.x);