mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
7abb7d9ccd
6 changed files with 41 additions and 39 deletions
|
@ -2128,9 +2128,12 @@ void Application::updateAvatars(float deltaTime, glm::vec3 mouseRayOrigin, glm::
|
|||
for (vector<Avatar*>::iterator fade = _avatarFades.begin(); fade != _avatarFades.end(); fade++) {
|
||||
Avatar* avatar = *fade;
|
||||
const float SHRINK_RATE = 0.9f;
|
||||
avatar->setNewScale(avatar->getNewScale() * SHRINK_RATE);
|
||||
const float MINIMUM_SCALE = 0.001f;
|
||||
if (avatar->getNewScale() < MINIMUM_SCALE) {
|
||||
|
||||
avatar->setTargetScale(avatar->getScale() * SHRINK_RATE);
|
||||
|
||||
const float MIN_FADE_SCALE = 0.001;
|
||||
|
||||
if (avatar->getTargetScale() < MIN_FADE_SCALE) {
|
||||
delete avatar;
|
||||
_avatarFades.erase(fade--);
|
||||
|
||||
|
|
|
@ -891,7 +891,7 @@ void Menu::editPreferences() {
|
|||
_maxVoxelPacketsPerSecond = maxVoxelsPPS->value();
|
||||
|
||||
applicationInstance->getAvatar()->setLeanScale(leanScale->value());
|
||||
applicationInstance->getAvatar()->setNewScale(avatarScale->value());
|
||||
applicationInstance->getAvatar()->setClampedTargetScale(avatarScale->value());
|
||||
|
||||
_audioJitterBufferSamples = audioJitterBufferSamples->value();
|
||||
|
||||
|
|
|
@ -167,8 +167,8 @@ void Avatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
follow(NULL);
|
||||
}
|
||||
|
||||
if (_scale != _newScale) {
|
||||
setScale(_newScale);
|
||||
if (_scale != _targetScale) {
|
||||
setScale(_targetScale);
|
||||
}
|
||||
|
||||
// copy velocity so we can use it later for acceleration
|
||||
|
@ -439,30 +439,30 @@ void Avatar::goHome() {
|
|||
}
|
||||
|
||||
void Avatar::increaseSize() {
|
||||
if ((1.f + SCALING_RATIO) * _newScale < MAX_SCALE) {
|
||||
_newScale *= (1.f + SCALING_RATIO);
|
||||
qDebug("Changed scale to %f\n", _newScale);
|
||||
if ((1.f + SCALING_RATIO) * _targetScale < MAX_AVATAR_SCALE) {
|
||||
_targetScale *= (1.f + SCALING_RATIO);
|
||||
qDebug("Changed scale to %f\n", _targetScale);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::decreaseSize() {
|
||||
if (MIN_SCALE < (1.f - SCALING_RATIO) * _newScale) {
|
||||
_newScale *= (1.f - SCALING_RATIO);
|
||||
qDebug("Changed scale to %f\n", _newScale);
|
||||
if (MIN_AVATAR_SCALE < (1.f - SCALING_RATIO) * _targetScale) {
|
||||
_targetScale *= (1.f - SCALING_RATIO);
|
||||
qDebug("Changed scale to %f\n", _targetScale);
|
||||
}
|
||||
}
|
||||
|
||||
void Avatar::resetSize() {
|
||||
_newScale = 1.0f;
|
||||
qDebug("Reseted scale to %f\n", _newScale);
|
||||
_targetScale = 1.0f;
|
||||
qDebug("Reseted scale to %f\n", _targetScale);
|
||||
}
|
||||
|
||||
void Avatar::setScale(const float scale) {
|
||||
_scale = scale;
|
||||
|
||||
if (_newScale * (1.f - RESCALING_TOLERANCE) < _scale &&
|
||||
_scale < _newScale * (1.f + RESCALING_TOLERANCE)) {
|
||||
_scale = _newScale;
|
||||
if (_targetScale * (1.f - RESCALING_TOLERANCE) < _scale &&
|
||||
_scale < _targetScale * (1.f + RESCALING_TOLERANCE)) {
|
||||
_scale = _targetScale;
|
||||
}
|
||||
|
||||
_skeleton.setScale(_scale);
|
||||
|
|
|
@ -92,12 +92,12 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
}
|
||||
|
||||
// Ajust, scale, position and lookAt position when following an other avatar
|
||||
if (_leadingAvatar && _newScale != _leadingAvatar->getScale()) {
|
||||
_newScale = _leadingAvatar->getScale();
|
||||
if (_leadingAvatar && _targetScale != _leadingAvatar->getScale()) {
|
||||
_targetScale = _leadingAvatar->getScale();
|
||||
}
|
||||
|
||||
if (_scale != _newScale) {
|
||||
float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _newScale;
|
||||
if (_scale != _targetScale) {
|
||||
float scale = (1.f - SMOOTHING_RATIO) * _scale + SMOOTHING_RATIO * _targetScale;
|
||||
setScale(scale);
|
||||
Application::getInstance()->getCamera()->setScale(scale);
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ void MyAvatar::saveData(QSettings* settings) {
|
|||
settings->setValue("pupilDilation", _head.getPupilDilation());
|
||||
|
||||
settings->setValue("leanScale", _leanScale);
|
||||
settings->setValue("scale", _newScale);
|
||||
settings->setValue("scale", _targetScale);
|
||||
|
||||
settings->endGroup();
|
||||
}
|
||||
|
@ -536,7 +536,7 @@ void MyAvatar::loadData(QSettings* settings) {
|
|||
|
||||
_leanScale = loadSetting(settings, "leanScale", 0.05f);
|
||||
|
||||
_newScale = loadSetting(settings, "scale", 1.0f);
|
||||
_targetScale = loadSetting(settings, "scale", 1.0f);
|
||||
setScale(_scale);
|
||||
Application::getInstance()->getCamera()->setScale(_scale);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ AvatarData::AvatarData(Node* owningNode) :
|
|||
_bodyYaw(-90.0),
|
||||
_bodyPitch(0.0),
|
||||
_bodyRoll(0.0),
|
||||
_newScale(1.0f),
|
||||
_targetScale(1.0f),
|
||||
_leaderUUID(),
|
||||
_handState(0),
|
||||
_keyState(NO_KEY_DOWN),
|
||||
|
@ -76,7 +76,7 @@ int AvatarData::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
destinationBuffer += packFloatAngleToTwoByte(destinationBuffer, _bodyRoll);
|
||||
|
||||
// Body scale
|
||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _newScale);
|
||||
destinationBuffer += packFloatRatioToTwoByte(destinationBuffer, _targetScale);
|
||||
|
||||
// Follow mode info
|
||||
memcpy(destinationBuffer, _leaderUUID.toRfc4122().constData(), NUM_BYTES_RFC4122_UUID);
|
||||
|
@ -198,7 +198,7 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
sourceBuffer += unpackFloatAngleFromTwoByte((uint16_t*) sourceBuffer, &_bodyRoll);
|
||||
|
||||
// Body scale
|
||||
sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer, _newScale);
|
||||
sourceBuffer += unpackFloatRatioFromTwoByte(sourceBuffer, _targetScale);
|
||||
|
||||
// Follow mode info
|
||||
_leaderUUID = QUuid::fromRfc4122(QByteArray((char*) sourceBuffer, NUM_BYTES_RFC4122_UUID));
|
||||
|
@ -296,12 +296,10 @@ int AvatarData::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
void AvatarData::setNewScale(float newScale) {
|
||||
if (newScale > MAX_SCALE) {
|
||||
newScale = MAX_SCALE;
|
||||
} else if (newScale < MIN_SCALE) {
|
||||
newScale = MIN_SCALE;
|
||||
}
|
||||
_newScale = newScale;
|
||||
qDebug() << "Changed scale to " << _newScale << "\n";
|
||||
void AvatarData::setClampedTargetScale(float targetScale) {
|
||||
|
||||
targetScale = glm::clamp(targetScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE);
|
||||
|
||||
_targetScale = targetScale;
|
||||
qDebug() << "Changed scale to " << _targetScale << "\n";
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ const int HAND_STATE_START_BIT = 2; // 3rd and 4th bits
|
|||
const int IS_FACESHIFT_CONNECTED = 4; // 5th bit
|
||||
const int IS_CHAT_CIRCLING_ENABLED = 5;
|
||||
|
||||
static const float MAX_SCALE = 1000.f;
|
||||
static const float MIN_SCALE = .005f;
|
||||
static const float MAX_AVATAR_SCALE = 1000.f;
|
||||
static const float MIN_AVATAR_SCALE = .005f;
|
||||
|
||||
const float MAX_AUDIO_LOUDNESS = 1000.0; // close enough for mouth animation
|
||||
|
||||
|
@ -82,8 +82,9 @@ public:
|
|||
void setBodyRoll(float bodyRoll) { _bodyRoll = bodyRoll; }
|
||||
|
||||
// Scale
|
||||
float getNewScale() const { return _newScale; }
|
||||
void setNewScale(float);
|
||||
float getTargetScale() const { return _targetScale; }
|
||||
void setTargetScale(float targetScale) { _targetScale = targetScale; }
|
||||
void setClampedTargetScale(float targetScale);
|
||||
|
||||
// Hand State
|
||||
void setHandState(char s) { _handState = s; }
|
||||
|
@ -132,7 +133,7 @@ protected:
|
|||
float _bodyRoll;
|
||||
|
||||
// Body scale
|
||||
float _newScale;
|
||||
float _targetScale;
|
||||
|
||||
// Following mode infos
|
||||
QUuid _leaderUUID;
|
||||
|
|
Loading…
Reference in a new issue