added origin to mapper parameters
This commit is contained in:
+2
-2
@@ -28,7 +28,7 @@ namespace UwU {
|
||||
Coord2 uv;
|
||||
|
||||
for (int16_t x = ix0; x < ix1; x++) {
|
||||
uv = mapper.map(x, y);
|
||||
uv = mapper.map(ix0, iy0, x, y);
|
||||
buffer.drawPixel((uint16_t)x, (uint16_t)y, shader.shade(uv.x, uv.y));
|
||||
if (d > 0) {
|
||||
y += yi;
|
||||
@@ -56,7 +56,7 @@ namespace UwU {
|
||||
Coord2 uv;
|
||||
|
||||
for (int16_t y = iy0; y < iy1; y++) {
|
||||
uv = mapper.map(x, y);
|
||||
uv = mapper.map(ix0, iy0, x, y);
|
||||
buffer.drawPixel((uint16_t)x, (uint16_t)y, shader.shade(uv.x, uv.y));
|
||||
if (d > 0) {
|
||||
x += xi;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace UwU {
|
||||
template <class MapperT, class ShaderT>
|
||||
void draw (Buffer buffer, MapperBase<MapperT>& mapper, ShaderBase<ShaderT>& shader) {
|
||||
if (x > buffer.width || y > buffer.height) {return;};
|
||||
Coord2 uv = mapper.map(x, y);
|
||||
Coord2 uv = mapper.map(x, y, x, y);
|
||||
buffer.drawPixel(x, y, shader.shade(uv.x, uv.y));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace UwU {
|
||||
if (x0 > buffer.width || y0 > buffer.height || x1 > buffer.width || y1 > buffer.height) {return;};
|
||||
for (uint16_t y = y0; y <= y1; y++) {
|
||||
for (uint16_t x = x0; x <= x1; x++) {
|
||||
Coord2 uv = mapper.map(x, y);
|
||||
Coord2 uv = mapper.map(x0, y0, x, y);
|
||||
buffer.drawPixel(x, y, shader.shade(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,12 @@ namespace UwU {
|
||||
|
||||
Helpers::bresenham(0, xl0, y1 - y0, xl1, LeftBound);
|
||||
Helpers::bresenham(0, xr0, y1 - y0, xr1, RightBound);
|
||||
|
||||
uint16_t x0 = std::min(xl0, xl1);
|
||||
|
||||
for (uint16_t i = 0; i < height; i++) {
|
||||
for (uint16_t x = LeftBound[i]; x <= RightBound[i]; x++) {
|
||||
Coord2 uv = mapper.map(x, i + y0);
|
||||
Coord2 uv = mapper.map(x0, y0, x, i + y0);
|
||||
buffer.drawPixel(x, i + y0, shader.shade(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,13 +91,15 @@ namespace UwU {
|
||||
// Calculate LUT for short two lines
|
||||
Helpers::bresenham(0, topX, midY - topY, midX, splitBound);
|
||||
Helpers::bresenham(midY - topY, midX, height - 1, btmX, splitBound);
|
||||
|
||||
Coord2 uv;
|
||||
uint16_t leftX = std::min(topX, std::min(midX, btmX));
|
||||
|
||||
// Left-handed triangle case (midpoint is left of triangle)
|
||||
if ((int16_t)midX < longBound[midY - topY]) {
|
||||
for (uint16_t i = 0; i < height; i++) {
|
||||
for (uint16_t x = (uint16_t)splitBound[i]; x <= (uint16_t)longBound[i]; x++) {
|
||||
uv = mapper.map(x, i + (uint16_t)topY);
|
||||
uv = mapper.map(leftX, topY, x, i + (uint16_t)topY);
|
||||
buffer.drawPixel(x, i + (uint16_t)topY, shader.shade(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
@@ -105,7 +107,7 @@ namespace UwU {
|
||||
} else {
|
||||
for (uint16_t i = 0; i < height; i++) {
|
||||
for (uint16_t x = (uint16_t)longBound[i]; x <= (uint16_t)splitBound[i]; x++) {
|
||||
uv = mapper.map(x, i + (uint16_t)topY);
|
||||
uv = mapper.map(leftX, topY, x, i + (uint16_t)topY);
|
||||
buffer.drawPixel(x, i + (uint16_t)topY, shader.shade(uv.x, uv.y));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user