mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:24:08 +02:00
fix for flickering avatars
This commit is contained in:
parent
68cc49f19e
commit
15025bf8d8
5 changed files with 20 additions and 24 deletions
|
@ -50,7 +50,7 @@ Avatar::Avatar() :
|
|||
AvatarData(),
|
||||
_skeletonModel(this),
|
||||
_bodyYawDelta(0.0f),
|
||||
_lastPosition(0.0f),
|
||||
_lastPosition(_position),
|
||||
_velocity(0.0f),
|
||||
_lastVelocity(0.0f),
|
||||
_acceleration(0.0f),
|
||||
|
@ -204,7 +204,9 @@ void Avatar::simulate(float deltaTime) {
|
|||
_displayNameAlpha = abs(_displayNameAlpha - _displayNameTargetAlpha) < 0.01f ? _displayNameTargetAlpha : _displayNameAlpha;
|
||||
}
|
||||
|
||||
_position += _velocity * deltaTime;
|
||||
// NOTE: we shouldn't extrapolate an Avatar instance forward in time...
|
||||
// until velocity is in AvatarData update message.
|
||||
//_position += _velocity * deltaTime;
|
||||
measureMotionDerivatives(deltaTime);
|
||||
}
|
||||
|
||||
|
@ -223,20 +225,6 @@ void Avatar::measureMotionDerivatives(float deltaTime) {
|
|||
_lastOrientation = getOrientation();
|
||||
}
|
||||
|
||||
void Avatar::setPosition(const glm::vec3 position, bool overideReferential) {
|
||||
AvatarData::setPosition(position, overideReferential);
|
||||
_lastPosition = position;
|
||||
_velocity = glm::vec3(0.0f);
|
||||
_lastVelocity = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
void Avatar::slamPosition(const glm::vec3& newPosition) {
|
||||
_position = newPosition;
|
||||
_lastPosition = newPosition;
|
||||
_velocity = glm::vec3(0.0f);
|
||||
_lastVelocity = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
void Avatar::setMouseRay(const glm::vec3 &origin, const glm::vec3 &direction) {
|
||||
_mouseRayOrigin = origin;
|
||||
_mouseRayDirection = direction;
|
||||
|
|
|
@ -161,9 +161,6 @@ public:
|
|||
/// \param vector position to be scaled. Will store the result
|
||||
void scaleVectorRelativeToPosition(glm::vec3 &positionToScale) const;
|
||||
|
||||
void setPosition(const glm::vec3 position, bool overideReferential = false);
|
||||
void slamPosition(const glm::vec3& newPosition);
|
||||
|
||||
public slots:
|
||||
void updateCollisionGroups();
|
||||
|
||||
|
|
|
@ -609,6 +609,13 @@ void MyAvatar::setGravity(const glm::vec3& gravity) {
|
|||
// so it continues to point opposite to the previous gravity setting.
|
||||
}
|
||||
|
||||
void MyAvatar::slamPosition(const glm::vec3& newPosition) {
|
||||
AvatarData::setPosition(newPosition);
|
||||
_lastPosition = _position;
|
||||
_velocity = glm::vec3(0.0f);
|
||||
_lastVelocity = glm::vec3(0.0f);
|
||||
}
|
||||
|
||||
AnimationHandlePointer MyAvatar::addAnimationHandle() {
|
||||
AnimationHandlePointer handle = _skeletonModel.createAnimationHandle();
|
||||
_animationHandles.append(handle);
|
||||
|
@ -797,9 +804,11 @@ void MyAvatar::loadData(QSettings* settings) {
|
|||
|
||||
getHead()->setBasePitch(loadSetting(settings, "headPitch", 0.0f));
|
||||
|
||||
_position.x = loadSetting(settings, "position_x", START_LOCATION.x);
|
||||
_position.y = loadSetting(settings, "position_y", START_LOCATION.y);
|
||||
_position.z = loadSetting(settings, "position_z", START_LOCATION.z);
|
||||
glm::vec3 newPosition;
|
||||
newPosition.x = loadSetting(settings, "position_x", START_LOCATION.x);
|
||||
newPosition.y = loadSetting(settings, "position_y", START_LOCATION.y);
|
||||
newPosition.z = loadSetting(settings, "position_z", START_LOCATION.z);
|
||||
slamPosition(newPosition);
|
||||
|
||||
getHead()->setPupilDilation(loadSetting(settings, "pupilDilation", 0.0f));
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@ public:
|
|||
void setLeanScale(float scale) { _leanScale = scale; }
|
||||
void setLocalGravity(glm::vec3 gravity);
|
||||
void setShouldRenderLocally(bool shouldRender) { _shouldRender = shouldRender; }
|
||||
void slamPosition(const glm::vec3& position);
|
||||
|
||||
// getters
|
||||
float getLeanScale() const { return _leanScale; }
|
||||
|
|
|
@ -35,7 +35,8 @@ using namespace std;
|
|||
|
||||
AvatarData::AvatarData() :
|
||||
_sessionUUID(),
|
||||
_handPosition(0,0,0),
|
||||
_position(0.0f),
|
||||
_handPosition(0.0f),
|
||||
_referential(NULL),
|
||||
_bodyYaw(-90.f),
|
||||
_bodyPitch(0.0f),
|
||||
|
@ -326,7 +327,7 @@ int AvatarData::parseDataAtOffset(const QByteArray& packet, int offset) {
|
|||
}
|
||||
return maxAvailableSize;
|
||||
}
|
||||
_position = position;
|
||||
setPosition(position);
|
||||
|
||||
// rotation (NOTE: This needs to become a quaternion to save two bytes)
|
||||
float yaw, pitch, roll;
|
||||
|
|
Loading…
Reference in a new issue