mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 16:13:28 +02:00
Sitting abort post transit animation
This commit is contained in:
parent
7da5fa9ea7
commit
078baa86e4
5 changed files with 24 additions and 3 deletions
|
@ -162,7 +162,7 @@ void AvatarManager::handleTransitAnimations(AvatarTransit::Status status) {
|
|||
case AvatarTransit::Status::END_TRANSIT:
|
||||
qDebug() << "END_TRANSIT";
|
||||
_myAvatar->overrideNetworkAnimation(endAnimation._animationUrl, REFERENCE_FPS, false, endAnimation._firstFrame,
|
||||
endAnimation._firstFrame + endAnimation._frameCount);
|
||||
endAnimation._firstFrame + endAnimation._frameCount);
|
||||
break;
|
||||
case AvatarTransit::Status::ENDED:
|
||||
qDebug() << "END_FRAME";
|
||||
|
|
|
@ -116,6 +116,7 @@ public:
|
|||
void overrideNetworkAnimation(const QString& url, float fps, bool loop, float firstFrame, float lastFrame);
|
||||
void restoreAnimation();
|
||||
void restoreNetworkAnimation();
|
||||
|
||||
QStringList getAnimationRoles() const;
|
||||
void overrideRoleAnimation(const QString& role, const QString& url, float fps, bool loop, float firstFrame, float lastFrame);
|
||||
void restoreRoleAnimation(const QString& role);
|
||||
|
|
|
@ -132,9 +132,12 @@ AvatarTransit::Status AvatarTransit::update(float deltaTime, const glm::vec3& av
|
|||
|
||||
const float SETTLE_ABORT_DISTANCE = 0.1f;
|
||||
float scaledSettleAbortDistance = SETTLE_ABORT_DISTANCE * _scale;
|
||||
if (_isActive && oneFrameDistance > scaledSettleAbortDistance && _status == Status::POST_TRANSIT) {
|
||||
bool abortPostTransit = (_status == Status::POST_TRANSIT && _purpose == Purpose::SIT) ||
|
||||
(_isActive && oneFrameDistance > scaledSettleAbortDistance && _status == Status::POST_TRANSIT);
|
||||
if (abortPostTransit) {
|
||||
reset();
|
||||
_status = Status::ENDED;
|
||||
_purpose = Purpose::UNDEFINED;
|
||||
}
|
||||
return _status;
|
||||
}
|
||||
|
@ -203,6 +206,7 @@ AvatarTransit::Status AvatarTransit::updatePosition(float deltaTime) {
|
|||
_currentPosition = _endPosition;
|
||||
if (nextTime >= _totalTime) {
|
||||
_isActive = false;
|
||||
_purpose = Purpose::UNDEFINED;
|
||||
status = Status::ENDED;
|
||||
} else if (_currentTime < _totalTime - _postTransitTime) {
|
||||
status = Status::END_TRANSIT;
|
||||
|
@ -2000,7 +2004,12 @@ AvatarTransit::Status Avatar::updateTransit(float deltaTime, const glm::vec3& av
|
|||
|
||||
void Avatar::setTransitScale(float scale) {
|
||||
std::lock_guard<std::mutex> lock(_transitLock);
|
||||
return _transit.setScale(scale);
|
||||
_transit.setScale(scale);
|
||||
}
|
||||
|
||||
void Avatar::setTransitPurpose(int purpose) {
|
||||
std::lock_guard<std::mutex> lock(_transitLock);
|
||||
_transit.setPurpose(static_cast<AvatarTransit::Purpose>(purpose));
|
||||
}
|
||||
|
||||
void Avatar::overrideNextPacketPositionData(const glm::vec3& position) {
|
||||
|
|
|
@ -71,6 +71,12 @@ public:
|
|||
EASE_IN_OUT
|
||||
};
|
||||
|
||||
enum Purpose {
|
||||
UNDEFINED = 0,
|
||||
TELEPORT,
|
||||
SIT
|
||||
};
|
||||
|
||||
struct TransitAnimation {
|
||||
TransitAnimation(){};
|
||||
TransitAnimation(const QString& animationUrl, int firstFrame, int frameCount) :
|
||||
|
@ -99,6 +105,7 @@ public:
|
|||
glm::vec3 getCurrentPosition() { return _currentPosition; }
|
||||
glm::vec3 getEndPosition() { return _endPosition; }
|
||||
void setScale(float scale) { _scale = scale; }
|
||||
void setPurpose(const Purpose& purpose) { _purpose = purpose; }
|
||||
void reset();
|
||||
|
||||
private:
|
||||
|
@ -123,6 +130,7 @@ private:
|
|||
EaseType _easeType { EaseType::EASE_OUT };
|
||||
Status _status { Status::IDLE };
|
||||
float _scale { 1.0f };
|
||||
Purpose _purpose { Purpose::UNDEFINED };
|
||||
};
|
||||
|
||||
class Avatar : public AvatarData, public scriptable::ModelProvider {
|
||||
|
@ -449,6 +457,7 @@ public:
|
|||
|
||||
AvatarTransit::Status updateTransit(float deltaTime, const glm::vec3& avatarPosition, const AvatarTransit::TransitConfig& config);
|
||||
void setTransitScale(float scale);
|
||||
Q_INVOKABLE void setTransitPurpose(int purpose);
|
||||
|
||||
void overrideNextPacketPositionData(const glm::vec3& position);
|
||||
|
||||
|
|
|
@ -781,11 +781,13 @@ Script.include("/~/system/libraries/controllers.js");
|
|||
if (target === TARGET.NONE || target === TARGET.INVALID) {
|
||||
// Do nothing
|
||||
} else if (target === TARGET.SEAT) {
|
||||
MyAvatar.setTransitPurpose(2);
|
||||
Entities.callEntityMethod(result.objectID, 'sit');
|
||||
} else if (target === TARGET.SURFACE || target === TARGET.DISCREPANCY) {
|
||||
var offset = getAvatarFootOffset();
|
||||
result.intersection.y += offset;
|
||||
var shouldLandSafe = target === TARGET.DISCREPANCY;
|
||||
MyAvatar.setTransitPurpose(1);
|
||||
MyAvatar.goToLocation(result.intersection, true, HMD.orientation, false, shouldLandSafe);
|
||||
HMD.centerUI();
|
||||
MyAvatar.centerBody();
|
||||
|
|
Loading…
Reference in a new issue