mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 14:47:19 +02:00
fix ubuntu compile warnings
This commit is contained in:
parent
010c714abc
commit
dd90c8c515
7 changed files with 41 additions and 44 deletions
|
@ -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;
|
||||
|
|
|
@ -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<scriptable::ScriptableMeshBase> 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);
|
||||
|
|
|
@ -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<QScriptEngine*>(parent)) {
|
||||
this->registerMetaTypes(scriptEngine);
|
||||
}
|
||||
|
|
|
@ -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<quint32> scriptable::ScriptableMesh::findNearbyIndices(const glm::vec3& origin, float epsilon) const {
|
||||
QVector<quint32> result;
|
||||
if (auto mesh = getMeshPointer()) {
|
||||
|
|
|
@ -33,14 +33,11 @@ namespace scriptable {
|
|||
bool hasValidOwnedMesh() const { return (bool)getOwnedMeshPointer(); }
|
||||
|
||||
operator const ScriptableMeshBase*() const { return (qobject_cast<const scriptable::ScriptableMeshBase*>(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<scriptable::ScriptableModel*>(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));
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -281,13 +281,22 @@ gpu::BufferView buffer_helpers::fromVector(const QVector<T>& elements, const gpu
|
|||
auto vertexBuffer = std::make_shared<gpu::Buffer>(elements.size() * sizeof(T), (gpu::Byte*)elements.data());
|
||||
return { vertexBuffer, 0, vertexBuffer->getSize(),sizeof(T), elementType };
|
||||
}
|
||||
|
||||
namespace {
|
||||
template <typename T>
|
||||
gpu::BufferView _fromVector(const QVector<T>& elements, const gpu::Element& elementType) {
|
||||
auto vertexBuffer = std::make_shared<gpu::Buffer>(elements.size() * sizeof(T), (gpu::Byte*)elements.data());
|
||||
return { vertexBuffer, 0, vertexBuffer->getSize(),sizeof(T), elementType };
|
||||
}
|
||||
}
|
||||
|
||||
template<> gpu::BufferView buffer_helpers::fromVector<unsigned int>(
|
||||
const QVector<unsigned int>& elements, const gpu::Element& elementType
|
||||
) { return fromVector(elements, elementType); }
|
||||
) { return _fromVector(elements, elementType); }
|
||||
|
||||
template<> gpu::BufferView buffer_helpers::fromVector<glm::vec3>(
|
||||
const QVector<glm::vec3>& elements, const gpu::Element& elementType
|
||||
) { return fromVector(elements, elementType); }
|
||||
) { return _fromVector(elements, elementType); }
|
||||
|
||||
template <typename T> struct GpuVec4ToGlm;
|
||||
template <typename T> struct GpuScalarToGlm;
|
||||
|
@ -537,14 +546,14 @@ std::map<QString, gpu::BufferView> 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<QString, gpu::BufferView> 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<glm::vec3>(j);
|
||||
glm::vec3 normal { 0.0f, 0.0f, 0.0f };
|
||||
QString key { glm::to_string(verts.get<glm::vec3>(j)).c_str() };
|
||||
QString key { glm::to_string(glm::dvec3(verts.get<glm::vec3>(j))).c_str() };
|
||||
const auto& faces = vertexToFaces.value(key);
|
||||
if (faces.size()) {
|
||||
for (const auto i : faces) {
|
||||
|
|
Loading…
Reference in a new issue