mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 22:15:16 +02:00
Merge pull request #14141 from luiscuenca/transitFirstPacketFix
Fix avatars transit on domain enter
This commit is contained in:
commit
7aa715c383
5 changed files with 28 additions and 6 deletions
|
@ -275,7 +275,11 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
if (inView && avatar->hasNewJointData()) {
|
if (inView && avatar->hasNewJointData()) {
|
||||||
numAvatarsUpdated++;
|
numAvatarsUpdated++;
|
||||||
}
|
}
|
||||||
avatar->_transit.update(deltaTime, avatar->_globalPosition, _transitConfig);
|
auto transitStatus = avatar->_transit.update(deltaTime, avatar->_globalPosition, _transitConfig);
|
||||||
|
if (avatar->getIsNewAvatar() && (transitStatus == AvatarTransit::Status::START_TRANSIT || transitStatus == AvatarTransit::Status::ABORT_TRANSIT)) {
|
||||||
|
avatar->_transit.reset();
|
||||||
|
avatar->setIsNewAvatar(false);
|
||||||
|
}
|
||||||
avatar->simulate(deltaTime, inView);
|
avatar->simulate(deltaTime, inView);
|
||||||
avatar->updateRenderItem(renderTransaction);
|
avatar->updateRenderItem(renderTransaction);
|
||||||
avatar->updateSpaceProxy(workloadTransaction);
|
avatar->updateSpaceProxy(workloadTransaction);
|
||||||
|
|
|
@ -118,14 +118,24 @@ AvatarTransit::Status AvatarTransit::update(float deltaTime, const glm::vec3& av
|
||||||
float oneFrameDistance = glm::length(currentPosition - _lastPosition);
|
float oneFrameDistance = glm::length(currentPosition - _lastPosition);
|
||||||
const float MAX_TRANSIT_DISTANCE = 30.0f;
|
const float MAX_TRANSIT_DISTANCE = 30.0f;
|
||||||
float scaledMaxTransitDistance = MAX_TRANSIT_DISTANCE * _scale;
|
float scaledMaxTransitDistance = MAX_TRANSIT_DISTANCE * _scale;
|
||||||
if (oneFrameDistance > config._triggerDistance && oneFrameDistance < scaledMaxTransitDistance && !_isTransiting) {
|
if (oneFrameDistance > config._triggerDistance && !_isTransiting) {
|
||||||
start(deltaTime, _lastPosition, currentPosition, config);
|
if (oneFrameDistance < scaledMaxTransitDistance) {
|
||||||
|
start(deltaTime, _lastPosition, currentPosition, config);
|
||||||
|
} else {
|
||||||
|
_lastPosition = currentPosition;
|
||||||
|
return Status::ABORT_TRANSIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_lastPosition = currentPosition;
|
_lastPosition = currentPosition;
|
||||||
_status = updatePosition(deltaTime);
|
_status = updatePosition(deltaTime);
|
||||||
return _status;
|
return _status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AvatarTransit::reset() {
|
||||||
|
_lastPosition = _endPosition;
|
||||||
|
_currentPosition = _endPosition;
|
||||||
|
_isTransiting = false;
|
||||||
|
}
|
||||||
void AvatarTransit::start(float deltaTime, const glm::vec3& startPosition, const glm::vec3& endPosition, const AvatarTransit::TransitConfig& config) {
|
void AvatarTransit::start(float deltaTime, const glm::vec3& startPosition, const glm::vec3& endPosition, const AvatarTransit::TransitConfig& config) {
|
||||||
_startPosition = startPosition;
|
_startPosition = startPosition;
|
||||||
_endPosition = endPosition;
|
_endPosition = endPosition;
|
||||||
|
|
|
@ -56,7 +56,8 @@ public:
|
||||||
IDLE = 0,
|
IDLE = 0,
|
||||||
START_TRANSIT,
|
START_TRANSIT,
|
||||||
TRANSITING,
|
TRANSITING,
|
||||||
END_TRANSIT
|
END_TRANSIT,
|
||||||
|
ABORT_TRANSIT
|
||||||
};
|
};
|
||||||
|
|
||||||
enum EaseType {
|
enum EaseType {
|
||||||
|
@ -84,6 +85,7 @@ public:
|
||||||
glm::vec3 getEndPosition() { return _endPosition; }
|
glm::vec3 getEndPosition() { return _endPosition; }
|
||||||
float getTransitTime() { return _totalTime; }
|
float getTransitTime() { return _totalTime; }
|
||||||
void setScale(float scale) { _scale = scale; }
|
void setScale(float scale) { _scale = scale; }
|
||||||
|
void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Status updatePosition(float deltaTime);
|
Status updatePosition(float deltaTime);
|
||||||
|
|
|
@ -1190,6 +1190,9 @@ public:
|
||||||
void setReplicaIndex(int replicaIndex) { _replicaIndex = replicaIndex; }
|
void setReplicaIndex(int replicaIndex) { _replicaIndex = replicaIndex; }
|
||||||
int getReplicaIndex() { return _replicaIndex; }
|
int getReplicaIndex() { return _replicaIndex; }
|
||||||
|
|
||||||
|
void setIsNewAvatar(bool isNewAvatar) { _isNewAvatar = isNewAvatar; }
|
||||||
|
bool getIsNewAvatar() { return _isNewAvatar; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
|
@ -1452,6 +1455,7 @@ protected:
|
||||||
bool _hasProcessedFirstIdentity { false };
|
bool _hasProcessedFirstIdentity { false };
|
||||||
float _density;
|
float _density;
|
||||||
int _replicaIndex { 0 };
|
int _replicaIndex { 0 };
|
||||||
|
bool _isNewAvatar { true };
|
||||||
|
|
||||||
// null unless MyAvatar or ScriptableAvatar sending traits data to mixer
|
// null unless MyAvatar or ScriptableAvatar sending traits data to mixer
|
||||||
std::unique_ptr<ClientTraitsHandler> _clientTraitsHandler;
|
std::unique_ptr<ClientTraitsHandler> _clientTraitsHandler;
|
||||||
|
|
|
@ -259,18 +259,20 @@ AvatarSharedPointer AvatarHashMap::parseAvatarData(QSharedPointer<ReceivedMessag
|
||||||
if (isNewAvatar) {
|
if (isNewAvatar) {
|
||||||
QWriteLocker locker(&_hashLock);
|
QWriteLocker locker(&_hashLock);
|
||||||
_pendingAvatars.insert(sessionUUID, { std::chrono::steady_clock::now(), 0, avatar });
|
_pendingAvatars.insert(sessionUUID, { std::chrono::steady_clock::now(), 0, avatar });
|
||||||
|
avatar->setIsNewAvatar(true);
|
||||||
auto replicaIDs = _replicas.getReplicaIDs(sessionUUID);
|
auto replicaIDs = _replicas.getReplicaIDs(sessionUUID);
|
||||||
for (auto replicaID : replicaIDs) {
|
for (auto replicaID : replicaIDs) {
|
||||||
auto replicaAvatar = addAvatar(replicaID, sendingNode);
|
auto replicaAvatar = addAvatar(replicaID, sendingNode);
|
||||||
|
replicaAvatar->setIsNewAvatar(true);
|
||||||
_replicas.addReplica(sessionUUID, replicaAvatar);
|
_replicas.addReplica(sessionUUID, replicaAvatar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// have the matching (or new) avatar parse the data from the packet
|
// have the matching (or new) avatar parse the data from the packet
|
||||||
int bytesRead = avatar->parseDataFromBuffer(byteArray);
|
int bytesRead = avatar->parseDataFromBuffer(byteArray);
|
||||||
message->seek(positionBeforeRead + bytesRead);
|
message->seek(positionBeforeRead + bytesRead);
|
||||||
_replicas.parseDataFromBuffer(sessionUUID, byteArray);
|
_replicas.parseDataFromBuffer(sessionUUID, byteArray);
|
||||||
|
|
||||||
|
|
||||||
return avatar;
|
return avatar;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue