#Pygame draw dashed line code#
Mistakes in C++ code meant crashing the whole app. I much preferred having a managed language (C# or javascript) in Unity than the C++ support in UE4.
And the reasons were written up in an Internal bug report ( UE-11247 apparently) that the UE4 developers constantly refer to, but users aren’t actually allowed to view or see the status of! More annoyingly, it didn’t say why it didn’t work, it just simply disabled the Preview In VR button, giving no reason. This sucked because my artists all use Macs. UE4’s VR support simply didn’t work on a Mac.With UE4 it seemed so much more difficult. I could buy an asset and import it into my game with a couple of clicks.
#Pygame draw dashed line generator#
It is quite easy to modify the function to be a generator instead of adding a coordinate pair to points, yield it instead: def getLine(start, end): Consider changing the function getLine() to be a generator instead, so it returns a point at a time. The function getLine() creates a list of pixel coordinates, and then drawLine() iterates over it once, drawing each individual pixel, and then discards the list. Secondly, in fillFlatBottom and fillFlatTop functions, in for loops for both the functions, the upper and lower bound of range is converted to int because vertices of triangle making a mesh use floating point numbers, which might be avoidable through techniques i might not be aware of. This is passed to getLine, which forced me to convert them to int, otherwise it causes error as for loop in getLine function expects int. Invm1 and invm2 are inverse of slopes of 2 sides making up a triangle, which are always floating point numbers. It is called like this( drawLine calls getLine) drawLine(Vec2(curx1, y), Vec2(curx2, y)) I read that the whole point of bresenham's algorithm is to avoid this rounding off, but in my case i couldn't avoid it. Firstly, in getLine function, it converts the points it receives as arguments from float to int. I can see a couple of things which might be causing problems. When i tried to rotate the mesh, it causes heavy lag, so it is clearly of no use in rendering bigger models(by bigger models, i mean a cube. I tried implementing the code shown above to fill in a mesh (made of only 2 triangles). My goal is to fill in triangles that make up a 3d mesh. It uses bresenham's line algorithm and scan line algorithm to draw lines and fill triangle respectively. # RETURNS ALL THE PIXELS THAT NEEDS TO BE FILLED TO FORM A LINE I wrote the following script to fill a Triangle.