Implemented a depth-first search random maze generator for my project. C++11 in a single file:
https://github.com/corporateshark/random-maze-generator
Here is the example of output:

Implemented a depth-first search random maze generator for my project. C++11 in a single file:
https://github.com/corporateshark/random-maze-generator
Here is the example of output:

I was curious why std::vector<>::pop_back() does not return the popped value. Instead, there is a pair of methods: void pop_back() and const_reference back() const.
The answer was obvious when I tried to implement a vector-like class myself. Here is the code for an implementation of a would-be T std::vector<>::pop_back():
T pop_back()
{
FSize -= 1;
// call copy ctor
T Copy( FArray[ FSize ] );
// call dtor
FArray[ FSize ].~T();
// return the copy - this can raise an exception,
// but the value has been already popped from the stack
return Copy;
}
The implementation of the canonical pop_back() is straightforward and does not perform any redundant fuss with copying:
void pop_back()
{
FSize -= 1;
// this is exception safe since the dtor never throws
FArray[ FSize ].~T();
}
I wanted to add varying density maps to my poisson points generator. For example, I want to use this density field to generate foliage:

I started with multiplying the MinDist parameter by the density value. This broke the entire algorithm. The solution that works is to generate a rectangle full of poisson points and then roll a dice for every point and discard it if the roll of the dice is above the density value at the considered point:
float R = RandomFloat(); float P = g_DensityMap[ x + y * ImageSize ]; if ( R > P ) continue;
Here is the resulting image:

The complete source code is on GitHub: https://github.com/corporateshark/poisson-disk-generator
Was looking for a good implementation of 2D random points generator in C++ for my project.
Found this algorithm and this tutorial.
Here is my own implementation in C++11 packed into a single C++ file:
https://github.com/corporateshark/poisson-disk-generator
I hope it is simple enough to be useful for you.

