Merge branch 'master' of github.com:highfidelity/hifi into black

This commit is contained in:
Sam Gateau 2018-08-23 11:40:10 -07:00
commit b725ed440b
13 changed files with 67 additions and 42 deletions

View file

@ -164,7 +164,7 @@ bool EntityTreeSendThread::traverseTreeAndSendContents(SharedNodePointer node, O
// Send EntityQueryInitialResultsComplete reliable packet ... // Send EntityQueryInitialResultsComplete reliable packet ...
auto initialCompletion = NLPacket::create(PacketType::EntityQueryInitialResultsComplete, auto initialCompletion = NLPacket::create(PacketType::EntityQueryInitialResultsComplete,
sizeof(OCTREE_PACKET_SEQUENCE), true); sizeof(OCTREE_PACKET_SEQUENCE), true);
initialCompletion->writePrimitive(OCTREE_PACKET_SEQUENCE(nodeData->getSequenceNumber() - 1U)); initialCompletion->writePrimitive(OCTREE_PACKET_SEQUENCE(nodeData->getSequenceNumber()));
DependencyManager::get<NodeList>()->sendPacket(std::move(initialCompletion), *node); DependencyManager::get<NodeList>()->sendPacket(std::move(initialCompletion), *node);
} }

View file

@ -24,6 +24,7 @@
#include <plugins/CodecPlugin.h> #include <plugins/CodecPlugin.h>
#include <plugins/PluginManager.h> #include <plugins/PluginManager.h>
#include <ResourceManager.h> #include <ResourceManager.h>
#include <ResourceScriptingInterface.h>
#include <ScriptCache.h> #include <ScriptCache.h>
#include <ScriptEngines.h> #include <ScriptEngines.h>
#include <SoundCacheScriptingInterface.h> #include <SoundCacheScriptingInterface.h>
@ -55,7 +56,8 @@ int EntityScriptServer::_entitiesScriptEngineCount = 0;
EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssignment(message) { EntityScriptServer::EntityScriptServer(ReceivedMessage& message) : ThreadedAssignment(message) {
qInstallMessageHandler(messageHandler); qInstallMessageHandler(messageHandler);
DependencyManager::get<EntityScriptingInterface>()->setPacketSender(&_entityEditSender); DependencyManager::set<EntityScriptingInterface>(false)->setPacketSender(&_entityEditSender);
DependencyManager::set<ResourceScriptingInterface>();
DependencyManager::set<ResourceManager>(); DependencyManager::set<ResourceManager>();
DependencyManager::set<PluginManager>(); DependencyManager::set<PluginManager>();
@ -455,8 +457,11 @@ void EntityScriptServer::resetEntitiesScriptEngine() {
auto newEngineSP = qSharedPointerCast<EntitiesScriptEngineProvider>(newEngine); auto newEngineSP = qSharedPointerCast<EntitiesScriptEngineProvider>(newEngine);
DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(newEngineSP); DependencyManager::get<EntityScriptingInterface>()->setEntitiesScriptEngine(newEngineSP);
disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, if (_entitiesScriptEngine) {
this, &EntityScriptServer::updateEntityPPS); disconnect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated,
this, &EntityScriptServer::updateEntityPPS);
}
_entitiesScriptEngine.swap(newEngine); _entitiesScriptEngine.swap(newEngine);
connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated, connect(_entitiesScriptEngine.data(), &ScriptEngine::entityScriptDetailsUpdated,
this, &EntityScriptServer::updateEntityPPS); this, &EntityScriptServer::updateEntityPPS);
@ -487,6 +492,21 @@ void EntityScriptServer::shutdownScriptEngine() {
_shuttingDown = true; _shuttingDown = true;
clear(); // always clear() on shutdown clear(); // always clear() on shutdown
auto scriptEngines = DependencyManager::get<ScriptEngines>();
scriptEngines->shutdownScripting();
_entitiesScriptEngine.clear();
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
// our entity tree is going to go away so tell that to the EntityScriptingInterface
entityScriptingInterface->setEntityTree(nullptr);
// Should always be true as they are singletons.
if (entityScriptingInterface->getPacketSender() == &_entityEditSender) {
// The packet sender is about to go away.
entityScriptingInterface->setPacketSender(nullptr);
}
} }
void EntityScriptServer::addingEntity(const EntityItemID& entityID) { void EntityScriptServer::addingEntity(const EntityItemID& entityID) {
@ -559,24 +579,18 @@ void EntityScriptServer::handleOctreePacket(QSharedPointer<ReceivedMessage> mess
void EntityScriptServer::aboutToFinish() { void EntityScriptServer::aboutToFinish() {
shutdownScriptEngine(); shutdownScriptEngine();
auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
// our entity tree is going to go away so tell that to the EntityScriptingInterface
entityScriptingInterface->setEntityTree(nullptr);
// Should always be true as they are singletons.
if (entityScriptingInterface->getPacketSender() == &_entityEditSender) {
// The packet sender is about to go away.
entityScriptingInterface->setPacketSender(nullptr);
}
DependencyManager::destroy<AssignmentParentFinder>(); DependencyManager::destroy<AssignmentParentFinder>();
DependencyManager::get<ResourceManager>()->cleanup(); DependencyManager::get<ResourceManager>()->cleanup();
DependencyManager::destroy<PluginManager>(); DependencyManager::destroy<PluginManager>();
DependencyManager::destroy<ResourceScriptingInterface>();
DependencyManager::destroy<EntityScriptingInterface>();
// cleanup the AudioInjectorManager (and any still running injectors) // cleanup the AudioInjectorManager (and any still running injectors)
DependencyManager::destroy<AudioInjectorManager>(); DependencyManager::destroy<AudioInjectorManager>();
DependencyManager::destroy<ScriptEngines>(); DependencyManager::destroy<ScriptEngines>();
DependencyManager::destroy<EntityScriptServerServices>(); DependencyManager::destroy<EntityScriptServerServices>();

View file

@ -3659,7 +3659,7 @@ bool Application::event(QEvent* event) {
bool Application::eventFilter(QObject* object, QEvent* event) { bool Application::eventFilter(QObject* object, QEvent* event) {
if (_aboutToQuit) { if (_aboutToQuit && event->type() != QEvent::DeferredDelete && event->type() != QEvent::Destroy) {
return true; return true;
} }

View file

@ -105,7 +105,7 @@ MyAvatar::MyAvatar(QThread* thread) :
_eyeContactTarget(LEFT_EYE), _eyeContactTarget(LEFT_EYE),
_realWorldFieldOfView("realWorldFieldOfView", _realWorldFieldOfView("realWorldFieldOfView",
DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES), DEFAULT_REAL_WORLD_FIELD_OF_VIEW_DEGREES),
_useAdvancedMovementControls("advancedMovementForHandControllersIsChecked", false), _useAdvancedMovementControls("advancedMovementForHandControllersIsChecked", true),
_smoothOrientationTimer(std::numeric_limits<float>::max()), _smoothOrientationTimer(std::numeric_limits<float>::max()),
_smoothOrientationInitial(), _smoothOrientationInitial(),
_smoothOrientationTarget(), _smoothOrientationTarget(),
@ -203,6 +203,7 @@ MyAvatar::MyAvatar(QThread* thread) :
connect(recorder.data(), &Recorder::recordingStateChanged, [=] { connect(recorder.data(), &Recorder::recordingStateChanged, [=] {
if (recorder->isRecording()) { if (recorder->isRecording()) {
createRecordingIDs();
setRecordingBasis(); setRecordingBasis();
} else { } else {
clearRecordingBasis(); clearRecordingBasis();
@ -444,7 +445,6 @@ void MyAvatar::reset(bool andRecenter, bool andReload, bool andHead) {
} }
void MyAvatar::update(float deltaTime) { void MyAvatar::update(float deltaTime) {
// update moving average of HMD facing in xz plane. // update moving average of HMD facing in xz plane.
const float HMD_FACING_TIMESCALE = getRotationRecenterFilterLength(); const float HMD_FACING_TIMESCALE = getRotationRecenterFilterLength();

View file

@ -122,11 +122,11 @@ bool SafeLanding::isSequenceNumbersComplete() {
int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart: int sequenceSize = _initialStart <= _initialEnd ? _initialEnd - _initialStart:
_initialEnd + SEQUENCE_MODULO - _initialStart; _initialEnd + SEQUENCE_MODULO - _initialStart;
auto startIter = _sequenceNumbers.find(_initialStart); auto startIter = _sequenceNumbers.find(_initialStart);
auto endIter = _sequenceNumbers.find(_initialEnd); auto endIter = _sequenceNumbers.find(_initialEnd - 1);
if (sequenceSize == 0 || if (sequenceSize == 0 ||
(startIter != _sequenceNumbers.end() (startIter != _sequenceNumbers.end()
&& endIter != _sequenceNumbers.end() && endIter != _sequenceNumbers.end()
&& distance(startIter, endIter) == sequenceSize) ) { && distance(startIter, endIter) == sequenceSize - 1) ) {
_trackingEntities = false; // Don't track anything else that comes in. _trackingEntities = false; // Don't track anything else that comes in.
return true; return true;
} }

View file

@ -26,7 +26,7 @@ class SafeLanding : public QObject {
public: public:
void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer); void startEntitySequence(QSharedPointer<EntityTreeRenderer> entityTreeRenderer);
void stopEntitySequence(); void stopEntitySequence();
void setCompletionSequenceNumbers(int first, int last); void setCompletionSequenceNumbers(int first, int last); // 'last' exclusive.
void noteReceivedsequenceNumber(int sequenceNumber); void noteReceivedsequenceNumber(int sequenceNumber);
bool isLoadSequenceComplete(); bool isLoadSequenceComplete();

View file

@ -272,7 +272,7 @@ void setupPreferences() {
auto getter = [myAvatar]()->bool { return myAvatar->useAdvancedMovementControls(); }; auto getter = [myAvatar]()->bool { return myAvatar->useAdvancedMovementControls(); };
auto setter = [myAvatar](bool value) { myAvatar->setUseAdvancedMovementControls(value); }; auto setter = [myAvatar](bool value) { myAvatar->setUseAdvancedMovementControls(value); };
preferences->addPreference(new CheckPreference(VR_MOVEMENT, preferences->addPreference(new CheckPreference(VR_MOVEMENT,
QStringLiteral("Advanced movement for hand controllers"), QStringLiteral("Advanced movement in VR (Teleport movement when unchecked)"),
getter, setter)); getter, setter));
} }
{ {

View file

@ -376,6 +376,9 @@ void Avatar::updateAvatarEntities() {
} }
} }
} }
if (avatarEntities.size() != _avatarEntityForRecording.size()) {
createRecordingIDs();
}
}); });
setAvatarEntityDataChanged(false); setAvatarEntityDataChanged(false);

View file

@ -2308,6 +2308,15 @@ void AvatarData::setRecordingBasis(std::shared_ptr<Transform> recordingBasis) {
_recordingBasis = recordingBasis; _recordingBasis = recordingBasis;
} }
void AvatarData::createRecordingIDs() {
_avatarEntitiesLock.withReadLock([&] {
_avatarEntityForRecording.clear();
for (int i = 0; i < _avatarEntityData.size(); i++) {
_avatarEntityForRecording.insert(QUuid::createUuid());
}
});
}
void AvatarData::clearRecordingBasis() { void AvatarData::clearRecordingBasis() {
_recordingBasis.reset(); _recordingBasis.reset();
} }
@ -2368,21 +2377,15 @@ QJsonObject AvatarData::toJson() const {
if (!getDisplayName().isEmpty()) { if (!getDisplayName().isEmpty()) {
root[JSON_AVATAR_DISPLAY_NAME] = getDisplayName(); root[JSON_AVATAR_DISPLAY_NAME] = getDisplayName();
} }
if (!getAttachmentData().isEmpty()) {
QJsonArray attachmentsJson;
for (auto attachment : getAttachmentData()) {
attachmentsJson.push_back(attachment.toJson());
}
root[JSON_AVATAR_ATTACHMENTS] = attachmentsJson;
}
_avatarEntitiesLock.withReadLock([&] { _avatarEntitiesLock.withReadLock([&] {
if (!_avatarEntityData.empty()) { if (!_avatarEntityData.empty()) {
QJsonArray avatarEntityJson; QJsonArray avatarEntityJson;
int entityCount = 0;
for (auto entityID : _avatarEntityData.keys()) { for (auto entityID : _avatarEntityData.keys()) {
QVariantMap entityData; QVariantMap entityData;
entityData.insert("id", entityID); QUuid newId = _avatarEntityForRecording.size() == _avatarEntityData.size() ? _avatarEntityForRecording.values()[entityCount++] : entityID;
entityData.insert("properties", _avatarEntityData.value(entityID)); entityData.insert("id", newId);
entityData.insert("properties", _avatarEntityData.value(entityID).toBase64());
avatarEntityJson.push_back(QVariant(entityData).toJsonObject()); avatarEntityJson.push_back(QVariant(entityData).toJsonObject());
} }
root[JSON_AVATAR_ENTITIES] = avatarEntityJson; root[JSON_AVATAR_ENTITIES] = avatarEntityJson;
@ -2504,12 +2507,17 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
setAttachmentData(attachments); setAttachmentData(attachments);
} }
// if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) { if (json.contains(JSON_AVATAR_ENTITIES) && json[JSON_AVATAR_ENTITIES].isArray()) {
// QJsonArray attachmentsJson = json[JSON_AVATAR_ATTACHMENTS].toArray(); QJsonArray attachmentsJson = json[JSON_AVATAR_ENTITIES].toArray();
// for (auto attachmentJson : attachmentsJson) { for (auto attachmentJson : attachmentsJson) {
// // TODO -- something if (attachmentJson.isObject()) {
// } QVariantMap entityData = attachmentJson.toObject().toVariantMap();
// } QUuid entityID = entityData.value("id").toUuid();
QByteArray properties = QByteArray::fromBase64(entityData.value("properties").toByteArray());
updateAvatarEntity(entityID, properties);
}
}
}
if (json.contains(JSON_AVATAR_JOINT_ARRAY)) { if (json.contains(JSON_AVATAR_JOINT_ARRAY)) {
if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) { if (version == (int)JsonAvatarFrameVersion::JointRotationsInRelativeFrame) {

View file

@ -1089,6 +1089,7 @@ public:
void clearRecordingBasis(); void clearRecordingBasis();
TransformPointer getRecordingBasis() const; TransformPointer getRecordingBasis() const;
void setRecordingBasis(TransformPointer recordingBasis = TransformPointer()); void setRecordingBasis(TransformPointer recordingBasis = TransformPointer());
void createRecordingIDs();
QJsonObject toJson() const; QJsonObject toJson() const;
void fromJson(const QJsonObject& json, bool useFrameSkeleton = true); void fromJson(const QJsonObject& json, bool useFrameSkeleton = true);
@ -1421,6 +1422,7 @@ protected:
mutable ReadWriteLockable _avatarEntitiesLock; mutable ReadWriteLockable _avatarEntitiesLock;
AvatarEntityIDs _avatarEntityDetached; // recently detached from this avatar AvatarEntityIDs _avatarEntityDetached; // recently detached from this avatar
AvatarEntityIDs _avatarEntityForRecording; // create new entities id for avatar recording
AvatarEntityMap _avatarEntityData; AvatarEntityMap _avatarEntityData;
bool _avatarEntityDataChanged { false }; bool _avatarEntityDataChanged { false };

View file

@ -94,6 +94,8 @@ PacketVersion versionForPacketType(PacketType packetType) {
return static_cast<PacketVersion>(AvatarQueryVersion::ConicalFrustums); return static_cast<PacketVersion>(AvatarQueryVersion::ConicalFrustums);
case PacketType::AvatarIdentityRequest: case PacketType::AvatarIdentityRequest:
return 22; return 22;
case PacketType::EntityQueryInitialResultsComplete:
return static_cast<PacketVersion>(EntityVersion::ParticleSpin);
default: default:
return 22; return 22;
} }

View file

@ -176,9 +176,7 @@ ScriptEngine::ScriptEngine(Context context, const QString& scriptContents, const
_timerFunctionMap(), _timerFunctionMap(),
_fileNameString(fileNameString), _fileNameString(fileNameString),
_arrayBufferClass(new ArrayBufferClass(this)), _arrayBufferClass(new ArrayBufferClass(this)),
_assetScriptingInterface(new AssetScriptingInterface(this)), _assetScriptingInterface(new AssetScriptingInterface(this))
// don't delete `ScriptEngines` until all `ScriptEngine`s are gone
_scriptEngines(DependencyManager::get<ScriptEngines>())
{ {
switch (_context) { switch (_context) {
case Context::CLIENT_SCRIPT: case Context::CLIENT_SCRIPT:

View file

@ -806,8 +806,6 @@ protected:
static const QString _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS; static const QString _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS;
Setting::Handle<bool> _enableExtendedJSExceptions { _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS, true }; Setting::Handle<bool> _enableExtendedJSExceptions { _SETTINGS_ENABLE_EXTENDED_EXCEPTIONS, true };
QSharedPointer<ScriptEngines> _scriptEngines;
}; };
ScriptEnginePointer scriptEngineFactory(ScriptEngine::Context context, ScriptEnginePointer scriptEngineFactory(ScriptEngine::Context context,