MCPcopy Create free account
hub / github.com/RenderKit/embree / clickFunc

Method clickFunc

tutorials/common/tutorial/tutorial.cpp:825–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

823 }
824
825 void TutorialApplication::clickFunc(GLFWwindow* window, int button, int action, int mods)
826 {
827 ImGui_ImplGlfw_MouseButtonCallback(window,button,action,mods);
828 if (ImGui::GetIO().WantCaptureMouse) return;
829
830 double x,y;
831 glfwGetCursorPos(window,&x,&y);
832
833 if (action == GLFW_RELEASE)
834 {
835 mouseMode = 0;
836 }
837 else if (action == GLFW_PRESS)
838 {
839 if (button == GLFW_MOUSE_BUTTON_RIGHT)
840 {
841 ISPCCamera ispccamera = camera.getISPCCamera(width,height);
842 Vec3fa p; bool hit = device_pick(float(x),float(y),ispccamera,p);
843
844 if (hit) {
845 Vec3fa delta = p - camera.to;
846 Vec3fa right = normalize(ispccamera.xfm.l.vx);
847 Vec3fa up = normalize(ispccamera.xfm.l.vy);
848 camera.to = p;
849 camera.from += dot(delta,right)*right + dot(delta,up)*up;
850 }
851 }
852 else if (button == GLFW_MOUSE_BUTTON_MIDDLE) {
853 printf("pixel pos (%d, %d)\n", (int)x, (int)y);
854 }
855 else
856 {
857 clickX = x; clickY = y;
858 if (button == GLFW_MOUSE_BUTTON_LEFT && mods == GLFW_MOD_SHIFT) mouseMode = 1;
859 else if (button == GLFW_MOUSE_BUTTON_LEFT && mods == GLFW_MOD_CONTROL ) mouseMode = 3;
860 else if (button == GLFW_MOUSE_BUTTON_LEFT) mouseMode = 4;
861 }
862 }
863 }
864
865 void TutorialApplication::motionFunc(GLFWwindow* window, double x, double y)
866 {

Callers 1

clickFuncFunction · 0.80

Calls 5

device_pickFunction · 0.85
getISPCCameraMethod · 0.80
normalizeFunction · 0.50
dotFunction · 0.50

Tested by

no test coverage detected