Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/chris/src/collision.h @ 2010

Last change on this file since 2010 was 2010, checked in by chris, 20 years ago

orxonox/branches/chris: Even more doxygen tags added, now it gets dokumented without haveing to enable EXTRACT_ALL

File size: 2.4 KB
Line 
1
2#ifndef COLLISION_H
3#define COLLISION_H
4
5#include "vector.h"
6#include "coordinates.h"
7#include <stdlib.h>
8#include <stdio.h>
9#include <strings.h>
10
11typedef struct CC_Tree
12{
13  unsigned long n;
14  union
15  {
16  struct CC_Tree** b;
17  unsigned long ID;
18  } data;
19  float r;
20  Vector m;
21} CC_Tree;
22
23/**
24  This class implements a more or less efficient collision system based on nested hitzones.
25  Instead of using a brute force approach (try if any hitzone intersects with any other hitzone)
26  this features a tree of spheric hitzones. Only some of them are actually the solid groundstones
27  the collision model bases on, the others serve to group them into sets of spheres that are only
28  checked for collision when the assigned top level sphere has registered a collision, preventing
29  unnessessary checks (like between every sphere of two collision clusters at the other end of the world)
30  from being performed.
31  The CollisionCluster features collision detection between multiple CollisionClusters as well as
32  traceing a collision between a line of defined length and a cluster. In both cases the base spheres
33  that have intersected are marked with a flag in an unsigned long for hitlocation queries. In the case
34  of a trace, the exact point of interception is returned as well.
35*/
36
37class CollisionCluster {
38 
39  CC_Tree* root;
40 
41 
42 public:
43  CollisionCluster (float r, Vector m); // simple cluster
44  CollisionCluster (char* filename); // get cluster from file
45  ~CollisionCluster ();
46 
47  int store (char* filename);
48 
49  friend bool cctree_trace( const Placement* p, CC_Tree* t, unsigned long* hitflags, const Line* trace, Vector* impactpoint);
50  friend bool cctree_iterate(const Placement* pa, CC_Tree* ta, unsigned long* ahitflags, const Placement* pb, CC_Tree* tb, unsigned long* bhitflags);
51  friend bool check_trace (const Placement* pa, const CollisionCluster* a, unsigned long* ahitflags, const Line* trace, Vector* impactpoint);
52  friend bool check_collision (const Placement* pa, const CollisionCluster* a, unsigned long* ahitflags, const Placement* pb, const CollisionCluster* b, unsigned long* bhitflags);
53};
54
55bool sphere_sphere_collision( Vector m1, float r1, Vector m2, float r2);
56bool trace_sphere_collision( Vector m, float r, const Line* l, Vector* impactpoint);
57
58void setflag( unsigned long* flags, unsigned long ID);
59
60void free_CC_Tree( CC_Tree* tree);
61CC_Tree* load_CC_Tree (FILE* stream);
62int save_CC_Tree (CC_Tree* tree, FILE* stream);
63
64#endif
Note: See TracBrowser for help on using the repository browser.