mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:27:04 +02:00
fix ShapeInfoTests to use reduced HashKey API
This commit is contained in:
parent
a3567dea3a
commit
d7f38bac17
1 changed files with 18 additions and 18 deletions
|
@ -55,20 +55,20 @@ void ShapeInfoTests::testHashFunctions() {
|
||||||
// test sphere
|
// test sphere
|
||||||
info.setSphere(radiusX);
|
info.setSphere(radiusX);
|
||||||
++testCount;
|
++testCount;
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey(info.getHash());
|
||||||
hashPtr = hashes.find(key);
|
hashPtr = hashes.find(hashKey);
|
||||||
if (hashPtr) {
|
if (hashPtr) {
|
||||||
std::cout << testCount << " hash collision sphere radius = " << radiusX
|
std::cout << testCount << " hash collision sphere radius = " << radiusX
|
||||||
<< " h = 0x" << std::hex << key.getHash() << " : 0x" << *hashPtr
|
<< " h = 0x" << std::hex << hashKey.getHash() << " : 0x" << *hashPtr
|
||||||
<< std::dec << std::endl;
|
<< std::dec << std::endl;
|
||||||
++numCollisions;
|
++numCollisions;
|
||||||
assert(false);
|
assert(false);
|
||||||
} else {
|
} else {
|
||||||
hashes.insert(key, key.getHash());
|
hashes.insert(hashKey, hashKey.getHash());
|
||||||
}
|
}
|
||||||
// track bit distribution counts to evaluate hash function randomness
|
// track bit distribution counts to evaluate hash function randomness
|
||||||
for (int j = 0; j < NUM_HASH_BITS; ++j) {
|
for (int j = 0; j < NUM_HASH_BITS; ++j) {
|
||||||
if (masks[j] & key.getHash()) {
|
if (masks[j] & hashKey.getHash()) {
|
||||||
++bits[j];
|
++bits[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,21 +80,21 @@ void ShapeInfoTests::testHashFunctions() {
|
||||||
// test box
|
// test box
|
||||||
info.setBox(glm::vec3(radiusX, radiusY, radiusZ));
|
info.setBox(glm::vec3(radiusX, radiusY, radiusZ));
|
||||||
++testCount;
|
++testCount;
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey(info.getHash());
|
||||||
hashPtr = hashes.find(key);
|
hashPtr = hashes.find(hashKey);
|
||||||
if (hashPtr) {
|
if (hashPtr) {
|
||||||
std::cout << testCount << " hash collision box dimensions = < " << radiusX
|
std::cout << testCount << " hash collision box dimensions = < " << radiusX
|
||||||
<< ", " << radiusY << ", " << radiusZ << " >"
|
<< ", " << radiusY << ", " << radiusZ << " >"
|
||||||
<< " h = 0x" << std::hex << key.getHash() << " : 0x" << *hashPtr << " : 0x" << key.getHash64()
|
<< " h = 0x" << std::hex << hashKey.getHash() << " : 0x" << *hashPtr << " : 0x" << hashKey.getHash64()
|
||||||
<< std::dec << std::endl;
|
<< std::dec << std::endl;
|
||||||
++numCollisions;
|
++numCollisions;
|
||||||
assert(false);
|
assert(false);
|
||||||
} else {
|
} else {
|
||||||
hashes.insert(key, key.getHash());
|
hashes.insert(hashKey, hashKey.getHash());
|
||||||
}
|
}
|
||||||
// track bit distribution counts to evaluate hash function randomness
|
// track bit distribution counts to evaluate hash function randomness
|
||||||
for (int k = 0; k < NUM_HASH_BITS; ++k) {
|
for (int k = 0; k < NUM_HASH_BITS; ++k) {
|
||||||
if (masks[k] & key.getHash()) {
|
if (masks[k] & hashKey.getHash()) {
|
||||||
++bits[k];
|
++bits[k];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,14 +117,14 @@ void ShapeInfoTests::testBoxShape() {
|
||||||
ShapeInfo info;
|
ShapeInfo info;
|
||||||
glm::vec3 halfExtents(1.23f, 4.56f, 7.89f);
|
glm::vec3 halfExtents(1.23f, 4.56f, 7.89f);
|
||||||
info.setBox(halfExtents);
|
info.setBox(halfExtents);
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey(info.getHash());
|
||||||
|
|
||||||
const btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
const btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
|
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
HashKey otherKey = otherInfo.getHash();
|
HashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(hashKey.getHash(), otherKey.getHash());
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
@ -133,14 +133,14 @@ void ShapeInfoTests::testSphereShape() {
|
||||||
ShapeInfo info;
|
ShapeInfo info;
|
||||||
float radius = 1.23f;
|
float radius = 1.23f;
|
||||||
info.setSphere(radius);
|
info.setSphere(radius);
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey = info.getHash();
|
||||||
|
|
||||||
const btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
const btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
|
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
HashKey otherKey = otherInfo.getHash();
|
HashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(hashKey.getHash(), otherKey.getHash());
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
}
|
}
|
||||||
|
@ -151,14 +151,14 @@ void ShapeInfoTests::testCylinderShape() {
|
||||||
float radius = 1.23f;
|
float radius = 1.23f;
|
||||||
float height = 4.56f;
|
float height = 4.56f;
|
||||||
info.setCylinder(radius, height);
|
info.setCylinder(radius, height);
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey(info.getHash());
|
||||||
|
|
||||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
|
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
HashKey otherKey = otherInfo.getHash();
|
HashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(hashKey.getHash(), otherKey.getHash());
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
*/
|
*/
|
||||||
|
@ -170,14 +170,14 @@ void ShapeInfoTests::testCapsuleShape() {
|
||||||
float radius = 1.23f;
|
float radius = 1.23f;
|
||||||
float height = 4.56f;
|
float height = 4.56f;
|
||||||
info.setCapsule(radius, height);
|
info.setCapsule(radius, height);
|
||||||
HashKey key = info.getHash();
|
HashKey hashKey(info.getHash());
|
||||||
|
|
||||||
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
btCollisionShape* shape = ShapeFactory::createShapeFromInfo(info);
|
||||||
QCOMPARE(shape != nullptr, true);
|
QCOMPARE(shape != nullptr, true);
|
||||||
|
|
||||||
ShapeInfo otherInfo = info;
|
ShapeInfo otherInfo = info;
|
||||||
HashKey otherKey = otherInfo.getHash();
|
HashKey otherKey = otherInfo.getHash();
|
||||||
QCOMPARE(key.getHash(), otherKey.getHash());
|
QCOMPARE(hashKey.getHash(), otherKey.getHash());
|
||||||
|
|
||||||
delete shape;
|
delete shape;
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue