Pioneer
Geom.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _GEOM_H
5 #define _GEOM_H
6 
7 #include "../matrix4x4.h"
8 #include "../vector3.h"
9 
10 struct CollisionContact;
11 class GeomTree;
12 struct isect_t;
13 struct Sphere;
14 struct BVHNode;
15 
16 class Geom {
17 public:
18  Geom(const GeomTree *geomtree, const matrix4x4d &m, const vector3d &pos, void *data);
19  void MoveTo(const matrix4x4d &m);
20  void MoveTo(const matrix4x4d &m, const vector3d &pos);
21  inline const matrix4x4d &GetInvTransform() const { return m_invOrient; }
22  inline const matrix4x4d &GetTransform() const { return m_orient; }
23  //matrix4x4d GetRotation() const;
24  inline const vector3d &GetPosition() const { return m_pos; }
25  inline void Enable() { m_active = true; }
26  inline void Disable() { m_active = false; }
27  inline bool IsEnabled() const { return m_active; }
28  inline const GeomTree *GetGeomTree() const { return m_geomtree; }
29  void Collide(Geom *b, void (*callback)(CollisionContact *)) const;
30  void CollideSphere(Sphere &sphere, void (*callback)(CollisionContact *)) const;
31  inline void *GetUserData() const { return m_data; }
32  inline void SetMailboxIndex(int idx) { m_mailboxIndex = idx; }
33  inline int GetMailboxIndex() const { return m_mailboxIndex; }
34  inline void SetGroup(int g) { m_group = g; }
35  inline int GetGroup() const { return m_group; }
36 
38 
39 private:
40  void CollideEdgesWithTrisOf(int &maxContacts, const Geom *b, const matrix4x4d &transTo, void (*callback)(CollisionContact *)) const;
41  void CollideEdgesTris(int &maxContacts, const BVHNode *edgeNode, const matrix4x4d &transToB,
42  const Geom *b, const BVHNode *btriNode, void (*callback)(CollisionContact *)) const;
43 
44  // double-buffer position so we can keep previous position
45  matrix4x4d m_orient, m_invOrient;
46  vector3d m_pos;
47  const GeomTree *m_geomtree;
48  void *m_data;
49  int m_group;
50  int m_mailboxIndex; // used to avoid duplicate collisions
51  bool m_active;
52 };
53 
54 #endif /* _GEOM_H */
Definition: GeomTree.h:23
Definition: Geom.h:16
const matrix4x4d & GetInvTransform() const
Definition: Geom.h:21
void CollideSphere(Sphere &sphere, void(*callback)(CollisionContact *)) const
Definition: Geom.cpp:51
void Enable()
Definition: Geom.h:25
const matrix4x4d & GetTransform() const
Definition: Geom.h:22
void * GetUserData() const
Definition: Geom.h:31
void Collide(Geom *b, void(*callback)(CollisionContact *)) const
Definition: Geom.cpp:76
void MoveTo(const matrix4x4d &m)
Definition: Geom.cpp:36
int GetMailboxIndex() const
Definition: Geom.h:33
const GeomTree * GetGeomTree() const
Definition: Geom.h:28
Geom(const GeomTree *geomtree, const matrix4x4d &m, const vector3d &pos, void *data)
Definition: Geom.cpp:15
matrix4x4d m_animTransform
Definition: Geom.h:37
void SetGroup(int g)
Definition: Geom.h:34
const vector3d & GetPosition() const
Definition: Geom.h:24
bool IsEnabled() const
Definition: Geom.h:27
int GetGroup() const
Definition: Geom.h:35
void SetMailboxIndex(int idx)
Definition: Geom.h:32
void Disable()
Definition: Geom.h:26
Definition: BVHTree.h:13
Definition: CollisionContact.h:9
Definition: CollisionSpace.h:14
Definition: GeomTree.h:14