mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 08:17:35 +02:00
Asset baking status first pass
This commit is contained in:
parent
cefd16ad95
commit
fac6015bb0
4 changed files with 91 additions and 0 deletions
|
@ -331,6 +331,17 @@ void AssetServer::completeSetup() {
|
||||||
qCCritical(asset_server) << "Asset Server assignment will not continue because mapping file could not be loaded.";
|
qCCritical(asset_server) << "Asset Server assignment will not continue because mapping file could not be loaded.";
|
||||||
setFinished(true);
|
setFinished(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRegExp hashFileRegex { "^[a-f0-9]{" + QString::number(SHA256_HASH_HEX_LENGTH) + "}" };
|
||||||
|
auto files = _filesDirectory.entryInfoList(QDir::Files);
|
||||||
|
auto mappedHashes = _fileMappings.values();
|
||||||
|
for (const auto& fileInfo : files) {
|
||||||
|
AssetHash hash = fileInfo.fileName();
|
||||||
|
bool isAsset = hashFileRegex.exactMatch(hash);
|
||||||
|
if (isAsset && _baker.assetNeedsBaking(hash)) {
|
||||||
|
_baker.addPendingBake(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetServer::cleanupUnmappedFiles() {
|
void AssetServer::cleanupUnmappedFiles() {
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <ThreadedAssignment.h>
|
#include <ThreadedAssignment.h>
|
||||||
|
|
||||||
#include "AssetUtils.h"
|
#include "AssetUtils.h"
|
||||||
|
#include "AutoBaker.h"
|
||||||
#include "ReceivedMessage.h"
|
#include "ReceivedMessage.h"
|
||||||
|
|
||||||
class BakeAssetTask : public QObject, public QRunnable {
|
class BakeAssetTask : public QObject, public QRunnable {
|
||||||
|
@ -105,6 +106,8 @@ private:
|
||||||
|
|
||||||
QHash<QString, std::shared_ptr<BakeAssetTask>> _pendingBakes;
|
QHash<QString, std::shared_ptr<BakeAssetTask>> _pendingBakes;
|
||||||
QThreadPool _bakingTaskPool;
|
QThreadPool _bakingTaskPool;
|
||||||
|
|
||||||
|
AutoBaker _baker;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
38
assignment-client/src/assets/AutoBaker.cpp
Normal file
38
assignment-client/src/assets/AutoBaker.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// AutoBaker.cpp
|
||||||
|
// assignment-client/src/assets
|
||||||
|
//
|
||||||
|
// Created by Clement Brisset on 8/9/17
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "AutoBaker.h"
|
||||||
|
|
||||||
|
void AutoBaker::addPendingBake(AssetHash hash) {
|
||||||
|
_pendingBakes.push_back(hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool AutoBaker::assetNeedsBaking(AssetHash hash) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AutoBaker::Status AutoBaker::getAssetStatus(AssetHash hash) {
|
||||||
|
auto pendingIt = std::find(_pendingBakes.cbegin(), _pendingBakes.cend(), hash);
|
||||||
|
if (pendingIt != _pendingBakes.cend()) {
|
||||||
|
return Pending;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto bakingIt = std::find(_currentlyBaking.cbegin(), _currentlyBaking.cend(), hash);
|
||||||
|
if (bakingIt != _currentlyBaking.cend()) {
|
||||||
|
return Baking;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (assetNeedsBaking(hash)) {
|
||||||
|
return NotBaked;
|
||||||
|
} else {
|
||||||
|
return Baked;
|
||||||
|
}
|
||||||
|
}
|
39
assignment-client/src/assets/AutoBaker.h
Normal file
39
assignment-client/src/assets/AutoBaker.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
//
|
||||||
|
// AutoBaker.h
|
||||||
|
// assignment-client/src/assets
|
||||||
|
//
|
||||||
|
// Created by Clement Brisset on 8/9/17
|
||||||
|
// Copyright 2015 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_AutoBaker_h
|
||||||
|
#define hifi_AutoBaker_h
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "AssetUtils.h"
|
||||||
|
|
||||||
|
class AutoBaker {
|
||||||
|
public:
|
||||||
|
enum Status {
|
||||||
|
NotBaked,
|
||||||
|
Pending,
|
||||||
|
Baking,
|
||||||
|
Baked
|
||||||
|
};
|
||||||
|
|
||||||
|
void addPendingBake(AssetHash hash);
|
||||||
|
|
||||||
|
bool assetNeedsBaking(AssetHash hash);
|
||||||
|
|
||||||
|
Status getAssetStatus(AssetHash hash);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<AssetHash> _pendingBakes;
|
||||||
|
std::vector<AssetHash> _currentlyBaking;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* hifi_AutoBaker_h */
|
Loading…
Reference in a new issue