mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-09-13 06:16:45 -04:00
Fix small implementation error in binary heap.
This commit is contained in:
parent
5051f9444a
commit
06aa06be86
@ -61,7 +61,7 @@ uint getVoxel(int voxelIndex) {
|
|||||||
voxelIndex = (voxelIndex & 0xf) | (voxelIndex>>1 & 0xf0) | (voxelIndex>>2 & 0xf00);
|
voxelIndex = (voxelIndex & 0xf) | (voxelIndex>>1 & 0xf0) | (voxelIndex>>2 & 0xf00);
|
||||||
int shift = 4*(voxelIndex & 7);
|
int shift = 4*(voxelIndex & 7);
|
||||||
int arrayIndex = voxelIndex >> 3;
|
int arrayIndex = voxelIndex >> 3;
|
||||||
return (voxelModels[modelIndex].bitPackedData[arrayIndex]>>shift & 15);
|
return (voxelModels[modelIndex].bitPackedData[arrayIndex]>>shift & 15u);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RayMarchResult {
|
struct RayMarchResult {
|
||||||
|
@ -178,7 +178,7 @@ pub const Window = struct {
|
|||||||
if(c.gladLoadGL() == 0) {
|
if(c.gladLoadGL() == 0) {
|
||||||
return error.GLADFailed;
|
return error.GLADFailed;
|
||||||
}
|
}
|
||||||
c.glfwSwapInterval(1);
|
c.glfwSwapInterval(0);
|
||||||
|
|
||||||
if(@import("builtin").mode == .Debug) {
|
if(@import("builtin").mode == .Debug) {
|
||||||
c.glEnable(c.GL_DEBUG_OUTPUT);
|
c.glEnable(c.GL_DEBUG_OUTPUT);
|
||||||
|
@ -120,8 +120,8 @@ pub fn BlockingMaxHeap(comptime T: type) type {
|
|||||||
fn siftDown(self: *@This(), _i: usize) void {
|
fn siftDown(self: *@This(), _i: usize) void {
|
||||||
std.debug.assert(!self.mutex.tryLock()); // The mutex should be locked when calling this function.
|
std.debug.assert(!self.mutex.tryLock()); // The mutex should be locked when calling this function.
|
||||||
var i = _i;
|
var i = _i;
|
||||||
while(2*i + 2 < self.size) {
|
while(2*i + 1 < self.size) {
|
||||||
var biggest = if(self.array[2*i + 1].biggerThan(self.array[2*i + 2])) 2*i + 1 else 2*i + 2;
|
var biggest = if(2*i + 2 < self.size and self.array[2*i + 2].biggerThan(self.array[2*i + 1])) 2*i + 2 else 2*i + 1;
|
||||||
// Break if all childs are smaller.
|
// Break if all childs are smaller.
|
||||||
if(self.array[i].biggerThan(self.array[biggest])) return;
|
if(self.array[i].biggerThan(self.array[biggest])) return;
|
||||||
// Swap it:
|
// Swap it:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user