unproject_onto_mesh.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // This file is part of libigl, a simple c++ geometry processing library.
  2. //
  3. // Copyright (C) 2014 Daniele Panozzo <[email protected]>
  4. //
  5. // This Source Code Form is subject to the terms of the Mozilla Public License
  6. // v. 2.0. If a copy of the MPL was not distributed with this file, You can
  7. // obtain one at http://mozilla.org/MPL/2.0/.
  8. #ifndef IGL_EMBREE_UNPROJECT_ONTO_MESH_H
  9. #define IGL_EMBREE_UNPROJECT_ONTO_MESH_H
  10. #include "../igl_inline.h"
  11. #include <Eigen/Core>
  12. #include <vector>
  13. namespace igl
  14. {
  15. namespace embree
  16. {
  17. // Forward define
  18. class EmbreeIntersector;
  19. /// Unproject a screen location (using the given model, proj and viewport) to find
  20. /// the first hit on a mesh.
  21. ///
  22. /// @param[in] pos screen space coordinates
  23. /// @param[in] model model matrix
  24. /// @param[in] proj projection matrix
  25. /// @param[in] viewport vieweport vector
  26. /// @param[in] ei EmbreeIntersector containing (V,F)
  27. /// @param[out] fid id of the first face hit
  28. /// @param[out] bc barycentric coordinates of hit
  29. /// @return true if there is a hit
  30. IGL_INLINE bool unproject_onto_mesh(
  31. const Eigen::Vector2f& pos,
  32. const Eigen::Matrix4f& model,
  33. const Eigen::Matrix4f& proj,
  34. const Eigen::Vector4f& viewport,
  35. const EmbreeIntersector & ei,
  36. int& fid,
  37. Eigen::Vector3f& bc);
  38. /// \overload
  39. /// @param[in] vid vertex id of the closest vertex hit
  40. IGL_INLINE bool unproject_onto_mesh(
  41. const Eigen::Vector2f& pos,
  42. const Eigen::MatrixXi& F,
  43. const Eigen::Matrix4f& model,
  44. const Eigen::Matrix4f& proj,
  45. const Eigen::Vector4f& viewport,
  46. const EmbreeIntersector & ei,
  47. int& fid,
  48. int& vid);
  49. }
  50. }
  51. #ifndef IGL_STATIC_LIBRARY
  52. # include "unproject_onto_mesh.cpp"
  53. #endif
  54. #endif