mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 21:02:17 +02:00
added requested changes
This commit is contained in:
parent
2ac7fcadd2
commit
689fbd2da0
6 changed files with 29 additions and 31 deletions
|
@ -1231,7 +1231,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
|
||||
connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] {
|
||||
getEntities()->reloadEntityScripts();
|
||||
loadAvatarScripts(getMyAvatar()->getSkeletonModel()->getFBXGeometry().scripts);
|
||||
loadAvatarScripts(getMyAvatar()->getScriptUrls());
|
||||
}, Qt::QueuedConnection);
|
||||
|
||||
connect(scriptEngines, &ScriptEngines::scriptLoadError,
|
||||
|
@ -4728,16 +4728,14 @@ void Application::init() {
|
|||
}
|
||||
|
||||
void Application::loadAvatarScripts(const QVector<QString>& urls) {
|
||||
if (urls.size() > 0) {
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
auto runningScripts = scriptEngines->getRunningScripts();
|
||||
for (auto url : urls) {
|
||||
int index = runningScripts.indexOf(url);
|
||||
if (index < 0) {
|
||||
auto scriptEnginePointer = scriptEngines->loadScript(url, false);
|
||||
if (scriptEnginePointer) {
|
||||
scriptEnginePointer->setType(ScriptEngine::Type::AVATAR);
|
||||
}
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
auto runningScripts = scriptEngines->getRunningScripts();
|
||||
for (auto url : urls) {
|
||||
int index = runningScripts.indexOf(url);
|
||||
if (index < 0) {
|
||||
auto scriptEnginePointer = scriptEngines->loadScript(url, false);
|
||||
if (scriptEnginePointer) {
|
||||
scriptEnginePointer->setType(ScriptEngine::Type::AVATAR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4746,12 +4744,10 @@ void Application::loadAvatarScripts(const QVector<QString>& urls) {
|
|||
void Application::unloadAvatarScripts() {
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
auto urls = scriptEngines->getRunningScripts();
|
||||
if (urls.size() > 0) {
|
||||
for (auto url : urls) {
|
||||
auto scriptEngine = scriptEngines->getScriptEngine(url);
|
||||
if (scriptEngine->getType() == ScriptEngine::Type::AVATAR) {
|
||||
scriptEngines->stopScript(url, false);
|
||||
}
|
||||
for (auto url : urls) {
|
||||
auto scriptEngine = scriptEngines->getScriptEngine(url);
|
||||
if (scriptEngine->getType() == ScriptEngine::Type::AVATAR) {
|
||||
scriptEngines->stopScript(url, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,7 +210,6 @@ bool ModelPackager::zipModel() {
|
|||
_mapping[TEXDIR_FIELD] = tempDir.relativeFilePath(texDir.path());
|
||||
|
||||
for (auto multi : _mapping.values(SCRIPT_FIELD)) {
|
||||
|
||||
multi.fromValue(tempDir.relativeFilePath(scriptDir.path()) + multi.toString());
|
||||
}
|
||||
// Copy FST
|
||||
|
|
|
@ -2852,6 +2852,11 @@ void MyAvatar::setWalkSpeed(float value) {
|
|||
_walkSpeed.set(value);
|
||||
}
|
||||
|
||||
QVector<QString> MyAvatar::getScriptUrls() {
|
||||
QVector<QString> scripts = _skeletonModel->isLoaded() ? _skeletonModel->getFBXGeometry().scripts : QVector<QString>();
|
||||
return scripts;
|
||||
}
|
||||
|
||||
glm::vec3 MyAvatar::getPositionForAudio() {
|
||||
glm::vec3 result;
|
||||
switch (_audioListenerMode) {
|
||||
|
|
|
@ -594,6 +594,8 @@ public:
|
|||
void setWalkSpeed(float value);
|
||||
float getWalkSpeed() const;
|
||||
|
||||
QVector<QString> getScriptUrls();
|
||||
|
||||
public slots:
|
||||
void increaseSize();
|
||||
void decreaseSize();
|
||||
|
|
|
@ -193,17 +193,15 @@ QVector<QString> FSTReader::getScripts(const QUrl& url, const QVariantHash& mapp
|
|||
QVector<QString> scriptPaths;
|
||||
if (!fstMapping.value(SCRIPT_FIELD).isNull()) {
|
||||
auto scripts = fstMapping.values(SCRIPT_FIELD).toVector();
|
||||
if (scripts.size() > 0) {
|
||||
for (auto &script : scripts) {
|
||||
QString scriptPath = script.toString();
|
||||
if (QUrl(scriptPath).isRelative()) {
|
||||
if (scriptPath.at(0) == '/') {
|
||||
scriptPath = scriptPath.right(scriptPath.length() - 1);
|
||||
}
|
||||
scriptPath = url.resolved(QUrl(scriptPath)).toString();
|
||||
for (auto &script : scripts) {
|
||||
QString scriptPath = script.toString();
|
||||
if (QUrl(scriptPath).isRelative()) {
|
||||
if (scriptPath.at(0) == '/') {
|
||||
scriptPath = scriptPath.right(scriptPath.length() - 1);
|
||||
}
|
||||
scriptPaths.push_back(scriptPath);
|
||||
scriptPath = url.resolved(QUrl(scriptPath)).toString();
|
||||
}
|
||||
scriptPaths.push_back(scriptPath);
|
||||
}
|
||||
}
|
||||
return scriptPaths;
|
||||
|
|
|
@ -221,10 +221,8 @@ void GeometryReader::run() {
|
|||
// Add scripts to fbxgeometry
|
||||
if (!_mapping.value(SCRIPT_FIELD).isNull()) {
|
||||
QVariantList scripts = _mapping.values(SCRIPT_FIELD);
|
||||
if (scripts.size() > 0) {
|
||||
for (auto &script : scripts) {
|
||||
fbxGeometry->scripts.push_back(script.toString());
|
||||
}
|
||||
for (auto &script : scripts) {
|
||||
fbxGeometry->scripts.push_back(script.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue