I am trying to use Camera::Project and Context::DrawLine to draw a 2d grid in 3d space for an map editor I am working on, but if 1 of the points go behind the camera, the grid gets goofy and is not drawing the line to connect to where it should in 3D space. Is this a bug or am I doing something wrong?
I see that the "Z" axis goes to a negative number when the point is behind the camera, but I don't understand why the X & Y axis go way out of what they are supposed to be nor how to get them to what they are supposed to be.
I have written a simple code snippet that does the same issue:
Vec3 p1 = Vec3(context->GetWidth()/2, context->GetHeight()/2, 0);
Vec3 p2 = camera->Project(Vec3(0, 0, 10));
context->DrawLine(p1.x, p1.y, p2.x, p2.y);
Here is a screenshot of what I am experiencing with the code above: