collision_data.h 2.58 KB
Newer Older
sachinc's avatar
sachinc committed
1
2
3
4
5
6
#ifndef FCL_COLLISION_DATA_H
#define FCL_COLLISION_DATA_H

#include "fcl/collision_object.h"
#include "fcl/vec_3f.h"
#include <vector>
jpan's avatar
jpan committed
7
#include <limits>
sachinc's avatar
sachinc committed
8
9
10
11
12
13
14


namespace fcl
{

struct Contact
{
15
  FCL_REAL penetration_depth;
sachinc's avatar
sachinc committed
16
17
  Vec3f normal;
  Vec3f pos;
18
19
  const CollisionGeometry* o1;
  const CollisionGeometry* o2;
sachinc's avatar
sachinc committed
20
21
22
23
24
25
26
27
28
29
30
  int b1;
  int b2;

  Contact()
  {
    o1 = NULL;
    o2 = NULL;
    b1 = -1;
    b2 = -1;
  }

31
  Contact(const CollisionGeometry* o1_, const CollisionGeometry* o2_, int b1_, int b2_)
sachinc's avatar
sachinc committed
32
33
34
35
36
37
38
  {
    o1 = o1_;
    o2 = o2_;
    b1 = b1_;
    b2 = b2_;
  }

39
  Contact(const CollisionGeometry* o1_, const CollisionGeometry* o2_, int b1_, int b2_,
40
          const Vec3f& pos_, const Vec3f& normal_, FCL_REAL depth_)
sachinc's avatar
sachinc committed
41
42
43
44
45
46
47
48
49
50
51
  {
    o1 = o1_;
    o2 = o2_;
    b1 = b1_;
    b2 = b2_;
    normal = normal_;
    pos = pos_;
    penetration_depth = depth_;
  }
};

52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
struct CostSource
{
  Vec3f aabb_min;
  Vec3f aabb_max;
  FCL_REAL cost; // density
};

struct CollisionRequest
{
  bool exhaustive;
  int num_max_contacts;
  bool enable_contact;
  int num_max_cost_sources;
  bool enable_cost;

  CollisionRequest(bool exhaustive_ = false,
                   unsigned int num_max_contacts_ = 1,
                   bool enable_contact_ = false,
                   unsigned int num_max_cost_sources_ = 1,
                   bool enable_cost_ = false) : exhaustive(exhaustive_),
                                                num_max_contacts(num_max_contacts_),
                                                enable_contact(enable_contact_),
                                                num_max_cost_sources(num_max_cost_sources_),
                                                enable_cost(enable_cost_)
  {
  }

};


struct CollisionResult
{
  std::vector<Contact> contacts;
  std::vector<CostSource> cost_sources;

  bool is_collision;

  CollisionResult() : is_collision(false)
  {
  }

  void clear()
  {
    contacts.clear();
    cost_sources.clear();
    is_collision = false;
  }
};


sachinc's avatar
sachinc committed
102
103
104
105
106
107
108
struct CollisionData
{
  CollisionData()
  {
    done = false;
  }

109
110
  CollisionRequest request;
  CollisionResult result;
sachinc's avatar
sachinc committed
111
  bool done;
112
};
sachinc's avatar
sachinc committed
113

114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136

struct DistanceRequest
{
  bool enable_nearest_points;
  DistanceRequest() : enable_nearest_points(false)
  {
  }
};

struct DistanceResult
{
  FCL_REAL min_distance;

  Vec3f nearest_points[2];
  
  DistanceResult() : min_distance(std::numeric_limits<FCL_REAL>::max())
  {
  }

  void clear()
  {
    min_distance = std::numeric_limits<FCL_REAL>::max();
  }
sachinc's avatar
sachinc committed
137
138
};

jpan's avatar
jpan committed
139
140
141
142
143
144
145
146
struct DistanceData
{
  DistanceData()
  {
    done = false;
  }

  bool done;
147
148
149

  DistanceRequest request;
  DistanceResult result;
jpan's avatar
jpan committed
150
151
};

sachinc's avatar
sachinc committed
152
153
154
155
156


}

#endif