From dd90c8c515561ec4c480d12975a84ae722ee2d15 Mon Sep 17 00:00:00 2001 From: humbletim Date: Thu, 22 Feb 2018 09:36:17 -0500 Subject: [PATCH] fix ubuntu compile warnings --- interface/src/Application.cpp | 2 +- .../src/graphics-scripting/Forward.h | 14 +++------- .../GraphicsScriptingInterface.cpp | 2 +- .../src/graphics-scripting/ScriptableMesh.cpp | 13 ++-------- .../src/graphics-scripting/ScriptableMesh.h | 18 +++++-------- .../graphics-scripting/ScriptableModel.cpp | 10 +++++++ .../src/graphics/BufferViewHelpers.cpp | 26 +++++++++++++------ 7 files changed, 41 insertions(+), 44 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index f344c94161..69be01fc0c 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -607,7 +607,7 @@ void messageHandler(QtMsgType type, const QMessageLogContext& context, const QSt class ApplicationMeshProvider : public scriptable::ModelProviderFactory { public: - virtual scriptable::ModelProviderPointer lookupModelProvider(const QUuid& uuid) { + virtual scriptable::ModelProviderPointer lookupModelProvider(const QUuid& uuid) override { QString error; scriptable::ModelProviderPointer provider; diff --git a/libraries/graphics-scripting/src/graphics-scripting/Forward.h b/libraries/graphics-scripting/src/graphics-scripting/Forward.h index 95fcf51921..7b2126cf8f 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/Forward.h +++ b/libraries/graphics-scripting/src/graphics-scripting/Forward.h @@ -42,7 +42,7 @@ namespace scriptable { ScriptableMeshBase(WeakModelProviderPointer provider, ScriptableModelBasePointer model, WeakMeshPointer mesh, const QVariantMap& metadata); ScriptableMeshBase(WeakMeshPointer mesh = WeakMeshPointer()); ScriptableMeshBase(MeshPointer mesh, const QVariantMap& metadata); - ScriptableMeshBase(const ScriptableMeshBase& other) { *this = other; } + ScriptableMeshBase(const ScriptableMeshBase& other) : QObject() { *this = other; } ScriptableMeshBase& operator=(const ScriptableMeshBase& view); virtual ~ScriptableMeshBase(); Q_INVOKABLE const scriptable::MeshPointer getMeshPointer() const { return mesh.lock(); } @@ -60,16 +60,8 @@ namespace scriptable { QVector meshes; ScriptableModelBase(QObject* parent = nullptr) : QObject(parent) {} - ScriptableModelBase(const ScriptableModelBase& other) { *this = other; } - ScriptableModelBase& operator=(const ScriptableModelBase& other) { - provider = other.provider; - objectID = other.objectID; - metadata = other.metadata; - for (auto& mesh : other.meshes) { - append(mesh); - } - return *this; - } + ScriptableModelBase(const ScriptableModelBase& other) : QObject() { *this = other; } + ScriptableModelBase& operator=(const ScriptableModelBase& other); virtual ~ScriptableModelBase(); void mixin(const QVariantMap& other); diff --git a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp index 58fcd7a064..28d5d0edfc 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/GraphicsScriptingInterface.cpp @@ -27,7 +27,7 @@ #include "GraphicsScriptingInterface.moc" -GraphicsScriptingInterface::GraphicsScriptingInterface(QObject* parent) : QObject(parent) { +GraphicsScriptingInterface::GraphicsScriptingInterface(QObject* parent) : QObject(parent), QScriptable() { if (auto scriptEngine = qobject_cast(parent)) { this->registerMetaTypes(scriptEngine); } diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp index 28e57692f6..3678c54b7b 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.cpp @@ -23,12 +23,12 @@ #include "ScriptableMesh.moc" scriptable::ScriptableMeshPart::ScriptableMeshPart(scriptable::ScriptableMeshPointer parentMesh, int partIndex) - : parentMesh(parentMesh), partIndex(partIndex) { + : QObject(), parentMesh(parentMesh), partIndex(partIndex) { setObjectName(QString("%1.part[%2]").arg(parentMesh ? parentMesh->objectName() : "").arg(partIndex)); } scriptable::ScriptableMesh::ScriptableMesh(const ScriptableMeshBase& other) - : ScriptableMeshBase(other) { + : ScriptableMeshBase(other), QScriptable() { auto mesh = getMeshPointer(); QString name = mesh ? QString::fromStdString(mesh->modelName) : ""; if (name.isEmpty()) { @@ -60,15 +60,6 @@ quint32 scriptable::ScriptableMesh::getNumVertices() const { return 0; } -// glm::vec3 ScriptableMesh::getPos3(quint32 index) const { -// if (auto mesh = getMeshPointer()) { -// if (index < getNumVertices()) { -// return mesh->getPos3(index); -// } -// } -// return glm::vec3(NAN); -// } - QVector scriptable::ScriptableMesh::findNearbyIndices(const glm::vec3& origin, float epsilon) const { QVector result; if (auto mesh = getMeshPointer()) { diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h index 2b9399d6ef..2cba33edde 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableMesh.h @@ -33,14 +33,11 @@ namespace scriptable { bool hasValidOwnedMesh() const { return (bool)getOwnedMeshPointer(); } operator const ScriptableMeshBase*() const { return (qobject_cast(this)); } - ScriptableMesh(scriptable::MeshPointer mesh) : ScriptableMeshBase(mesh) { ownedMesh = mesh; } + ScriptableMesh(scriptable::MeshPointer mesh) : ScriptableMeshBase(mesh), QScriptable() { ownedMesh = mesh; } ScriptableMesh(WeakModelProviderPointer provider, ScriptableModelBasePointer model, MeshPointer mesh, const QVariantMap& metadata) - : ScriptableMeshBase(provider, model, mesh, metadata) { ownedMesh = mesh; } - //ScriptableMesh& operator=(const ScriptableMesh& other) { model=other.model; mesh=other.mesh; metadata=other.metadata; return *this; }; - //ScriptableMesh() : QObject(), model(nullptr) {} - //ScriptableMesh(const ScriptableMesh& other) : QObject(), model(other.model), mesh(other.mesh), metadata(other.metadata) {} + : ScriptableMeshBase(provider, model, mesh, metadata), QScriptable() { ownedMesh = mesh; } ScriptableMesh(const ScriptableMeshBase& other); - ScriptableMesh(const ScriptableMesh& other) : ScriptableMeshBase(other) {}; + ScriptableMesh(const ScriptableMesh& other) : ScriptableMeshBase(other), QScriptable() {}; virtual ~ScriptableMesh(); Q_INVOKABLE const scriptable::ScriptableModelPointer getParentModel() const { return qobject_cast(model); } @@ -91,12 +88,9 @@ namespace scriptable { Q_PROPERTY(QVariantMap metadata MEMBER metadata) - //Q_PROPERTY(scriptable::ScriptableMeshPointer parentMesh MEMBER parentMesh CONSTANT HIDE) - ScriptableMeshPart(scriptable::ScriptableMeshPointer parentMesh, int partIndex); ScriptableMeshPart& operator=(const ScriptableMeshPart& view) { parentMesh=view.parentMesh; return *this; }; - ScriptableMeshPart(const ScriptableMeshPart& other) : parentMesh(other.parentMesh), partIndex(other.partIndex) {} - // ~ScriptableMeshPart() { qDebug() << "~ScriptableMeshPart" << this; } + ScriptableMeshPart(const ScriptableMeshPart& other) : QObject(), QScriptable(), parentMesh(other.parentMesh), partIndex(other.partIndex) {} public slots: scriptable::ScriptableMeshPointer getParentMesh() const { return parentMesh; } @@ -148,8 +142,8 @@ namespace scriptable { class GraphicsScriptingInterface : public QObject, QScriptable { Q_OBJECT public: - GraphicsScriptingInterface(QObject* parent = nullptr) : QObject(parent) {} - GraphicsScriptingInterface(const GraphicsScriptingInterface& other) {} + GraphicsScriptingInterface(QObject* parent = nullptr) : QObject(parent), QScriptable() {} + GraphicsScriptingInterface(const GraphicsScriptingInterface& other) : QObject(), QScriptable() {} public slots: ScriptableMeshPartPointer exportMeshPart(ScriptableMeshPointer mesh, int part=0) { return ScriptableMeshPartPointer(new ScriptableMeshPart(mesh, part)); diff --git a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp index 5d0d459446..cc882aa7bb 100644 --- a/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp +++ b/libraries/graphics-scripting/src/graphics-scripting/ScriptableModel.cpp @@ -27,6 +27,16 @@ void scriptable::ScriptableModelBase::mixin(const QVariantMap& modelMetaData) { } } +scriptable::ScriptableModelBase& scriptable::ScriptableModelBase::operator=(const scriptable::ScriptableModelBase& other) { + provider = other.provider; + objectID = other.objectID; + metadata = other.metadata; + for (auto& mesh : other.meshes) { + append(mesh); + } + return *this; +} + scriptable::ScriptableModelBase::~ScriptableModelBase() { #ifdef SCRIPTABLE_MESH_DEBUG qCDebug(graphics_scripting) << "~ScriptableModelBase" << this; diff --git a/libraries/graphics/src/graphics/BufferViewHelpers.cpp b/libraries/graphics/src/graphics/BufferViewHelpers.cpp index ea511d82f4..a15ce1b998 100644 --- a/libraries/graphics/src/graphics/BufferViewHelpers.cpp +++ b/libraries/graphics/src/graphics/BufferViewHelpers.cpp @@ -281,13 +281,22 @@ gpu::BufferView buffer_helpers::fromVector(const QVector& elements, const gpu auto vertexBuffer = std::make_shared(elements.size() * sizeof(T), (gpu::Byte*)elements.data()); return { vertexBuffer, 0, vertexBuffer->getSize(),sizeof(T), elementType }; } + +namespace { + template + gpu::BufferView _fromVector(const QVector& elements, const gpu::Element& elementType) { + auto vertexBuffer = std::make_shared(elements.size() * sizeof(T), (gpu::Byte*)elements.data()); + return { vertexBuffer, 0, vertexBuffer->getSize(),sizeof(T), elementType }; + } +} + template<> gpu::BufferView buffer_helpers::fromVector( const QVector& elements, const gpu::Element& elementType -) { return fromVector(elements, elementType); } +) { return _fromVector(elements, elementType); } template<> gpu::BufferView buffer_helpers::fromVector( const QVector& elements, const gpu::Element& elementType -) { return fromVector(elements, elementType); } +) { return _fromVector(elements, elementType); } template struct GpuVec4ToGlm; template struct GpuScalarToGlm; @@ -537,14 +546,14 @@ std::map buffer_helpers::gatherBufferViews(graphics::M auto slot = a.second; auto view = getBufferView(mesh, slot); auto beforeCount = view.getNumElements(); +#if DEV_BUILD auto beforeTotal = view._size; +#endif if (expandToMatchPositions.contains(name)) { expandAttributeToMatchPositions(mesh, slot); } if (beforeCount > 0) { auto element = view._element; - auto vecN = element.getScalarCount(); - //auto type = element.getType(); QString typeName = QString("%1").arg(element.getType()); #ifdef DEBUG_BUFFERVIEW_SCRIPTING typeName = DebugNames::stringFrom(element.getType()); @@ -553,6 +562,7 @@ std::map buffer_helpers::gatherBufferViews(graphics::M attributeViews[name] = getBufferView(mesh, slot); #if DEV_BUILD + const auto vecN = element.getScalarCount(); auto afterTotal = attributeViews[name]._size; auto afterCount = attributeViews[name].getNumElements(); if (beforeTotal != afterTotal || beforeCount != afterCount) { @@ -604,14 +614,14 @@ bool buffer_helpers::recalculateNormals(graphics::MeshPointer mesh) { #endif break; } - vertexToFaces[glm::to_string(face.v0).c_str()] << i; - vertexToFaces[glm::to_string(face.v1).c_str()] << i; - vertexToFaces[glm::to_string(face.v2).c_str()] << i; + vertexToFaces[glm::to_string(glm::dvec3(face.v0)).c_str()] << i; + vertexToFaces[glm::to_string(glm::dvec3(face.v1)).c_str()] << i; + vertexToFaces[glm::to_string(glm::dvec3(face.v2)).c_str()] << i; } for (quint32 j = 0; j < numNormals; j++) { //auto v = verts.get(j); glm::vec3 normal { 0.0f, 0.0f, 0.0f }; - QString key { glm::to_string(verts.get(j)).c_str() }; + QString key { glm::to_string(glm::dvec3(verts.get(j))).c_str() }; const auto& faces = vertexToFaces.value(key); if (faces.size()) { for (const auto i : faces) {