Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(DNM) script debugging build #1301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
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
6 changes: 6 additions & 0 deletions libraries/entities-renderer/src/EntityTreeRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,7 @@ void EntityTreeRenderer::deletingEntity(const EntityItemID& entityID) {
}

void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
qDebug() << "SCRIPT DEBUGGING addingEntity " << entityID;
checkAndCallPreload(entityID);
auto entity = std::static_pointer_cast<EntityTree>(_tree)->findEntityByID(entityID);
if (entity) {
Expand All @@ -1153,6 +1154,7 @@ void EntityTreeRenderer::addingEntity(const EntityItemID& entityID) {
}

void EntityTreeRenderer::entityScriptChanging(const EntityItemID& entityID, bool reload) {
qDebug() << "SCRIPT DEBUGGING entityScriptChanging " << entityID;
checkAndCallPreload(entityID, reload, true);
// Force "re-checking" entities so that the logic inside `checkEnterLeaveEntities()` is run.
// This will ensure that the `enterEntity()` signal is emitted on clients whose avatars
Expand All @@ -1164,11 +1166,13 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool
if (_tree && !_shuttingDown) {
EntityItemPointer entity = getTree()->findEntityByEntityItemID(entityID);
if (!entity) {
qDebug() << "SCRIPT DEBUGGING checkAndCallPreload entity doesn't exist " << entityID;
return;
}
auto& scriptEngine = (entity->isLocalEntity() || entity->isMyAvatarEntity()) ? _persistentEntitiesScriptManager : _nonPersistentEntitiesScriptManager;
bool shouldLoad = entity->shouldPreloadScript() && scriptEngine;
QString scriptUrl = entity->getScript();
qDebug() << "SCRIPT DEBUGGING checkAndCallPreload check " << entityID << shouldLoad << (bool)scriptEngine << entity->shouldPreloadScript() << entity->getScript();
if ((shouldLoad && unloadFirst) || scriptUrl.isEmpty()) {
if (scriptEngine) {
if (_currentEntitiesInside.contains(entityID)) {
Expand All @@ -1185,6 +1189,8 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, bool
scriptEngine->loadEntityScript(entityID, resolveScriptURL(scriptUrl), reload);
entity->scriptHasPreloaded();
}
} else {
qDebug() << "SCRIPT DEBUGGING checkAndCallPreload failed " << (bool)_tree << _shuttingDown << entityID;
}
}

Expand Down