mirror of
https://github.com/bulletphysics/bullet3
synced 2024-12-15 06:00:12 +00:00
ab8f16961e
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
82 lines
2.4 KiB
C++
82 lines
2.4 KiB
C++
/*
|
|
Copyright (c) 2012 Advanced Micro Devices, Inc.
|
|
|
|
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 <stdio.h>
|
|
|
|
#include "Bullet3Common/b3Vector3.h"
|
|
#include "Bullet3Collision/BroadPhaseCollision/b3DynamicBvhBroadphase.h"
|
|
#include "Bullet3Common/b3CommandLineArgs.h"
|
|
#include "Bullet3Common/b3MinMax.h"
|
|
#include "Bullet3Collision/BroadPhaseCollision/b3OverlappingPairCache.h"
|
|
|
|
int g_nPassed = 0;
|
|
int g_nFailed = 0;
|
|
bool g_testFailed = 0;
|
|
|
|
#define TEST_INIT g_testFailed = 0;
|
|
#define TEST_ASSERT(x) \
|
|
if (!(x)) \
|
|
{ \
|
|
g_testFailed = 1; \
|
|
}
|
|
#define TEST_REPORT(testName) \
|
|
printf("[%s] %s\n", (g_testFailed) ? "X" : "O", testName); \
|
|
if (g_testFailed) \
|
|
g_nFailed++; \
|
|
else \
|
|
g_nPassed++;
|
|
|
|
inline void broadphaseTest()
|
|
{
|
|
TEST_INIT;
|
|
|
|
b3DynamicBvhBroadphase* bp = new b3DynamicBvhBroadphase(2);
|
|
|
|
int group = 1;
|
|
int mask = 1;
|
|
b3Vector3 aabbMin(0, 0, 0);
|
|
b3Vector3 aabbMax(1, 1, 1);
|
|
int userId = 0;
|
|
bp->createProxy(aabbMin, aabbMax, userId++, 0, group, mask);
|
|
|
|
aabbMin.setValue(1, 1, 1);
|
|
aabbMax.setValue(2, 2, 2);
|
|
|
|
bp->createProxy(aabbMin, aabbMax, userId++, 0, group, mask);
|
|
|
|
bp->calculateOverlappingPairs();
|
|
|
|
int numOverlap = bp->getOverlappingPairCache()->getNumOverlappingPairs();
|
|
|
|
TEST_ASSERT(numOverlap == 1);
|
|
|
|
delete bp;
|
|
|
|
TEST_REPORT("broadphaseTest");
|
|
}
|
|
|
|
int main(int argc, char** argv)
|
|
{
|
|
broadphaseTest();
|
|
|
|
printf("%d tests passed\n", g_nPassed, g_nFailed);
|
|
if (g_nFailed)
|
|
{
|
|
printf("%d tests failed\n", g_nFailed);
|
|
}
|
|
printf("End, press <enter>\n");
|
|
|
|
getchar();
|
|
}
|