physics_query_assistant.h
1 /*
2 ** ClanLib SDK
3 ** Copyright (c) 1997-2013 The ClanLib Team
4 **
5 ** This software is provided 'as-is', without any express or implied
6 ** warranty. In no event will the authors be held liable for any damages
7 ** arising from the use of this software.
8 **
9 ** Permission is granted to anyone to use this software for any purpose,
10 ** including commercial applications, and to alter it and redistribute it
11 ** freely, subject to the following restrictions:
12 **
13 ** 1. The origin of this software must not be misrepresented; you must not
14 ** claim that you wrote the original software. If you use this software
15 ** in a product, an acknowledgment in the product documentation would be
16 ** appreciated but is not required.
17 ** 2. Altered source versions must be plainly marked as such, and must not be
18 ** misrepresented as being the original software.
19 ** 3. This notice may not be removed or altered from any source distribution.
20 **
21 ** Note: Some of the libraries ClanLib may link to may have additional
22 ** requirements or restrictions.
23 **
24 ** File Author(s):
25 **
26 ** Arkadiusz Kalinowski
27 */
28 
29 
30 #pragma once
31 
32 #include "../api_physics2d.h"
33 #include "query_result.h"
34 #include "../../Core/Math/rect.h"
35 
36 
37 namespace clan
38 {
41  class PhysicsWorld;
42  class PhysicsQueryAssistant_Impl;
43  class Pointf;
44 
45 class CL_API_PHYSICS PhysicsQueryAssistant
46 {
49 public:
52 
57 
59 
63 
65  bool is_null() const { return !impl; }
66 
68  bool has_query_result();
69 
71  int get_query_result_amount();
72 
74  QueryResult get_query_result(int id = 0);
75 
77  Rectf prepare_rect(const Pointf &point, const float range = 0.001f);
78 
80  Rectf prepare_rect(const int x, const int y, const float range = 0.001f);
81 
83  Rectf prepare_rect(const float x, const float y, const float range = 0.001f);
84 
85 
89 
91  void raycast_first(const Pointf &start, const Pointf &end);
92 
94  void raycast_any(const Pointf &start, const Pointf &end);
95 
97  void raycast_all(const Pointf &start, const Pointf &end);
98 
100  void query_any(const Rectf &rect);
101 
103  void query_some(const Rectf &rect, const int amount);
104 
106  void query_all(const Rectf &rect);
107 
108 protected:
109 
111  inline void raycast(const Pointf &start, const Pointf &end);
112 
114  inline void query(const Rectf &rect);
115 
119 
120 private:
121  std::shared_ptr<PhysicsQueryAssistant_Impl> impl;
122 
124 };
125 
126 }
127 
128 /// \}
2D (left,top,right,bottom) rectangle structure - Float
Definition: rect.h:467
Top-level world class.
Definition: physics_world.h:52
bool is_null() const
Returns true if this object is invalid.
Definition: physics_query_assistant.h:65
Used by physics query assistant.
Definition: query_result.h:57
Definition: physics_query_assistant.h:45
2D (x,y) point structure - Float
Definition: point.h:73