Remove extraneous code changes; remove QUrlAncestry code; remove extra logging

This commit is contained in:
Zach Fox 2018-10-19 11:32:31 -07:00 committed by Kerry Ivan Kurian
parent 55c1a88404
commit 493262052c
30 changed files with 210 additions and 345 deletions

View file

@ -895,7 +895,7 @@ void Agent::aboutToFinish() {
{
DependencyManager::get<ScriptEngines>()->shutdownScripting();
}
DependencyManager::destroy<ScriptEngines>();
DependencyManager::destroy<AssignmentDynamicFactory>();

View file

@ -37,7 +37,6 @@
#include "AssignmentFactory.h"
#include "ResourceRequestObserver.h"
const QString ASSIGNMENT_CLIENT_TARGET_NAME = "assignment-client";
const long long ASSIGNMENT_REQUEST_INTERVAL_MSECS = 1 * 1000;
@ -162,7 +161,7 @@ void AssignmentClient::setUpStatusToMonitor() {
void AssignmentClient::sendStatusPacketToACM() {
// tell the assignment client monitor what this assignment client is doing (if anything)
auto nodeList = DependencyManager::get<NodeList>();
quint8 assignmentType = Assignment::Type::AllTypes;
if (_currentAssignment) {
@ -173,7 +172,7 @@ void AssignmentClient::sendStatusPacketToACM() {
statusPacket->write(_childAssignmentUUID.toRfc4122());
statusPacket->writePrimitive(assignmentType);
nodeList->sendPacket(std::move(statusPacket), _assignmentClientMonitorSocket);
}
@ -259,10 +258,10 @@ void AssignmentClient::handleCreateAssignmentPacket(QSharedPointer<ReceivedMessa
void AssignmentClient::handleStopNodePacket(QSharedPointer<ReceivedMessage> message) {
const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {
qCDebug(assignment_client) << "AssignmentClientMonitor at" << senderSockAddr << "requested stop via PacketType::StopNode.";
QCoreApplication::quit();
} else {
@ -315,6 +314,6 @@ void AssignmentClient::assignmentCompleted() {
nodeList->setOwnerType(NodeType::Unassigned);
nodeList->reset();
nodeList->resetNodeInterestSet();
_isAssigned = false;
}

View file

@ -170,7 +170,6 @@
#include "ModelPackager.h"
#include "scripting/Audio.h"
#include "networking/CloseEventSender.h"
#include "QUrlAncestry.h"
#include "scripting/TestScriptingInterface.h"
#include "scripting/AssetMappingsScriptingInterface.h"
#include "scripting/ClipboardScriptingInterface.h"
@ -947,6 +946,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
DependencyManager::set<Ledger>();
DependencyManager::set<Wallet>();
DependencyManager::set<WalletScriptingInterface>();
DependencyManager::set<FadeEffect>();
DependencyManager::set<ResourceRequestObserver>();
@ -1783,7 +1783,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
updateHeartbeat();
QTimer* settingsTimer = new QTimer();
moveToNewNamedThread(settingsTimer, "Settings Thread", [this, settingsTimer]{
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
// This needs to run on the settings thread, so we need to pass the `settingsTimer` as the
// receiver object, otherwise it will run on the application thread and trigger a warning
// about trying to kill the timer on the main thread.
connect(qApp, &Application::beforeAboutToQuit, settingsTimer, [this, settingsTimer]{
@ -5029,7 +5029,8 @@ bool Application::importEntities(const QString& urlOrFilename, const bool isObse
bool success = false;
_entityClipboard->withWriteLock([&] {
_entityClipboard->eraseAllOctreeElements();
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId, QUrlAncestry());
success = _entityClipboard->readFromURL(urlOrFilename, isObservable, callerId);
if (success) {
_entityClipboard->reaverageOctreeElements();
}

View file

@ -203,7 +203,7 @@ void ATPAssetMigrator::loadEntityServerFile() {
void ATPAssetMigrator::migrateResource(ResourceRequest* request) {
// use an asset client to upload the asset
auto assetClient = DependencyManager::get<AssetClient>();
auto upload = assetClient->createUpload(request->getData());
// add this URL to our hash of AssetUpload to original URL
@ -243,7 +243,7 @@ void ATPAssetMigrator::assetUploadFinished(AssetUpload *upload, const QString& h
}
checkIfFinished();
upload->deleteLater();
}
@ -299,24 +299,24 @@ void ATPAssetMigrator::checkIfFinished() {
bool ATPAssetMigrator::wantsToMigrateResource(const QUrl& url) {
static bool hasAskedForCompleteMigration { false };
static bool wantsCompleteMigration { false };
if (!hasAskedForCompleteMigration) {
// this is the first resource migration - ask the user if they just want to migrate everything
static const QString COMPLETE_MIGRATION_TEXT { "Do you want to migrate all assets found in this entity-server file?\n"\
"Select \"Yes\" to upload all discovered assets to the current asset-server immediately.\n"\
"Select \"No\" to be prompted for each discovered asset."
};
auto button = OffscreenUi::question(_dialogParent, MESSAGE_BOX_TITLE, COMPLETE_MIGRATION_TEXT,
QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
if (button == QMessageBox::Yes) {
wantsCompleteMigration = true;
}
hasAskedForCompleteMigration = true;
}
if (wantsCompleteMigration) {
return true;
} else {

View file

@ -64,7 +64,7 @@ public:
* @returns {boolean} <code>true</code> if the export was successful, otherwise <code>false</code>.
*/
Q_INVOKABLE bool exportEntities(const QString& filename, const QVector<EntityItemID>& entityIDs);
/**jsdoc
* Export the entities with centers within a cube to a JSON file.
* @function Clipboard.exportEntities

View file

@ -61,7 +61,6 @@
#include "AboutUtil.h"
#include "ResourceRequestObserver.h"
static int MAX_WINDOW_SIZE = 4096;
static const float METERS_TO_INCHES = 39.3701f;
static const float OPAQUE_ALPHA_THRESHOLD = 0.99f;
@ -539,7 +538,7 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) {
* @property {boolean} visible=true - If <code>true</code>, the overlay is rendered, otherwise it is not rendered.
*
* @property {string} name="" - A friendly name for the overlay.
* @property {Vec3} position - The position of the overlay center. Synonyms: <code>p1</code>, <code>point</code>, and
* @property {Vec3} position - The position of the overlay center. Synonyms: <code>p1</code>, <code>point</code>, and
* <code>start</code>.
* @property {Vec3} localPosition - The local position of the overlay relative to its parent if the overlay has a
* <code>parentID</code> set, otherwise the same value as <code>position</code>.
@ -564,7 +563,7 @@ void Web3DOverlay::setProperties(const QVariantMap& properties) {
* @property {string} url - The URL of the Web page to display.
* @property {string} scriptURL="" - The URL of a JavaScript file to inject into the Web page.
* @property {number} dpi=30 - The dots per inch to display the Web page at, on the overlay.
* @property {Vec2} dimensions=1,1 - The size of the overlay to display the Web page on, in meters. Synonyms:
* @property {Vec2} dimensions=1,1 - The size of the overlay to display the Web page on, in meters. Synonyms:
* <code>scale</code>, <code>size</code>.
* @property {number} maxFPS=10 - The maximum update rate for the Web overlay content, in frames/second.
* @property {boolean} showKeyboardFocusHighlight=true - If <code>true</code>, the Web overlay is highlighted when it has

View file

@ -380,7 +380,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
} else {
AVATAR_MEMCPY(_globalPosition);
}
int numBytes = destinationBuffer - startSection;
@ -648,7 +648,7 @@ QByteArray AvatarData::toByteArray(AvatarDataDetail dataDetail, quint64 lastSent
if (!data.translationIsDefaultPose) {
if (sendAll || last.translationIsDefaultPose || (!cullSmallChanges && last.translation != data.translation)
|| (cullSmallChanges && glm::distance(data.translation, lastSentJointData[i].translation) > minTranslation)) {
validity |= (1 << validityBit);
#ifdef WANT_DEBUG
translationSentCount++;
@ -1055,7 +1055,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
auto newHasProceduralEyeFaceMovement = oneAtBit16(bitItems, PROCEDURAL_EYE_FACE_MOVEMENT);
auto newHasProceduralBlinkFaceMovement = oneAtBit16(bitItems, PROCEDURAL_BLINK_FACE_MOVEMENT);
bool keyStateChanged = (_keyState != newKeyState);
bool handStateChanged = (_handState != newHandState);
bool faceStateChanged = (_headData->_isFaceTrackerConnected != newFaceTrackerConnected);
@ -1527,7 +1527,7 @@ glm::vec3 AvatarData::getJointTranslation(int index) const {
}
glm::vec3 AvatarData::getJointTranslation(const QString& name) const {
// Can't do this, because the lock needs to cover the entire set of logic. In theory, the joints could change
// Can't do this, because the lock needs to cover the entire set of logic. In theory, the joints could change
// on another thread in between the call to getJointIndex and getJointTranslation
// return getJointTranslation(getJointIndex(name));
return readLockWithNamedJointIndex<glm::vec3>(name, [this](int index) {
@ -1608,7 +1608,7 @@ bool AvatarData::isJointDataValid(const QString& name) const {
// return isJointDataValid(getJointIndex(name));
return readLockWithNamedJointIndex<bool>(name, false, [&](int index) {
// This is technically superfluous.... the lambda is only called if index is a valid
// This is technically superfluous.... the lambda is only called if index is a valid
// offset for _jointData. Nevertheless, it would be confusing to leave the lamdba as
// `return true`
return index < _jointData.size();
@ -1827,7 +1827,7 @@ qint64 AvatarData::packTrait(AvatarTraits::TraitType traitType, ExtendedIODevice
if (traitVersion > AvatarTraits::DEFAULT_TRAIT_VERSION) {
bytesWritten += destination.writePrimitive(traitVersion);
}
AvatarTraits::TraitWireSize encodedURLSize = encodedSkeletonURL.size();
bytesWritten += destination.writePrimitive(encodedURLSize);
@ -1936,7 +1936,7 @@ void AvatarData::setSkeletonModelURL(const QUrl& skeletonModelURL) {
if (expanded == _skeletonModelURL) {
return;
}
_skeletonModelURL = expanded;
qCDebug(avatars) << "Changing skeleton model for avatar" << getSessionUUID() << "to" << _skeletonModelURL.toString();
@ -2163,7 +2163,7 @@ void AvatarData::updateJointMappings() {
if (_skeletonModelURL.fileName().toLower().endsWith(".fst")) {
////
// TODO: Should we rely upon HTTPResourceRequest instead?
// TODO: Should we rely upon HTTPResourceRequest for ResourceRequestObserver instead?
// HTTPResourceRequest::doSend() covers all of the following and
// then some. It doesn't cover the connect() call, so we may
// want to add a HTTPResourceRequest::doSend() method that does
@ -2402,7 +2402,7 @@ QJsonObject AvatarData::toJson() const {
for (auto entityID : _avatarEntityData.keys()) {
QVariantMap entityData;
QUuid newId = _avatarEntityForRecording.size() == _avatarEntityData.size() ? _avatarEntityForRecording.values()[entityCount++] : entityID;
entityData.insert("id", newId);
entityData.insert("id", newId);
entityData.insert("properties", _avatarEntityData.value(entityID).toBase64());
avatarEntityJson.push_back(QVariant(entityData).toJsonObject());
}

View file

@ -24,7 +24,7 @@ QList<EntityItemID> EntityEditFilters::getZonesByPosition(glm::vec3& position) {
for (auto id : zoneIDs) {
if (!id.isInvalidID()) {
// for now, look it up in the tree (soon we need to cache or similar?)
EntityItemPointer itemPtr = _tree->findEntityByEntityItemID(id);
EntityItemPointer itemPtr = _tree->findEntityByEntityItemID(id);
auto zone = std::dynamic_pointer_cast<ZoneEntityItem>(itemPtr);
if (!zone) {
// TODO: maybe remove later?
@ -33,7 +33,7 @@ QList<EntityItemID> EntityEditFilters::getZonesByPosition(glm::vec3& position) {
zones.append(id);
}
} else {
// the null id is the global filter we put in the domain server's
// the null id is the global filter we put in the domain server's
// advanced entity server settings
zones.append(id);
}
@ -43,7 +43,7 @@ QList<EntityItemID> EntityEditFilters::getZonesByPosition(glm::vec3& position) {
bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut,
bool& wasChanged, EntityTree::FilterType filterType, EntityItemID& itemID, EntityItemPointer& existingEntity) {
// get the ids of all the zones (plus the global entity edit filter) that the position
// lies within
auto zoneIDs = getZonesByPosition(position);
@ -51,12 +51,12 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper
if (!itemID.isInvalidID() && id == itemID) {
continue;
}
// get the filter pair, etc...
// get the filter pair, etc...
_lock.lockForRead();
FilterData filterData = _filterDataMap.value(id);
_lock.unlock();
if (filterData.valid()) {
if (filterData.rejectAll) {
return false;
@ -153,13 +153,13 @@ bool EntityEditFilters::filter(glm::vec3& position, EntityItemProperties& proper
// otherwise, assume it wants to pass all properties
propertiesOut = propertiesIn;
wasChanged = false;
} else {
return false;
}
}
}
// if we made it here,
// if we made it here,
return true;
}
@ -175,23 +175,23 @@ void EntityEditFilters::removeFilter(EntityItemID entityID) {
void EntityEditFilters::addFilter(EntityItemID entityID, QString filterURL) {
QUrl scriptURL(filterURL);
// setting it to an empty string is same as removing
// setting it to an empty string is same as removing
if (filterURL.size() == 0) {
removeFilter(entityID);
return;
}
// The following should be abstracted out for use in Agent.cpp (and maybe later AvatarMixer.cpp)
if (scriptURL.scheme().isEmpty() || (scriptURL.scheme() == URL_SCHEME_FILE)) {
qWarning() << "Cannot load script from local filesystem, because assignment may be on a different computer.";
scriptRequestFinished(entityID);
return;
}
// first remove any existing info for this entity
removeFilter(entityID);
// reject all edits until we load the script
FilterData filterData;
filterData.rejectAll = true;
@ -199,7 +199,7 @@ void EntityEditFilters::addFilter(EntityItemID entityID, QString filterURL) {
_lock.lockForWrite();
_filterDataMap.insert(entityID, filterData);
_lock.unlock();
auto scriptRequest = DependencyManager::get<ResourceManager>()->createResourceRequest(
this, scriptURL, true, -1, "EntityEditFilters::addFilter");
if (!scriptRequest) {
@ -265,7 +265,7 @@ void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
FilterData filterData;
filterData.engine = engine;
filterData.rejectAll = false;
// define the uncaughtException function
QScriptEngine& engineRef = *engine;
filterData.uncaughtExceptions = [&engineRef, urlString]() { return hadUncaughtExceptions(engineRef, urlString); };
@ -369,11 +369,11 @@ void EntityEditFilters::scriptRequestFinished(EntityItemID entityID) {
_lock.unlock();
qDebug() << "script request filter processed for entity id " << entityID;
emit filterAdded(entityID, true);
return;
}
}
}
} else if (scriptRequest) {
const QString urlString = scriptRequest->getUrl().toString();
qCritical() << "Failed to download script at" << urlString;

View file

@ -38,8 +38,6 @@
#include "LogHandler.h"
#include "EntityEditFilters.h"
#include "EntityDynamicFactoryInterface.h"
#include "QUrlAncestry.h"
static const quint64 DELETED_ENTITIES_EXTRA_USECS_TO_CONSIDER = USECS_PER_MSEC * 50;
const float EntityTree::DEFAULT_MAX_TMP_ENTITY_LIFETIME = 60 * 60; // 1 hour
@ -100,7 +98,7 @@ EntityTree::~EntityTree() {
eraseAllOctreeElements(false);
}
void EntityTree::setEntityScriptSourceWhitelist(const QString& entityScriptSourceWhitelist) {
void EntityTree::setEntityScriptSourceWhitelist(const QString& entityScriptSourceWhitelist) {
_entityScriptSourceWhitelist = entityScriptSourceWhitelist.split(',', QString::SkipEmptyParts);
}
@ -862,7 +860,7 @@ float findRayIntersectionSortingOp(const OctreeElementPointer& element, void* ex
EntityItemID EntityTree::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
QVector<EntityItemID> entityIdsToInclude, QVector<EntityItemID> entityIdsToDiscard,
bool visibleOnly, bool collidableOnly, bool precisionPicking,
bool visibleOnly, bool collidableOnly, bool precisionPicking,
OctreeElementPointer& element, float& distance,
BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo,
Octree::lockType lockType, bool* accurateResult) {
@ -1353,7 +1351,7 @@ bool EntityTree::verifyNonce(const QString& certID, const QString& nonce, Entity
key = sent.second;
}
QString annotatedKey = "-----BEGIN PUBLIC KEY-----\n" + key.insert(64, "\n") + "\n-----END PUBLIC KEY-----\n";
QString annotatedKey = "-----BEGIN PUBLIC KEY-----\n" + key.insert(64, "\n") + "\n-----END PUBLIC KEY-----\n";
QByteArray hashedActualNonce = QCryptographicHash::hash(QByteArray(actualNonce.toUtf8()), QCryptographicHash::Sha256);
bool verificationSuccess = EntityItemProperties::verifySignature(annotatedKey.toUtf8(), hashedActualNonce, QByteArray::fromBase64(nonce.toUtf8()));
@ -1797,7 +1795,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
if (newEntity) {
newEntity->markAsChangedOnServer();
notifyNewlyCreatedEntity(*newEntity, senderNode);
startLogging = usecTimestampNow();
if (wantEditLogging()) {
qCDebug(entities) << "User [" << senderNode->getUUID() << "] added entity. ID:"
@ -1822,7 +1820,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
}
} else {
HIFI_FCDEBUG(entities(), "Edit failed. [" << message.getType() <<"] " <<
"entity id:" << entityItemID <<
"entity id:" << entityItemID <<
"existingEntity pointer:" << existingEntity.get());
}
}
@ -2043,7 +2041,7 @@ bool EntityTree::hasEntitiesDeletedSince(quint64 sinceTime) {
if (hasSomethingNewer) {
int elapsed = usecTimestampNow() - considerEntitiesSince;
int difference = considerEntitiesSince - sinceTime;
qCDebug(entities) << "EntityTree::hasEntitiesDeletedSince() sinceTime:" << sinceTime
qCDebug(entities) << "EntityTree::hasEntitiesDeletedSince() sinceTime:" << sinceTime
<< "considerEntitiesSince:" << considerEntitiesSince << "elapsed:" << elapsed << "difference:" << difference;
}
#endif
@ -2495,7 +2493,7 @@ bool EntityTree::writeToMap(QVariantMap& entityDescription, OctreeElementPointer
return true;
}
bool EntityTree::readFromMap(QVariantMap& map, const QUrlAncestry& ancestry) {
bool EntityTree::readFromMap(QVariantMap& map) {
// These are needed to deal with older content (before adding inheritance modes)
int contentVersion = map["Version"].toInt();
bool needsConversion = (contentVersion < (int)EntityVersion::ZoneLightInheritModes);

View file

@ -22,8 +22,6 @@
#include "EntityTreeElement.h"
#include "DeleteEntityOperator.h"
#include "MovingEntitiesOperator.h"
#include "QUrlAncestry.h"
class EntityTree;
using EntityTreePointer = std::shared_ptr<EntityTree>;
@ -96,7 +94,7 @@ public:
virtual EntityItemID findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
QVector<EntityItemID> entityIdsToInclude, QVector<EntityItemID> entityIdsToDiscard,
bool visibleOnly, bool collidableOnly, bool precisionPicking,
bool visibleOnly, bool collidableOnly, bool precisionPicking,
OctreeElementPointer& element, float& distance,
BoxFace& face, glm::vec3& surfaceNormal, QVariantMap& extraInfo,
Octree::lockType lockType = Octree::TryLock, bool* accurateResult = NULL);
@ -172,7 +170,7 @@ public:
void addNewlyCreatedHook(NewlyCreatedEntityHook* hook);
void removeNewlyCreatedHook(NewlyCreatedEntityHook* hook);
bool hasAnyDeletedEntities() const {
bool hasAnyDeletedEntities() const {
QReadLocker locker(&_recentlyDeletedEntitiesLock);
return _recentlyDeletedEntityItemIDs.size() > 0;
}
@ -180,7 +178,7 @@ public:
bool hasEntitiesDeletedSince(quint64 sinceTime);
static quint64 getAdjustedConsiderSince(quint64 sinceTime);
QMultiMap<quint64, QUuid> getRecentlyDeletedEntityIDs() const {
QMultiMap<quint64, QUuid> getRecentlyDeletedEntityIDs() const {
QReadLocker locker(&_recentlyDeletedEntitiesLock);
return _recentlyDeletedEntityItemIDs;
}
@ -225,7 +223,7 @@ public:
virtual bool writeToMap(QVariantMap& entityDescription, OctreeElementPointer element, bool skipDefaultValues,
bool skipThoseWithBadParents) override;
virtual bool readFromMap(QVariantMap& entityDescription, const QUrlAncestry& ancestry = {}) override;
virtual bool readFromMap(QVariantMap& entityDescription) override;
glm::vec3 getContentsDimensions();
float getContentsLargestDimension();

View file

@ -40,7 +40,7 @@ GLTFReader::GLTFReader() {
}
bool GLTFReader::getStringVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getStringVal(const QJsonObject& object, const QString& fieldname,
QString& value, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isString());
if (_defined) {
@ -60,7 +60,7 @@ bool GLTFReader::getBoolVal(const QJsonObject& object, const QString& fieldname,
return _defined;
}
bool GLTFReader::getIntVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getIntVal(const QJsonObject& object, const QString& fieldname,
int& value, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && !object[fieldname].isNull());
if (_defined) {
@ -70,7 +70,7 @@ bool GLTFReader::getIntVal(const QJsonObject& object, const QString& fieldname,
return _defined;
}
bool GLTFReader::getDoubleVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getDoubleVal(const QJsonObject& object, const QString& fieldname,
double& value, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isDouble());
if (_defined) {
@ -79,7 +79,7 @@ bool GLTFReader::getDoubleVal(const QJsonObject& object, const QString& fieldnam
defined.insert(fieldname, _defined);
return _defined;
}
bool GLTFReader::getObjectVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getObjectVal(const QJsonObject& object, const QString& fieldname,
QJsonObject& value, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isObject());
if (_defined) {
@ -89,7 +89,7 @@ bool GLTFReader::getObjectVal(const QJsonObject& object, const QString& fieldnam
return _defined;
}
bool GLTFReader::getIntArrayVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getIntArrayVal(const QJsonObject& object, const QString& fieldname,
QVector<int>& values, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isArray());
if (_defined) {
@ -104,7 +104,7 @@ bool GLTFReader::getIntArrayVal(const QJsonObject& object, const QString& fieldn
return _defined;
}
bool GLTFReader::getDoubleArrayVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getDoubleArrayVal(const QJsonObject& object, const QString& fieldname,
QVector<double>& values, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isArray());
if (_defined) {
@ -119,7 +119,7 @@ bool GLTFReader::getDoubleArrayVal(const QJsonObject& object, const QString& fie
return _defined;
}
bool GLTFReader::getObjectArrayVal(const QJsonObject& object, const QString& fieldname,
bool GLTFReader::getObjectArrayVal(const QJsonObject& object, const QString& fieldname,
QJsonArray& objects, QMap<QString, bool>& defined) {
bool _defined = (object.contains(fieldname) && object[fieldname].isArray());
if (_defined) {
@ -229,7 +229,7 @@ bool GLTFReader::setAsset(const QJsonObject& object) {
QJsonObject jsAsset;
bool isAssetDefined = getObjectVal(object, "asset", jsAsset, _file.defined);
if (isAssetDefined) {
if (!getStringVal(jsAsset, "version", _file.asset.version,
if (!getStringVal(jsAsset, "version", _file.asset.version,
_file.asset.defined) || _file.asset.version != "2.0") {
return false;
}
@ -241,7 +241,7 @@ bool GLTFReader::setAsset(const QJsonObject& object) {
bool GLTFReader::addAccessor(const QJsonObject& object) {
GLTFAccessor accessor;
getIntVal(object, "bufferView", accessor.bufferView, accessor.defined);
getIntVal(object, "byteOffset", accessor.byteOffset, accessor.defined);
getIntVal(object, "componentType", accessor.componentType, accessor.defined);
@ -261,7 +261,7 @@ bool GLTFReader::addAccessor(const QJsonObject& object) {
bool GLTFReader::addAnimation(const QJsonObject& object) {
GLTFAnimation animation;
QJsonArray channels;
if (getObjectArrayVal(object, "channels", channels, animation.defined)) {
foreach(const QJsonValue & v, channels) {
@ -272,7 +272,7 @@ bool GLTFReader::addAnimation(const QJsonObject& object) {
if (getObjectVal(v.toObject(), "target", jsChannel, channel.defined)) {
getIntVal(jsChannel, "node", channel.target.node, channel.target.defined);
getIntVal(jsChannel, "path", channel.target.path, channel.target.defined);
}
}
}
}
}
@ -291,7 +291,7 @@ bool GLTFReader::addAnimation(const QJsonObject& object) {
}
}
}
_file.animations.push_back(animation);
return true;
@ -299,20 +299,20 @@ bool GLTFReader::addAnimation(const QJsonObject& object) {
bool GLTFReader::addBufferView(const QJsonObject& object) {
GLTFBufferView bufferview;
getIntVal(object, "buffer", bufferview.buffer, bufferview.defined);
getIntVal(object, "byteLength", bufferview.byteLength, bufferview.defined);
getIntVal(object, "byteOffset", bufferview.byteOffset, bufferview.defined);
getIntVal(object, "target", bufferview.target, bufferview.defined);
_file.bufferviews.push_back(bufferview);
return true;
}
bool GLTFReader::addBuffer(const QJsonObject& object) {
GLTFBuffer buffer;
getIntVal(object, "byteLength", buffer.byteLength, buffer.defined);
if (getStringVal(object, "uri", buffer.uri, buffer.defined)) {
if (!readBinary(buffer.uri, buffer.blob)) {
@ -320,13 +320,13 @@ bool GLTFReader::addBuffer(const QJsonObject& object) {
}
}
_file.buffers.push_back(buffer);
return true;
}
bool GLTFReader::addCamera(const QJsonObject& object) {
GLTFCamera camera;
QJsonObject jsPerspective;
QJsonObject jsOrthographic;
QString type;
@ -346,28 +346,28 @@ bool GLTFReader::addCamera(const QJsonObject& object) {
} else if (getStringVal(object, "type", type, camera.defined)) {
camera.type = getCameraType(type);
}
_file.cameras.push_back(camera);
return true;
}
bool GLTFReader::addImage(const QJsonObject& object) {
GLTFImage image;
QString mime;
getStringVal(object, "uri", image.uri, image.defined);
if (getStringVal(object, "mimeType", mime, image.defined)) {
image.mimeType = getImageMimeType(mime);
}
getIntVal(object, "bufferView", image.bufferView, image.defined);
_file.images.push_back(image);
return true;
}
bool GLTFReader::getIndexFromObject(const QJsonObject& object, const QString& field,
bool GLTFReader::getIndexFromObject(const QJsonObject& object, const QString& field,
int& outidx, QMap<QString, bool>& defined) {
QJsonObject subobject;
if (getObjectVal(object, field, subobject, defined)) {
@ -393,20 +393,20 @@ bool GLTFReader::addMaterial(const QJsonObject& object) {
getDoubleVal(object, "alphaCutoff", material.alphaCutoff, material.defined);
QJsonObject jsMetallicRoughness;
if (getObjectVal(object, "pbrMetallicRoughness", jsMetallicRoughness, material.defined)) {
getDoubleArrayVal(jsMetallicRoughness, "baseColorFactor",
material.pbrMetallicRoughness.baseColorFactor,
getDoubleArrayVal(jsMetallicRoughness, "baseColorFactor",
material.pbrMetallicRoughness.baseColorFactor,
material.pbrMetallicRoughness.defined);
getIndexFromObject(jsMetallicRoughness, "baseColorTexture",
material.pbrMetallicRoughness.baseColorTexture,
getIndexFromObject(jsMetallicRoughness, "baseColorTexture",
material.pbrMetallicRoughness.baseColorTexture,
material.pbrMetallicRoughness.defined);
getDoubleVal(jsMetallicRoughness, "metallicFactor",
material.pbrMetallicRoughness.metallicFactor,
getDoubleVal(jsMetallicRoughness, "metallicFactor",
material.pbrMetallicRoughness.metallicFactor,
material.pbrMetallicRoughness.defined);
getDoubleVal(jsMetallicRoughness, "roughnessFactor",
material.pbrMetallicRoughness.roughnessFactor,
getDoubleVal(jsMetallicRoughness, "roughnessFactor",
material.pbrMetallicRoughness.roughnessFactor,
material.pbrMetallicRoughness.defined);
getIndexFromObject(jsMetallicRoughness, "metallicRoughnessTexture",
material.pbrMetallicRoughness.metallicRoughnessTexture,
getIndexFromObject(jsMetallicRoughness, "metallicRoughnessTexture",
material.pbrMetallicRoughness.metallicRoughnessTexture,
material.pbrMetallicRoughness.defined);
}
_file.materials.push_back(material);
@ -428,7 +428,7 @@ bool GLTFReader::addMesh(const QJsonObject& object) {
getIntVal(jsPrimitive, "mode", primitive.mode, primitive.defined);
getIntVal(jsPrimitive, "indices", primitive.indices, primitive.defined);
getIntVal(jsPrimitive, "material", primitive.material, primitive.defined);
QJsonObject jsAttributes;
if (getObjectVal(jsPrimitive, "attributes", jsAttributes, primitive.defined)) {
QStringList attrKeys = jsAttributes.keys();
@ -455,7 +455,7 @@ bool GLTFReader::addMesh(const QJsonObject& object) {
primitive.targets.push_back(target);
}
}
}
}
mesh.primitives.push_back(primitive);
}
}
@ -469,7 +469,7 @@ bool GLTFReader::addMesh(const QJsonObject& object) {
bool GLTFReader::addNode(const QJsonObject& object) {
GLTFNode node;
getStringVal(object, "name", node.name, node.defined);
getIntVal(object, "camera", node.camera, node.defined);
getIntVal(object, "mesh", node.mesh, node.defined);
@ -524,10 +524,10 @@ bool GLTFReader::addSkin(const QJsonObject& object) {
}
bool GLTFReader::addTexture(const QJsonObject& object) {
GLTFTexture texture;
GLTFTexture texture;
getIntVal(object, "sampler", texture.sampler, texture.defined);
getIntVal(object, "source", texture.source, texture.defined);
_file.textures.push_back(texture);
return true;
@ -535,7 +535,7 @@ bool GLTFReader::addTexture(const QJsonObject& object) {
bool GLTFReader::parseGLTF(const QByteArray& model) {
PROFILE_RANGE_EX(resource_parse, __FUNCTION__, 0xffff0000, nullptr);
QJsonDocument d = QJsonDocument::fromJson(model);
QJsonObject jsFile = d.object();
@ -707,25 +707,25 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
foreach(int child, node.children) nodeDependencies[child].push_back(nodecount);
nodecount++;
}
nodecount = 0;
foreach(auto &node, _file.nodes) {
// collect node transform
_file.nodes[nodecount].transforms.push_back(getModelTransform(node));
_file.nodes[nodecount].transforms.push_back(getModelTransform(node));
if (nodeDependencies[nodecount].size() == 1) {
int parentidx = nodeDependencies[nodecount][0];
while (true) { // iterate parents
// collect parents transforms
_file.nodes[nodecount].transforms.push_back(getModelTransform(_file.nodes[parentidx]));
_file.nodes[nodecount].transforms.push_back(getModelTransform(_file.nodes[parentidx]));
if (nodeDependencies[parentidx].size() == 1) {
parentidx = nodeDependencies[parentidx][0];
} else break;
}
}
nodecount++;
}
//Build default joints
geometry.joints.resize(1);
geometry.joints[0].isFree = false;
@ -756,7 +756,7 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
setFBXMaterial(fbxMaterial, _file.materials[i]);
}
nodecount = 0;
// Build meshes
@ -789,11 +789,11 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
QVector<glm::vec3> raw_vertices;
QVector<glm::vec3> raw_normals;
bool success = addArrayOfType(indicesBuffer.blob,
indicesBufferview.byteOffset + indicesAccBoffset,
indicesAccessor.count,
part.triangleIndices,
indicesAccessor.type,
bool success = addArrayOfType(indicesBuffer.blob,
indicesBufferview.byteOffset + indicesAccBoffset,
indicesAccessor.count,
part.triangleIndices,
indicesAccessor.type,
indicesAccessor.componentType);
if (!success) {
@ -813,10 +813,10 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
int accBoffset = accessor.defined["byteOffset"] ? accessor.byteOffset : 0;
if (key == "POSITION") {
QVector<float> vertices;
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count, vertices,
accessor.type,
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count, vertices,
accessor.type,
accessor.componentType);
if (!success) {
qWarning(modelformat) << "There was a problem reading glTF POSITION data for model " << _url;
@ -827,11 +827,11 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
}
} else if (key == "NORMAL") {
QVector<float> normals;
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
normals,
accessor.type,
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
normals,
accessor.type,
accessor.componentType);
if (!success) {
qWarning(modelformat) << "There was a problem reading glTF NORMAL data for model " << _url;
@ -842,11 +842,11 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
}
} else if (key == "TEXCOORD_0") {
QVector<float> texcoords;
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
texcoords,
accessor.type,
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
texcoords,
accessor.type,
accessor.componentType);
if (!success) {
qWarning(modelformat) << "There was a problem reading glTF TEXCOORD_0 data for model " << _url;
@ -857,11 +857,11 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
}
} else if (key == "TEXCOORD_1") {
QVector<float> texcoords;
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
texcoords,
accessor.type,
success = addArrayOfType(buffer.blob,
bufferview.byteOffset + accBoffset,
accessor.count,
texcoords,
accessor.type,
accessor.componentType);
if (!success) {
qWarning(modelformat) << "There was a problem reading glTF TEXCOORD_1 data for model " << _url;
@ -888,8 +888,8 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
mesh.meshExtents.addPoint(vertex);
geometry.meshExtents.addPoint(vertex);
}
// since mesh.modelTransform seems to not have any effect I apply the transformation the model
// since mesh.modelTransform seems to not have any effect I apply the transformation the model
for (int h = 0; h < mesh.vertices.size(); h++) {
glm::vec4 ver = glm::vec4(mesh.vertices[h], 1);
if (node.transforms.size() > 0) {
@ -901,18 +901,18 @@ bool GLTFReader::buildGeometry(FBXGeometry& geometry, const QUrl& url) {
mesh.meshIndex = geometry.meshes.size();
FBXReader::buildModelMesh(mesh, url.toString());
}
}
nodecount++;
}
return true;
}
FBXGeometry* GLTFReader::readGLTF(QByteArray& model, const QVariantHash& mapping,
FBXGeometry* GLTFReader::readGLTF(QByteArray& model, const QVariantHash& mapping,
const QUrl& url, bool loadLightmaps, float lightmapLevel) {
_url = url;
// Normalize url for local files
@ -928,10 +928,10 @@ FBXGeometry* GLTFReader::readGLTF(QByteArray& model, const QVariantHash& mapping
FBXGeometry& geometry = *geometryPtr;
buildGeometry(geometry, url);
//fbxDebugDump(geometry);
return geometryPtr;
}
bool GLTFReader::readBinary(const QString& url, QByteArray& outdata) {
@ -940,7 +940,7 @@ bool GLTFReader::readBinary(const QString& url, QByteArray& outdata) {
qCDebug(modelformat) << "binaryUrl: " << binaryUrl << " OriginalUrl: " << _url;
bool success;
std::tie<bool, QByteArray>(success, outdata) = requestData(binaryUrl);
return success;
}
@ -1000,7 +1000,7 @@ QNetworkReply* GLTFReader::request(QUrl& url, bool isTest) {
FBXTexture GLTFReader::getFBXTexture(const GLTFTexture& texture) {
FBXTexture fbxtex = FBXTexture();
fbxtex.texcoordSet = 0;
if (texture.defined["source"]) {
QString url = _file.images[texture.source].uri;
QString fname = QUrl(url).fileName();
@ -1020,10 +1020,10 @@ void GLTFReader::setFBXMaterial(FBXMaterial& fbxmat, const GLTFMaterial& materia
if (material.defined["name"]) {
fbxmat.name = fbxmat.materialID = material.name;
}
if (material.defined["emissiveFactor"] && material.emissiveFactor.size() == 3) {
glm::vec3 emissive = glm::vec3(material.emissiveFactor[0],
material.emissiveFactor[1],
glm::vec3 emissive = glm::vec3(material.emissiveFactor[0],
material.emissiveFactor[1],
material.emissiveFactor[2]);
fbxmat._material->setEmissive(emissive);
}
@ -1032,12 +1032,12 @@ void GLTFReader::setFBXMaterial(FBXMaterial& fbxmat, const GLTFMaterial& materia
fbxmat.emissiveTexture = getFBXTexture(_file.textures[material.emissiveTexture]);
fbxmat.useEmissiveMap = true;
}
if (material.defined["normalTexture"]) {
fbxmat.normalTexture = getFBXTexture(_file.textures[material.normalTexture]);
fbxmat.useNormalMap = true;
}
if (material.defined["occlusionTexture"]) {
fbxmat.occlusionTexture = getFBXTexture(_file.textures[material.occlusionTexture]);
fbxmat.useOcclusionMap = true;
@ -1045,7 +1045,7 @@ void GLTFReader::setFBXMaterial(FBXMaterial& fbxmat, const GLTFMaterial& materia
if (material.defined["pbrMetallicRoughness"]) {
fbxmat.isPBSMaterial = true;
if (material.pbrMetallicRoughness.defined["metallicFactor"]) {
fbxmat.metallic = material.pbrMetallicRoughness.metallicFactor;
}
@ -1063,23 +1063,23 @@ void GLTFReader::setFBXMaterial(FBXMaterial& fbxmat, const GLTFMaterial& materia
if (material.pbrMetallicRoughness.defined["roughnessFactor"]) {
fbxmat._material->setRoughness(material.pbrMetallicRoughness.roughnessFactor);
}
if (material.pbrMetallicRoughness.defined["baseColorFactor"] &&
if (material.pbrMetallicRoughness.defined["baseColorFactor"] &&
material.pbrMetallicRoughness.baseColorFactor.size() == 4) {
glm::vec3 dcolor = glm::vec3(material.pbrMetallicRoughness.baseColorFactor[0],
material.pbrMetallicRoughness.baseColorFactor[1],
glm::vec3 dcolor = glm::vec3(material.pbrMetallicRoughness.baseColorFactor[0],
material.pbrMetallicRoughness.baseColorFactor[1],
material.pbrMetallicRoughness.baseColorFactor[2]);
fbxmat.diffuseColor = dcolor;
fbxmat._material->setAlbedo(dcolor);
fbxmat._material->setOpacity(material.pbrMetallicRoughness.baseColorFactor[3]);
}
}
}
}
template<typename T, typename L>
bool GLTFReader::readArray(const QByteArray& bin, int byteOffset, int count,
bool GLTFReader::readArray(const QByteArray& bin, int byteOffset, int count,
QVector<L>& outarray, int accessorType) {
QDataStream blobstream(bin);
blobstream.setByteOrder(QDataStream::LittleEndian);
blobstream.setVersion(QDataStream::Qt_5_9);
@ -1134,9 +1134,9 @@ bool GLTFReader::readArray(const QByteArray& bin, int byteOffset, int count,
return true;
}
template<typename T>
bool GLTFReader::addArrayOfType(const QByteArray& bin, int byteOffset, int count,
bool GLTFReader::addArrayOfType(const QByteArray& bin, int byteOffset, int count,
QVector<T>& outarray, int accessorType, int componentType) {
switch (componentType) {
case GLTFAccessorComponentType::BYTE: {}
case GLTFAccessorComponentType::UNSIGNED_BYTE: {
@ -1158,8 +1158,8 @@ bool GLTFReader::addArrayOfType(const QByteArray& bin, int byteOffset, int count
return false;
}
void GLTFReader::retriangulate(const QVector<int>& inIndices, const QVector<glm::vec3>& in_vertices,
const QVector<glm::vec3>& in_normals, QVector<int>& outIndices,
void GLTFReader::retriangulate(const QVector<int>& inIndices, const QVector<glm::vec3>& in_vertices,
const QVector<glm::vec3>& in_normals, QVector<int>& outIndices,
QVector<glm::vec3>& out_vertices, QVector<glm::vec3>& out_normals) {
for (int i = 0; i < inIndices.size(); i = i + 3) {

View file

@ -15,7 +15,7 @@
#include "OBJReader.h"
#include <ctype.h> // .obj files are not locale-specific. The C/ASCII charset applies.
#include <sstream>
#include <sstream>
#include <QtCore/QBuffer>
#include <QtCore/QIODevice>
@ -263,16 +263,16 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
default:
materials[matName] = currentMaterial;
#ifdef WANT_DEBUG
qCDebug(modelformat) <<
qCDebug(modelformat) <<
"OBJ Reader Last material illumination model:" << currentMaterial.illuminationModel <<
" shininess:" << currentMaterial.shininess <<
" shininess:" << currentMaterial.shininess <<
" opacity:" << currentMaterial.opacity <<
" diffuse color:" << currentMaterial.diffuseColor <<
" specular color:" << currentMaterial.specularColor <<
" emissive color:" << currentMaterial.emissiveColor <<
" diffuse texture:" << currentMaterial.diffuseTextureFilename <<
" specular texture:" << currentMaterial.specularTextureFilename <<
" emissive texture:" << currentMaterial.emissiveTextureFilename <<
" diffuse color:" << currentMaterial.diffuseColor <<
" specular color:" << currentMaterial.specularColor <<
" emissive color:" << currentMaterial.emissiveColor <<
" diffuse texture:" << currentMaterial.diffuseTextureFilename <<
" specular texture:" << currentMaterial.specularTextureFilename <<
" emissive texture:" << currentMaterial.emissiveTextureFilename <<
" bump texture:" << currentMaterial.bumpTextureFilename <<
" opacity texture:" << currentMaterial.opacityTextureFilename;
#endif
@ -352,7 +352,7 @@ void OBJReader::parseMaterialLibrary(QIODevice* device) {
}
}
}
}
}
void OBJReader::parseTextureLine(const QByteArray& textureLine, QByteArray& filename, OBJMaterialTextureOptions& textureOptions) {
// Texture options reference http://paulbourke.net/dataformats/mtl/
@ -794,7 +794,7 @@ FBXGeometry::Pointer OBJReader::readOBJ(QByteArray& model, const QVariantHash& m
n0 = checked_at(normals, face.normalIndices[0]);
n1 = checked_at(normals, face.normalIndices[1]);
n2 = checked_at(normals, face.normalIndices[2]);
} else {
} else {
// generate normals from triangle plane if not provided
n0 = n1 = n2 = glm::cross(v1 - v0, v2 - v0);
}
@ -924,7 +924,7 @@ FBXGeometry::Pointer OBJReader::readOBJ(QByteArray& model, const QVariantHash& m
bool applyNonMetallic = false;
bool fresnelOn = false;
// Illumination model reference http://paulbourke.net/dataformats/mtl/
// Illumination model reference http://paulbourke.net/dataformats/mtl/
switch (objMaterial.illuminationModel) {
case 0: // Color on and Ambient off
// We don't support ambient = do nothing?
@ -968,7 +968,7 @@ FBXGeometry::Pointer OBJReader::readOBJ(QByteArray& model, const QVariantHash& m
case 10: // Casts shadows onto invisible surfaces
// Do nothing?
break;
}
}
if (applyTransparency) {
fbxMaterial.opacity = std::max(fbxMaterial.opacity, ILLUMINATION_MODEL_MIN_OPACITY);

View file

@ -39,7 +39,7 @@ AssetResourceRequest::~AssetResourceRequest() {
if (_assetMappingRequest) {
_assetMappingRequest->deleteLater();
}
if (_assetRequest) {
_assetRequest->deleteLater();
}
@ -82,7 +82,7 @@ void AssetResourceRequest::requestMappingForPath(const AssetUtils::AssetPath& pa
// make sure we'll hear about the result of the get mapping request
connect(_assetMappingRequest, &GetMappingRequest::finished, this, [this, path](GetMappingRequest* request){
auto statTracker = DependencyManager::get<StatTracker>();
Q_ASSERT(_state == InProgress);
Q_ASSERT(request == _assetMappingRequest);

View file

@ -12,19 +12,19 @@
#ifndef hifi_FileResourceRequest_h
#define hifi_FileResourceRequest_h
#include "ResourceRequest.h"
#include "QUrlAncestry.h"
#include <QUrl>
#include "ResourceRequest.h"
class FileResourceRequest : public ResourceRequest {
Q_OBJECT
public:
FileResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = true,
const qint64 callerId = -1,
const QString& extra = ""
) : ResourceRequest(urlAncestry, isObservable, callerId, extra) { }
) : ResourceRequest(url, isObservable, callerId, extra) { }
protected:
virtual void doSend() override;

View file

@ -13,21 +13,20 @@
#define hifi_HTTPResourceRequest_h
#include <QNetworkReply>
#include <QUrl>
#include <QTimer>
#include "ResourceRequest.h"
#include "QUrlAncestry.h"
class HTTPResourceRequest : public ResourceRequest {
Q_OBJECT
public:
HTTPResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = true,
const qint64 callerId = -1,
const QString& = ""
) : ResourceRequest(urlAncestry, isObservable, callerId) { }
) : ResourceRequest(url, isObservable, callerId) { }
~HTTPResourceRequest();
protected:

View file

@ -22,7 +22,7 @@ QNetworkAccessManager& NetworkAccessManager::getInstance() {
if (!networkAccessManagers.hasLocalData()) {
networkAccessManagers.setLocalData(new QNetworkAccessManager());
}
return *networkAccessManagers.localData();
}

View file

@ -320,7 +320,7 @@ QVariantList ResourceCache::getResourceList() {
return list;
}
void ResourceCache::setRequestLimit(uint32_t limit) {
auto sharedItems = DependencyManager::get<ResourceCacheSharedItems>();
sharedItems->setRequestLimit(limit);
@ -337,7 +337,6 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
QReadLocker locker(&_resourcesLock);
resource = _resources.value(url).lock();
}
if (resource) {
removeUnusedResource(resource);
}
@ -382,7 +381,7 @@ void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource)
return;
}
reserveUnusedResource(resource->getBytes());
resource->setLRUKey(++_lastLRUKey);
{
@ -411,7 +410,7 @@ void ResourceCache::reserveUnusedResource(qint64 resourceSize) {
_unusedResourcesSize + resourceSize > _unusedResourcesMaxSize) {
// unload the oldest resource
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
it.value()->setCache(nullptr);
auto size = it.value()->getBytes();
@ -477,7 +476,7 @@ void ResourceCache::updateTotalSize(const qint64& deltaSize) {
emit dirty();
}
QList<QSharedPointer<Resource>> ResourceCache::getLoadingRequests() {
return DependencyManager::get<ResourceCacheSharedItems>()->getLoadingRequests();
}
@ -592,7 +591,7 @@ void Resource::refresh() {
_request = nullptr;
ResourceCache::requestCompleted(_self);
}
_activeUrl = _url;
init();
ensureLoading();
@ -606,7 +605,7 @@ void Resource::allReferencesCleared() {
}
if (_cache && isCacheable()) {
// create and reinsert new shared pointer
// create and reinsert new shared pointer
QSharedPointer<Resource> self(this, &Resource::deleter);
setSelf(self);
reinsert();
@ -631,10 +630,10 @@ void Resource::init(bool resetLoaded) {
_loaded = false;
}
_attempts = 0;
if (_url.isEmpty()) {
_startedLoading = _loaded = true;
} else if (!(_url.isValid())) {
_startedLoading = _failedToLoad = true;
}
@ -756,7 +755,7 @@ void Resource::handleReplyFinished() {
} else {
handleFailedRequest(result);
}
_request->disconnect(this);
_request->deleteLater();
_request = nullptr;

View file

@ -26,7 +26,6 @@
#include "NetworkAccessManager.h"
#include "NetworkLogging.h"
ResourceManager::ResourceManager(bool atpSupportEnabled) : _atpSupportEnabled(atpSupportEnabled) {
_thread.setObjectName("Resource Manager Thread");
@ -125,7 +124,6 @@ ResourceRequest* ResourceManager::createResourceRequest(
ResourceRequest* request = nullptr;
qDebug() << "!!!! in createResourceRequest " << callerId;
if (scheme == URL_SCHEME_FILE || scheme == URL_SCHEME_QRC) {
request = new FileResourceRequest(normalizedURL, isObservable, callerId, extra);
} else if (scheme == URL_SCHEME_HTTP || scheme == URL_SCHEME_HTTPS || scheme == URL_SCHEME_FTP) {
@ -146,7 +144,6 @@ ResourceRequest* ResourceManager::createResourceRequest(
QObject::connect(parent, &QObject::destroyed, request, &QObject::deleteLater);
}
request->moveToThread(&_thread);
return request;
}

View file

@ -21,9 +21,8 @@
void ResourceRequest::send() {
if (_isObservable) {
DependencyManager::get<ResourceRequestObserver>()->update(
_urlAncestry, _callerId, _extra + " => ResourceRequest::send" );
_url, _callerId, _extra + " => ResourceRequest::send" );
}
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "send", Qt::QueuedConnection);
return;

View file

@ -18,8 +18,6 @@
#include <cstdint>
#include "ByteRange.h"
#include "QUrlAncestry.h"
const QString STAT_ATP_REQUEST_STARTED = "StartedATPRequest";
const QString STAT_HTTP_REQUEST_STARTED = "StartedHTTPRequest";
@ -46,15 +44,14 @@ public:
static const bool IS_NOT_OBSERVABLE = false;
ResourceRequest(
const QUrlAncestry& urlAncestry,
const QUrl& url,
const bool isObservable = IS_OBSERVABLE,
const qint64 callerId = -1,
const QString& extra = ""
) : _urlAncestry(urlAncestry),
) : _url(url),
_isObservable(isObservable),
_callerId(callerId),
_extra(extra),
_url(urlAncestry.last())
_extra(extra)
{ }
virtual ~ResourceRequest() = default;
@ -103,7 +100,6 @@ protected:
virtual void doSend() = 0;
void recordBytesDownloadedInStats(const QString& statName, int64_t bytesReceived);
QUrl _url;
QUrl _relativePathURL;
State _state { NotStarted };
@ -119,7 +115,6 @@ protected:
bool _isObservable;
qint64 _callerId;
QString _extra;
QUrlAncestry _urlAncestry;
};
#endif

View file

@ -669,7 +669,7 @@ OctreeElementPointer Octree::getElementEnclosingPoint(const glm::vec3& point, Oc
return args.element;
}
bool Octree::readFromFile(const char* fileName, const QUrlAncestry& urlAncestry) {
bool Octree::readFromFile(const char* fileName) {
QString qFileName = findMostRecentFileExtension(fileName, PERSIST_EXTENSIONS);
if (qFileName.endsWith(".json.gz")) {
@ -689,7 +689,7 @@ bool Octree::readFromFile(const char* fileName, const QUrlAncestry& urlAncestry)
qCDebug(octree) << "Loading file" << qFileName << "...";
bool success = readFromStream(fileLength, fileInputStream, "", urlAncestry);
bool success = readFromStream(fileLength, fileInputStream, "");
file.close();
@ -737,8 +737,7 @@ QString getMarketplaceID(const QString& urlString) {
bool Octree::readFromURL(
const QString& urlString,
const bool isObservable,
const qint64 callerId,
const QUrlAncestry& urlAncestry
const qint64 callerId
) {
QString trimmedUrl = urlString.trimmed();
QString marketplaceID = getMarketplaceID(trimmedUrl);
@ -767,19 +766,18 @@ bool Octree::readFromURL(
if (wasCompressed) {
QDataStream inputStream(uncompressedJsonData);
return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID, urlAncestry);
return readFromStream(uncompressedJsonData.size(), inputStream, marketplaceID);
}
QDataStream inputStream(data);
return readFromStream(data.size(), inputStream, marketplaceID, urlAncestry);
return readFromStream(data.size(), inputStream, marketplaceID);
}
bool Octree::readFromStream(
uint64_t streamLength,
QDataStream& inputStream,
const QString& marketplaceID,
const QUrlAncestry& urlAncestry
const QString& marketplaceID
) {
// decide if this is binary SVO or JSON-formatted SVO
QIODevice *device = inputStream.device();
@ -792,7 +790,7 @@ bool Octree::readFromStream(
return false;
} else {
qCDebug(octree) << "Reading from JSON SVO Stream length:" << streamLength;
return readJSONFromStream(streamLength, inputStream, marketplaceID, urlAncestry);
return readJSONFromStream(streamLength, inputStream, marketplaceID);
}
}
@ -824,8 +822,7 @@ const int READ_JSON_BUFFER_SIZE = 2048;
bool Octree::readJSONFromStream(
uint64_t streamLength,
QDataStream& inputStream,
const QString& marketplaceID, /*=""*/
const QUrlAncestry& urlAncestry
const QString& marketplaceID /*=""*/
) {
// if the data is gzipped we may not have a useful bytesAvailable() result, so just keep reading until
// we get an eof. Leave streamLength parameter for consistency.
@ -851,7 +848,7 @@ bool Octree::readJSONFromStream(
}
QVariant asVariant = asDocument.toVariant();
QVariantMap asMap = asVariant.toMap();
bool success = readFromMap(asMap, urlAncestry);
bool success = readFromMap(asMap);
delete[] rawData;
return success;
}

View file

@ -29,7 +29,6 @@
#include "OctreePacketData.h"
#include "OctreeSceneStats.h"
#include "OctreeUtils.h"
#include "QUrlAncestry.h"
class ReadBitstreamToTreeParams;
class Octree;
@ -210,13 +209,13 @@ public:
bool skipThoseWithBadParents) = 0;
// Octree importers
bool readFromFile(const char* filename, const QUrlAncestry& urlAncestry = {});
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1, const QUrlAncestry& urlAncestry = {}); // will support file urls as well...
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const QUrlAncestry& urlAncestry = {});
bool readFromFile(const char* filename);
bool readFromURL(const QString& url, const bool isObservable = true, const qint64 callerId = -1); // will support file urls as well...
bool readFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readSVOFromStream(uint64_t streamLength, QDataStream& inputStream);
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="", const QUrlAncestry& urlAncestry = {});
bool readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID="");
bool readJSONFromGzippedFile(QString qFileName);
virtual bool readFromMap(QVariantMap& entityDescription, const QUrlAncestry& urlAncestry = {}) = 0;
virtual bool readFromMap(QVariantMap& entityDescription) = 0;
uint64_t getOctreeElementsCount();

View file

@ -258,29 +258,24 @@ void OffscreenSurface::setMaxFps(uint8_t maxFps) {
}
void OffscreenSurface::load(const QUrl& qmlSource, QQuickItem* parent, const QJSValue& callback) {
qDebug() << "Here 1";
loadInternal(qmlSource, false, parent, [callback](QQmlContext* context, QQuickItem* newItem) {
QJSValue(callback).call(QJSValueList() << context->engine()->newQObject(newItem));
});
}
void OffscreenSurface::load(const QUrl& qmlSource, bool createNewContext, const QmlContextObjectCallback& callback) {
qDebug() << "Here 2";
loadInternal(qmlSource, createNewContext, nullptr, callback);
}
void OffscreenSurface::loadInNewContext(const QUrl& qmlSource, const QmlContextObjectCallback& callback, const QmlContextCallback& contextCallback) {
qDebug() << "Here 3";
loadInternal(qmlSource, true, nullptr, callback, contextCallback);
}
void OffscreenSurface::load(const QUrl& qmlSource, const QmlContextObjectCallback& callback) {
qDebug() << "Here 4";
load(qmlSource, false, callback);
}
void OffscreenSurface::load(const QString& qmlSourceFile, const QmlContextObjectCallback& callback) {
qDebug() << "Here 5";
return load(QUrl(qmlSourceFile), callback);
}

View file

@ -50,7 +50,7 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
tempDir = zipTemp.path();
path.remove("file:///");
}
qCDebug(scriptengine) << "Temporary directory at: " + tempDir;
if (!isTempDir(tempDir)) {
qCDebug(scriptengine) << "Temporary directory mismatch; risk of losing files";
@ -58,7 +58,7 @@ void FileScriptingInterface::runUnzip(QString path, QUrl url, bool autoAdd, bool
}
QStringList fileList = unzipFile(path, tempDir);
if (!fileList.isEmpty()) {
qCDebug(scriptengine) << "First file to upload: " + fileList.first();
} else {

View file

@ -63,7 +63,7 @@ QScriptValue XMLHttpRequestClass::constructor(QScriptContext* context, QScriptEn
QScriptValue XMLHttpRequestClass::getStatus() const {
if (_reply) {
return QScriptValue(_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt());
}
}
return QScriptValue(0);
}
@ -144,7 +144,7 @@ void XMLHttpRequestClass::open(const QString& method, const QString& url, bool a
if (url.toLower().left(METAVERSE_API_URL.length()) == METAVERSE_API_URL) {
auto accountManager = DependencyManager::get<AccountManager>();
if (accountManager->hasValidAccessToken()) {
static const QString HTTP_AUTHORIZATION_HEADER = "Authorization";
QString bearerString = "Bearer " + accountManager->getAccountInfo().getAccessToken().token;

View file

@ -1,31 +0,0 @@
//
// EntityItemWeakPointerWithUrlAncestry.h
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian 10/15/18
// Copyright 2018 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_EntityItemWeakPointerWithUrlAncestry_h
#define hifi_EntityItemWeakPointerWithUrlAncestry_h
#include "EntityTypes.h"
#include "QUrlAncestry.h"
struct EntityItemWeakPointerWithUrlAncestry {
EntityItemWeakPointerWithUrlAncestry(
const EntityItemWeakPointer& a,
const QUrlAncestry& b
) : entityItemWeakPointer(a), urlAncestry(b) {}
EntityItemWeakPointer entityItemWeakPointer;
QUrlAncestry urlAncestry;
};
#endif // hifi_EntityItemWeakPointerWithUrlAncestry_h

View file

@ -1,35 +0,0 @@
//
// QUrlAncestry.cpp
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian on 10/12/18.
// Copyright (c) 2018 High Fidelity, Inc. All rights reserved.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "QUrlAncestry.h"
QUrlAncestry::QUrlAncestry(const QUrl& resource, const QUrl& referrer) {
this->append(referrer);
this->append(resource);
}
QUrlAncestry::QUrlAncestry(
const QUrl& resource,
const QUrlAncestry& ancestors) : QVector<QUrl>(ancestors)
{
this->append(resource);
}
void QUrlAncestry::toJson(QJsonArray& array) const {
for (auto const& qurl : *this) {
array.append(qurl.toDisplayString());
}
}
const QUrl QUrlAncestry::url() const {
return this->last();
}

View file

@ -1,32 +0,0 @@
//
// QUrlAncestry.h
// libraries/shared/src/
//
// Created by Kerry Ivan Kurian on 10/12/18.
// Copyright (c) 2018 High Fidelity, Inc. All rights reserved.
//
// 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_QUrlAncestry_H
#define hifi_QUrlAncestry_H
#include <QJsonArray>
#include <QUrl>
#include <QVector>
class QUrlAncestry : public QVector<QUrl> {
public:
QUrlAncestry() {}
QUrlAncestry(const QUrl& resource, const QUrl& referrer = QUrl("__NONE__"));
QUrlAncestry(const QUrl& resource, const QUrlAncestry& ancestors);
void toJson(QJsonArray& array) const;
const QUrl url() const;
};
#endif // hifi_QUrlVector_H

View file

@ -15,22 +15,12 @@
#include <QString>
#include <QUrl>
#include "ResourceRequestObserver.h"
#include "QUrlAncestry.h"
// void ResourceRequestObserver::update(const QNetworkRequest& request, const qint64 callerId, const QString& extra) {
// update(QUrlAncestry(request.url()), callerId, extra);
// }
void ResourceRequestObserver::update(
const QUrlAncestry& urlAncestry,
void ResourceRequestObserver::update(const QUrl& requestUrl,
const qint64 callerId,
const QString& extra
) {
const QString& extra) {
QJsonArray array;
urlAncestry.toJson(array);
QJsonObject data {
{ "url", array },
QJsonObject data { { "url", requestUrl.toString() },
{ "callerId", callerId },
{ "extra", extra }
};

View file

@ -15,7 +15,6 @@
#include <QNetworkRequest>
#include "DependencyManager.h"
#include "QUrlAncestry.h"
class ResourceRequestObserver : public QObject, public Dependency {
@ -23,8 +22,7 @@ class ResourceRequestObserver : public QObject, public Dependency {
SINGLETON_DEPENDENCY
public:
// void update(const QNetworkRequest& request, const qint64 callerId = -1, const QString& extra = "");
void update(const QUrlAncestry& urlAncestry, const qint64 callerId = -1, const QString& extra = "");
void update(const QUrl& requestUrl, const qint64 callerId = -1, const QString& extra = "");
signals:
void resourceRequestEvent(QVariantMap result);