mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 15:49:24 +02:00
Apply transit logic if avatar instance is client side
This commit is contained in:
parent
767f4e9d6d
commit
056fe338e1
3 changed files with 22 additions and 9 deletions
|
@ -266,6 +266,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) {
|
||||||
if (avatar->getSkeletonModel()->isLoaded()) {
|
if (avatar->getSkeletonModel()->isLoaded()) {
|
||||||
// remove the orb if it is there
|
// remove the orb if it is there
|
||||||
avatar->removeOrb();
|
avatar->removeOrb();
|
||||||
|
avatar->setIsClientAvatar(true);
|
||||||
if (avatar->needsPhysicsUpdate()) {
|
if (avatar->needsPhysicsUpdate()) {
|
||||||
_avatarsToChangeInPhysics.insert(avatar);
|
_avatarsToChangeInPhysics.insert(avatar);
|
||||||
}
|
}
|
||||||
|
|
|
@ -883,13 +883,23 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_serverPosition = glm::vec3(data->globalPosition[0], data->globalPosition[1], data->globalPosition[2]) + offset;
|
_serverPosition = glm::vec3(data->globalPosition[0], data->globalPosition[1], data->globalPosition[2]) + offset;
|
||||||
if (_globalPosition != _serverPosition) {
|
if (_isClientAvatar) {
|
||||||
_globalPositionChanged = now;
|
auto oneStepDistance = glm::length(_globalPosition - _serverPosition);
|
||||||
}
|
if (oneStepDistance <= AVATAR_TRANSIT_MIN_TRIGGER_DISTANCE || oneStepDistance >= AVATAR_TRANSIT_MAX_TRIGGER_DISTANCE) {
|
||||||
auto oneStepDistance = glm::length(_globalPosition - _serverPosition);
|
_globalPosition = _serverPosition;
|
||||||
if (oneStepDistance <= AVATAR_TRANSIT_MIN_TRIGGER_DISTANCE || oneStepDistance >= AVATAR_TRANSIT_MAX_TRIGGER_DISTANCE) {
|
// if we don't have a parent, make sure to also set our local position
|
||||||
_globalPosition = _serverPosition;
|
if (!hasParent()) {
|
||||||
// if we don't have a parent, make sure to also set our local position
|
setLocalPosition(_serverPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_globalPosition != _serverPosition) {
|
||||||
|
_globalPositionChanged = now;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (_globalPosition != _serverPosition) {
|
||||||
|
_globalPosition = _serverPosition;
|
||||||
|
_globalPositionChanged = now;
|
||||||
|
}
|
||||||
if (!hasParent()) {
|
if (!hasParent()) {
|
||||||
setLocalPosition(_serverPosition);
|
setLocalPosition(_serverPosition);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1110,8 +1110,8 @@ public:
|
||||||
QJsonObject toJson() const;
|
QJsonObject toJson() const;
|
||||||
void fromJson(const QJsonObject& json, bool useFrameSkeleton = true);
|
void fromJson(const QJsonObject& json, bool useFrameSkeleton = true);
|
||||||
|
|
||||||
glm::vec3 getClientGlobalPosition() const { return _serverPosition; }
|
glm::vec3 getClientGlobalPosition() const { return _globalPosition; }
|
||||||
AABox getGlobalBoundingBox() const { return AABox(_serverPosition + _globalBoundingBoxOffset - _globalBoundingBoxDimensions, _globalBoundingBoxDimensions); }
|
AABox getGlobalBoundingBox() const { return AABox(_globalPosition + _globalBoundingBoxOffset - _globalBoundingBoxDimensions, _globalBoundingBoxDimensions); }
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* @function MyAvatar.getAvatarEntityData
|
* @function MyAvatar.getAvatarEntityData
|
||||||
|
@ -1206,6 +1206,7 @@ public:
|
||||||
|
|
||||||
void setIsNewAvatar(bool isNewAvatar) { _isNewAvatar = isNewAvatar; }
|
void setIsNewAvatar(bool isNewAvatar) { _isNewAvatar = isNewAvatar; }
|
||||||
bool getIsNewAvatar() { return _isNewAvatar; }
|
bool getIsNewAvatar() { return _isNewAvatar; }
|
||||||
|
void setIsClientAvatar(bool isClientAvatar) { _isClientAvatar = isClientAvatar; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -1469,6 +1470,7 @@ protected:
|
||||||
float _density;
|
float _density;
|
||||||
int _replicaIndex { 0 };
|
int _replicaIndex { 0 };
|
||||||
bool _isNewAvatar { true };
|
bool _isNewAvatar { true };
|
||||||
|
bool _isClientAvatar { false };
|
||||||
|
|
||||||
// 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;
|
||||||
|
|
Loading…
Reference in a new issue