mirror of
https://github.com/overte-org/overte.git
synced 2025-07-24 00:43:49 +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 {
|
class ApplicationMeshProvider : public scriptable::ModelProviderFactory {
|
||||||
public:
|
public:
|
||||||
virtual scriptable::ModelProviderPointer lookupModelProvider(const QUuid& uuid) {
|
virtual scriptable::ModelProviderPointer lookupModelProvider(const QUuid& uuid) override {
|
||||||
QString error;
|
QString error;
|
||||||
|
|
||||||
scriptable::ModelProviderPointer provider;
|
scriptable::ModelProviderPointer provider;
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace scriptable {
|
||||||
ScriptableMeshBase(WeakModelProviderPointer provider, ScriptableModelBasePointer model, WeakMeshPointer mesh, const QVariantMap& metadata);
|
ScriptableMeshBase(WeakModelProviderPointer provider, ScriptableModelBasePointer model, WeakMeshPointer mesh, const QVariantMap& metadata);
|
||||||
ScriptableMeshBase(WeakMeshPointer mesh = WeakMeshPointer());
|
ScriptableMeshBase(WeakMeshPointer mesh = WeakMeshPointer());
|
||||||
ScriptableMeshBase(MeshPointer mesh, const QVariantMap& metadata);
|
ScriptableMeshBase(MeshPointer mesh, const QVariantMap& metadata);
|
||||||
ScriptableMeshBase(const ScriptableMeshBase& other) { *this = other; }
|
ScriptableMeshBase(const ScriptableMeshBase& other) : QObject() { *this = other; }
|
||||||
ScriptableMeshBase& operator=(const ScriptableMeshBase& view);
|
ScriptableMeshBase& operator=(const ScriptableMeshBase& view);
|
||||||
virtual ~ScriptableMeshBase();
|
virtual ~ScriptableMeshBase();
|
||||||
Q_INVOKABLE const scriptable::MeshPointer getMeshPointer() const { return mesh.lock(); }
|
Q_INVOKABLE const scriptable::MeshPointer getMeshPointer() const { return mesh.lock(); }
|
||||||
|
@ -60,16 +60,8 @@ namespace scriptable {
|
||||||
QVector<scriptable::ScriptableMeshBase> meshes;
|
QVector<scriptable::ScriptableMeshBase> meshes;
|
||||||
|
|
||||||
ScriptableModelBase(QObject* parent = nullptr) : QObject(parent) {}
|
ScriptableModelBase(QObject* parent = nullptr) : QObject(parent) {}
|
||||||
ScriptableModelBase(const ScriptableModelBase& other) { *this = other; }
|
ScriptableModelBase(const ScriptableModelBase& other) : QObject() { *this = other; }
|
||||||
ScriptableModelBase& operator=(const ScriptableModelBase& other) {
|
ScriptableModelBase& operator=(const ScriptableModelBase& other);
|
||||||
provider = other.provider;
|
|
||||||
objectID = other.objectID;
|
|
||||||
metadata = other.metadata;
|
|
||||||
for (auto& mesh : other.meshes) {
|
|
||||||
append(mesh);
|
|
||||||
}
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
virtual ~ScriptableModelBase();
|
virtual ~ScriptableModelBase();
|
||||||
|
|
||||||
void mixin(const QVariantMap& other);
|
void mixin(const QVariantMap& other);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
#include "GraphicsScriptingInterface.moc"
|
#include "GraphicsScriptingInterface.moc"
|
||||||
|
|
||||||
GraphicsScriptingInterface::GraphicsScriptingInterface(QObject* parent) : QObject(parent) {
|
GraphicsScriptingInterface::GraphicsScriptingInterface(QObject* parent) : QObject(parent), QScriptable() {
|
||||||
if (auto scriptEngine = qobject_cast<QScriptEngine*>(parent)) {
|
if (auto scriptEngine = qobject_cast<QScriptEngine*>(parent)) {
|
||||||
this->registerMetaTypes(scriptEngine);
|
this->registerMetaTypes(scriptEngine);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
#include "ScriptableMesh.moc"
|
#include "ScriptableMesh.moc"
|
||||||
|
|
||||||
scriptable::ScriptableMeshPart::ScriptableMeshPart(scriptable::ScriptableMeshPointer parentMesh, int partIndex)
|
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));
|
setObjectName(QString("%1.part[%2]").arg(parentMesh ? parentMesh->objectName() : "").arg(partIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptable::ScriptableMesh::ScriptableMesh(const ScriptableMeshBase& other)
|
scriptable::ScriptableMesh::ScriptableMesh(const ScriptableMeshBase& other)
|
||||||
: ScriptableMeshBase(other) {
|
: ScriptableMeshBase(other), QScriptable() {
|
||||||
auto mesh = getMeshPointer();
|
auto mesh = getMeshPointer();
|
||||||
QString name = mesh ? QString::fromStdString(mesh->modelName) : "";
|
QString name = mesh ? QString::fromStdString(mesh->modelName) : "";
|
||||||
if (name.isEmpty()) {
|
if (name.isEmpty()) {
|
||||||
|
@ -60,15 +60,6 @@ quint32 scriptable::ScriptableMesh::getNumVertices() const {
|
||||||
return 0;
|
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> scriptable::ScriptableMesh::findNearbyIndices(const glm::vec3& origin, float epsilon) const {
|
||||||
QVector<quint32> result;
|
QVector<quint32> result;
|
||||||
if (auto mesh = getMeshPointer()) {
|
if (auto mesh = getMeshPointer()) {
|
||||||
|
|
|
@ -33,14 +33,11 @@ namespace scriptable {
|
||||||
bool hasValidOwnedMesh() const { return (bool)getOwnedMeshPointer(); }
|
bool hasValidOwnedMesh() const { return (bool)getOwnedMeshPointer(); }
|
||||||
|
|
||||||
operator const ScriptableMeshBase*() const { return (qobject_cast<const scriptable::ScriptableMeshBase*>(this)); }
|
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)
|
ScriptableMesh(WeakModelProviderPointer provider, ScriptableModelBasePointer model, MeshPointer mesh, const QVariantMap& metadata)
|
||||||
: ScriptableMeshBase(provider, model, mesh, metadata) { ownedMesh = mesh; }
|
: ScriptableMeshBase(provider, model, mesh, metadata), QScriptable() { 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) {}
|
|
||||||
ScriptableMesh(const ScriptableMeshBase& other);
|
ScriptableMesh(const ScriptableMeshBase& other);
|
||||||
ScriptableMesh(const ScriptableMesh& other) : ScriptableMeshBase(other) {};
|
ScriptableMesh(const ScriptableMesh& other) : ScriptableMeshBase(other), QScriptable() {};
|
||||||
virtual ~ScriptableMesh();
|
virtual ~ScriptableMesh();
|
||||||
|
|
||||||
Q_INVOKABLE const scriptable::ScriptableModelPointer getParentModel() const { return qobject_cast<scriptable::ScriptableModel*>(model); }
|
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(QVariantMap metadata MEMBER metadata)
|
||||||
|
|
||||||
//Q_PROPERTY(scriptable::ScriptableMeshPointer parentMesh MEMBER parentMesh CONSTANT HIDE)
|
|
||||||
|
|
||||||
ScriptableMeshPart(scriptable::ScriptableMeshPointer parentMesh, int partIndex);
|
ScriptableMeshPart(scriptable::ScriptableMeshPointer parentMesh, int partIndex);
|
||||||
ScriptableMeshPart& operator=(const ScriptableMeshPart& view) { parentMesh=view.parentMesh; return *this; };
|
ScriptableMeshPart& operator=(const ScriptableMeshPart& view) { parentMesh=view.parentMesh; return *this; };
|
||||||
ScriptableMeshPart(const ScriptableMeshPart& other) : parentMesh(other.parentMesh), partIndex(other.partIndex) {}
|
ScriptableMeshPart(const ScriptableMeshPart& other) : QObject(), QScriptable(), parentMesh(other.parentMesh), partIndex(other.partIndex) {}
|
||||||
// ~ScriptableMeshPart() { qDebug() << "~ScriptableMeshPart" << this; }
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
scriptable::ScriptableMeshPointer getParentMesh() const { return parentMesh; }
|
scriptable::ScriptableMeshPointer getParentMesh() const { return parentMesh; }
|
||||||
|
@ -148,8 +142,8 @@ namespace scriptable {
|
||||||
class GraphicsScriptingInterface : public QObject, QScriptable {
|
class GraphicsScriptingInterface : public QObject, QScriptable {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
GraphicsScriptingInterface(QObject* parent = nullptr) : QObject(parent) {}
|
GraphicsScriptingInterface(QObject* parent = nullptr) : QObject(parent), QScriptable() {}
|
||||||
GraphicsScriptingInterface(const GraphicsScriptingInterface& other) {}
|
GraphicsScriptingInterface(const GraphicsScriptingInterface& other) : QObject(), QScriptable() {}
|
||||||
public slots:
|
public slots:
|
||||||
ScriptableMeshPartPointer exportMeshPart(ScriptableMeshPointer mesh, int part=0) {
|
ScriptableMeshPartPointer exportMeshPart(ScriptableMeshPointer mesh, int part=0) {
|
||||||
return ScriptableMeshPartPointer(new ScriptableMeshPart(mesh, part));
|
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() {
|
scriptable::ScriptableModelBase::~ScriptableModelBase() {
|
||||||
#ifdef SCRIPTABLE_MESH_DEBUG
|
#ifdef SCRIPTABLE_MESH_DEBUG
|
||||||
qCDebug(graphics_scripting) << "~ScriptableModelBase" << this;
|
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());
|
auto vertexBuffer = std::make_shared<gpu::Buffer>(elements.size() * sizeof(T), (gpu::Byte*)elements.data());
|
||||||
return { vertexBuffer, 0, vertexBuffer->getSize(),sizeof(T), elementType };
|
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>(
|
template<> gpu::BufferView buffer_helpers::fromVector<unsigned int>(
|
||||||
const QVector<unsigned int>& elements, const gpu::Element& elementType
|
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>(
|
template<> gpu::BufferView buffer_helpers::fromVector<glm::vec3>(
|
||||||
const QVector<glm::vec3>& elements, const gpu::Element& elementType
|
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 GpuVec4ToGlm;
|
||||||
template <typename T> struct GpuScalarToGlm;
|
template <typename T> struct GpuScalarToGlm;
|
||||||
|
@ -537,14 +546,14 @@ std::map<QString, gpu::BufferView> buffer_helpers::gatherBufferViews(graphics::M
|
||||||
auto slot = a.second;
|
auto slot = a.second;
|
||||||
auto view = getBufferView(mesh, slot);
|
auto view = getBufferView(mesh, slot);
|
||||||
auto beforeCount = view.getNumElements();
|
auto beforeCount = view.getNumElements();
|
||||||
|
#if DEV_BUILD
|
||||||
auto beforeTotal = view._size;
|
auto beforeTotal = view._size;
|
||||||
|
#endif
|
||||||
if (expandToMatchPositions.contains(name)) {
|
if (expandToMatchPositions.contains(name)) {
|
||||||
expandAttributeToMatchPositions(mesh, slot);
|
expandAttributeToMatchPositions(mesh, slot);
|
||||||
}
|
}
|
||||||
if (beforeCount > 0) {
|
if (beforeCount > 0) {
|
||||||
auto element = view._element;
|
auto element = view._element;
|
||||||
auto vecN = element.getScalarCount();
|
|
||||||
//auto type = element.getType();
|
|
||||||
QString typeName = QString("%1").arg(element.getType());
|
QString typeName = QString("%1").arg(element.getType());
|
||||||
#ifdef DEBUG_BUFFERVIEW_SCRIPTING
|
#ifdef DEBUG_BUFFERVIEW_SCRIPTING
|
||||||
typeName = DebugNames::stringFrom(element.getType());
|
typeName = DebugNames::stringFrom(element.getType());
|
||||||
|
@ -553,6 +562,7 @@ std::map<QString, gpu::BufferView> buffer_helpers::gatherBufferViews(graphics::M
|
||||||
attributeViews[name] = getBufferView(mesh, slot);
|
attributeViews[name] = getBufferView(mesh, slot);
|
||||||
|
|
||||||
#if DEV_BUILD
|
#if DEV_BUILD
|
||||||
|
const auto vecN = element.getScalarCount();
|
||||||
auto afterTotal = attributeViews[name]._size;
|
auto afterTotal = attributeViews[name]._size;
|
||||||
auto afterCount = attributeViews[name].getNumElements();
|
auto afterCount = attributeViews[name].getNumElements();
|
||||||
if (beforeTotal != afterTotal || beforeCount != afterCount) {
|
if (beforeTotal != afterTotal || beforeCount != afterCount) {
|
||||||
|
@ -604,14 +614,14 @@ bool buffer_helpers::recalculateNormals(graphics::MeshPointer mesh) {
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vertexToFaces[glm::to_string(face.v0).c_str()] << i;
|
vertexToFaces[glm::to_string(glm::dvec3(face.v0)).c_str()] << i;
|
||||||
vertexToFaces[glm::to_string(face.v1).c_str()] << i;
|
vertexToFaces[glm::to_string(glm::dvec3(face.v1)).c_str()] << i;
|
||||||
vertexToFaces[glm::to_string(face.v2).c_str()] << i;
|
vertexToFaces[glm::to_string(glm::dvec3(face.v2)).c_str()] << i;
|
||||||
}
|
}
|
||||||
for (quint32 j = 0; j < numNormals; j++) {
|
for (quint32 j = 0; j < numNormals; j++) {
|
||||||
//auto v = verts.get<glm::vec3>(j);
|
//auto v = verts.get<glm::vec3>(j);
|
||||||
glm::vec3 normal { 0.0f, 0.0f, 0.0f };
|
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);
|
const auto& faces = vertexToFaces.value(key);
|
||||||
if (faces.size()) {
|
if (faces.size()) {
|
||||||
for (const auto i : faces) {
|
for (const auto i : faces) {
|
||||||
|
|
Loading…
Reference in a new issue