Skip to content
Snippets Groups Projects
Commit 511f02ce authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Don't render massive triangles

parent 57b8a480
No related branches found
No related tags found
1 merge request!151Implements #216 triangle renderer
...@@ -136,16 +136,16 @@ float getZAtCoordinate(const float3 &barycentricCoord, const float (&tri)[3]) { ...@@ -136,16 +136,16 @@ float getZAtCoordinate(const float3 &barycentricCoord, const float (&tri)[3]) {
const int maxX = max(v[0].x, max(v[1].x, v[2].x)); const int maxX = max(v[0].x, max(v[1].x, v[2].x));
const int maxY = max(v[0].y, max(v[1].y, v[2].y)); const int maxY = max(v[0].y, max(v[1].y, v[2].y));
//if ((maxX - minX) * (maxY - minY) > 200) return; if ((maxX - minX) * (maxY - minY) > 200) return;
int incx = ((maxX - minX) / 20) + 1; //int incx = ((maxX - minX) / 20) + 1;
int incy = ((maxY - minY) / 20) + 1; //int incy = ((maxY - minY) / 20) + 1;
float2 vs0 = make_float2(v[0].x, v[0].y); float2 vs0 = make_float2(v[0].x, v[0].y);
float2 vs1 = make_float2(v[1].x, v[1].y); float2 vs1 = make_float2(v[1].x, v[1].y);
float2 vs2 = make_float2(v[2].x, v[2].y); float2 vs2 = make_float2(v[2].x, v[2].y);
for (int sy=minY; sy <= maxY; sy+=incy) { for (int sy=minY; sy <= maxY; ++sy) {
for (int sx=minX; sx <= maxX; sx+=incx) { for (int sx=minX; sx <= maxX; ++sx) {
if (sx >= params.camera.width || sx < 0 || sy >= params.camera.height || sy < 0) continue; if (sx >= params.camera.width || sx < 0 || sy >= params.camera.height || sy < 0) continue;
//float2 q = make_float2(sx, sy); //float2 q = make_float2(sx, sy);
//float s = det(q - vs0, vs1) / det(vs0, vs1); //cross(q, vs2) / cross(vs1, vs2); //float s = det(q - vs0, vs1) / det(vs0, vs1); //cross(q, vs2) / cross(vs1, vs2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment