Настроение: | accomplished |
Entry tags: | gamedev |
9000 segfaults later
Finally fixed the issue with painting in perspective projection.
The perspective projection code was correct all this time, but I had an bug in the code shared with orthogonal projection painting. The bug doesn't affect orthogonal projection, since all screen pixel vectors are parallel, but gets nasty in the perspective projection. Bug itself came out because I don't use the homogeneous matrices, so "translation" part of the linear equation is moved out, and at one point I forgot to add these x,y,z related to the objects center, resulting in projection points being slightly skewed. Guess I should refactor my code and move all matrix mult + translation instances into a separate method, so such nonsense wont ever happen again.