Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/cpu_voxelizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ namespace cpu_voxelizer {

// Set specific bit in voxel table
void setBit(unsigned int* voxel_table, size_t index) {
size_t int_location = index / size_t(32);
uint32_t bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR
size_t int_location = index >> 5;
uint32_t bit_pos = size_t(31) - (location & s31);
uint32_t mask = 1 << bit_pos | 0;
#pragma omp critical
{
voxel_table[int_location] = (voxel_table[int_location] | mask);
}
#pragma omp atomic
voxel_table[int_location] |= mask;
}


Expand Down Expand Up @@ -194,13 +192,11 @@ namespace cpu_voxelizer {

// use Xor for voxels whose corresponding bits have to flipped
void setBitXor(unsigned int* voxel_table, size_t index) {
size_t int_location = index / size_t(32);
unsigned int bit_pos = size_t(31) - (index % size_t(32)); // we count bit positions RtL, but array indices LtR
size_t int_location = index >> 5;
unsigned int bit_pos = size_t(31) - (location & 31);
unsigned int mask = 1 << bit_pos;
#pragma omp critical
{
voxel_table[int_location] = (voxel_table[int_location] ^ mask);
}
#pragma omp atomic
voxel_table[int_location] ^= mask;
}

bool TopLeftEdge(glm::vec2 v0, glm::vec2 v1) {
Expand Down Expand Up @@ -326,4 +322,4 @@ namespace cpu_voxelizer {
}
cpu_voxelization_timer.stop(); fprintf(stdout, "[Perf] CPU voxelization time: %.1f ms \n", cpu_voxelization_timer.elapsed_time_milliseconds);
}
}
}