Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ba2d93c
ensure all #include's to QtScript are labeled as such (easier to find)
odysseus654 Apr 26, 2021
5e36015
isolate calls to the QtScript libraries to an interface we control
odysseus654 May 16, 2021
897ff08
Merge branch vircadia:master into feature/scripting
odysseus654 May 16, 2021
b52624c
working to clean up the QtScript implementation and move towards comp…
odysseus654 Aug 30, 2021
90c15af
Merge remote-tracking branch 'remotes/origin/HEAD' into feature/scrip…
odysseus654 Aug 30, 2021
87bb35c
adding basic script-engine documentation
odysseus654 Aug 30, 2021
dd34b77
shifting classes around and adding static initializers to resolve dep…
odysseus654 Sep 1, 2021
e799518
moving EntityItemID from script-engine to shared
odysseus654 Sep 1, 2021
8db1cfe
dropping dependencies from networking to script-engine by moving Enti…
odysseus654 Sep 1, 2021
d8546da
added custom type support
odysseus654 Sep 1, 2021
e5be895
early smoketesting
odysseus654 Sep 2, 2021
6462ac1
rework ScriptValue to act like a stack variable rather than a pointer
odysseus654 Sep 3, 2021
e6117d2
changes in response to build log on other compilers
odysseus654 Sep 3, 2021
3a24305
more changes in response to build log on other compilers
odysseus654 Sep 3, 2021
803ec1b
more debugging using github compiler runs
odysseus654 Sep 4, 2021
cae568c
more code review using github compiler runs
odysseus654 Sep 4, 2021
1d67628
more code review using github compiler runs (hopefully the macos buil…
odysseus654 Sep 4, 2021
2b60842
hopefully resolves the last reported link error on macos
odysseus654 Sep 4, 2021
876736a
finished coding and smoketested ScriptContextQtAgent (required to get…
odysseus654 Sep 4, 2021
4abbff2
patch review and removal of unnecessary differences
odysseus654 Sep 4, 2021
28d7964
significant cleanup of ScriptEngineQtScript (which isn't exposed to t…
odysseus654 Sep 6, 2021
ff46561
more simplification of ScriptEngineQtScript declarations
odysseus654 Sep 6, 2021
26c9810
more shifting around of ScriptEngineQtScript declaration
odysseus654 Sep 6, 2021
4f03899
convert script engine variables from QSharedPointer to std::shared_ptr
odysseus654 Sep 12, 2021
c036c04
changes from code review suggestions
odysseus654 Nov 15, 2021
170a8f3
Merge remote-tracking branch 'remotes/vircadia/master' into feature/s…
odysseus654 Nov 25, 2021
e407507
Merge remote-tracking branch 'remotes/vircadia/master' into feature/s…
odysseus654 Dec 4, 2021
9eb325f
first pass creating Qt <-> QtScript interface
odysseus654 Dec 14, 2021
3035457
not sure what would have broken this but... adding required windows d…
odysseus654 Dec 15, 2021
3b37bbc
Merge remote-tracking branch 'remotes/vircadia/master' into feature/s…
odysseus654 Dec 15, 2021
0144609
Continued tightening and testing of the scripting engine "glue" logic
odysseus654 Dec 15, 2021
7a49155
minor tweaks in response to code review (very belated) and reported i…
odysseus654 Jan 20, 2022
bc8d57a
Merge remote-tracking branch 'remotes/vircadia/master' into feature/s…
odysseus654 Jan 25, 2022
0bd5c11
Merge remote-tracking branch 'remotes/vircadia/master' into feature/s…
odysseus654 Mar 14, 2022
8198991
force Qt registration of PerformanceManager::PerformancePreset, as it…
odysseus654 Mar 21, 2022
e30cf41
identify the largest number of parameters any of our method overrides…
odysseus654 Mar 21, 2022
e9ed543
fix typo preventing methods from being discovered on scriptable objec…
odysseus654 Mar 21, 2022
9029337
remove requirement that ScriptManager::evaluate be meta-invokable
odysseus654 Mar 21, 2022
6f9e77e
dropped unused meta declaration
odysseus654 Mar 21, 2022
32584b7
dropped KALILA global script attributes
odysseus654 Mar 21, 2022
52c8344
fixed missing #include required by new template blockingInvokeMethod …
odysseus654 Mar 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assignment-client/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(TARGET_NAME assignment-client)

setup_hifi_project(Core Gui Network Script Quick WebSockets)
setup_hifi_project(Core Gui Network Quick WebSockets)

# Fix up the rpath so macdeployqt works
if (APPLE)
Expand Down
46 changes: 25 additions & 21 deletions assignment-client/src/Agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@
#include <DebugDraw.h>
#include <EntityScriptingInterface.h>
#include <LocationScriptingInterface.h>
#include <AudioScriptingInterface.h>
#include <MessagesClient.h>
#include <NetworkAccessManager.h>
#include <NodeList.h>
#include <udt/PacketHeaders.h>
#include <ResourceCache.h>
#include <ResourceScriptingInterface.h>
#include <ScriptCache.h>
#include <ScriptEngine.h>
#include <ScriptEngines.h>
#include <ScriptManager.h>
#include <SoundCacheScriptingInterface.h>
#include <SoundCache.h>
#include <UserActivityLoggerScriptingInterface.h>
Expand All @@ -56,7 +59,7 @@

#include "entities/AssignmentParentFinder.h"
#include "AssignmentDynamicFactory.h"
#include "RecordingScriptingInterface.h"
#include <recording/RecordingScriptingInterface.h>
#include "AbstractAudioInterface.h"
#include "AgentScriptingInterface.h"

Expand Down Expand Up @@ -180,7 +183,7 @@ static const QString AGENT_LOGGING_NAME = "agent";

void Agent::run() {
// Create ScriptEngines on threaded-assignment thread then move to main thread.
DependencyManager::set<ScriptEngines>(ScriptEngine::AGENT_SCRIPT)->moveToThread(qApp->thread());
DependencyManager::set<ScriptEngines>(ScriptManager::AGENT_SCRIPT)->moveToThread(qApp->thread());

DependencyManager::set<ScriptCache>();

Expand Down Expand Up @@ -372,7 +375,7 @@ void Agent::executeScript() {
// the following block is scoped so that any shared pointers we take here
// are cleared before we call setFinished at the end of the function
{
_scriptEngine = scriptEngineFactory(ScriptEngine::AGENT_SCRIPT, _scriptContents, _payload);
_scriptManager = scriptManagerFactory(ScriptManager::AGENT_SCRIPT, _scriptContents, _payload);

// setup an Avatar for the script to use
auto scriptedAvatar = DependencyManager::get<ScriptableAvatar>();
Expand All @@ -386,10 +389,11 @@ void Agent::executeScript() {
scriptedAvatar->getHeadOrientation();

// give this AvatarData object to the script engine
_scriptEngine->registerGlobalObject("Avatar", scriptedAvatar.data());
auto scriptEngine = _scriptManager->engine();
scriptEngine->registerGlobalObject("Avatar", scriptedAvatar.data());

// give scripts access to the Users object
_scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());
scriptEngine->registerGlobalObject("Users", DependencyManager::get<UsersScriptingInterface>().data());

auto player = DependencyManager::get<recording::Deck>();
connect(player.data(), &recording::Deck::playbackStateChanged, [&player, &scriptedAvatar] {
Expand Down Expand Up @@ -493,26 +497,26 @@ void Agent::executeScript() {
});

auto avatarHashMap = DependencyManager::set<AvatarHashMap>();
_scriptEngine->registerGlobalObject("AvatarList", avatarHashMap.data());
scriptEngine->registerGlobalObject("AvatarList", avatarHashMap.data());

// register ourselves to the script engine
_scriptEngine->registerGlobalObject("Agent", new AgentScriptingInterface(this));
scriptEngine->registerGlobalObject("Agent", new AgentScriptingInterface(this));

_scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
_scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());
scriptEngine->registerGlobalObject("AnimationCache", DependencyManager::get<AnimationCacheScriptingInterface>().data());
scriptEngine->registerGlobalObject("SoundCache", DependencyManager::get<SoundCacheScriptingInterface>().data());

QScriptValue webSocketServerConstructorValue = _scriptEngine->newFunction(WebSocketServerClass::constructor);
_scriptEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);
ScriptValue webSocketServerConstructorValue = scriptEngine->newFunction(WebSocketServerClass::constructor);
scriptEngine->globalObject().setProperty("WebSocketServer", webSocketServerConstructorValue);

auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();

_scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer);
scriptEngine->registerGlobalObject("EntityViewer", &_entityViewer);

_scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
scriptEngine->registerGetterSetter("location", LocationScriptingInterface::locationGetter,
LocationScriptingInterface::locationSetter);

auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();
_scriptEngine->registerGlobalObject("Recording", recordingInterface.data());
scriptEngine->registerGlobalObject("Recording", recordingInterface.data());

entityScriptingInterface->init();

Expand All @@ -522,8 +526,8 @@ void Agent::executeScript() {

DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());

DependencyManager::get<ScriptEngines>()->runScriptInitializers(_scriptEngine);
_scriptEngine->run();
DependencyManager::get<ScriptEngines>()->runScriptInitializers(_scriptManager);
_scriptManager->run();

Frame::clearFrameHandler(AUDIO_FRAME_TYPE);
Frame::clearFrameHandler(AVATAR_FRAME_TYPE);
Expand Down Expand Up @@ -602,7 +606,7 @@ void Agent::setIsAvatar(bool isAvatar) {
// start the timer
_avatarQueryTimer->start(AVATAR_VIEW_PACKET_SEND_INTERVAL_MSECS);

connect(_scriptEngine.data(), &ScriptEngine::update,
connect(_scriptManager.get(), &ScriptManager::update,
scriptableAvatar.data(), &ScriptableAvatar::update, Qt::QueuedConnection);

// tell the avatarAudioTimer to start ticking
Expand Down Expand Up @@ -638,7 +642,7 @@ void Agent::setIsAvatar(bool isAvatar) {
nodeList->sendPacket(std::move(packet), *node);
});

disconnect(_scriptEngine.data(), &ScriptEngine::update,
disconnect(_scriptManager.get(), &ScriptManager::update,
scriptableAvatar.data(), &ScriptableAvatar::update);

QMetaObject::invokeMethod(&_avatarAudioTimer, "stop");
Expand Down Expand Up @@ -875,7 +879,7 @@ void Agent::aboutToFinish() {

// drop our shared pointer to the script engine, then ask ScriptEngines to shutdown scripting
// this ensures that the ScriptEngine goes down before ScriptEngines
_scriptEngine.clear();
_scriptManager.reset();

{
DependencyManager::get<ScriptEngines>()->shutdownScripting();
Expand All @@ -895,8 +899,8 @@ void Agent::aboutToFinish() {
}

void Agent::stop() {
if (_scriptEngine) {
_scriptEngine->stop();
if (_scriptManager) {
_scriptManager->stop();
} else {
setFinished(true);
}
Expand Down
10 changes: 8 additions & 2 deletions assignment-client/src/Agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
#include <memory>
#include <vector>

#include <QtScript/QScriptEngine>
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QtCore/QUrl>
#include <QtCore/QTimer>
#include <QUuid>
#include <QtCore/QSharedPointer>

#include <EntityEditPacketSender.h>
#include <EntityTree.h>
Expand All @@ -29,11 +29,17 @@

#include <plugins/CodecPlugin.h>

#include <Sound.h>
Comment thread
HifiExperiments marked this conversation as resolved.
#include "AudioGate.h"
#include "MixedAudioStream.h"
#include "entities/EntityTreeHeadlessViewer.h"
#include "avatars/ScriptableAvatar.h"

class ScriptEngine;
class ScriptManager;
using ScriptEnginePointer = std::shared_ptr<ScriptEngine>;
using ScriptManagerPointer = std::shared_ptr<ScriptManager>;

class Agent : public ThreadedAssignment {
Q_OBJECT

Expand Down Expand Up @@ -90,7 +96,7 @@ private slots:
void encodeFrameOfZeros(QByteArray& encodedZeros);
void computeLoudness(const QByteArray* decodedBuffer, QSharedPointer<ScriptableAvatar>);

ScriptEnginePointer _scriptEngine;
ScriptManagerPointer _scriptManager;
EntityEditPacketSender _entityEditSender;
EntityTreeHeadlessViewer _entityViewer;

Expand Down
10 changes: 6 additions & 4 deletions assignment-client/src/avatars/ScriptableAvatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@

#include <shared/QtHelpers.h>
#include <AnimUtil.h>
#include <AvatarHashMap.h>
#include <ClientTraitsHandler.h>
#include <GLMHelpers.h>
#include <ResourceRequestObserver.h>
#include <AvatarLogging.h>
#include <EntityItem.h>
#include <EntityItemProperties.h>
#include <NetworkAccessManager.h>
Comment thread
HifiExperiments marked this conversation as resolved.
#include <NetworkingConstants.h>


ScriptableAvatar::ScriptableAvatar() {
ScriptableAvatar::ScriptableAvatar(): _scriptEngine(newScriptEngine()) {
_clientTraitsHandler.reset(new ClientTraitsHandler(this));
}

Expand Down Expand Up @@ -311,7 +313,7 @@ AvatarEntityMap ScriptableAvatar::getAvatarEntityDataInternal(bool allProperties
EntityItemProperties properties = entity->getProperties(desiredProperties);

QByteArray blob;
EntityItemProperties::propertiesToBlob(_scriptEngine, sessionID, properties, blob, allProperties);
EntityItemProperties::propertiesToBlob(*_scriptEngine, sessionID, properties, blob, allProperties);
data[id] = blob;
}
});
Expand All @@ -335,7 +337,7 @@ void ScriptableAvatar::setAvatarEntityData(const AvatarEntityMap& avatarEntityDa
while (dataItr != avatarEntityData.end()) {
EntityItemProperties properties;
const QByteArray& blob = dataItr.value();
if (!blob.isNull() && EntityItemProperties::blobToProperties(_scriptEngine, blob, properties)) {
if (!blob.isNull() && EntityItemProperties::blobToProperties(*_scriptEngine, blob, properties)) {
newProperties[dataItr.key()] = properties;
}
++dataItr;
Expand Down Expand Up @@ -415,7 +417,7 @@ void ScriptableAvatar::updateAvatarEntity(const QUuid& entityID, const QByteArra

EntityItemPointer entity;
EntityItemProperties properties;
if (!EntityItemProperties::blobToProperties(_scriptEngine, entityData, properties)) {
if (!EntityItemProperties::blobToProperties(*_scriptEngine, entityData, properties)) {
// entityData is corrupt
return;
}
Expand Down
2 changes: 1 addition & 1 deletion assignment-client/src/avatars/ScriptableAvatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public slots:
QHash<QString, int> _fstJointIndices; ///< 1-based, since zero is returned for missing keys
QStringList _fstJointNames; ///< in order of depth-first traversal
QUrl _skeletonFBXURL;
mutable QScriptEngine _scriptEngine;
mutable ScriptEnginePointer _scriptEngine;
std::map<QUuid, EntityItemPointer> _entities;

/// Loads the joint indices, names from the FST file (if any)
Expand Down
Loading