Fix small implementation error in binary heap.

This commit is contained in:
IntegratedQuantum 2022-12-12 21:06:36 +01:00
parent 5051f9444a
commit 06aa06be86
3 changed files with 4 additions and 4 deletions

View File

@ -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 {

View File

@ -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);

View File

@ -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: