Small tasks for beginners

There are some tasks that do not require enormous amounts of work or engine knowledge. We try to summarise them here.

Task: Legacy methods in array.h and string.h

Difficulty: 0/5 (anyone could do that)

Following some renaming/refactoring that occurred in trunk/src/lol/base/array.h and trunk/src/lol/base/string.h, some methods only remain here for backwards compatibility. Look for the string “TODO” in these files:

    /* TODO: remove these legacy functions one day */
    inline void Push(T... args) { push(args...); }
    inline void Insert(ptrdiff_t pos, T... args) { insert(pos, args...); }

Each of these methods needs to be removed and all resulting compilation errors fixed. Do not perform a blind search/replace, and pay attention to indentation.

Task: Variadic versions of min() and max()

Difficulty: 2/5 (understand variadic templates and move operator)

The prototypes for min() and max() in trunk/src/lol/base/functions.h are defined as follows:

    static inline T min(T x, T y) { return std::min(x, y); }
    static inline T max(T x, T y) { return std::max(x, y); }

We would like a variadic version that takes an arbitrary number of arguments instead. Maybe something like this:

    template<typename T, typename... Ts>
    static inline T min(T x, T y, Ts&&... z) { ... }

This will allow us to write the following:

float foo = min(x, y, z, w);

Be careful that the code should build with Visual Studio 2013, which is actually the real difficulty here.

Task: rand() for vector types

Difficulty: 2/5 (a lot of template code to read)

We would like to write the following code:

vec4 p1 = rand<vec4>();
vec3 p2 = rand(vec3(-1.f), vec3(1.f));

This involves specialising the following templates from trunk/src/lol/math/rand.h:

template<typename T> static inline T rand();
template<typename T> static inline T rand(T a);
template<typename T> static inline T rand(T a, T b);

Make sure it works for all vec_t<N,T> types, not just vec3 or vec4.

Task: degree 3 polynomial roots

Difficulty: 3/5 (some maths required)

The polynomial class in trunk/src/lol/math/polynomial.h has a roots() method that returns the polynomial roots for degrees ≤ 2.

I’d like to have an implementation for degree 3 polynomials.

Make sure to write unit tests for this code!

Task: switch to C++11 timers

Difficulty: 3/5

C++11 provides a high resolution clock type. Replace the platform-dependent code in trunk/src/sys/timer.cpp with portable code from std::chrono.

WIP tasks

Task: switch to C++11 threads (STARTED 2015/04/06 by Touky)

Difficulty: 3/5

C++11 provides threads and mutexes.

Finished tasks

Task: matrix inversion that doesn’t suck (DONE 2015/03/04 by guite)

Difficulty: 3/5 (some maths required)

The current implementation of matrix inversion in trunk/src/lol/math/matrix.h is the mediocre cofactor technique. It has factorial complexity which wasn’t a problem when we only had 4×4 matrices (though it was already slightly slow) but is no longer acceptable.


  • rewrite mat_t::inverse() but also mat_t::determinant() and get rid of mat_t::cofactor()
  • use Gauss-Jordan elimination in the general case (see trunk/tools/lolremez/matrix.h for a simple implementation
  • specialise inversion for 2×2, 3×3 and maybe 4×4 matrices (see this page for formulas)

Make sure to write unit tests for this code!

Last modified 8 years ago Last modified on Apr 7, 2015, 12:09:53 AM