Implementing a null object to allow deselection
Adding a deselection by doing a click into the background of the application window comes with a bunch of interesting implications. For instance, the position 0
may be a valid index in the miAssimpInstance
vector, stating that the first instance has been selected. So, simply using zero to signal that no instances are selected does not work. Even worse: Using zero as the first index may confuse users of the application, as it is not intentional to start counting numbers at zero, instead of one.
In addition, the default buffer background value of –1
is an invalid array index. Using the value of -1
as an index into the miAssimpInstance
vector would simply crash the application. Since we will use the instance vector frequently in the code, adding a range check for every single access would be crucial because even missing a single check will lead to a crash.
So, we need another signalling mechanism to switch between the two...