mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 10:30:28 +02:00
we don't need to force, but we do need some extra room for confined spaces
This commit is contained in:
parent
c48b729527
commit
02c46080f7
2 changed files with 15 additions and 17 deletions
|
@ -439,7 +439,7 @@ void MyAvatar::update(float deltaTime) {
|
||||||
}
|
}
|
||||||
if (_physicsSafetyPending && qApp->isPhysicsEnabled() && _characterController.isEnabledAndReady()) { // fix only when needed and ready
|
if (_physicsSafetyPending && qApp->isPhysicsEnabled() && _characterController.isEnabledAndReady()) { // fix only when needed and ready
|
||||||
_physicsSafetyPending = false;
|
_physicsSafetyPending = false;
|
||||||
safeLanding(_goToPosition, _characterController.isStuck()); // no-op if already safe
|
safeLanding(_goToPosition); // no-op if already safe
|
||||||
}
|
}
|
||||||
|
|
||||||
Head* head = getHead();
|
Head* head = getHead();
|
||||||
|
@ -1555,11 +1555,11 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
|
||||||
|
|
||||||
if (_characterController.isEnabledAndReady()) {
|
if (_characterController.isEnabledAndReady()) {
|
||||||
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
|
||||||
if (_characterController.isStuck()) {
|
/*FIXME if (_characterController.isStuck()) {
|
||||||
_physicsSafetyPending = true;
|
_physicsSafetyPending = true;
|
||||||
_goToPosition = getPosition();
|
_goToPosition = getPosition();
|
||||||
qDebug() << "FIXME setting safety test at:" << _goToPosition;
|
qDebug() << "FIXME setting safety test at:" << _goToPosition;
|
||||||
}
|
}*/
|
||||||
} else {
|
} else {
|
||||||
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
setVelocity(getVelocity() + _characterController.getFollowVelocity());
|
||||||
}
|
}
|
||||||
|
@ -2236,7 +2236,7 @@ void MyAvatar::goToLocationAndEnableCollisions(const glm::vec3& position) { // S
|
||||||
goToLocation(position);
|
goToLocation(position);
|
||||||
QMetaObject::invokeMethod(this, "setCollisionsEnabled", Qt::QueuedConnection, Q_ARG(bool, true));
|
QMetaObject::invokeMethod(this, "setCollisionsEnabled", Qt::QueuedConnection, Q_ARG(bool, true));
|
||||||
}
|
}
|
||||||
bool MyAvatar::safeLanding(const glm::vec3& position, bool force) {
|
bool MyAvatar::safeLanding(const glm::vec3& position) {
|
||||||
// Considers all collision hull or non-collisionless primitive intersections on a vertical line through the point.
|
// Considers all collision hull or non-collisionless primitive intersections on a vertical line through the point.
|
||||||
// There needs to be a "landing" if:
|
// There needs to be a "landing" if:
|
||||||
// a) the closest above and the closest below are less than the avatar capsule height apart, or
|
// a) the closest above and the closest below are less than the avatar capsule height apart, or
|
||||||
|
@ -2253,7 +2253,7 @@ bool MyAvatar::safeLanding(const glm::vec3& position, bool force) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
glm::vec3 better;
|
glm::vec3 better;
|
||||||
if (!requiresSafeLanding(position, better, force)) {
|
if (!requiresSafeLanding(position, better)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
qDebug() << "rechecking" << position << " => " << better << " collisions:" << getCollisionsEnabled() << " physics:" << qApp->isPhysicsEnabled();
|
qDebug() << "rechecking" << position << " => " << better << " collisions:" << getCollisionsEnabled() << " physics:" << qApp->isPhysicsEnabled();
|
||||||
|
@ -2269,7 +2269,7 @@ bool MyAvatar::safeLanding(const glm::vec3& position, bool force) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If position is not reliably safe from being stuck by physics, answer true and place a candidate better position in betterPositionOut.
|
// If position is not reliably safe from being stuck by physics, answer true and place a candidate better position in betterPositionOut.
|
||||||
bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& betterPositionOut, bool force) {
|
bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& betterPositionOut) {
|
||||||
// We could repeat this whole test for each of the four corners of our bounding box, in case the surface is uneven. However:
|
// We could repeat this whole test for each of the four corners of our bounding box, in case the surface is uneven. However:
|
||||||
// 1) This is only meant to cover the most important cases, and even the four corners won't handle random spikes in the surfaces or avatar.
|
// 1) This is only meant to cover the most important cases, and even the four corners won't handle random spikes in the surfaces or avatar.
|
||||||
// 2) My feeling is that this code is already at the limit of what can realistically be reviewed and maintained.
|
// 2) My feeling is that this code is already at the limit of what can realistically be reviewed and maintained.
|
||||||
|
@ -2302,7 +2302,8 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
|
||||||
float distance;
|
float distance;
|
||||||
BoxFace face;
|
BoxFace face;
|
||||||
const bool visibleOnly = false;
|
const bool visibleOnly = false;
|
||||||
// FIXME: this doesn't do what we want here. findRayIntersection always works on mesh, skipping entirely based on collidable. What we really want is to use the collision hull! See CharacterGhostObject::rayTest?
|
// This isn't quite what we really want here. findRayIntersection always works on mesh, skipping entirely based on collidable.
|
||||||
|
// What we really want is to use the collision hull!
|
||||||
// See https://highfidelity.fogbugz.com/f/cases/5003/findRayIntersection-has-option-to-use-collidableOnly-but-doesn-t-actually-use-colliders
|
// See https://highfidelity.fogbugz.com/f/cases/5003/findRayIntersection-has-option-to-use-collidableOnly-but-doesn-t-actually-use-colliders
|
||||||
const bool collidableOnly = true;
|
const bool collidableOnly = true;
|
||||||
const bool precisionPicking = true;
|
const bool precisionPicking = true;
|
||||||
|
@ -2324,11 +2325,7 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
|
||||||
if (!findIntersection(capsuleCenter, up, upperIntersection, upperId, upperNormal)) {
|
if (!findIntersection(capsuleCenter, up, upperIntersection, upperId, upperNormal)) {
|
||||||
// We currently believe that physics will reliably push us out if our feet are embedded,
|
// We currently believe that physics will reliably push us out if our feet are embedded,
|
||||||
// as long as our capsule center is out and there's room above us. Here we have those
|
// as long as our capsule center is out and there's room above us. Here we have those
|
||||||
// conditions, so no need to check our feet below, unless forced.
|
// conditions, so no need to check our feet below.
|
||||||
if (force) {
|
|
||||||
upperIntersection = capsuleCenter;
|
|
||||||
return mustMove();
|
|
||||||
}
|
|
||||||
return ok("nothing above");
|
return ok("nothing above");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2342,7 +2339,8 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
|
||||||
// The surface above us is the bottom of something, and the surface below us it the top of something.
|
// The surface above us is the bottom of something, and the surface below us it the top of something.
|
||||||
// I.e., we are in a clearing between two objects.
|
// I.e., we are in a clearing between two objects.
|
||||||
auto delta = glm::distance(upperIntersection, lowerIntersection);
|
auto delta = glm::distance(upperIntersection, lowerIntersection);
|
||||||
if (delta > (2 * halfHeight)) {
|
const float halfHeightFactor = 2.5f; // Until case 5003 is fixed (and maybe after?), we need a fudge factor. Also account for content modelers not being precise.
|
||||||
|
if (delta > (halfHeightFactor * halfHeight)) {
|
||||||
// There is room for us to fit in that clearing. If there wasn't, physics would oscilate us between the objects above and below.
|
// There is room for us to fit in that clearing. If there wasn't, physics would oscilate us between the objects above and below.
|
||||||
// We're now going to iterate upwards through successive upperIntersections, testing to see if we're contained within the top surface of some entity.
|
// We're now going to iterate upwards through successive upperIntersections, testing to see if we're contained within the top surface of some entity.
|
||||||
// There will be one of two outcomes:
|
// There will be one of two outcomes:
|
||||||
|
@ -2368,11 +2366,11 @@ bool MyAvatar::requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& bette
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "FIXME need to compute safe landing for" << capsuleCenter << " based on " << (isDown(upperNormal) ? "down " : "up ") << upperIntersection << "@" << upperId << " and " << (isUp(lowerNormal) ? "up " : "down ") << lowerIntersection << "@" << lowerId;
|
include.push_back(upperId); // We're now looking for the intersection from above onto this entity.
|
||||||
const float big = (float)TREE_SCALE;
|
const float big = (float)TREE_SCALE;
|
||||||
const auto skyHigh = up * big;
|
const auto skyHigh = up * big;
|
||||||
auto fromAbove = capsuleCenter + skyHigh;
|
auto fromAbove = capsuleCenter + skyHigh;
|
||||||
include.push_back(upperId); // We're looking for the intersection from above onto this entity.
|
qDebug() << "FIXME need to compute safe landing for" << capsuleCenter << " based on " << (isDown(upperNormal) ? "down " : "up ") << upperIntersection << "@" << upperId << " and " << (isUp(lowerNormal) ? "up " : "down ") << lowerIntersection << "@" << lowerId;
|
||||||
if (!findIntersection(fromAbove, down, upperIntersection, upperId, upperNormal)) {
|
if (!findIntersection(fromAbove, down, upperIntersection, upperId, upperNormal)) {
|
||||||
return ok("Unable to find a landing");
|
return ok("Unable to find a landing");
|
||||||
}
|
}
|
||||||
|
|
|
@ -523,7 +523,7 @@ public slots:
|
||||||
bool shouldFaceLocation = false);
|
bool shouldFaceLocation = false);
|
||||||
void goToLocation(const QVariant& properties);
|
void goToLocation(const QVariant& properties);
|
||||||
void goToLocationAndEnableCollisions(const glm::vec3& newPosition);
|
void goToLocationAndEnableCollisions(const glm::vec3& newPosition);
|
||||||
bool safeLanding(const glm::vec3& position, bool force = false);
|
bool safeLanding(const glm::vec3& position);
|
||||||
|
|
||||||
void restrictScaleFromDomainSettings(const QJsonObject& domainSettingsObject);
|
void restrictScaleFromDomainSettings(const QJsonObject& domainSettingsObject);
|
||||||
void clearScaleRestriction();
|
void clearScaleRestriction();
|
||||||
|
@ -571,7 +571,7 @@ private:
|
||||||
|
|
||||||
glm::vec3 getWorldBodyPosition() const;
|
glm::vec3 getWorldBodyPosition() const;
|
||||||
glm::quat getWorldBodyOrientation() const;
|
glm::quat getWorldBodyOrientation() const;
|
||||||
bool requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& positionOut, bool force = false);
|
bool requiresSafeLanding(const glm::vec3& positionIn, glm::vec3& positionOut);
|
||||||
|
|
||||||
virtual QByteArray toByteArrayStateful(AvatarDataDetail dataDetail) override;
|
virtual QByteArray toByteArrayStateful(AvatarDataDetail dataDetail) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue