fixed memoryleak,
added RayTestSingle to CollisionWorld prepared to add VehicleDemo
This commit is contained in:
@@ -101,6 +101,7 @@ void OverlappingPairCache::AddOverlappingPair(BroadphaseProxy* proxy0,Broadphase
|
||||
///this FindPair becomes really slow. Either sort the list to speedup the query, or
|
||||
///use a different solution. It is mainly used for Removing overlapping pairs. Removal could be delayed.
|
||||
///we could keep a linked list in each proxy, and store pair in one of the proxies (with lowest memory address)
|
||||
///Also we can use a 2D bitmap, which can be useful for a future GPU implementation
|
||||
BroadphasePair* OverlappingPairCache::FindPair(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1)
|
||||
{
|
||||
BroadphasePair* foundPair = 0;
|
||||
|
||||
@@ -103,6 +103,8 @@ void CollisionWorld::PerformDiscreteCollisionDetection()
|
||||
m_pairCache->SetAabb(m_collisionObjects[i]->m_broadphaseHandle,aabbMin,aabbMax);
|
||||
}
|
||||
|
||||
m_pairCache->RefreshOverlappingPairs();
|
||||
|
||||
Dispatcher* dispatcher = GetDispatcher();
|
||||
if (dispatcher)
|
||||
dispatcher->DispatchAllCollisionPairs(&m_pairCache->GetOverlappingPair(0),m_pairCache->GetNumOverlappingPairs(),dispatchInfo);
|
||||
@@ -140,11 +142,11 @@ void CollisionWorld::RemoveCollisionObject(CollisionObject* collisionObject)
|
||||
}
|
||||
}
|
||||
|
||||
void RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
void CollisionWorld::RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
CollisionObject* collisionObject,
|
||||
const CollisionShape* collisionShape,
|
||||
const SimdTransform& colObjWorldTransform,
|
||||
CollisionWorld::RayResultCallback& resultCallback)
|
||||
RayResultCallback& resultCallback)
|
||||
{
|
||||
|
||||
SphereShape pointShape(0.0f);
|
||||
|
||||
@@ -204,8 +204,18 @@ public:
|
||||
return m_collisionObjects.size();
|
||||
}
|
||||
|
||||
/// RayTest performs a raycast on all objects in the CollisionWorld, and calls the resultCallback
|
||||
/// This allows for several queries: first hit, all hits, any hit, dependent on the value returned by the callback.
|
||||
void RayTest(const SimdVector3& rayFromWorld, const SimdVector3& rayToWorld, RayResultCallback& resultCallback);
|
||||
|
||||
/// RayTestSingle performs a raycast call and calls the resultCallback. It is used internally by RayTest.
|
||||
/// In a future implementation, we consider moving the ray test as a virtual method in CollisionShape.
|
||||
/// This allows more customization.
|
||||
void RayTestSingle(const SimdTransform& rayFromTrans,const SimdTransform& rayToTrans,
|
||||
CollisionObject* collisionObject,
|
||||
const CollisionShape* collisionShape,
|
||||
const SimdTransform& colObjWorldTransform,
|
||||
RayResultCallback& resultCallback);
|
||||
|
||||
void AddCollisionObject(CollisionObject* collisionObject,short int collisionFilterGroup=1,short int collisionFilterMask=1);
|
||||
|
||||
|
||||
@@ -85,6 +85,11 @@ void OptimizedBvh::Build(StridingMeshInterface* triangles)
|
||||
// OptimizedBvhNode* leafNodes = new OptimizedBvhNode;
|
||||
}
|
||||
|
||||
OptimizedBvh::~OptimizedBvh()
|
||||
{
|
||||
if (m_contiguousNodes)
|
||||
delete m_contiguousNodes;
|
||||
}
|
||||
|
||||
OptimizedBvhNode* OptimizedBvh::BuildTree (NodeArray& leafNodes,int startIndex,int endIndex)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ class OptimizedBvh
|
||||
|
||||
public:
|
||||
OptimizedBvh() :m_rootNode1(0), m_numNodes(0) { }
|
||||
virtual ~OptimizedBvh() {};
|
||||
virtual ~OptimizedBvh();
|
||||
|
||||
void Build(StridingMeshInterface* triangles);
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
SUBDIRS( OpenGL CcdPhysicsDemo BspDemo ColladaDemo )
|
||||
SUBDIRS( OpenGL CcdPhysicsDemo BspDemo ColladaDemo VehicleDemo )
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ SubInclude TOP Demos BspDemo ;
|
||||
SubInclude TOP Demos ConvexDecompositionDemo ;
|
||||
SubInclude TOP Demos ColladaDemo ;
|
||||
SubInclude TOP Demos BspDemo ;
|
||||
SubInclude TOP Demos VehicleDemo ;
|
||||
SubInclude TOP Demos CollisionDemo ;
|
||||
SubInclude TOP Demos CollisionInterfaceDemo ;
|
||||
SubInclude TOP Demos ConcaveDemo ;
|
||||
|
||||
61
Demos/VehicleDemo/CMakeLists.txt
Normal file
61
Demos/VehicleDemo/CMakeLists.txt
Normal file
@@ -0,0 +1,61 @@
|
||||
# This is basically the overall name of the project in Visual Studio this is the name of the Solution File
|
||||
|
||||
|
||||
# For every executable you have with a main method you should have an add_executable line below.
|
||||
# For every add executable line you should list every .cpp and .h file you have associated with that executable.
|
||||
|
||||
|
||||
# This is the variable for Windows. I use this to define the root of my directory structure.
|
||||
SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
|
||||
|
||||
# You shouldn't have to modify anything below this line
|
||||
########################################################
|
||||
|
||||
|
||||
# This is the shortcut to finding GLU, GLUT and OpenGL if they are properly installed on your system
|
||||
# This should be the case.
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/FindGLU.cmake)
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/FindGLUT.cmake)
|
||||
INCLUDE (${CMAKE_ROOT}/Modules/FindOpenGL.cmake)
|
||||
|
||||
|
||||
IF (WIN32)
|
||||
# This is the Windows code for which Opengl, and Glut are not properly installed
|
||||
# since I can't install them I must cheat and copy libraries around
|
||||
INCLUDE_DIRECTORIES(${GLUT_ROOT})
|
||||
# LINK_DIRECTORIES(${GLUT_ROOT}\\lib)
|
||||
IF (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
|
||||
SET(GLUT_glut_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glut32.lib)
|
||||
# LINK_LIBRARIES(${GLUT_ROOT}\\lib\\glut32 ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
|
||||
# TARGET_LINK_LIBRARIES(table ${GLUT_ROOT}\\lib\\glut32)
|
||||
#
|
||||
# ADD_CUSTOM_COMMAND(TARGET table POST_BUILD COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2005\\Debug
|
||||
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs2003\\Debug
|
||||
# COMMAND copy ${GLUT_ROOT}\\lib\\glut32.dll ${GLUT_ROOT}\\bin\\vs6\\Debug)
|
||||
ELSE (${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
|
||||
# LINK_LIBRARIES(${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
|
||||
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY})
|
||||
ENDIF(${GLUT_glut_LIBRARY} MATCHES "GLUT_glut_LIBRARY-NOTFOUND")
|
||||
# TARGET_LINK_LIBRARIES(table ${OPENGL_gl_LIBRARY})
|
||||
# TARGET_LINK_LIBRARIES(table ${OPENGL_glu_LIBRARY})
|
||||
ELSE (WIN32)
|
||||
# This is the lines for linux. This should always work if everything is installed and working fine.
|
||||
# SET(CMAKE_BUILD_TYPE Debug)
|
||||
# SET(CMAKE_CXX_FLAGS_DEBUG "-g")
|
||||
INCLUDE_DIRECTORIES(/usr/include /usr/local/include ${GLUT_INCLUDE_DIR})
|
||||
# TARGET_LINK_LIBRARIES(table ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
|
||||
# TARGET_LINK_LIBRARIES(checker ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY})
|
||||
ENDIF (WIN32)
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/LinearMath ${BULLET_PHYSICS_SOURCE_DIR}/Bullet ${BULLET_PHYSICS_SOURCE_DIR}/BulletDynamics ${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL ${BULLET_PHYSICS_SOURCE_DIR}/Extras/PhysicsInterface/Common ${BULLET_PHYSICS_SOURCE_DIR}/Extras/PhysicsInterface/CcdPhysics }
|
||||
)
|
||||
|
||||
LINK_LIBRARIES(
|
||||
LibCcdPhysicsInterface LibOpenGLSupport LibBulletDynamics LibPhysicsCommonInterface LibBulletCollision LibLinearMath ${GLUT_glut_LIBRARY} ${OPENGL_gl_LIBRARY} ${OPENGL_glU_LIBRARY}
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(VehicleDemo
|
||||
VehicleDemo.cpp
|
||||
)
|
||||
|
||||
3
Demos/VehicleDemo/Jamfile
Normal file
3
Demos/VehicleDemo/Jamfile
Normal file
@@ -0,0 +1,3 @@
|
||||
SubDir TOP Demos VehicleDemo ;
|
||||
|
||||
BulletDemo VehicleDemo : [ Wildcard *.h *.cpp ] ;
|
||||
1044
Demos/VehicleDemo/VehicleDemo.cpp
Normal file
1044
Demos/VehicleDemo/VehicleDemo.cpp
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user