unibas-gravis / scalismo-faces

Scalable Image Analysis and Shape Modelling: Module to work with 2d images, with a focus on face images
Apache License 2.0
118 stars 27 forks source link

TriangleRenderer Bugfix #114

Closed imagar closed 6 years ago

imagar commented 6 years ago

Bug Description: Currently, the triangle bounding box is only considering the vertices of the triangle. All points in this bounding box are then checked for laying inside the triangle and only then for laying inside the viewport. For triangles with large areas outside the viewport, this slows the renderer down unbearably.

Bug Fix: Only check points that we already know lay inside the viewport by cropping the bounding box to the viewport.

sschoenborn commented 6 years ago

I like this update. Simple, but with a big effect in your case.

One minor detail: maximal values to access the buffer/viewport are buffer.width - 1 for x and accordingly for y.