00001 /*======================================================================= 00002 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), *** 00003 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. *** 00004 *** *** 00005 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS *** 00006 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR *** 00007 *** WRITTEN AUTHORIZATION OF FEI S.A.S. *** 00008 *** *** 00009 *** RESTRICTED RIGHTS LEGEND *** 00010 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS *** 00011 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN *** 00012 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT *** 00013 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN *** 00014 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. *** 00015 *** *** 00016 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, *** 00017 *** BORDEAUX, FRANCE *** 00018 *** ALL RIGHTS RESERVED *** 00019 **=======================================================================*/ 00020 /*======================================================================= 00021 ** Author : JM Godinaud (Jan 2006) 00022 **=======================================================================*/ 00023 00024 #ifndef _SO_DUAL_SCENE_COLLIDER_ 00025 #define _SO_DUAL_SCENE_COLLIDER_ 00026 00027 #include <Inventor/SbBasic.h> 00028 #include <Inventor/SbLinear.h> 00029 #include <Inventor/sensors/SoNodeSensor.h> 00030 00031 class SoNode; 00032 class SoGroup; 00033 class SoPath; 00034 class SoTransform; 00035 00036 class SoCmStaticScene; 00037 class SoCmMovingScene; 00038 00112 class SoDualSceneCollider { 00113 00114 public: 00115 00120 SoDualSceneCollider(); 00121 virtual ~SoDualSceneCollider(); 00122 00131 void setMovingScene(SoPath* object, int max_triangles_per_leaf=0); 00132 00141 void setStaticScene(SoPath* scene, int max_triangles_per_leaf=0); 00142 00149 void activate(SoTransform* transform); 00150 00158 virtual SbBool checkCollision() const; 00159 00165 virtual SbBool searchNextIntersection() const { return FALSE; } 00166 00167 00176 void setMinEdgeLength(double minEdgeLength); 00177 00183 double getMinEdgeLength() const; 00184 00199 void enableMultiThread(bool enable); 00200 00205 bool isMultiThreadEnabled() const 00206 { return m_isMultiThread; } 00207 00208 private: protected: 00209 00215 const SoPath* getCollidingStaticPath() const; 00216 00222 const SoPath* getCollidingMovingPath() const; 00223 00229 void getCollidingStaticTriangle(SbVec3f &v0, SbVec3f &v1, SbVec3f &v2) const; 00230 00236 void getCollidingMovingTriangle(SbVec3f &v0, SbVec3f &v1, SbVec3f &v2) const; 00237 00243 void getCommonPoints(SbVec3f &p0, SbVec3f &p1) const; 00244 00251 virtual SbBool isSensitiveStaticObject(const SoPath *object_path) const; 00252 00259 virtual SbBool isSensitiveMovingObject(const SoPath *object_path) const; 00260 00270 virtual void staticTriangleListBuilt(int num_triangles) const; 00271 00280 virtual void staticLeafBuilt(int num_triangles) const; 00281 00291 virtual void movingTriangleListBuilt(int num_triangles) const; 00292 00301 virtual void movingLeafBuilt(int num_triangles) const; 00302 00303 private: 00304 //private usage 00305 void updateMovingScene(); 00306 void triangleListBuilt(int num_triangles) const; 00307 void leafBuilt(int num_triangles) const; // a new leaf is built : it contains num_triangles 00308 SbBool isSensitiveObject(const SoPath *object_path) const; 00309 00310 // return true if checkcollision should stop for searching new intersection 00311 bool isStopIntersectionSearchRequested() const 00312 { return m_stopSearchingforIntersection; } 00313 // reset flag the searching flag 00314 void setStopIntersectionSearchRequested(bool value) 00315 { m_stopSearchingforIntersection = value; } 00316 00317 // return the octree depth where parallelism should be used 00318 int getMaxParallelDepth() const 00319 { return m_maxparallelDepth; } 00320 00321 private: 00322 00323 SoPath *m_staticPath; 00324 SoCmStaticScene *m_staticScene; 00325 SoCmMovingScene *m_movingScene; 00326 SoPath *m_movingPath; 00327 00328 private: 00329 SoNodeSensor m_sensor; 00330 SoTransform *m_transform; 00331 int m_trianglePerStaticLeaf; 00332 int m_trianglePerMovingLeaf; 00333 SbBool m_staticSceneBeingBuilt; 00334 double m_minEdgeLength; 00335 bool m_stopSearchingforIntersection; 00336 bool m_isMultiThread; 00337 int m_maxparallelDepth; 00338 }; 00339 00340 inline SbBool 00341 SoDualSceneCollider::isSensitiveStaticObject(const SoPath *) const 00342 { return TRUE; } 00343 00344 inline SbBool 00345 SoDualSceneCollider::isSensitiveMovingObject(const SoPath *) const 00346 { return TRUE; } 00347 00348 inline void 00349 SoDualSceneCollider::staticTriangleListBuilt(int) const 00350 {} 00351 00352 inline void 00353 SoDualSceneCollider::staticLeafBuilt(int) const 00354 {} 00355 00356 inline void 00357 SoDualSceneCollider::movingTriangleListBuilt(int) const 00358 {} 00359 00360 inline void 00361 SoDualSceneCollider::movingLeafBuilt(int) const 00362 {} 00363 00364 00365 00366 #endif // SO_DUAL_SCENE_COLLIDER_ 00367 00368 00369