mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 17:55:36 +02:00
do Model::getMeshes on the correct thread. added ModelScriptingInterface::getVertexCount and ModelScriptingInterface::getVertex
This commit is contained in:
parent
8a0b43981c
commit
72e5fecb4e
5 changed files with 45 additions and 5 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <PerfStat.h>
|
||||
#include <render/Scene.h>
|
||||
#include <DependencyManager.h>
|
||||
#include <shared/QtHelpers.h>
|
||||
|
||||
#include "EntityTreeRenderer.h"
|
||||
#include "EntitiesRendererLogging.h"
|
||||
|
@ -1287,5 +1288,6 @@ bool RenderableModelEntityItem::getMeshes(MeshProxyList& result) {
|
|||
if (!_model || !_model->isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
return _model->getMeshes(result);
|
||||
BLOCKING_INVOKE_METHOD(_model.get(), "getMeshes", Q_RETURN_ARG(MeshProxyList, result));
|
||||
return !result.isEmpty();
|
||||
}
|
||||
|
|
|
@ -463,12 +463,13 @@ bool Model::convexHullContains(glm::vec3 point) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Model::getMeshes(MeshProxyList& result) {
|
||||
MeshProxyList Model::getMeshes() {
|
||||
MeshProxyList result;
|
||||
const Geometry::Pointer& renderGeometry = getGeometry();
|
||||
const Geometry::GeometryMeshes& meshes = renderGeometry->getMeshes();
|
||||
|
||||
if (!isLoaded()) {
|
||||
return false;
|
||||
return result;
|
||||
}
|
||||
|
||||
Transform offset;
|
||||
|
@ -490,7 +491,7 @@ bool Model::getMeshes(MeshProxyList& result) {
|
|||
result << meshProxy;
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Model::calculateTriangleSets() {
|
||||
|
|
|
@ -257,7 +257,7 @@ public:
|
|||
int getResourceDownloadAttempts() { return _renderWatcher.getResourceDownloadAttempts(); }
|
||||
int getResourceDownloadAttemptsRemaining() { return _renderWatcher.getResourceDownloadAttemptsRemaining(); }
|
||||
|
||||
bool getMeshes(MeshProxyList& result);
|
||||
Q_INVOKABLE MeshProxyList getMeshes();
|
||||
|
||||
public slots:
|
||||
void loadURLFinished(bool success);
|
||||
|
|
|
@ -138,6 +138,41 @@ QScriptValue ModelScriptingInterface::transformMesh(glm::mat4 transform, MeshPro
|
|||
return meshToScriptValue(_modelScriptEngine, resultProxy);
|
||||
}
|
||||
|
||||
QScriptValue ModelScriptingInterface::getVertexCount(MeshProxy* meshProxy) {
|
||||
if (!meshProxy) {
|
||||
return QScriptValue(false);
|
||||
}
|
||||
MeshPointer mesh = meshProxy->getMeshPointer();
|
||||
if (!mesh) {
|
||||
return QScriptValue(false);
|
||||
}
|
||||
|
||||
gpu::BufferView::Index numVertices = (gpu::BufferView::Index)mesh->getNumVertices();
|
||||
|
||||
return numVertices;
|
||||
}
|
||||
|
||||
QScriptValue ModelScriptingInterface::getVertex(MeshProxy* meshProxy, int vertexIndex) {
|
||||
if (!meshProxy) {
|
||||
return QScriptValue(false);
|
||||
}
|
||||
MeshPointer mesh = meshProxy->getMeshPointer();
|
||||
if (!mesh) {
|
||||
return QScriptValue(false);
|
||||
}
|
||||
|
||||
const gpu::BufferView& vertexBufferView = mesh->getVertexBuffer();
|
||||
gpu::BufferView::Index numVertices = (gpu::BufferView::Index)mesh->getNumVertices();
|
||||
|
||||
if (vertexIndex < 0 || vertexIndex >= numVertices) {
|
||||
return QScriptValue(false);
|
||||
}
|
||||
|
||||
glm::vec3 pos = vertexBufferView.get<glm::vec3>(vertexIndex);
|
||||
return vec3toScriptValue(_modelScriptEngine, pos);
|
||||
}
|
||||
|
||||
|
||||
QScriptValue ModelScriptingInterface::newMesh(const QVector<glm::vec3>& vertices,
|
||||
const QVector<glm::vec3>& normals,
|
||||
const QVector<MeshFace>& faces) {
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
Q_INVOKABLE QScriptValue newMesh(const QVector<glm::vec3>& vertices,
|
||||
const QVector<glm::vec3>& normals,
|
||||
const QVector<MeshFace>& faces);
|
||||
Q_INVOKABLE QScriptValue getVertexCount(MeshProxy* meshProxy);
|
||||
Q_INVOKABLE QScriptValue getVertex(MeshProxy* meshProxy, int vertexIndex);
|
||||
|
||||
private:
|
||||
QScriptEngine* _modelScriptEngine { nullptr };
|
||||
|
|
Loading…
Reference in a new issue