mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 19:56:44 +02:00
Fix for findEntities not returning some entities that are within range.
This bug has been around a long time... introduced by commit 39ed7f7b
in 2014.
This became apparent to me when testing the tablet-ui, there was a case where the
hand styluses were not appearing when close to a web entity. Because findEntities
is such a fundamental feature used by handControllerGrab, this fix should make all
grabbing feel more consistent and predictable.
I added a unit test that reproduces the issue.
This commit is contained in:
parent
f0238ec4d7
commit
a14dcbd513
3 changed files with 16 additions and 1 deletions
|
@ -360,7 +360,7 @@ glm::vec3 AABox::getClosestPointOnFace(const glm::vec3& point, BoxFace face) con
|
||||||
|
|
||||||
case MIN_Z_FACE:
|
case MIN_Z_FACE:
|
||||||
return glm::clamp(point, glm::vec3(_corner.x, _corner.y, _corner.z),
|
return glm::clamp(point, glm::vec3(_corner.x, _corner.y, _corner.z),
|
||||||
glm::vec3(_corner.x + _scale.z, _corner.y + _scale.y, _corner.z));
|
glm::vec3(_corner.x + _scale.x, _corner.y + _scale.y, _corner.z));
|
||||||
|
|
||||||
default: //quiet windows warnings
|
default: //quiet windows warnings
|
||||||
case MAX_Z_FACE:
|
case MAX_Z_FACE:
|
||||||
|
|
|
@ -169,3 +169,17 @@ void AABoxTests::testScale() {
|
||||||
box3 += glm::vec3(-1.0f, -1.0f, -1.0f);
|
box3 += glm::vec3(-1.0f, -1.0f, -1.0f);
|
||||||
QCOMPARE(box3.contains(glm::vec3(0.5f, 0.5f, 0.5f)), true);
|
QCOMPARE(box3.contains(glm::vec3(0.5f, 0.5f, 0.5f)), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AABoxTests::testFindSpherePenetration() {
|
||||||
|
vec3 searchPosition(-0.0141186f, 0.0640736f, -0.116081f);
|
||||||
|
float searchRadius = 0.5f;
|
||||||
|
|
||||||
|
vec3 boxMin(-0.800014f, -0.450025f, -0.00503815f);
|
||||||
|
vec3 boxDim(1.60003f, 0.900049f, 0.0100763f);
|
||||||
|
AABox testBox(boxMin, boxDim);
|
||||||
|
|
||||||
|
vec3 penetration;
|
||||||
|
bool hit = testBox.findSpherePenetration(searchPosition, searchRadius, penetration);
|
||||||
|
QCOMPARE(hit, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ private slots:
|
||||||
void testContainsPoint();
|
void testContainsPoint();
|
||||||
void testTouchesSphere();
|
void testTouchesSphere();
|
||||||
void testScale();
|
void testScale();
|
||||||
|
void testFindSpherePenetration();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_AABoxTests_h
|
#endif // hifi_AABoxTests_h
|
||||||
|
|
Loading…
Reference in a new issue