bool QtwaylandSurfaceNode::computeLocalSurfaceIntersection(const Geometry::Ray &localRay, QPointF &localIntersection, float &t) const { Geometry::Plane surfacePlane = Geometry::Plane(glm::vec3(0.0f), glm::vec3(0.0f,0.0f,1.0f)); if(glm::dot(localRay.d, surfacePlane.n) == 0) return false; Geometry::Ray transformedRay = localRay.transform(glm::inverse(surfaceTransform())); t = surfacePlane.intersect(transformedRay); glm::vec3 intersection = transformedRay.solve(t); glm::vec3 coords= intersection * glm::vec3(m_surface->size().width(), m_surface->size().height(), 0); localIntersection = QPointF(coords.x, coords.y); return true; }
bool WaylandSurfaceNode::computeLocalSurfaceIntersection(const Geometry::Ray &localRay, glm::vec2 &localIntersection, float &t) { Geometry::Plane surfacePlane = Geometry::Plane(glm::vec3(0), glm::vec3(0,0,1)); if(glm::dot(localRay.d, surfacePlane.n) == 0) return false; Geometry::Ray transformedRay = localRay.transform(glm::inverse(surfaceTransform())); //transformedRay.print(); t = surfacePlane.intersect(transformedRay); //std::cout << "t = " << t << std::endl; glm::vec3 intersection = transformedRay.solve(t); //Geometry::printVector(glm::vec3(intersection)); //transformedRay.print(); //transformedRay.draw(this, glm::vec3(0,0,1), surfaceTransform()); glm::vec3 coords= intersection * glm::vec3(m_surface->size().x, m_surface->size().y, 0); localIntersection = glm::vec2(coords); return t >= 0; }