initial commit

This commit is contained in:
cirdan 2008-01-16 11:45:17 +00:00
commit 8f17a3a819
1068 changed files with 384278 additions and 0 deletions

16
Makefile Normal file
View File

@ -0,0 +1,16 @@
all clean:
@$(MAKE) -s -C zlib $@
@$(MAKE) -s -C libpng $@
@$(MAKE) -s -C glfw $@
@$(MAKE) -s -C trimeshloader $@
@$(MAKE) -s -C physfs $@
@$(MAKE) -s -C freetype $@
@$(MAKE) -s -C ftgl $@
@$(MAKE) -s -C bullet $@
@$(MAKE) -s -C corona $@
@$(MAKE) -s -C glew $@
@$(MAKE) -s -C squirrel $@
@$(MAKE) -s -C ode $@
@$(MAKE) -s -C tinyxml $@
@$(MAKE) -s -C engine $@
@echo done

41
Makefile.common Normal file
View File

@ -0,0 +1,41 @@
ifdef RELEASE
# RELEASE CFLAGS
#export CFLAGS := -fmessage-length=0 -O3 -fomit-frame-pointer -pipe -march=pentium-m -msse2 -msse -mmmx
export CFLAGS := -O2 -fomit-frame-pointer -pipe -march=i686
export CXXFLAGS := $(CFLAGS)
export LDFLAGS := -s
else
# DEBUG CFLAGS
export CFLAGS := -g3 -fmessage-length=0 -Wall -DDEBUG -pipe
export CXXFLAGS := $(CFLAGS)
export LDFLAGS :=
endif
ifeq ($(MAKE),mingw32-make)
# Windows
export OS = WIN32
export RM = del /F
export RMSUB = del /F /s /Q
export EXT = .exe
export SLASH = \\
export CC = gcc
export CP = copy
export MKDIR = mkdir
else
# Linux
export OS = LINUX
export RM = rm -f
export RMSUB = rm -Rf
export EXT =
export SLASH = /
export CP = cp
export MKDIR = mkdir -p
endif
%.o: %.cpp
@echo Compiling $@ ...
@$(CXX) -c $(CXXFLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o $@ $<
%.o: %.c
@echo Compiling $@ ...
@$(CC) -c $(CFLAGS) -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o $@ $<

11
Versions.txt Normal file
View File

@ -0,0 +1,11 @@
libpng: 1.2.8
zlib: 1.2.3
glfw: 2.6.beta1
trimeshloader: 0.0.12
physfs: 1.1.1
freetype: 2.2.1
ftgl: 2.1.2
bullet: 2.56
corona: 1.0.2
glew: 1.4.0
tinyxml: 2.3.4

22
bullet/AUTHORS Normal file
View File

@ -0,0 +1,22 @@
Bullet Physics Library is an open source project with help from the community at the Physics Forum
See the forum at http://bulletphysics.com
The project was started by Erwin Coumans
Following people contributed to Bullet
(random order, please let us know on the forum if your name should be in this list)
Gino van den Bergen: LinearMath classes
Christer Ericson: parts of the voronoi simplex solver
Simon Hobbs: 3d axis sweep and prune, Extras/SATCollision, separating axis theorem + SIMD code
Dirk Gregorius: generic D6 constraint
Erin Catto: accumulated impulse in sequential impulse
Nathanael Presson: EPA penetration depth calculation
Francisco Leon: GIMPACT Concave Concave collision
Joerg Henrichs: make buildsystem (work in progress)
Eric Sunshine: jam + msvcgen buildsystem
Steve Baker: GPU physics and general implementation improvements
Jay Lee: Double precision support
KleMiX, aka Vsevolod Klementjev, managed version, rewritten in C# for XNA
Erwin Coumans: most other source code

17
bullet/BulletLicense.txt Normal file
View File

@ -0,0 +1,17 @@
/*
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
Free for commercial use, but please mail bullet@erwincoumans.com to report projects, and join the forum at
www.continuousphysics.com/Bullet/phpBB2

357
bullet/ChangeLog.txt Normal file
View File

@ -0,0 +1,357 @@
Bullet Continuous Collision Detection and Physics Library
Primary author and maintainer: Erwin Coumans
2007 Aug 15
- fixed bug in Extras/GIMPACT 0.2 related to moving triangle meshes
Thanks Thomas, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1368
2007 Aug 14
- added parallel constraint solver. Works on Playstation 3 Cell SPU and multi core (Win Threads on PC and XBox 360).
See Extras/BulletMultiThreaded for SpuSolverTask subfolder and SpuParallelSolver.cpp
Thanks Marten Svanfeldt (Starbreeze Studios)
- fixed some bugs related to parallel collision detection (Extras/BulletMultiThreaded)
Thanks Marten Svanfeldt (Starbreeze Studios)
2007 Aug 2
- added compound and concave-convex (swapped) case for BulletMultiThreaded collision detection, thanks to Marten Svanfeldt
- refactored broadphase and overlapping pair cache. This allows performance improvement by combining multiple broadphases. This helps add/remove of large batches of objects and large worlds. See also Pierre Terdiman forum topic:
http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1329
2007 July 27
- added Ragdoll Demo
Thanks to Marten Svanfeldt (Starbreeze Studios)
- added Vector Math library for SIMD 3D graphics linear algebra (vector, matrix, quaternion)
See Bullet/Extras/vectormathlibrary
Supports SIMD SSE, PowerPC PPU and Cell SPU (including PS3 Linux and CellBlade), as well as generic portable scalar version
Will be used to improve BulletMultiThreaded performance
Open Sourced by Sony Computer Entertainment Inc. under the new BSD license
- added SIMD math library
4-way SIMD for common math functions like atan2f4, cosf4, floorf4, fabsf4, rsqrtf4 etc. Used by Vector Math library under PPU and SPU.
Supports PowerPC (PPU) and Cell SPU, including PS3 Linux and CellBlade.
See Bullet/Extras/simdmathlibrary
Open sourced by Sony Computer Entertainment Inc. under the new BSD license
2007 July 25
- added several patches: per-rigidbody sleeping threshold. added Assert to prevent deletion of rigidbody while constraints are still pointing at it
Thanks to Marten Svanfeldt (Starbreeze Studios)
2007 July 13
- fixed relative #include paths again. We can't use "../" relative paths: some compilers choke on it (it causes extreme long paths)
Within the libraries, we always need to start with "BulletCollision/" or "BulletDynamics/ or "LinearMath/"
2007 July 10
- Updated Bullet User Manual
2007 July 5
- added btConeTwistConstraint, especially useful for ragdolls. See Demos/RagdollDemo
Thanks to Marten Svanfeldt (Starbreeze Studios)
2007 June 29
- btHeightfieldTerrainShape: Added heightfield support, with customizations
- Upgraded to GIMPACT 0.2, see Extras/GIMPACT and MovingConcaveDemo
- Several patches from Marten Svanfeldt (Starbreeze Studios)
Improved collision filtering (in broadphase and rigidbody)
Improved debug rendering
Allow to set collision filter group/mask in addRigidBody
2007 June 15
- Changed btAlignedObjectArray to call copy constructor/replacement new for duplication, rather then assignment operator (operator=).
2007 June 11
- Added multi-threading. Originally for Playstation 3 Cell SPU, but the same code can run using Win32 Threads using fake DMA transfers (memcpy)
Libspe2 support for Cell Blade / PS3 Linux is upcoming
See Extras/BulletMultiThreaded. Usage: replace btCollisionDispatcher by btSpuGatheringCollisionDispatcher
- Added managed Bullet library, entirely rewritten in C# for Windows and XBox 360 XNA
See Extras/BulletX
Thanks to KleMiX, aka Vsevolod Klementjev
2007 May 31
- sign-bit went wrong in case of 32-bit broadphase, causing quantization problems.
Thanks DevO for reporting.
2007 May 23
- Fixed quantization problem for planar triangle meshes in btOptimizedBvh
Thanks Phil Knight for reporting and helping to fix this bug.
2007 May 20
- btAxisSweep3: Fixed a bug in btAxisSweep3 (sweep and prune) related to object removal. Only showed up when at least one btStaticPlaneShape was inserted.
Thanks tbp for more details on reproducing case.
- btAxisSweep3: Fixed issue with full 32bit precision btAxisSweep3 (define BP_USE_FIXEDPOINT_INT_32), it used only 0xffff/65536 for quantization instead of full integer space (0xffffffff)
- btRaycastVehicle: Added 'getForwardVector' and getCurrentSpeedKmHour utility functions
- Fixed local scaling issues (btConvexTriangleMeshShape, btBvhTriangleMeshShape, removed scaling from btMatrix3x3).
Thanks Volker for reporting!
- Added second filename search, so that starting BspDemo and ConvexDecompositionDemo from within Visual Studio (without setting the starting path) still works
2007 April 22
- Added braking functionality to btRaycastVehicle
- Removed tons of warnings, under MSVC 2005 compilation in -W4
2007 March 21
- Fixed issues: comma at end of enum causes errors for some compilers
- Fixed initialization bug in LocalRayResult ( m_localShapeInfo(localShapeInfo) )
2007 March 20
- Added refit tree to quantized stackless tree, and updated ConcaveDemo as example.
2007 March 17
- Added constraint solver optimizations, avoiding cross products during iterations, and gather rigidbody/constraint info in contiguous memory (btSolverBody/btSolverConstraint)
- These optimizations don't give large benefit yet, but it has good potential. Turned on by default. Can be switched off using solver->setSolverMode(SOLVER_RANDMIZE_ORDER).
- Enabled anti-jitter for rigid bodies. This is experimental, and can be switched off by setting a global (it is experimental so no proper interface) gJitterVelocityDampingFactor = 1.0;
- Fixed bug in islandmanifold.heapSort(btPersistentManifoldSortPredicate()); , thanks Noehrgel for reporting this (affected Sun Solaris)
2007 March 12
- Added compile-time toggle between on 16-bit and 32-bit fixed-point SAP broadphase.
This allows the number of bodies to exceed 32767
- Enable useQuantizedAabbCompression on btTriangleMesh, see ColladaDemo
2007 March 8
- Fixed bug in constraint/island sorting (caused by replacing STL by dedicated btAlignedObjectArray with heapSort)
Thanks Clemens Unterkofler for pointing this out!
2007 March 6
- removed STL from the Bullet library: replace std::vector by btAlignedObjectArray. Also removed the std::set for overlapping pair set, and turned it into an overlapping pair array. The SAP only adds objects, never removed. Removal is postponed for during traversal of overlapping pairs (duplicates and non-overlapping pairs are removed during that traversal).
- added heap sort and binary search/linear search to btAlignedObjectArray
- fixed wrong cast, thanks Hamstray, http://www.continuousphysics.com/Bullet/phpBB2/viewtopic.php?t=1015
2007 Feb 25
- Improved performance of convex collision shapes, cache local AABB instead of recomputation. This fixes issue with very slow performance in larger .bsp levels
2007 Feb 24
- Added compressed/quantized AABB tree, 16 bytes per node, while supporting 32-bit (triangle) indices.
Should be faster and smaller then original version (quantized aabb check is done in integer space)
Original aabb tree nodes are still supported. They are 44 bytes, with full floating point precision and additional subPart index.
- added meter-unit scaling support in ColladaConverter.cpp
2007 Feb 21
- Build system: updated bullet.pc.in library names
- Updated EPA comparison integration (missing parameter)
2007 Jan 04
- fixed optimized AABB tree building: in some cases the tree building fails due to unbalanced trees, which generated stack overflow
2006 Dec 15
- added contribution to allow double precision collision detection/dynamics. Define BT_USE_DOUBLE_PRECISION in your project and libraries that include Bullet
2006 Dec 14
- merged contact and non-contact constraint solving into one loop, will improve stability of jointed bodies during collisions
- added first draft for hingeConstraint motor
2006 Dec 8, Erwin Coumans
- preparation for SIMD: added btAlignedAllocator and btAlignedObjectArray, to replace stl std::vector, same interface, but compatible with 16 byte alignment
- cleaned up dependencies in autogenerated msvc projectfiles
- aligned btVector3 on 16 bytes boundary, under win32. see if developers will come up with problems
2006 Dec 04, Erwin Coumans
Added btNearCallback. This is similar to Open Dynamics Engine (ODE) dNearCallback, but important differences:
- contact points are persistent (lifetime more then one frame, for warmstarting/incremental contact point management)
- continuous collision detection, time of impact
Added btRigidBody::isInWorld(), returns true if btRigidBody is inside a btCollisionWorld/btDynamicsWorld derived class
Added angularFactor to btRigidbody, this helps some character control (no angular impulse applied)
2006 Nov 28
Moved StackAlloc from EPA into LinearMath/btStackAlloc
renamed internal class ConcaveShape into btConcaveShape
added btHeightfieldTerrainShape (not completed yet)
2006 Nov 15 Nathanael Presson
Added EPA penetration depth algorithm, Expanding Polytope Algorithm
Added Pierre Terdiman penetration depth comparison/test DEMO
Fixed Bullet's Minkowski sampling penetration depth solver
Contributed by Nathanael Presson
2006 Nov 11 Francisco León Nájera
Added GIMPACT trimesh collision detection: concave versus concave,
Contributed by Francisco León Nájera
2006 Nov 2
Minor refactoring: btCollisionObject changes from struct into class, added accessor methods
Force use of btMotionState to synchronize graphics transform, disabled old btRigidBody constructor that accepts btTransform
Renamed treshold into threshold throughout the code
2006 Oct 30
Enable decoupling of physics and graphics framerate using interpolation and internal fixed timestep, based on btMotionState
Enabled raycast vehicle demo (still needs tuning)
Refresh contact points, even when they are already persistent.
Fixed debugDraw colors (thanks pc0de for reporting)
Use Dispatcher in ConcaveConvexCollisionAlgorithm (so it uses the registered collision algorithm, not hardcoded convexconcave)
Improved performance of constraint solver by precalculating the cross product/impulse arm
Added collision comparison code: ODE box-box, also sphere-triangle
Added safety check into GJK, and an assert for AABB's that are very large
Fixed kinematic support (deriving velocities for animated objects)
Updated comparison/optional quickstep solver in Extras
UserCollisionAlgorithm demonstrates btTriangleMesh usage (easier trimesh compared to index array version)
Removed scaling from btTransform (we only want to deal with rigid transforms)
2006 Oct 4
Fixed minor leak in btOptimizeBVH
Cleanup of btRigidBody construction
added getW() in btQuaternion
assert when setLinearVelocity is called on btRigidBody
renamed projectfile library from collada-dom to colladadom (to make VC6 happy)
2006 Sept 27
Big Refactoring: renamed and moved files, create a replacement for CcdPhysicsEnvironment/CcdPhysicsController.
All Bullet classes in LinearMath, BulletCollision and BulletDynamics start with bt, and methods start with lowercase.
Moved classes into src folder, which is the only include folder needed.
Added 2 headerfiles in src: btBulletCollisionCommon.h and btBulletDynamicsCommon.h
2006 Sept 23
Fixed 2 bugs, causing crashes when removing objects. Should do better unit-testing. UnionFind and 3D SAP were involved.
2006 Sept 19
Allow programmable friction and contact solver model. User can register their own functions for several interaction types.
Improved performance, and removed hardcoded maximum overlaps (switched from C-array to stl::set)
2006 Sept 16
Added Bullet 2.0 User Manual
Allow registration of custom user collision algorithms
2006 Sept 10
Started cleaning up demos
2006 Sept 4
Fixed concave collision bug (caused instability/missing collisions in meshes/compounds)
Fixed memoryleak in OptimizedBvh, added RayTestSingle to CollisionWorld
Prepared for VehicleDemo
Increased Performance (island generation for sleeping objects took too much time)
Better COLLADA 1.4.1 physics conformance in ColladaDemo
2006 August 11
Added Quake BspDemo
Improved CCD for compound and non-convex objects
2006 August 10
Added per-triangle material (friction/restitution) support for non-convex meshes. See ConcaveDemo for usage.
2006 August 9
Added CMake support (see http://cmake.org)
This can autogenerate makefiles, projectfiles cross platform (including MacOS X Xcode )
Just run cmake . in the root folder and it will autogenerate build files
2006 July 26 Erwin Coumans
Upgraded to COLLADA-DOM 1.4.1, latest SVN version
ColladaDemo can export snapshots to .dae
2006 July 24 Erwin Coumans
Added Compound CollisionShape support
(this is still low performance -> requires stackless tree-versus-tree traversal for better performance)
2006 July 15 Erwin Coumans
Added initial support for Parallel execution (collision detection, constraint solving)
See ParallelPhysicsEnvironment in Extras\PhysicsInterface\CcdPhysics
2006 July 10 Erwin Coumans
Added MacOS X support (some build issues mainly)
2006 July 5 Erwin Coumans
Improved COLLADA 1.4 physics import, both COLLADA-DOM and FCollada
2006 June 29 Erwin Coumans
Refactoring of the broadphase
Moved some optional files to Extras: Algebraic ccd and EPA, quickstep
Moved the limits on bodies/overlap to 32k and 65k
2006 June 25 Erwin Coumans
Added basic Collision Filtering, during broadphase
Allow adding meshes to the TriangleIndexVertexArray,
(input for TriangleMeshShape)
Preparation for CompoundShape
2006 June 19 Erwin Coumans
Added support for COLLADA Physics Import.
Both jam and Visual Studio can compile ColladaDemo
2006 June 18 Dirk Gregorius <dirk@dirkgregorius.de>
Started implementing Generic6DOF joint and setup basic interface
2006 June 17 Frank Richter <resqu@gmx.ch>
Bumped version in configure.ac to 1.5.6 (assuming that "1.5f" is
the next version released).
Updated files in mk/autoconf and mk/jam with copies from CS; fixes a
GLU detection issue on MinGW.
Set msvc/bullet_ico.ico as the default application icon.
Disabled exceptions for gcc builds.
Applied a patch from Michael D. Adams to fix a warning with gcc.
2006 jUNE 16 Erwin Coumans
Constraints now merge simulation islands.
2006 May 24
Improved GJK accuracy, fixed GjkConvexCast issue, thanks to ~MyXa~ for reporting
2006 May 19
Added restitution support
Moved out Friction and Dynamics info from ManifoldPoint (removed logical dependency)
Added a void* m_userPersistentData in ManifoldPoint.
Added a ContactDestroyedCallback, to allow user to handle destruction of m_userPersistentData
2006 May 13
Fixed some bugs in friction / jacobian calculations. Reported by Dirk Gregorius. Thanks!
2006 May 9
Fixed raycasting filtering
Moved repository to SVN at https://svn.sourceforge.net/svnroot/bullet
2006 April 27
Moved raycasting to CollisionWorld, to make it more generic
Added basic CCD option in the CcdCollisionDemo
Fixed 'noResponse' mode, for triggering rigidbodies (useful for Artificial Intelligence queries)
Improved Bullet/ODE sample (in Extras)
2006 April 10
Separating Axis Test (SAT) convex hull collision detector, contribution by Simon Hobbs
Added SIMD SSE Math classes (for above SAT)
Added Mouse picking in CcdPhysicsDemo
Improved penetration depth estimation in MinkowskiPenetrationDepthSolver, both accuracy and performance
Added Hinge constraint
Added quickprof profiling (see http://sourceforge.net/projects/quickprof )
2006 March 21 Frank Richter <resqu@gmx.ch>
Removed VC manifest files.
Removed superfluous "grpplugins" projects.
2006 March 20 Erwin Coumans
Clamped the acculumated impulse rather then intermediate impulse (within the iteration)
Use the persistent contacts for reusing the impulse
Separated friction and normal solving for better stability
Decreased the default number of iterations of the constraint solver from 10 to 4
2006 March 19 Frank Richter <resqu@gmx.ch>
Removed a couple of CSisms from the VC projects.
Fixed VC include & lib paths to go to the Addtional* options
instead the command line arguments.
Added pkgconfig support.
2006 March 14 Frank Richter <resqu@gmx.ch>
Added support for shipped GLUT on MinGW.
Fixed GLUT support on MinGW.
2006 March 13 Frank Richter <resqu@gmx.ch>
Bolted on Jam-based build system.
Generated VC project files.
Fixed GCC warnings.
Fixed Linux build issues.
2006 March 13
Added 3D Sweep and Prune Broadphase Collision Detection, Contribution from Simon Hobbs.
2006 March 2
Minor change in license to ZLib/LibPNG
This makes it legally a bit easier to deploy on Playstation 3
Prepared for more generic constraints, added ConstraintsDemo
2006 Feb 23
Rearranged files and dependencies to allow for easier standalone Collision Detection without Bullet Dynamics.
See Demos/CollisionInterfaceDemo and Extras/ode/ode/test/test_BulletGjk.cpp for examples how to use.
... todo: add history
2003 Initial version (continuous collision detection)

19
bullet/LICENSE Normal file
View File

@ -0,0 +1,19 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
All files in the Bullet/src folder are under this Zlib license.
Optional Extras/GIMPACT and Extras/GIMPACTBullet is also under ZLib license. Other optional external libraries in Extras/Demos have own license,see respective files.
This means Bullet can freely be used in any software, including commercial and console software. A Playstation 3 optimized version is available through Sony.

42
bullet/Makefile Normal file
View File

@ -0,0 +1,42 @@
include ../Makefile.common
OBJ += $(patsubst %.cpp,%.o,$(wildcard src/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard src/*/*.cpp)) $(patsubst %.cpp,%.o,$(wildcard src/*/*/*.cpp))
LIBNAME = libbullet.a
CXXFLAGS = -Isrc
all: $(LIBNAME)
$(LIBNAME): $(OBJ)
@echo Creating archive $@
@ar -crsu $@ $(OBJ)
@echo
clean:
-@$(RM) src$(SLASH)*.o
-@$(RM) src$(SLASH)*.d
-@$(RM) src$(SLASH)LinearMath$(SLASH)*.o
-@$(RM) src$(SLASH)LinearMath$(SLASH)*.d
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)ConstraintSolver$(SLASH)*.o
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)ConstraintSolver$(SLASH)*.d
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)Dynamics$(SLASH)*.o
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)Dynamics$(SLASH)*.d
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)Vehicle$(SLASH)*.o
-@$(RM) src$(SLASH)BulletDynamics$(SLASH)Vehicle$(SLASH)*.d
-@$(RM) src$(SLASH)BulletCollision$(SLASH)BroadphaseCollision$(SLASH)*.o
-@$(RM) src$(SLASH)BulletCollision$(SLASH)BroadphaseCollision$(SLASH)*.d
-@$(RM) src$(SLASH)BulletCollision$(SLASH)CollisionDispatch$(SLASH)*.o
-@$(RM) src$(SLASH)BulletCollision$(SLASH)CollisionDispatch$(SLASH)*.d
-@$(RM) src$(SLASH)BulletCollision$(SLASH)CollisionShapes$(SLASH)*.o
-@$(RM) src$(SLASH)BulletCollision$(SLASH)CollisionShapes$(SLASH)*.d
-@$(RM) src$(SLASH)BulletCollision$(SLASH)NarrowPhaseCollision$(SLASH)*.o
-@$(RM) src$(SLASH)BulletCollision$(SLASH)NarrowPhaseCollision$(SLASH)*.d
-@$(RM) $(LIBNAME)

4
bullet/NEWS Normal file
View File

@ -0,0 +1,4 @@
For news, visit the Bullet Physics Forum at
http://www.continuousphysics.com/Bullet/phpBB2/viewforum.php?f=9

7
bullet/README Normal file
View File

@ -0,0 +1,7 @@
Bullet is a 3D Collision Detection and Rigid Body Dynamics Library for games and animation.
Free for commercial use, including Playstation 3, open source under the ZLib License.
Discrete and continuous collision detection, integrated into Blender 3D, and COLLADA 1.4 Physics import.
See the Bullet_User_Manual.pdf for more info and visit the Bullet Physics Forum at
http://bulletphysics.com

3
bullet/VERSION Normal file
View File

@ -0,0 +1,3 @@
Bullet Collision Detection and Physics Library version 2.56
http://bullet.sourceforge.net

View File

@ -0,0 +1,680 @@
//Bullet Continuous Collision Detection and Physics Library
//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
//
// btAxisSweep3
//
// Copyright (c) 2006 Simon Hobbs
//
// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
#include "btAxisSweep3.h"
#include <assert.h>
#ifdef DEBUG_BROADPHASE
#include <stdio.h>
void btAxisSweep3::debugPrintAxis(int axis, bool checkCardinality)
{
int numEdges = m_pHandles[0].m_maxEdges[axis];
printf("SAP Axis %d, numEdges=%d\n",axis,numEdges);
int i;
for (i=0;i<numEdges+1;i++)
{
Edge* pEdge = m_pEdges[axis] + i;
Handle* pHandlePrev = getHandle(pEdge->m_handle);
int handleIndex = pEdge->IsMax()? pHandlePrev->m_maxEdges[axis] : pHandlePrev->m_minEdges[axis];
char beginOrEnd;
beginOrEnd=pEdge->IsMax()?'E':'B';
printf(" [%c,h=%d,p=%x,i=%d]\n",beginOrEnd,pEdge->m_handle,pEdge->m_pos,handleIndex);
}
if (checkCardinality)
assert(numEdges == m_numHandles*2+1);
}
#endif //DEBUG_BROADPHASE
btBroadphaseProxy* btAxisSweep3::createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr,short int collisionFilterGroup,short int collisionFilterMask)
{
(void)shapeType;
BP_FP_INT_TYPE handleId = addHandle(aabbMin,aabbMax, userPtr,collisionFilterGroup,collisionFilterMask);
Handle* handle = getHandle(handleId);
return handle;
}
void btAxisSweep3::destroyProxy(btBroadphaseProxy* proxy)
{
Handle* handle = static_cast<Handle*>(proxy);
removeHandle(handle->m_handleId);
}
void btAxisSweep3::setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)
{
Handle* handle = static_cast<Handle*>(proxy);
updateHandle(handle->m_handleId,aabbMin,aabbMax);
}
btAxisSweep3::btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles, btOverlappingPairCache* pairCache)
:m_invalidPair(0),
m_pairCache(pairCache),
m_ownsPairCache(false)
{
if (!m_pairCache)
{
m_pairCache = new btOverlappingPairCache();
m_ownsPairCache = true;
}
//assert(bounds.HasVolume());
// 1 handle is reserved as sentinel
btAssert(maxHandles > 1 && maxHandles < BP_MAX_HANDLES);
// init bounds
m_worldAabbMin = worldAabbMin;
m_worldAabbMax = worldAabbMax;
btVector3 aabbSize = m_worldAabbMax - m_worldAabbMin;
BP_FP_INT_TYPE maxInt = BP_HANDLE_SENTINEL;
m_quantize = btVector3(btScalar(maxInt),btScalar(maxInt),btScalar(maxInt)) / aabbSize;
// allocate handles buffer and put all handles on free list
m_pHandles = new Handle[maxHandles];
m_maxHandles = maxHandles;
m_numHandles = 0;
// handle 0 is reserved as the null index, and is also used as the sentinel
m_firstFreeHandle = 1;
{
for (BP_FP_INT_TYPE i = m_firstFreeHandle; i < maxHandles; i++)
m_pHandles[i].SetNextFree(i + 1);
m_pHandles[maxHandles - 1].SetNextFree(0);
}
{
// allocate edge buffers
for (int i = 0; i < 3; i++)
m_pEdges[i] = new Edge[maxHandles * 2];
}
//removed overlap management
// make boundary sentinels
m_pHandles[0].m_clientObject = 0;
for (int axis = 0; axis < 3; axis++)
{
m_pHandles[0].m_minEdges[axis] = 0;
m_pHandles[0].m_maxEdges[axis] = 1;
m_pEdges[axis][0].m_pos = 0;
m_pEdges[axis][0].m_handle = 0;
m_pEdges[axis][1].m_pos = BP_HANDLE_SENTINEL;
m_pEdges[axis][1].m_handle = 0;
#ifdef DEBUG_BROADPHASE
debugPrintAxis(axis);
#endif //DEBUG_BROADPHASE
}
}
btAxisSweep3::~btAxisSweep3()
{
for (int i = 2; i >= 0; i--)
delete[] m_pEdges[i];
delete[] m_pHandles;
if (m_ownsPairCache)
{
delete m_pairCache;
}
}
void btAxisSweep3::quantize(BP_FP_INT_TYPE* out, const btPoint3& point, int isMax) const
{
btPoint3 clampedPoint(point);
clampedPoint.setMax(m_worldAabbMin);
clampedPoint.setMin(m_worldAabbMax);
btVector3 v = (clampedPoint - m_worldAabbMin) * m_quantize;
out[0] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getX() & BP_HANDLE_MASK) | isMax);
out[1] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getY() & BP_HANDLE_MASK) | isMax);
out[2] = (BP_FP_INT_TYPE)(((BP_FP_INT_TYPE)v.getZ() & BP_HANDLE_MASK) | isMax);
}
BP_FP_INT_TYPE btAxisSweep3::allocHandle()
{
assert(m_firstFreeHandle);
BP_FP_INT_TYPE handle = m_firstFreeHandle;
m_firstFreeHandle = getHandle(handle)->GetNextFree();
m_numHandles++;
return handle;
}
void btAxisSweep3::freeHandle(BP_FP_INT_TYPE handle)
{
assert(handle > 0 && handle < m_maxHandles);
getHandle(handle)->SetNextFree(m_firstFreeHandle);
m_firstFreeHandle = handle;
m_numHandles--;
}
BP_FP_INT_TYPE btAxisSweep3::addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask)
{
// quantize the bounds
BP_FP_INT_TYPE min[3], max[3];
quantize(min, aabbMin, 0);
quantize(max, aabbMax, 1);
// allocate a handle
BP_FP_INT_TYPE handle = allocHandle();
assert(handle!= 0xcdcd);
Handle* pHandle = getHandle(handle);
pHandle->m_handleId = handle;
//pHandle->m_pOverlaps = 0;
pHandle->m_clientObject = pOwner;
pHandle->m_collisionFilterGroup = collisionFilterGroup;
pHandle->m_collisionFilterMask = collisionFilterMask;
// compute current limit of edge arrays
BP_FP_INT_TYPE limit = m_numHandles * 2;
// insert new edges just inside the max boundary edge
for (BP_FP_INT_TYPE axis = 0; axis < 3; axis++)
{
m_pHandles[0].m_maxEdges[axis] += 2;
m_pEdges[axis][limit + 1] = m_pEdges[axis][limit - 1];
m_pEdges[axis][limit - 1].m_pos = min[axis];
m_pEdges[axis][limit - 1].m_handle = handle;
m_pEdges[axis][limit].m_pos = max[axis];
m_pEdges[axis][limit].m_handle = handle;
pHandle->m_minEdges[axis] = limit - 1;
pHandle->m_maxEdges[axis] = limit;
}
// now sort the new edges to their correct position
sortMinDown(0, pHandle->m_minEdges[0], false);
sortMaxDown(0, pHandle->m_maxEdges[0], false);
sortMinDown(1, pHandle->m_minEdges[1], false);
sortMaxDown(1, pHandle->m_maxEdges[1], false);
sortMinDown(2, pHandle->m_minEdges[2], true);
sortMaxDown(2, pHandle->m_maxEdges[2], true);
return handle;
}
void btAxisSweep3::removeHandle(BP_FP_INT_TYPE handle)
{
Handle* pHandle = getHandle(handle);
//explicitly remove the pairs containing the proxy
//we could do it also in the sortMinUp (passing true)
//todo: compare performance
m_pairCache->removeOverlappingPairsContainingProxy(pHandle);
// compute current limit of edge arrays
int limit = m_numHandles * 2;
int axis;
for (axis = 0;axis<3;axis++)
{
m_pHandles[0].m_maxEdges[axis] -= 2;
}
// remove the edges by sorting them up to the end of the list
for ( axis = 0; axis < 3; axis++)
{
Edge* pEdges = m_pEdges[axis];
BP_FP_INT_TYPE max = pHandle->m_maxEdges[axis];
pEdges[max].m_pos = BP_HANDLE_SENTINEL;
sortMaxUp(axis,max,false);
BP_FP_INT_TYPE i = pHandle->m_minEdges[axis];
pEdges[i].m_pos = BP_HANDLE_SENTINEL;
sortMinUp(axis,i,false);
pEdges[limit-1].m_handle = 0;
pEdges[limit-1].m_pos = BP_HANDLE_SENTINEL;
#ifdef DEBUG_BROADPHASE
debugPrintAxis(axis,false);
#endif //DEBUG_BROADPHASE
}
// free the handle
freeHandle(handle);
}
extern int gOverlappingPairs;
void btAxisSweep3::calculateOverlappingPairs()
{
if (m_ownsPairCache)
{
btBroadphasePairArray& overlappingPairArray = m_pairCache->getOverlappingPairArray();
//perform a sort, to find duplicates and to sort 'invalid' pairs to the end
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
m_invalidPair = 0;
int i;
btBroadphasePair previousPair;
previousPair.m_pProxy0 = 0;
previousPair.m_pProxy1 = 0;
previousPair.m_algorithm = 0;
for (i=0;i<overlappingPairArray.size();i++)
{
btBroadphasePair& pair = overlappingPairArray[i];
bool isDuplicate = (pair == previousPair);
previousPair = pair;
bool needsRemoval = false;
if (!isDuplicate)
{
bool hasOverlap = testAabbOverlap(pair.m_pProxy0,pair.m_pProxy1);
if (hasOverlap)
{
needsRemoval = false;//callback->processOverlap(pair);
} else
{
needsRemoval = true;
}
} else
{
//remove duplicate
needsRemoval = true;
//should have no algorithm
btAssert(!pair.m_algorithm);
}
if (needsRemoval)
{
m_pairCache->cleanOverlappingPair(pair);
// m_overlappingPairArray.swap(i,m_overlappingPairArray.size()-1);
// m_overlappingPairArray.pop_back();
pair.m_pProxy0 = 0;
pair.m_pProxy1 = 0;
m_invalidPair++;
gOverlappingPairs--;
}
}
///if you don't like to skip the invalid pairs in the array, execute following code:
#define CLEAN_INVALID_PAIRS 1
#ifdef CLEAN_INVALID_PAIRS
//perform a sort, to sort 'invalid' pairs to the end
overlappingPairArray.heapSort(btBroadphasePairSortPredicate());
overlappingPairArray.resize(overlappingPairArray.size() - m_invalidPair);
m_invalidPair = 0;
#endif//CLEAN_INVALID_PAIRS
}
}
bool btAxisSweep3::testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1)
{
const Handle* pHandleA = static_cast<Handle*>(proxy0);
const Handle* pHandleB = static_cast<Handle*>(proxy1);
//optimization 1: check the array index (memory address), instead of the m_pos
for (int axis = 0; axis < 3; axis++)
{
if (pHandleA->m_maxEdges[axis] < pHandleB->m_minEdges[axis] ||
pHandleB->m_maxEdges[axis] < pHandleA->m_minEdges[axis])
{
return false;
}
}
return true;
}
bool btAxisSweep3::testOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB)
{
//optimization 1: check the array index (memory address), instead of the m_pos
for (int axis = 0; axis < 3; axis++)
{
if (axis != ignoreAxis)
{
if (pHandleA->m_maxEdges[axis] < pHandleB->m_minEdges[axis] ||
pHandleB->m_maxEdges[axis] < pHandleA->m_minEdges[axis])
{
return false;
}
}
}
//optimization 2: only 2 axis need to be tested (conflicts with 'delayed removal' optimization)
/*for (int axis = 0; axis < 3; axis++)
{
if (m_pEdges[axis][pHandleA->m_maxEdges[axis]].m_pos < m_pEdges[axis][pHandleB->m_minEdges[axis]].m_pos ||
m_pEdges[axis][pHandleB->m_maxEdges[axis]].m_pos < m_pEdges[axis][pHandleA->m_minEdges[axis]].m_pos)
{
return false;
}
}
*/
return true;
}
void btAxisSweep3::updateHandle(BP_FP_INT_TYPE handle, const btPoint3& aabbMin,const btPoint3& aabbMax)
{
// assert(bounds.IsFinite());
//assert(bounds.HasVolume());
Handle* pHandle = getHandle(handle);
// quantize the new bounds
BP_FP_INT_TYPE min[3], max[3];
quantize(min, aabbMin, 0);
quantize(max, aabbMax, 1);
// update changed edges
for (int axis = 0; axis < 3; axis++)
{
BP_FP_INT_TYPE emin = pHandle->m_minEdges[axis];
BP_FP_INT_TYPE emax = pHandle->m_maxEdges[axis];
int dmin = (int)min[axis] - (int)m_pEdges[axis][emin].m_pos;
int dmax = (int)max[axis] - (int)m_pEdges[axis][emax].m_pos;
m_pEdges[axis][emin].m_pos = min[axis];
m_pEdges[axis][emax].m_pos = max[axis];
// expand (only adds overlaps)
if (dmin < 0)
sortMinDown(axis, emin);
if (dmax > 0)
sortMaxUp(axis, emax);
// shrink (only removes overlaps)
if (dmin > 0)
sortMinUp(axis, emin);
if (dmax < 0)
sortMaxDown(axis, emax);
#ifdef DEBUG_BROADPHASE
debugPrintAxis(axis);
#endif //DEBUG_BROADPHASE
}
}
// sorting a min edge downwards can only ever *add* overlaps
void btAxisSweep3::sortMinDown(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1;
Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos < pPrev->m_pos)
{
Handle* pHandlePrev = getHandle(pPrev->m_handle);
if (pPrev->IsMax())
{
// if previous edge is a maximum check the bounds and add an overlap if necessary
if (updateOverlaps && testOverlap(axis,pHandleEdge, pHandlePrev))
{
m_pairCache->addOverlappingPair(pHandleEdge,pHandlePrev);
//AddOverlap(pEdge->m_handle, pPrev->m_handle);
}
// update edge reference in other handle
pHandlePrev->m_maxEdges[axis]++;
}
else
pHandlePrev->m_minEdges[axis]++;
pHandleEdge->m_minEdges[axis]--;
// swap the edges
Edge swap = *pEdge;
*pEdge = *pPrev;
*pPrev = swap;
// decrement
pEdge--;
pPrev--;
}
#ifdef DEBUG_BROADPHASE
debugPrintAxis(axis);
#endif //DEBUG_BROADPHASE
}
// sorting a min edge upwards can only ever *remove* overlaps
void btAxisSweep3::sortMinUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1;
Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
{
Handle* pHandleNext = getHandle(pNext->m_handle);
if (pNext->IsMax())
{
// if next edge is maximum remove any overlap between the two handles
if (updateOverlaps)
{
/*
Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = getHandle(pNext->m_handle);
btBroadphasePair tmpPair(*handle0,*handle1);
removeOverlappingPair(tmpPair);
*/
}
// update edge reference in other handle
pHandleNext->m_maxEdges[axis]--;
}
else
pHandleNext->m_minEdges[axis]--;
pHandleEdge->m_minEdges[axis]++;
// swap the edges
Edge swap = *pEdge;
*pEdge = *pNext;
*pNext = swap;
// increment
pEdge++;
pNext++;
}
}
// sorting a max edge downwards can only ever *remove* overlaps
void btAxisSweep3::sortMaxDown(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pPrev = pEdge - 1;
Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pEdge->m_pos < pPrev->m_pos)
{
Handle* pHandlePrev = getHandle(pPrev->m_handle);
if (!pPrev->IsMax())
{
// if previous edge was a minimum remove any overlap between the two handles
if (updateOverlaps)
{
//this is done during the overlappingpairarray iteration/narrowphase collision
/*
Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = getHandle(pPrev->m_handle);
btBroadphasePair* pair = findPair(handle0,handle1);
//assert(pair);
if (pair)
{
removeOverlappingPair(*pair);
}
*/
}
// update edge reference in other handle
pHandlePrev->m_minEdges[axis]++;;
}
else
pHandlePrev->m_maxEdges[axis]++;
pHandleEdge->m_maxEdges[axis]--;
// swap the edges
Edge swap = *pEdge;
*pEdge = *pPrev;
*pPrev = swap;
// decrement
pEdge--;
pPrev--;
}
#ifdef DEBUG_BROADPHASE
debugPrintAxis(axis);
#endif //DEBUG_BROADPHASE
}
// sorting a max edge upwards can only ever *add* overlaps
void btAxisSweep3::sortMaxUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps)
{
Edge* pEdge = m_pEdges[axis] + edge;
Edge* pNext = pEdge + 1;
Handle* pHandleEdge = getHandle(pEdge->m_handle);
while (pNext->m_handle && (pEdge->m_pos >= pNext->m_pos))
{
Handle* pHandleNext = getHandle(pNext->m_handle);
if (!pNext->IsMax())
{
// if next edge is a minimum check the bounds and add an overlap if necessary
if (updateOverlaps && testOverlap(axis, pHandleEdge, pHandleNext))
{
Handle* handle0 = getHandle(pEdge->m_handle);
Handle* handle1 = getHandle(pNext->m_handle);
m_pairCache->addOverlappingPair(handle0,handle1);
}
// update edge reference in other handle
pHandleNext->m_minEdges[axis]--;
}
else
pHandleNext->m_maxEdges[axis]--;
pHandleEdge->m_maxEdges[axis]++;
// swap the edges
Edge swap = *pEdge;
*pEdge = *pNext;
*pNext = swap;
// increment
pEdge++;
pNext++;
}
}

View File

@ -0,0 +1,153 @@
//Bullet Continuous Collision Detection and Physics Library
//Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
//
// btAxisSweep3.h
//
// Copyright (c) 2006 Simon Hobbs
//
// This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
#ifndef AXIS_SWEEP_3_H
#define AXIS_SWEEP_3_H
#include "LinearMath/btPoint3.h"
#include "LinearMath/btVector3.h"
#include "btOverlappingPairCache.h"
#include "btBroadphaseInterface.h"
#include "btBroadphaseProxy.h"
//Enable BP_USE_FIXEDPOINT_INT_32 if you need more then 32767 objects
//#define BP_USE_FIXEDPOINT_INT_32 1
#ifdef BP_USE_FIXEDPOINT_INT_32
#define BP_FP_INT_TYPE unsigned int
#define BP_MAX_HANDLES 1500000 //arbitrary maximum number of handles
#define BP_HANDLE_SENTINEL 0x7fffffff
#define BP_HANDLE_MASK 0xfffffffe
#else
#define BP_FP_INT_TYPE unsigned short int
#define BP_MAX_HANDLES 32767
#define BP_HANDLE_SENTINEL 0xffff
#define BP_HANDLE_MASK 0xfffe
#endif //BP_USE_FIXEDPOINT_INT_32
//#define DEBUG_BROADPHASE 1
/// btAxisSweep3 is an efficient implementation of the 3d axis sweep and prune broadphase.
/// It uses arrays rather then lists for storage of the 3 axis. Also it operates using integer coordinates instead of floats.
/// The testOverlap check is optimized to check the array index, rather then the actual AABB coordinates/pos
class btAxisSweep3 : public btBroadphaseInterface
{
public:
class Edge
{
public:
BP_FP_INT_TYPE m_pos; // low bit is min/max
BP_FP_INT_TYPE m_handle;
BP_FP_INT_TYPE IsMax() const {return m_pos & 1;}
};
public:
class Handle : public btBroadphaseProxy
{
public:
// indexes into the edge arrays
BP_FP_INT_TYPE m_minEdges[3], m_maxEdges[3]; // 6 * 2 = 12
BP_FP_INT_TYPE m_handleId;
BP_FP_INT_TYPE m_pad;
//void* m_pOwner; this is now in btBroadphaseProxy.m_clientObject
inline void SetNextFree(BP_FP_INT_TYPE next) {m_minEdges[0] = next;}
inline BP_FP_INT_TYPE GetNextFree() const {return m_minEdges[0];}
}; // 24 bytes + 24 for Edge structures = 44 bytes total per entry
protected:
btPoint3 m_worldAabbMin; // overall system bounds
btPoint3 m_worldAabbMax; // overall system bounds
btVector3 m_quantize; // scaling factor for quantization
BP_FP_INT_TYPE m_numHandles; // number of active handles
int m_maxHandles; // max number of handles
Handle* m_pHandles; // handles pool
BP_FP_INT_TYPE m_firstFreeHandle; // free handles list
Edge* m_pEdges[3]; // edge arrays for the 3 axes (each array has m_maxHandles * 2 + 2 sentinel entries)
btOverlappingPairCache* m_pairCache;
bool m_ownsPairCache;
int m_invalidPair;
// allocation/deallocation
BP_FP_INT_TYPE allocHandle();
void freeHandle(BP_FP_INT_TYPE handle);
bool testOverlap(int ignoreAxis,const Handle* pHandleA, const Handle* pHandleB);
#ifdef DEBUG_BROADPHASE
void debugPrintAxis(int axis,bool checkCardinality=true);
#endif //DEBUG_BROADPHASE
//Overlap* AddOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
//void RemoveOverlap(BP_FP_INT_TYPE handleA, BP_FP_INT_TYPE handleB);
void quantize(BP_FP_INT_TYPE* out, const btPoint3& point, int isMax) const;
void sortMinDown(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps = true);
void sortMinUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps = true);
void sortMaxDown(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps = true);
void sortMaxUp(int axis, BP_FP_INT_TYPE edge, bool updateOverlaps = true);
public:
btAxisSweep3(const btPoint3& worldAabbMin,const btPoint3& worldAabbMax, int maxHandles = 16384, btOverlappingPairCache* pairCache=0);
virtual ~btAxisSweep3();
virtual void calculateOverlappingPairs();
BP_FP_INT_TYPE addHandle(const btPoint3& aabbMin,const btPoint3& aabbMax, void* pOwner,short int collisionFilterGroup,short int collisionFilterMask);
void removeHandle(BP_FP_INT_TYPE handle);
void updateHandle(BP_FP_INT_TYPE handle, const btPoint3& aabbMin,const btPoint3& aabbMax);
inline Handle* getHandle(BP_FP_INT_TYPE index) const {return m_pHandles + index;}
void processAllOverlappingPairs(btOverlapCallback* callback);
//Broadphase Interface
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr ,short int collisionFilterGroup,short int collisionFilterMask);
virtual void destroyProxy(btBroadphaseProxy* proxy);
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax);
bool testAabbOverlap(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1);
btOverlappingPairCache* getOverlappingPairCache()
{
return m_pairCache;
}
const btOverlappingPairCache* getOverlappingPairCache() const
{
return m_pairCache;
}
};
#endif

View File

@ -0,0 +1,46 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BROADPHASE_INTERFACE_H
#define BROADPHASE_INTERFACE_H
struct btDispatcherInfo;
class btDispatcher;
#include "btBroadphaseProxy.h"
class btOverlappingPairCache;
#include "LinearMath/btVector3.h"
///BroadphaseInterface for aabb-overlapping object pairs
class btBroadphaseInterface
{
public:
virtual ~btBroadphaseInterface() {}
virtual btBroadphaseProxy* createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask) =0;
virtual void destroyProxy(btBroadphaseProxy* proxy)=0;
virtual void setAabb(btBroadphaseProxy* proxy,const btVector3& aabbMin,const btVector3& aabbMax)=0;
///calculateOverlappingPairs is optional: incremental algorithms (sweep and prune) might do it during the set aabb
virtual void calculateOverlappingPairs()=0;
virtual btOverlappingPairCache* getOverlappingPairCache()=0;
virtual const btOverlappingPairCache* getOverlappingPairCache() const =0;
};
#endif //BROADPHASE_INTERFACE_H

View File

@ -0,0 +1,17 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "btBroadphaseProxy.h"

View File

@ -0,0 +1,217 @@
/*
Bullet Continuous Collision Detection and Physics Library
Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef BROADPHASE_PROXY_H
#define BROADPHASE_PROXY_H
#include "LinearMath/btScalar.h" //for SIMD_FORCE_INLINE
/// btDispatcher uses these types
/// IMPORTANT NOTE:The types are ordered polyhedral, implicit convex and concave
/// to facilitate type checking
enum BroadphaseNativeTypes
{
// polyhedral convex shapes
BOX_SHAPE_PROXYTYPE,
TRIANGLE_SHAPE_PROXYTYPE,
TETRAHEDRAL_SHAPE_PROXYTYPE,
CONVEX_TRIANGLEMESH_SHAPE_PROXYTYPE,
CONVEX_HULL_SHAPE_PROXYTYPE,
//implicit convex shapes
IMPLICIT_CONVEX_SHAPES_START_HERE,
SPHERE_SHAPE_PROXYTYPE,
MULTI_SPHERE_SHAPE_PROXYTYPE,
CAPSULE_SHAPE_PROXYTYPE,
CONE_SHAPE_PROXYTYPE,
CONVEX_SHAPE_PROXYTYPE,
CYLINDER_SHAPE_PROXYTYPE,
UNIFORM_SCALING_SHAPE_PROXYTYPE,
MINKOWSKI_SUM_SHAPE_PROXYTYPE,
MINKOWSKI_DIFFERENCE_SHAPE_PROXYTYPE,
//concave shapes
CONCAVE_SHAPES_START_HERE,
//keep all the convex shapetype below here, for the check IsConvexShape in broadphase proxy!
TRIANGLE_MESH_SHAPE_PROXYTYPE,
///used for demo integration FAST/Swift collision library and Bullet
FAST_CONCAVE_MESH_PROXYTYPE,
//terrain
TERRAIN_SHAPE_PROXYTYPE,
///Used for GIMPACT Trimesh integration
GIMPACT_SHAPE_PROXYTYPE,
EMPTY_SHAPE_PROXYTYPE,
STATIC_PLANE_PROXYTYPE,
CONCAVE_SHAPES_END_HERE,
COMPOUND_SHAPE_PROXYTYPE,
MAX_BROADPHASE_COLLISION_TYPES
};
///btBroadphaseProxy
struct btBroadphaseProxy
{
///optional filtering to cull potential collisions
enum CollisionFilterGroups
{
DefaultFilter = 1,
StaticFilter = 2,
KinematicFilter = 4,
DebrisFilter = 8,
SensorTrigger = 16,
AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorTrigger
};
//Usually the client btCollisionObject or Rigidbody class
void* m_clientObject;
///in the case of btMultiSapBroadphase, we store the collifionFilterGroup/Mask in the m_multiSapParentProxy
union
{
struct
{
short int m_collisionFilterGroup;
short int m_collisionFilterMask;
};
void* m_multiSapParentProxy;
};
//used for memory pools
btBroadphaseProxy() :m_clientObject(0){}
btBroadphaseProxy(void* userPtr,short int collisionFilterGroup, short int collisionFilterMask)
:m_clientObject(userPtr),
m_collisionFilterGroup(collisionFilterGroup),