X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Ftacos.cpp;h=fe1c7aa68c73bc1b5b5f3d39e39677c93b59d537;hb=57f81dc2a126e77e48e8962a9d6730c59ffddbda;hp=e477ab4a97e00a17da46bcbd151cea7eb0608480;hpb=2e761a60d1717297b7e308ef1b66e2a81319fdff;p=tacos.git diff --git a/src/tacos.cpp b/src/tacos.cpp index e477ab4..fe1c7aa 100644 --- a/src/tacos.cpp +++ b/src/tacos.cpp @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) { VP = viewport.Perspective() * V; { // mouse inverse_VP = glm::inverse(VP); - glm::vec2 clip_mouse((screen_mouse / glm::vec2(viewport.Width(), viewport.Height()) - 0.5f) * 2.0f); + glm::vec2 clip_mouse((screen_mouse * viewport.InverseSize() - 0.5f) * 2.0f); // viewport space has origin in lower left, but sdl gives coordinates with orgin in upper left, // so Y is inverted here (since it maps from -1 to 1 simply by negating) glm::vec4 ray_begin(inverse_VP * glm::vec4(clip_mouse.x, -clip_mouse.y, -1.0f, 1.0f)); @@ -227,10 +227,13 @@ int main(int argc, char *argv[]) { world_mouse.direction = glm::normalize((glm::vec3(ray_end) / ray_end.w) - world_mouse.origin); } + //std::cout << "ray " << world_mouse.origin << ", " << world_mouse.direction << std::endl; if (floor.Intersection(world_mouse, pointer)) { cursor.FloorTile(floor, int(pointer.x), int(pointer.z)); + //std::cout << " +++ intersecting at " << pointer << std::endl; } else { cursor.Hide(); + //std::cout << " --- not intersecting" << std::endl; } // render