mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 22:51:20 +02:00
Merge pull request #14170 from Atlante45/fix/invisible-agents
Fix non-avatar agents appearing as avatars
This commit is contained in:
commit
3fab542009
3 changed files with 34 additions and 31 deletions
|
@ -368,11 +368,7 @@ void Agent::executeScript() {
|
||||||
|
|
||||||
// setup an Avatar for the script to use
|
// setup an Avatar for the script to use
|
||||||
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||||
|
|
||||||
scriptedAvatar->setID(getSessionUUID());
|
scriptedAvatar->setID(getSessionUUID());
|
||||||
|
|
||||||
connect(_scriptEngine.data(), SIGNAL(update(float)),
|
|
||||||
scriptedAvatar.data(), SLOT(update(float)), Qt::ConnectionType::QueuedConnection);
|
|
||||||
scriptedAvatar->setForceFaceTrackerConnected(true);
|
scriptedAvatar->setForceFaceTrackerConnected(true);
|
||||||
|
|
||||||
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
// call model URL setters with empty URLs so our avatar, if user, will have the default models
|
||||||
|
@ -504,8 +500,6 @@ void Agent::executeScript() {
|
||||||
|
|
||||||
DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());
|
DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());
|
||||||
|
|
||||||
_avatarAudioTimer.start();
|
|
||||||
|
|
||||||
// Agents should run at 45hz
|
// Agents should run at 45hz
|
||||||
static const int AVATAR_DATA_HZ = 45;
|
static const int AVATAR_DATA_HZ = 45;
|
||||||
static const int AVATAR_DATA_IN_MSECS = MSECS_PER_SECOND / AVATAR_DATA_HZ;
|
static const int AVATAR_DATA_IN_MSECS = MSECS_PER_SECOND / AVATAR_DATA_HZ;
|
||||||
|
@ -530,7 +524,8 @@ void Agent::executeScript() {
|
||||||
}
|
}
|
||||||
|
|
||||||
avatarDataTimer->stop();
|
avatarDataTimer->stop();
|
||||||
_avatarAudioTimer.stop();
|
|
||||||
|
setIsAvatar(false); // will stop timers for sending identity packets
|
||||||
}
|
}
|
||||||
|
|
||||||
setFinished(true);
|
setFinished(true);
|
||||||
|
@ -582,28 +577,33 @@ void Agent::setIsAvatar(bool isAvatar) {
|
||||||
}
|
}
|
||||||
_isAvatar = isAvatar;
|
_isAvatar = isAvatar;
|
||||||
|
|
||||||
if (_isAvatar && !_avatarIdentityTimer) {
|
auto scriptableAvatar = DependencyManager::get<ScriptableAvatar>();
|
||||||
// set up the avatar timers
|
if (_isAvatar) {
|
||||||
_avatarIdentityTimer = new QTimer(this);
|
if (!_avatarIdentityTimer) {
|
||||||
_avatarQueryTimer = new QTimer(this);
|
// set up the avatar timers
|
||||||
|
_avatarIdentityTimer = new QTimer(this);
|
||||||
|
_avatarQueryTimer = new QTimer(this);
|
||||||
|
|
||||||
// connect our slot
|
// connect our slot
|
||||||
connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket);
|
connect(_avatarIdentityTimer, &QTimer::timeout, this, &Agent::sendAvatarIdentityPacket);
|
||||||
connect(_avatarQueryTimer, &QTimer::timeout, this, &Agent::queryAvatars);
|
connect(_avatarQueryTimer, &QTimer::timeout, this, &Agent::queryAvatars);
|
||||||
|
|
||||||
static const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000;
|
static const int AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS = 1000;
|
||||||
static const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 1000;
|
static const int AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS = 1000;
|
||||||
|
|
||||||
// start the timers
|
// start the timers
|
||||||
_avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets
|
_avatarIdentityTimer->start(AVATAR_IDENTITY_PACKET_SEND_INTERVAL_MSECS); // FIXME - we shouldn't really need to constantly send identity packets
|
||||||
_avatarQueryTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS);
|
_avatarQueryTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS);
|
||||||
|
|
||||||
// tell the avatarAudioTimer to start ticking
|
connect(_scriptEngine.data(), &ScriptEngine::update,
|
||||||
QMetaObject::invokeMethod(&_avatarAudioTimer, "start");
|
scriptableAvatar.data(), &ScriptableAvatar::update, Qt::QueuedConnection);
|
||||||
}
|
|
||||||
|
|
||||||
if (!_isAvatar) {
|
// tell the avatarAudioTimer to start ticking
|
||||||
|
QMetaObject::invokeMethod(&_avatarAudioTimer, "start");
|
||||||
|
}
|
||||||
|
|
||||||
|
_entityEditSender.setMyAvatar(scriptableAvatar.data());
|
||||||
|
} else {
|
||||||
if (_avatarIdentityTimer) {
|
if (_avatarIdentityTimer) {
|
||||||
_avatarIdentityTimer->stop();
|
_avatarIdentityTimer->stop();
|
||||||
delete _avatarIdentityTimer;
|
delete _avatarIdentityTimer;
|
||||||
|
@ -630,14 +630,14 @@ void Agent::setIsAvatar(bool isAvatar) {
|
||||||
packet->writePrimitive(KillAvatarReason::NoReason);
|
packet->writePrimitive(KillAvatarReason::NoReason);
|
||||||
nodeList->sendPacket(std::move(packet), *node);
|
nodeList->sendPacket(std::move(packet), *node);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
disconnect(_scriptEngine.data(), &ScriptEngine::update,
|
||||||
|
scriptableAvatar.data(), &ScriptableAvatar::update);
|
||||||
|
|
||||||
|
QMetaObject::invokeMethod(&_avatarAudioTimer, "stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&_avatarAudioTimer, "stop");
|
|
||||||
|
|
||||||
_entityEditSender.setMyAvatar(nullptr);
|
_entityEditSender.setMyAvatar(nullptr);
|
||||||
} else {
|
|
||||||
auto scriptableAvatar = DependencyManager::get<ScriptableAvatar>();
|
|
||||||
_entityEditSender.setMyAvatar(scriptableAvatar.data());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -864,8 +864,6 @@ void Agent::processAgentAvatarAudio() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Agent::aboutToFinish() {
|
void Agent::aboutToFinish() {
|
||||||
setIsAvatar(false);// will stop timers for sending identity packets
|
|
||||||
|
|
||||||
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
||||||
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(nullptr);
|
DependencyManager::get<EntityScriptingInterface>()->setEntityTree(nullptr);
|
||||||
|
|
||||||
|
|
|
@ -380,6 +380,11 @@ void AvatarMixerSlave::broadcastAvatarDataToAgent(const SharedNodePointer& node)
|
||||||
if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) {
|
if (lastSeqToReceiver == lastSeqFromSender && lastSeqToReceiver != 0) {
|
||||||
++numAvatarsHeldBack;
|
++numAvatarsHeldBack;
|
||||||
shouldIgnore = true;
|
shouldIgnore = true;
|
||||||
|
} else if (lastSeqFromSender == 0) {
|
||||||
|
// We have have not yet recieved any data about this avatar. Ignore it for now
|
||||||
|
// This is important for Agent scripts that are not avatar
|
||||||
|
// so that they don't appear to be an avatar at the origin
|
||||||
|
shouldIgnore = true;
|
||||||
} else if (lastSeqFromSender - lastSeqToReceiver > 1) {
|
} else if (lastSeqFromSender - lastSeqToReceiver > 1) {
|
||||||
// this is a skip - we still send the packet but capture the presence of the skip so we see it happening
|
// this is a skip - we still send the packet but capture the presence of the skip so we see it happening
|
||||||
++numAvatarsWithSkippedFrames;
|
++numAvatarsWithSkippedFrames;
|
||||||
|
|
|
@ -164,7 +164,7 @@ public:
|
||||||
void setHasAudioEnabledFaceMovement(bool hasAudioEnabledFaceMovement);
|
void setHasAudioEnabledFaceMovement(bool hasAudioEnabledFaceMovement);
|
||||||
bool getHasAudioEnabledFaceMovement() const override { return _headData->getHasAudioEnabledFaceMovement(); }
|
bool getHasAudioEnabledFaceMovement() const override { return _headData->getHasAudioEnabledFaceMovement(); }
|
||||||
|
|
||||||
private slots:
|
public slots:
|
||||||
void update(float deltatime);
|
void update(float deltatime);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in a new issue