You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think we're effectively cutting off the top/right edge of the image in the current lesson 1 code.
I think the solution here would be to do something like this?
int x0 = (v0.x+1.)*(width - 1)/2.;
int y0 = (v0.y+1.)*(height - 1)/2.;
int x1 = (v1.x+1.)*(width - 1)/2.;
int y1 = (v1.y+1.)*(height - 1)/2.;
Happened to notice this because I implemented a difference image drawing class (for BMP instead of TGA), and I didn't have the bounds check in the set method.
As an easier way to confirm this, just comment out the bounds check code in TGAImage::set and you will get an out of bounds exception.
The text was updated successfully, but these errors were encountered:
I think we're saying that for example 1.0 as an x value in obj coordinates corresponds to the right side of the right-most pixel in image coordinates which seems logical to not draw.
Please correct if this is wrong here but I think there's a bug in the lesson one code when we draw the obj mesh.
Specifically here:
tinyrenderer/main.cpp
Line 49 in f6fecb7
If a vertex has a x/y value equal to 1.0 or -1.0, then x or y becomes equal to
width
/height
.The problem is the data variable in TGAImage has a max width/height of (width - 1)/(height - 1) because its zero indexed.
What is hiding this bug is the fact that we just exit TGAImage::set if the x/y is out of bounds:
tinyrenderer/tgaimage.cpp
Line 252 in f6fecb7
I think we're effectively cutting off the top/right edge of the image in the current lesson 1 code.
I think the solution here would be to do something like this?
Happened to notice this because I implemented a difference image drawing class (for BMP instead of TGA), and I didn't have the bounds check in the set method.
As an easier way to confirm this, just comment out the bounds check code in TGAImage::set and you will get an out of bounds exception.
The text was updated successfully, but these errors were encountered: