This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jetbrains.annotations.Contract; | |
import org.jetbrains.annotations.NotNull; | |
import java.awt.*; | |
import java.util.Random; | |
/** | |
* A utility library for performing calculations with colors represented as primitive ARGB integers. | |
*/ | |
public final class ColorMath { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constexpr size_t indexOf(int x, int y, int stride) | |
{ | |
return static_cast<size_t>(x + y * stride); | |
} | |
template <typename RGB> | |
void bresenhamDrawLineUnsafe(RGB *buffer, int w, int h, int x0, int y0, int x1, int y1, RGB rgb) | |
{ | |
const auto dx = x1 - x0, dy = y1 - y0; | |
const auto dxSign = mve::math::sgn(dx), dySign = mve::math::sgn(dy); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <cassert> | |
#include <set> | |
#include <tuple> | |
#include <random> | |
#include <memory.h> | |
#include <limits.h> | |
#include <functional> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[20:24:57] [DBUG] world.cpp@160: Allocated anonymous WorldVoxelObject with id 1ec7bd5b9ba331d1 | |
[20:24:57] [DBUG] voxelio_vox.cpp@98: calling voxelio::vox::Reader::init() | |
[20:24:57] [SPAM] voxelio_vox.cpp@238: reading MAIN (0self + 29498children = 29498) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping SIZE (12self + 0children = 12) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping XYZI (84self + 0children = 84) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping nTRN (28self + 0children = 28) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping nGRP (16self + 0children = 16) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping nTRN (43self + 0children = 43) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping nSHP (20self + 0children = 20) | |
[20:24:57] [SPAM] voxelio_vox.cpp@173: skipping LAYR (26self + 0children = 26) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UTIL_BITS_HPP | |
#define UTIL_BITS_HPP | |
#include <cstddef> | |
#include <cstdint> | |
#include <limits> | |
constexpr uint64_t ileave2(uint32_t x, uint32_t y) | |
{ | |
constexpr uint64_t MASKS_2[] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef SVO_HPP | |
#define SVO_HPP | |
#include "common_types.hpp" | |
#include "vec.hpp" | |
#include "vec_math.hpp" | |
#include "util_bits.hpp" | |
#include "util_common.hpp" | |
#include <algorithm> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef UTIL_BITS_HPP | |
#define UTIL_BITS_HPP | |
#include "assert.hpp" | |
#include "math.hpp" | |
#include "vec.hpp" | |
#include <algorithm> | |
#include <cstddef> | |
#include <cstdint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32_t fastMortonToHilbert3_32(const uint32_t morton, const unsigned iteration) noexcept | |
{ | |
// one specific permutation table for one specific case of morton <-> hilbert has very interesting properties | |
// it consists of 3 permutations (rot 1, xor 3, (rot 1, xor 6)) as well as their inverse | |
// rotations are all to the right | |
// the first column of this permutation table encodes the xor component (how convenient) | |
// the rotations simply have to be calculated but are always 0, 1, or 2 as a rotation of 3 is equiv. to 0 | |
constexpr uint32_t permTableXors = 0x5356'0300; // first digit of the 8 permutations, also encodes XOR component | |
constexpr uint32_t permTableRots = 0x2021'2021; // right-shifts of each permutation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Long division, unsigned (64/32 ==> 32). This procedure performs unsigned "long division" i.e., division of a 64-bit unsigned dividend by a 32-bit unsigned divisor, producing a 32-bit quotient. In the overflow cases (divide by 0, or quotient exceeds 32 bits), it returns a remainder of 0xFFFFFFFF (an impossible value). The dividend is u1 and u0, with u1 being the most significant word. The divisor is parameter v. The value returned is the quotient. Max line length is 57, to fit in hacker.book. */ | |
#define max(x, y)((x) > (y) ? (x) : (y)) | |
int nlz(unsigned x) { | |
int n; | |
if (x == 0) return (32); | |
n = 0; | |
if (x <= 0x0000FFFF) { | |
n = n + 16; | |
x = x << 16; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Long division, unsigned (64/32 ==> 32). | |
This procedure performs unsigned "long division" i.e., division of a | |
64-bit unsigned dividend by a 32-bit unsigned divisor, producing a | |
32-bit quotient. In the overflow cases (divide by 0, or quotient | |
exceeds 32 bits), it returns a remainder of 0xFFFFFFFF (an impossible | |
value). | |
The dividend is u1 and u0, with u1 being the most significant word. | |
The divisor is parameter v. The value returned is the quotient. | |
Max line length is 57, to fit in hacker.book. */ |
OlderNewer