Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSpatialTest.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cSpatialTest_H
7 #define _INC_cSpatialTest_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cSpatialObject.h"
15 
16 namespace Gray3D
17 {
18  // MIDL_INTERFACE("0C3E2E71-B93C-11d2-AAD0-006007654117") ISpatialTestVisitor
20  {
25 
27 
30  virtual bool ObjectIntersect(cSpatialObject* pObj) = 0; // true or full intersection. GINTERSECT_TYPE
31 
32  // these are called on partial intersection - frustum can be used for further (sub-objects) spatialization
33  // get rid of these ??? use GINTERSECT_TYPE
34  virtual bool ObjectIntersectSphere(cSpatialObject* pObj, const cSpheref& sphere) = 0;
35  virtual bool ObjectIntersectBounds(cSpatialObject* pObj, const cBounds3f& bbox) = 0;
36  virtual bool ObjectIntersectSegment(cSpatialObject* pObj, const cSegment3f& segment) = 0;
37  virtual bool ObjectIntersectHex(cSpatialObject* pObj, const cHexahedron& frustum, cHexahedron::PLANES_MASK_t planes) = 0;
38  };
39 
41  {
47 
48  public:
49  UINT _Count = 0;
50 
51  public:
53  {}
54  virtual bool ObjectIntersect(cSpatialObject* pObj) override
55  {
57  ASSERT(pObj != nullptr);
58  _Count++;
59  return true;
60  }
61  virtual bool ObjectIntersectSphere(cSpatialObject* pObj, const cSpheref& sphere) override
62  {
64  UNREFERENCED_REFERENCE(sphere);
65  return ObjectIntersect(pObj);
66  }
67  virtual bool ObjectIntersectBounds(cSpatialObject* pObj, const cBounds3f& bbox) override
68  {
71  return ObjectIntersect(pObj);
72  }
73  virtual bool ObjectIntersectSegment(cSpatialObject* pObj, const cSegment3f& segment) override
74  {
76  UNREFERENCED_REFERENCE(segment);
77  return ObjectIntersect(pObj);
78  }
79  virtual bool ObjectIntersectHex(cSpatialObject* pObj, const cHexahedron& frustum, cHexahedron::PLANES_MASK_t planes) override
80  {
82  UNREFERENCED_REFERENCE(frustum);
83  UNREFERENCED_PARAMETER(planes);
84  return ObjectIntersect(pObj);
85  }
86  };
87 
88  template< class _TYPE = cSpatialObject >
90  : public cArrayPtr< _TYPE >
91  , public cSpatialTestVisitor
92  {
96  public:
97  virtual bool ObjectIntersect(cSpatialObject* pObj) override
98  {
100  ITERATE_t i = this->AddTail(CHECKPTR_CAST(_TYPE, pObj));
101  _Count++;
102  return i >= 0 ;
103  }
104  };
105 
107  {
112 
113  virtual bool TraverseIntersectSphere(ISpatialTestVisitor* pResults, const cSpheref& bsphere) const = 0;
114  virtual bool TraverseIntersectBounds(ISpatialTestVisitor * pResults, const cBounds3f & bbox) const = 0;
115  virtual bool TraverseIntersectHex(ISpatialTestVisitor* pResults, const cHexahedron& frustum) = 0;
116  virtual bool TraverseIntersectSegment(ISpatialTestVisitor* pResults, const cSegment3f& segment) = 0;
117 
118  // Just get all objects in the system.
119  virtual bool TraverseAll(ISpatialTestVisitor* pResults) const = 0;
120  };
121 }
122 #endif
#define IGNORE_WARN_INTERFACE(c)
Definition: GrayCore.h:79
#define CHECKPTR_CAST(t, p)
Definition: PtrCast.h:50
#define UNREFERENCED_PARAMETER(P)
< _WIN32 type thing. get rid of stupid warning.
Definition: SysTypes.h:299
#define UNREFERENCED_REFERENCE(x)
Definition: SysTypes.h:318
#define ASSERT(exp)
Definition: cDebugAssert.h:87
Definition: cSpatialObject.h:21
Definition: cSpatialTest.h:92
virtual bool ObjectIntersect(cSpatialObject *pObj) override
Definition: cSpatialTest.h:97
Definition: cSpatialTest.h:41
UINT _Count
Definition: cSpatialTest.h:49
virtual ~cSpatialTestVisitor()
Definition: cSpatialTest.h:52
virtual bool ObjectIntersectHex(cSpatialObject *pObj, const cHexahedron &frustum, cHexahedron::PLANES_MASK_t planes) override
Definition: cSpatialTest.h:79
virtual bool ObjectIntersectSphere(cSpatialObject *pObj, const cSpheref &sphere) override
Definition: cSpatialTest.h:61
virtual bool ObjectIntersectSegment(cSpatialObject *pObj, const cSegment3f &segment) override
Definition: cSpatialTest.h:73
virtual bool ObjectIntersect(cSpatialObject *pObj) override
Definition: cSpatialTest.h:54
virtual bool ObjectIntersectBounds(cSpatialObject *pObj, const cBounds3f &bbox) override
Definition: cSpatialTest.h:67
Definition: cHexahedron.h:18
UINT PLANES_MASK_t
Bit Mask of the 6 planes.
Definition: cHexahedron.h:24
Definition: cSegment3.h:20
Definition: cSphere.h:20
Definition: cArray.h:864
ITERATE_t AddTail(TYPE * newElement)
Definition: cArray.h:666
Definition: cSpatialTest.h:19
Definition: cSpatialTest.h:106
Definition: Gray3D.cpp:12
DECLARE_INTERFACE(ISpatialTestVisitor)
int ITERATE_t
like size_t but signed
Definition: Index.h:28