public bool Get(System.Byte x, System.Byte y, System.Byte z, ref VOXMaterial instanceID) { if (_allocSize == 0) { return(false); } var index = HashInt(x, y, z) & _allocSize; var entry = _data[index]; while (entry != null) { if (entry.x == x && entry.y == y && entry.z == z) { instanceID = entry.element; return(instanceID != VOXMaterial.MaxValue); } index = (index + 1) & _allocSize; entry = _data[index]; } instanceID = VOXMaterial.MaxValue; return(false); }
public VOXHashMapNode(_Tx xx, _Tx yy, _Tx zz, VOXMaterial value) { x = xx; y = yy; z = zz; element = value; }
public VOXCruncher(int begin_x, int end_x, int begin_y, int end_y, int begin_z, int end_z, VOXVisiableFaces _faces, VOXMaterial _material) { begin.x = begin_x; begin.y = begin_y; begin.z = begin_z; end.x = end_x; end.y = end_y; end.z = end_z; material = _material; faces = _faces; }
public VOXCruncher(Vector3 begin, Vector3 end, VOXMaterial _material) { this.begin = begin; this.end = end; material = _material; faces.left = true; faces.right = true; faces.top = true; faces.bottom = true; faces.front = true; faces.back = true; }
public VOXCruncher(int begin_x, int end_x, int begin_y, int end_y, int begin_z, int end_z, VOXMaterial _material) { begin.x = begin_x; begin.y = begin_y; begin.z = begin_z; end.x = end_x; end.y = end_y; end.z = end_z; material = _material; faces.left = true; faces.right = true; faces.top = true; faces.bottom = true; faces.front = true; faces.back = true; }
public bool Set(System.Byte x, System.Byte y, System.Byte z, VOXMaterial value, bool replace = true) { if (_allocSize == 0) { this.Create(0xFF); } var index = HashInt(x, y, z) & _allocSize; var entry = _data[index]; while (entry != null) { if (entry.x == x && entry.y == y && entry.z == z) { if (replace) { _data[index].element = value; return(true); } return(false); } index = (index + 1) & _allocSize; entry = _data[index]; } if (value != VOXMaterial.MaxValue) { _data[index] = new VOXHashMapNode <System.Byte>(x, y, z, value); _count++; if (_count >= _allocSize) { this.Grow(); } return(true); } return(false); }
public static bool GetVisiableFaces(VOXMaterial[,,] map, Vector3Int bound, int x, int y, int z, VOXMaterial material, Color32[] palette, out VOXVisiableFaces faces) { VOXMaterial[] instanceID = new VOXMaterial[6] { VOXMaterial.MaxValue, VOXMaterial.MaxValue, VOXMaterial.MaxValue, VOXMaterial.MaxValue, VOXMaterial.MaxValue, VOXMaterial.MaxValue }; if (x >= 1) { instanceID[0] = map[(byte)(x - 1), y, z]; } if (y >= 1) { instanceID[2] = map[x, (byte)(y - 1), z]; } if (z >= 1) { instanceID[4] = map[x, y, (byte)(z - 1)]; } if (x <= bound.x) { instanceID[1] = map[(byte)(x + 1), y, z]; } if (y <= bound.y) { instanceID[3] = map[x, (byte)(y + 1), z]; } if (z <= bound.z) { instanceID[5] = map[x, y, (byte)(z + 1)]; } var alpha = palette[material].a; if (alpha < 255) { bool f1 = (instanceID[0] == VOXMaterial.MaxValue) ? true : palette[instanceID[0]].a != alpha ? true : false; bool f2 = (instanceID[1] == VOXMaterial.MaxValue) ? true : palette[instanceID[1]].a != alpha ? true : false; bool f3 = (instanceID[2] == VOXMaterial.MaxValue) ? true : palette[instanceID[2]].a != alpha ? true : false; bool f4 = (instanceID[3] == VOXMaterial.MaxValue) ? true : palette[instanceID[3]].a != alpha ? true : false; bool f5 = (instanceID[4] == VOXMaterial.MaxValue) ? true : palette[instanceID[4]].a != alpha ? true : false; bool f6 = (instanceID[5] == VOXMaterial.MaxValue) ? true : palette[instanceID[5]].a != alpha ? true : false; faces.left = f1; faces.right = f2; faces.bottom = f3; faces.top = f4; faces.front = f5; faces.back = f6; } else { bool f1 = (instanceID[0] == VOXMaterial.MaxValue) ? true : palette[instanceID[0]].a < 255 ? true : false; bool f2 = (instanceID[1] == VOXMaterial.MaxValue) ? true : palette[instanceID[1]].a < 255 ? true : false; bool f3 = (instanceID[2] == VOXMaterial.MaxValue) ? true : palette[instanceID[2]].a < 255 ? true : false; bool f4 = (instanceID[3] == VOXMaterial.MaxValue) ? true : palette[instanceID[3]].a < 255 ? true : false; bool f5 = (instanceID[4] == VOXMaterial.MaxValue) ? true : palette[instanceID[4]].a < 255 ? true : false; bool f6 = (instanceID[5] == VOXMaterial.MaxValue) ? true : palette[instanceID[5]].a < 255 ? true : false; faces.left = f1; faces.right = f2; faces.bottom = f3; faces.top = f4; faces.front = f5; faces.back = f6; } return(faces.left | faces.right | faces.bottom | faces.top | faces.front | faces.back); }
public bool Exists(System.Byte x, System.Byte y, System.Byte z) { VOXMaterial instanceID = VOXMaterial.MaxValue; return(this.Get(x, y, z, ref instanceID)); }
public VOXHashMapNode() { element = int.MaxValue; }