mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 15:54:32 +02:00
finished physics tests
This commit is contained in:
parent
0d9a661839
commit
c61b38f5e6
6 changed files with 170 additions and 192 deletions
|
@ -13,7 +13,6 @@
|
|||
#define hifi_BulletUtilTests_h
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// Add additional qtest functionality (the include order is important!)
|
||||
#include "GlmTestUtils.h"
|
||||
#include "../QTestExtensions.hpp"
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
//
|
||||
// PhysicsTestUtil.h
|
||||
// tests/physics/src
|
||||
//
|
||||
// Created by Andrew Meadows on 02/21/2014.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_PhysicsTestUtil_h
|
||||
#define hifi_PhysicsTestUtil_h
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/quaternion.hpp>
|
||||
#include <BulletUtil.h>
|
||||
|
||||
#include <qtextstream.h>
|
||||
|
||||
#include <CollisionInfo.h>
|
||||
|
||||
const glm::vec3 origin(0.0f);
|
||||
const glm::vec3 xAxis(1.0f, 0.0f, 0.0f);
|
||||
const glm::vec3 yAxis(0.0f, 1.0f, 0.0f);
|
||||
const glm::vec3 zAxis(0.0f, 0.0f, 1.0f);
|
||||
|
||||
// Implement these functions for whatever data types you need.
|
||||
//
|
||||
// fuzzyCompare takes two args of type T (the type you're comparing), and should
|
||||
// return an error / difference of type V (eg. if T is a vector, V is a scalar).
|
||||
// For vector types this is just the distance between a and b.
|
||||
//
|
||||
// stringify is just a toString() / repr() style function. For PoD types,
|
||||
// I'd recommend using the c++11 initialization syntax (type { constructor args... }),
|
||||
// since it's clear and unambiguous.
|
||||
//
|
||||
inline float fuzzyCompare (const glm::vec3 & a, const glm::vec3 & b) {
|
||||
return glm::distance(a, b);
|
||||
}
|
||||
inline QTextStream & operator << (QTextStream & stream, const glm::vec3 & v) {
|
||||
return stream << "glm::vec3 { " << v.x << ", " << v.y << ", " << v.z << " }";
|
||||
}
|
||||
|
||||
inline btScalar fuzzyCompare (btScalar a, btScalar b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
#include "../QTestExtensions.hpp"
|
||||
|
||||
|
||||
#endif // hifi_PhysicsTestUtil_h
|
|
@ -24,6 +24,7 @@
|
|||
QTEST_MAIN(ShapeInfoTests)
|
||||
|
||||
void ShapeInfoTests::testHashFunctions() {
|
||||
#if MANUAL_TEST
|
||||
int maxTests = 10000000;
|
||||
ShapeInfo info;
|
||||
btHashMap<btHashInt, uint32_t> hashes;
|
||||
|
@ -41,6 +42,7 @@ void ShapeInfoTests::testHashFunctions() {
|
|||
|
||||
int testCount = 0;
|
||||
int numCollisions = 0;
|
||||
|
||||
btClock timer;
|
||||
for (int x = 1; x < numSteps && testCount < maxTests; ++x) {
|
||||
float radiusX = (float)x * deltaLength;
|
||||
|
@ -136,6 +138,8 @@ void ShapeInfoTests::testHashFunctions() {
|
|||
for (int i = 0; i < 32; ++i) {
|
||||
std::cout << "bit 0x" << std::hex << masks[i] << std::dec << " = " << bits[i] << std::endl;
|
||||
}
|
||||
QCOMPARE(numCollisions, 0);
|
||||
#endif // MANUAL_TEST
|
||||
}
|
||||
|
||||
void ShapeInfoTests::testBoxShape() {
|
||||
|
@ -145,21 +149,24 @@ void ShapeInfoTests::testBoxShape() {
|
|||
DoubleHashKey key = info.getHash();
|
||||
|
||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||
if (!shape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
// if (!shape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: NULL Box shape" << std::endl;
|
||||
// }
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Box shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
}
|
||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||
// if (key.getHash() != otherKey.getHash()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Box shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
// }
|
||||
|
||||
if (key.getHash2() != otherKey.getHash2()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Box shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
}
|
||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||
// if (key.getHash2() != otherKey.getHash2()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Box shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
// }
|
||||
|
||||
delete shape;
|
||||
}
|
||||
|
@ -171,17 +178,20 @@ void ShapeInfoTests::testSphereShape() {
|
|||
DoubleHashKey key = info.getHash();
|
||||
|
||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Sphere shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
}
|
||||
if (key.getHash2() != otherKey.getHash2()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Sphere shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
}
|
||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||
// if (key.getHash() != otherKey.getHash()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Sphere shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
// }
|
||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||
// if (key.getHash2() != otherKey.getHash2()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Sphere shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
// }
|
||||
|
||||
delete shape;
|
||||
}
|
||||
|
@ -195,17 +205,20 @@ void ShapeInfoTests::testCylinderShape() {
|
|||
DoubleHashKey key = info.getHash();
|
||||
|
||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Cylinder shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
}
|
||||
if (key.getHash2() != otherKey.getHash2()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Cylinder shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
}
|
||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||
// if (key.getHash() != otherKey.getHash()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Cylinder shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
// }
|
||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||
// if (key.getHash2() != otherKey.getHash2()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Cylinder shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
// }
|
||||
|
||||
delete shape;
|
||||
*/
|
||||
|
@ -220,17 +233,20 @@ void ShapeInfoTests::testCapsuleShape() {
|
|||
DoubleHashKey key = info.getHash();
|
||||
|
||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
|
||||
ShapeInfo otherInfo = info;
|
||||
DoubleHashKey otherKey = otherInfo.getHash();
|
||||
if (key.getHash() != otherKey.getHash()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Capsule shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
}
|
||||
if (key.getHash2() != otherKey.getHash2()) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected Capsule shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
}
|
||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
||||
// if (key.getHash() != otherKey.getHash()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Capsule shape hash = " << key.getHash() << " but found hash = " << otherKey.getHash() << std::endl;
|
||||
// }
|
||||
QCOMPARE(key.getHash2(), otherKey.getHash2());
|
||||
// if (key.getHash2() != otherKey.getHash2()) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected Capsule shape hash2 = " << key.getHash2() << " but found hash2 = " << otherKey.getHash2() << std::endl;
|
||||
// }
|
||||
|
||||
delete shape;
|
||||
*/
|
||||
|
|
|
@ -14,9 +14,13 @@
|
|||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// Add additional qtest functionality (the include order is important!)
|
||||
#include "BulletTestUtils.h"
|
||||
#include "../QTestExtensions.hpp"
|
||||
//// Add additional qtest functionality (the include order is important!)
|
||||
//#include "BulletTestUtils.h"
|
||||
//#include "../QTestExtensions.hpp"
|
||||
|
||||
// Enable this to manually run testHashCollisions
|
||||
// (NOT a regular unit test; takes ~17 secs to run on an i7)
|
||||
#define MANUAL_TEST false
|
||||
|
||||
class ShapeInfoTests : public QObject {
|
||||
Q_OBJECT
|
||||
|
@ -28,6 +32,4 @@ private slots:
|
|||
void testCapsuleShape();
|
||||
};
|
||||
|
||||
#include "../QTestExtensions.hpp"
|
||||
|
||||
#endif // hifi_ShapeInfoTests_h
|
||||
|
|
|
@ -23,37 +23,42 @@ void ShapeManagerTests::testShapeAccounting() {
|
|||
info.setBox(glm::vec3(1.0f, 1.0f, 1.0f));
|
||||
|
||||
int numReferences = shapeManager.getNumReferences(info);
|
||||
if (numReferences != 0) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected ignorant ShapeManager after initialization" << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 0);
|
||||
// if (numReferences != 0) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected ignorant ShapeManager after initialization" << std::endl;
|
||||
// }
|
||||
|
||||
// create one shape and verify we get a valid pointer
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
if (!shape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected shape creation for default parameters" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
// if (!shape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected shape creation for default parameters" << std::endl;
|
||||
// }
|
||||
|
||||
// verify number of shapes
|
||||
if (shapeManager.getNumShapes() != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape" << std::endl;
|
||||
}
|
||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||
// if (shapeManager.getNumShapes() != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape" << std::endl;
|
||||
// }
|
||||
|
||||
// reference the shape again and verify that we get the same pointer
|
||||
btCollisionShape* otherShape = shapeManager.getShape(info);
|
||||
if (otherShape != shape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape* " << (void*)(shape)
|
||||
<< " but found shape* " << (void*)(otherShape) << std::endl;
|
||||
}
|
||||
QCOMPARE(otherShape, shape);
|
||||
// if (otherShape != shape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape* " << (void*)(shape)
|
||||
// << " but found shape* " << (void*)(otherShape) << std::endl;
|
||||
// }
|
||||
|
||||
// verify number of references
|
||||
numReferences = shapeManager.getNumReferences(info);
|
||||
int expectedNumReferences = 2;
|
||||
if (numReferences != expectedNumReferences) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected " << expectedNumReferences
|
||||
<< " references but found " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, expectedNumReferences);
|
||||
// if (numReferences != expectedNumReferences) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected " << expectedNumReferences
|
||||
// << " references but found " << numReferences << std::endl;
|
||||
// }
|
||||
|
||||
// release all references
|
||||
bool released = shapeManager.releaseShape(info);
|
||||
|
@ -62,59 +67,68 @@ void ShapeManagerTests::testShapeAccounting() {
|
|||
released = shapeManager.releaseShape(info) && released;
|
||||
numReferences--;
|
||||
}
|
||||
if (!released) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape released" << std::endl;
|
||||
}
|
||||
QCOMPARE(released, true);
|
||||
// if (!released) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected shape released" << std::endl;
|
||||
// }
|
||||
|
||||
// verify shape still exists (not yet garbage collected)
|
||||
if (shapeManager.getNumShapes() != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release but before garbage collection" << std::endl;
|
||||
}
|
||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||
// if (shapeManager.getNumShapes() != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release but before garbage collection" << std::endl;
|
||||
// }
|
||||
|
||||
// verify shape's refcount is zero
|
||||
numReferences = shapeManager.getNumReferences(info);
|
||||
if (numReferences != 0) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected refcount = 0 for shape but found refcount = " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 0);
|
||||
// if (numReferences != 0) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected refcount = 0 for shape but found refcount = " << numReferences << std::endl;
|
||||
// }
|
||||
|
||||
// reference the shape again and verify refcount is updated
|
||||
otherShape = shapeManager.getShape(info);
|
||||
numReferences = shapeManager.getNumReferences(info);
|
||||
if (numReferences != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 1);
|
||||
// if (numReferences != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
// }
|
||||
|
||||
// verify that shape is not collected as garbage
|
||||
shapeManager.collectGarbage();
|
||||
if (shapeManager.getNumShapes() != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release" << std::endl;
|
||||
}
|
||||
QCOMPARE(shapeManager.getNumShapes(), 1);
|
||||
// if (shapeManager.getNumShapes() != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected one shape after release" << std::endl;
|
||||
// }
|
||||
numReferences = shapeManager.getNumReferences(info);
|
||||
if (numReferences != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 1);
|
||||
// if (numReferences != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
// }
|
||||
|
||||
// release reference and verify that it is collected as garbage
|
||||
released = shapeManager.releaseShape(info);
|
||||
shapeManager.collectGarbage();
|
||||
if (shapeManager.getNumShapes() != 0) {
|
||||
std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected zero shapes after release" << std::endl;
|
||||
}
|
||||
if (shapeManager.hasShape(shape)) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected ignorant ShapeManager after garbage collection" << std::endl;
|
||||
}
|
||||
QCOMPARE(shapeManager.getNumShapes(), 0);
|
||||
// if (shapeManager.getNumShapes() != 0) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__ << " ERROR: expected zero shapes after release" << std::endl;
|
||||
// }
|
||||
QCOMPARE(shapeManager.hasShape(shape), false);
|
||||
// if (shapeManager.hasShape(shape)) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected ignorant ShapeManager after garbage collection" << std::endl;
|
||||
// }
|
||||
|
||||
// add the shape again and verify that it gets added again
|
||||
otherShape = shapeManager.getShape(info);
|
||||
numReferences = shapeManager.getNumReferences(info);
|
||||
if (numReferences != 1) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 1);
|
||||
// if (numReferences != 1) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected refcount = 1 for shape but found refcount = " << numReferences << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
void ShapeManagerTests::addManyShapes() {
|
||||
|
@ -134,49 +148,54 @@ void ShapeManagerTests::addManyShapes() {
|
|||
info.setBox(0.5f * scale);
|
||||
btCollisionShape* shape = shapeManager.getShape(info);
|
||||
shapes.push_back(shape);
|
||||
if (!shape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: i = " << i << " null box shape for scale = " << scale << std::endl;
|
||||
}
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
// if (!shape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: i = " << i << " null box shape for scale = " << scale << std::endl;
|
||||
// }
|
||||
|
||||
// make a box
|
||||
float radius = 0.5f * s;
|
||||
info.setSphere(radius);
|
||||
shape = shapeManager.getShape(info);
|
||||
shapes.push_back(shape);
|
||||
if (!shape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: i = " << i << " null sphere shape for radius = " << radius << std::endl;
|
||||
}
|
||||
QCOMPARE(shape != nullptr, true);
|
||||
// if (!shape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: i = " << i << " null sphere shape for radius = " << radius << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
// verify shape count
|
||||
int numShapes = shapeManager.getNumShapes();
|
||||
if (numShapes != 2 * numSizes) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected numShapes = " << numSizes << " but found numShapes = " << numShapes << std::endl;
|
||||
}
|
||||
QCOMPARE(numShapes, 2 * numSizes);
|
||||
// if (numShapes != 2 * numSizes) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected numShapes = " << numSizes << " but found numShapes = " << numShapes << std::endl;
|
||||
// }
|
||||
|
||||
// release each shape by pointer
|
||||
for (int i = 0; i < numShapes; ++i) {
|
||||
btCollisionShape* shape = shapes[i];
|
||||
bool success = shapeManager.releaseShape(shape);
|
||||
if (!success) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: failed to release shape index " << i << std::endl;
|
||||
break;
|
||||
}
|
||||
QCOMPARE(success, true);
|
||||
// if (!success) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: failed to release shape index " << i << std::endl;
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
|
||||
// verify zero references
|
||||
for (int i = 0; i < numShapes; ++i) {
|
||||
btCollisionShape* shape = shapes[i];
|
||||
int numReferences = shapeManager.getNumReferences(shape);
|
||||
if (numReferences != 0) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: expected zero references for shape " << i
|
||||
<< " but refCount = " << numReferences << std::endl;
|
||||
}
|
||||
QCOMPARE(numReferences, 0);
|
||||
// if (numReferences != 0) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: expected zero references for shape " << i
|
||||
// << " but refCount = " << numReferences << std::endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,10 +209,11 @@ void ShapeManagerTests::addBoxShape() {
|
|||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: Box ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape, otherShape);
|
||||
// if (shape != otherShape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: Box ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
void ShapeManagerTests::addSphereShape() {
|
||||
|
@ -206,10 +226,11 @@ void ShapeManagerTests::addSphereShape() {
|
|||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: Sphere ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape, otherShape);
|
||||
// if (shape != otherShape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: Sphere ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
// }
|
||||
}
|
||||
|
||||
void ShapeManagerTests::addCylinderShape() {
|
||||
|
@ -224,10 +245,11 @@ void ShapeManagerTests::addCylinderShape() {
|
|||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: Cylinder ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape, otherShape);
|
||||
// if (shape != otherShape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: Cylinder ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
// }
|
||||
*/
|
||||
}
|
||||
|
||||
|
@ -243,18 +265,10 @@ void ShapeManagerTests::addCapsuleShape() {
|
|||
|
||||
ShapeInfo otherInfo = info;
|
||||
btCollisionShape* otherShape = shapeManager.getShape(otherInfo);
|
||||
if (shape != otherShape) {
|
||||
std::cout << __FILE__ << ":" << __LINE__
|
||||
<< " ERROR: Capsule ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
}
|
||||
QCOMPARE(shape, otherShape);
|
||||
// if (shape != otherShape) {
|
||||
// std::cout << __FILE__ << ":" << __LINE__
|
||||
// << " ERROR: Capsule ShapeInfo --> shape --> ShapeInfo --> shape did not work" << std::endl;
|
||||
// }
|
||||
*/
|
||||
}
|
||||
|
||||
//void ShapeManagerTests::runAllTests() {
|
||||
// testShapeAccounting();
|
||||
// addManyShapes();
|
||||
// addBoxShape();
|
||||
// addSphereShape();
|
||||
// addCylinderShape();
|
||||
// addCapsuleShape();
|
||||
//}
|
||||
|
|
|
@ -24,7 +24,6 @@ private slots:
|
|||
void addSphereShape();
|
||||
void addCylinderShape();
|
||||
void addCapsuleShape();
|
||||
// void runAllTests();
|
||||
};
|
||||
|
||||
#endif // hifi_ShapeManagerTests_h
|
||||
|
|
Loading…
Reference in a new issue