C++ minimal std::any

A few days ago I wrote a simple alternative to std::any. It is heavily inspired by Sean Parent’s talk Better Code: Runtime Polymorphism. If you don’t know what std::any is, basically it is a structure that can hold data of any type, while maintaining the value semantics. With C++11 this is really easily done in just a few lines. I’m still unsure how and where can I use it. // "struct object" is the magic type. [Read More]

C++ reflection/introspection system

Why do I need this?      As some of you may know, I’m writing a game in my spare time. In order to make the level/game editor usable, I have to be able to quickly display and edit values. Doing the UI/Serialization/UndoRedo by hand for every type is just too much. The solution to that problem is usually some kind of reflection or introspection system.     Unfortunately C++ does not have a built in solution. [Read More]

2D Animation In Maya: Import images as planes

A while ago I wanted to create a simple 2D “cut-out” animation, just a few images imported and assigned on a planes. Unfortunately, Maya did not had this functionally built in. Doing this by hand requires you to: Create a File Texture Create some material and assign the texture as diffuse colour and alpha Create a plane with correct width/height ratio Modify the UV channel Assign the previously created material to the plane And on top of that you’ve got to do it for every single image that you want to use. [Read More]

C++ Code Snippets 1

This is a set of some code snippets that you might find useful. The 1st one is pretty popular, but I use it in the snippets below. Basically it is A way to retrieve the size of a C++ array. template <typename T, size_t N> char (&TArrSize_Safe(T (&)[N]))[N]; #define ARRSZ(A) (sizeof(TArrSize_Safe(A))) // Usage int myArray[1234]; printf("myArray has %d elements!" ARRSZ(myArray)); printf style std::string formatting: // The caller is EXPECTED to call va_end on the va_list args inline void string_format(std::string& retval, const char* const fmt_str, va_list args) { // [CAUTION] // Under Windows with msvc it is fine to call va_start once and then use the va_list multiple times. [Read More]