Changeset 7983 for code/branches/kicklib/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
- Timestamp:
- Feb 27, 2011, 7:43:24 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/kicklib/src/external/bullet/BulletCollision/CollisionDispatch/btCollisionWorld.h
r5781 r7983 23 23 * Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ). 24 24 * 25 * The main documentation is Bullet_User_Manual.pdf, included in the source code distribution. 25 26 * There is the Physics Forum for feedback and general Collision Detection and Physics discussions. 26 27 * Please visit http://www.bulletphysics.com … … 30 31 * @subsection step1 Step 1: Download 31 32 * You can download the Bullet Physics Library from the Google Code repository: http://code.google.com/p/bullet/downloads/list 33 * 32 34 * @subsection step2 Step 2: Building 33 * Bullet comes with autogenerated Project Files for Microsoft Visual Studio 6, 7, 7.1 and 8. 34 * The main Workspace/Solution is located in Bullet/msvc/8/wksbullet.sln (replace 8 with your version). 35 * 36 * Under other platforms, like Linux or Mac OS-X, Bullet can be build using either using make, cmake, http://www.cmake.org , or jam, http://www.perforce.com/jam/jam.html . cmake can autogenerate Xcode, KDevelop, MSVC and other build systems. just run cmake . in the root of Bullet. 37 * So if you are not using MSVC or cmake, you can run ./autogen.sh ./configure to create both Makefile and Jamfile and then run make or jam. 38 * Jam is a build system that can build the library, demos and also autogenerate the MSVC Project Files. 39 * If you don't have jam installed, you can make jam from the included jam-2.5 sources, or download jam from ftp://ftp.perforce.com/jam 35 * Bullet main build system for all platforms is cmake, you can download http://www.cmake.org 36 * cmake can autogenerate projectfiles for Microsoft Visual Studio, Apple Xcode, KDevelop and Unix Makefiles. 37 * The easiest is to run the CMake cmake-gui graphical user interface and choose the options and generate projectfiles. 38 * You can also use cmake in the command-line. Here are some examples for various platforms: 39 * cmake . -G "Visual Studio 9 2008" 40 * cmake . -G Xcode 41 * cmake . -G "Unix Makefiles" 42 * Although cmake is recommended, you can also use autotools for UNIX: ./autogen.sh ./configure to create a Makefile and then run make. 40 43 * 41 44 * @subsection step3 Step 3: Testing demos … … 54 57 * 55 58 * @section copyright Copyright 56 * Copyright (C) 2005-2008 Erwin Coumans, some contributions Copyright Gino van den Bergen, Christer Ericson, Simon Hobbs, Ricardo Padrela, F Richter(res), Stephane Redon 57 * Special thanks to all visitors of the Bullet Physics forum, and in particular above contributors, John McCutchan, Nathanael Presson, Dave Eberle, Dirk Gregorius, Erin Catto, Dave Eberle, Adam Moravanszky, 58 * Pierre Terdiman, Kenny Erleben, Russell Smith, Oliver Strunk, Jan Paul van Waveren, Marten Svanfeldt. 59 * For up-to-data information and copyright and contributors list check out the Bullet_User_Manual.pdf 59 60 * 60 61 */ 61 62 63 62 64 63 … … 71 70 class btConvexShape; 72 71 class btBroadphaseInterface; 72 class btSerializer; 73 73 74 #include "LinearMath/btVector3.h" 74 75 #include "LinearMath/btTransform.h" … … 82 83 { 83 84 84 85 85 86 86 protected: 87 87 88 88 btAlignedObjectArray<btCollisionObject*> m_collisionObjects; 89 90 89 91 90 btDispatcher* m_dispatcher1; … … 99 98 btIDebugDraw* m_debugDrawer; 100 99 101 102 100 ///m_forceUpdateAllAabbs can be set to false as an optimization to only update active object AABBs 101 ///it is true by default, because it is error-prone (setting the position of static objects wouldn't update their AABB) 102 bool m_forceUpdateAllAabbs; 103 104 void serializeCollisionObjects(btSerializer* serializer); 105 103 106 public: 104 107 … … 142 145 143 146 virtual void updateAabbs(); 144 145 147 146 148 virtual void setDebugDrawer(btIDebugDraw* debugDrawer) … … 153 155 return m_debugDrawer; 154 156 } 157 158 virtual void debugDrawWorld(); 159 160 virtual void debugDrawObject(const btTransform& worldTransform, const btCollisionShape* shape, const btVector3& color); 155 161 156 162 … … 161 167 int m_shapePart; 162 168 int m_triangleIndex; 163 164 169 165 170 //const btCollisionShape* m_shapeTemp; … … 239 244 btVector3 m_hitNormalWorld; 240 245 btVector3 m_hitPointWorld; 241 242 246 243 247 virtual btScalar addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace) … … 245 249 //caller already does the filter on the m_closestHitFraction 246 250 btAssert(rayResult.m_hitFraction <= m_closestHitFraction); 247 248 251 249 252 m_closestHitFraction = rayResult.m_hitFraction; … … 262 265 }; 263 266 267 struct AllHitsRayResultCallback : public RayResultCallback 268 { 269 AllHitsRayResultCallback(const btVector3& rayFromWorld,const btVector3& rayToWorld) 270 :m_rayFromWorld(rayFromWorld), 271 m_rayToWorld(rayToWorld) 272 { 273 } 274 275 btAlignedObjectArray<btCollisionObject*> m_collisionObjects; 276 277 btVector3 m_rayFromWorld;//used to calculate hitPointWorld from hitFraction 278 btVector3 m_rayToWorld; 279 280 btAlignedObjectArray<btVector3> m_hitNormalWorld; 281 btAlignedObjectArray<btVector3> m_hitPointWorld; 282 btAlignedObjectArray<btScalar> m_hitFractions; 283 284 virtual btScalar addSingleResult(LocalRayResult& rayResult,bool normalInWorldSpace) 285 { 286 m_collisionObject = rayResult.m_collisionObject; 287 m_collisionObjects.push_back(rayResult.m_collisionObject); 288 btVector3 hitNormalWorld; 289 if (normalInWorldSpace) 290 { 291 hitNormalWorld = rayResult.m_hitNormalLocal; 292 } else 293 { 294 ///need to transform normal into worldspace 295 hitNormalWorld = m_collisionObject->getWorldTransform().getBasis()*rayResult.m_hitNormalLocal; 296 } 297 m_hitNormalWorld.push_back(hitNormalWorld); 298 btVector3 hitPointWorld; 299 hitPointWorld.setInterpolate3(m_rayFromWorld,m_rayToWorld,rayResult.m_hitFraction); 300 m_hitPointWorld.push_back(hitPointWorld); 301 m_hitFractions.push_back(rayResult.m_hitFraction); 302 return m_closestHitFraction; 303 } 304 }; 305 264 306 265 307 struct LocalConvexResult … … 292 334 short int m_collisionFilterGroup; 293 335 short int m_collisionFilterMask; 294 295 336 296 337 ConvexResultCallback() … … 304 345 { 305 346 } 306 307 347 308 348 bool hasHit() const … … 310 350 return (m_closestHitFraction < btScalar(1.)); 311 351 } 312 313 352 314 353 … … 339 378 btVector3 m_hitPointWorld; 340 379 btCollisionObject* m_hitCollisionObject; 341 342 380 343 381 virtual btScalar addSingleResult(LocalConvexResult& convexResult,bool normalInWorldSpace) … … 345 383 //caller already does the filter on the m_closestHitFraction 346 384 btAssert(convexResult.m_hitFraction <= m_closestHitFraction); 347 348 385 349 386 m_closestHitFraction = convexResult.m_hitFraction; … … 362 399 }; 363 400 401 ///ContactResultCallback is used to report contact points 402 struct ContactResultCallback 403 { 404 short int m_collisionFilterGroup; 405 short int m_collisionFilterMask; 406 407 ContactResultCallback() 408 :m_collisionFilterGroup(btBroadphaseProxy::DefaultFilter), 409 m_collisionFilterMask(btBroadphaseProxy::AllFilter) 410 { 411 } 412 413 virtual ~ContactResultCallback() 414 { 415 } 416 417 virtual bool needsCollision(btBroadphaseProxy* proxy0) const 418 { 419 bool collides = (proxy0->m_collisionFilterGroup & m_collisionFilterMask) != 0; 420 collides = collides && (m_collisionFilterGroup & proxy0->m_collisionFilterMask); 421 return collides; 422 } 423 424 virtual btScalar addSingleResult(btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0,int index0,const btCollisionObject* colObj1,int partId1,int index1) = 0; 425 }; 426 427 428 364 429 int getNumCollisionObjects() const 365 430 { … … 369 434 /// rayTest performs a raycast on all objects in the btCollisionWorld, and calls the resultCallback 370 435 /// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback. 371 v oidrayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const;372 373 // convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback374 // This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback.436 virtual void rayTest(const btVector3& rayFromWorld, const btVector3& rayToWorld, RayResultCallback& resultCallback) const; 437 438 /// convexTest performs a swept convex cast on all objects in the btCollisionWorld, and calls the resultCallback 439 /// This allows for several queries: first hit, all hits, any hit, dependent on the value return by the callback. 375 440 void convexSweepTest (const btConvexShape* castShape, const btTransform& from, const btTransform& to, ConvexResultCallback& resultCallback, btScalar allowedCcdPenetration = btScalar(0.)) const; 441 442 ///contactTest performs a discrete collision test between colObj against all objects in the btCollisionWorld, and calls the resultCallback. 443 ///it reports one or more contact points for every overlapping object (including the one with deepest penetration) 444 void contactTest(btCollisionObject* colObj, ContactResultCallback& resultCallback); 445 446 ///contactTest performs a discrete collision test between two collision objects and calls the resultCallback if overlap if detected. 447 ///it reports one or more contact points (including the one with deepest penetration) 448 void contactPairTest(btCollisionObject* colObjA, btCollisionObject* colObjB, ContactResultCallback& resultCallback); 376 449 377 450 … … 392 465 ConvexResultCallback& resultCallback, btScalar allowedPenetration); 393 466 394 v oid addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter);467 virtual void addCollisionObject(btCollisionObject* collisionObject,short int collisionFilterGroup=btBroadphaseProxy::DefaultFilter,short int collisionFilterMask=btBroadphaseProxy::AllFilter); 395 468 396 469 btCollisionObjectArray& getCollisionObjectArray() … … 405 478 406 479 407 v oid removeCollisionObject(btCollisionObject* collisionObject);480 virtual void removeCollisionObject(btCollisionObject* collisionObject); 408 481 409 482 virtual void performDiscreteCollisionDetection(); … … 418 491 return m_dispatchInfo; 419 492 } 493 494 bool getForceUpdateAllAabbs() const 495 { 496 return m_forceUpdateAllAabbs; 497 } 498 void setForceUpdateAllAabbs( bool forceUpdateAllAabbs) 499 { 500 m_forceUpdateAllAabbs = forceUpdateAllAabbs; 501 } 502 503 ///Preliminary serialization test for Bullet 2.76. Loading those files requires a separate parser (Bullet/Demos/SerializeDemo) 504 virtual void serialize(btSerializer* serializer); 420 505 421 506 };
Note: See TracChangeset
for help on using the changeset viewer.