Go to the documentation of this file.
6 #ifndef CNOID_UTIL_COLLISION_DETECTOR_H
7 #define CNOID_UTIL_COLLISION_DETECTOR_H
11 #include <cnoid/stdx/optional>
13 #include "exportdecl.h"
25 static bool registerFactory(
const std::string& name, std::function<
CollisionDetector*()> factory);
26 static int numFactories();
27 static std::string factoryName(
int factoryIndex);
28 static int factoryIndex(
const std::string& name);
32 virtual const char* name()
const = 0;
41 virtual void clearGeometries() = 0;
42 virtual int numGeometries()
const = 0;
47 virtual stdx::optional<GeometryHandle> addGeometry(
SgNode* geometry) = 0;
49 virtual void setGeometryStatic(
GeometryHandle geometry,
bool isStatic =
true) = 0;
51 virtual bool makeReady() = 0;
54 virtual void updatePositions(
57 virtual void detectCollisions(std::function<
void(
const CollisionPair& collisionPair)> callback) = 0;
75 GeometryHandle geometries_[2];
82 geometries_[0] = geometry1;
83 geometries_[1] = geometry2;
86 geometries_[0] = geometry1;
87 geometries_[1] = geometry2;
88 objects_[0] = object1;
89 objects_[1] = object2;
91 GeometryHandle&
geometry(
int i) {
return geometries_[i]; };
92 const GeometryHandle
geometry(
int i)
const {
return geometries_[i]; };
93 const GeometryHandle*
geometries()
const {
return geometries_; }
101 bool empty()
const {
return collisions_.empty(); }
std::vector< Collision > CollisionArray
Definition: Collision.h:27
void addCollision(const Collision &c)
Definition: CollisionDetector.h:98
Eigen::Vector3d Vector3
Definition: EigenTypes.h:57
CollisionArray & collisions()
Definition: CollisionDetector.h:96
CollisionPair()
Definition: CollisionDetector.h:80
Eigen::Isometry3d Isometry3
Definition: EigenTypes.h:73
bool empty() const
Definition: CollisionDetector.h:101
const CollisionArray & collisions() const
Definition: CollisionDetector.h:97
Referenced *& object(int i)
Definition: CollisionDetector.h:94
const GeometryHandle geometry(int i) const
Definition: CollisionDetector.h:92
Definition: CollisionDetector.h:63
virtual double detectDistance(CollisionDetector::GeometryHandle geometry1, CollisionDetector::GeometryHandle geometry2, Vector3 &out_point1, Vector3 &out_point2)=0
Collision & newCollision()
Definition: CollisionDetector.h:99
Definition: AbstractSceneLoader.h:11
Definition: Collision.h:14
ref_ptr< CollisionDetector > CollisionDetectorPtr
Definition: CollisionDetector.h:60
void clearCollisions()
Definition: CollisionDetector.h:100
Definition: CollisionDetector.h:20
Definition: CollisionDetector.h:72
Definition: Referenced.h:54
CollisionPair(GeometryHandle geometry1, Referenced *object1, GeometryHandle geometry2, Referenced *object2)
Definition: CollisionDetector.h:85
intptr_t GeometryHandle
Definition: CollisionDetector.h:23
GeometryHandle & geometry(int i)
Definition: CollisionDetector.h:91
Referenced * object(int i) const
Definition: CollisionDetector.h:95
const GeometryHandle * geometries() const
Definition: CollisionDetector.h:93
int numCollisions() const
Definition: CollisionDetector.h:102
CollisionPair(GeometryHandle geometry1, GeometryHandle geometry2)
Definition: CollisionDetector.h:81
Definition: SceneGraph.h:157