All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
InteriorsEntityPickingService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "Types.h"
6 #include "IMultipleResultRayCaster.h"
7 #include "InteriorInteractionModel.h"
8 #include "Interiors.h"
9 #include "EnvironmentFlatteningService.h"
10 #include "CollisionBvh.h"
11 #include "IInteriorsEntityPicker.h"
12 #include "Camera.h"
13 #include "DebugRendering.h"
14 
15 #include <vector>
16 #include <string>
17 
18 namespace Eegeo
19 {
20  namespace Resources
21  {
22  namespace Interiors
23  {
24  namespace Entities
25  {
27  {
28  public:
31  InteriorInteractionModel& interiorInteractionModel,
32  const InteriorsInstanceRepository& instanceRepository,
33  const Eegeo::Rendering::EnvironmentFlatteningService& environmentFlatteningService,
35  bool debugDrawEnabled
36  );
37 
39 
40  virtual bool PickEntitiesAtScreenPosition(const Eegeo::Camera::RenderCamera& renderCamera, const v2& point, InteriorsEntityPickResult& out_result) const;
41  virtual bool PickEntitiesAtScreenPosition(const Eegeo::Camera::CameraState& cameraState, const v2& screenPoint, InteriorsEntityPickResult& out_result) const;
42 
43  private:
44 
45  typedef std::pair<Collision::RayCasterResult, std::string> RayCasterResultWithId;
46 
47  std::vector<RayCasterResultWithId> FindRayIntersectionsWithHighlights(const dv3& rayOriginEcef, const dv3& rayDirectionEcef) const;
48  std::vector<RayCasterResultWithId> FindRayIntersectionsWithInstancedEntities(const dv3& rayOriginEcef, const dv3& rayDirectionEcef) const;
49 
50  Collision::RayCasterResult FindFirstRayIntersectionWithInstancedEntity(
51  const InstanceStore& entityInstanceStore,
52  const dv3& rayOriginEcef,
53  const dv3& rayDirectionEcef,
54  const m44& environmentFlattenTransform
55  ) const;
56 
57  Collision::RayCasterResult FindFirstRayIntersectionWithTransformedBvh(
58  const Collision::CollisionBvh& entityCollisionBvh,
59  const m44& entityModelTransform,
60  const m44& entityInverseModelTransform,
61  const dv3& rayOriginEcef,
62  const dv3& rayDirectionEcef) const;
63 
64 
65  bool TryGetEntityIdFromRayCastResult(const Eegeo::Collision::RayCasterResult& pickResult, std::string& out_id) const;
66 
67  InteriorsEntityPickResult MakeInteriorsEntityPickResult(const std::vector<RayCasterResultWithId>& rayCasterResults) const;
68 
69  void DebugDrawInstancedEntityPicking(
70  const InstanceStore& entityInstanceStore,
71  const m44& entityModelTransform,
72  const m44& entityInverseModelTransform,
73  const dv3& rayOriginEcef,
74  const dv3& rayDirectionEcef,
75  const Collision::RayCasterResult& firstIntersection
76  ) const;
77 
79  const InteriorInteractionModel& m_interiorInteractionModel;
80  const InteriorsInstanceRepository& m_instanceRepository;
81  const Eegeo::Rendering::EnvironmentFlatteningService& m_environmentFlatteningService;
82  Eegeo::DebugRendering::DebugRenderer& m_debugRenderer;
83  bool m_debugDrawEnabled;
84 
85 
86  };
87  }
88  }
89  }
90 }