mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-07-22 18:13:52 +02:00
* remove unneeded Q_DECLARE_METATYPEs
* CR feedback
This commit is contained in:
parent
767569bc40
commit
d3bae87066
7 changed files with 25 additions and 28 deletions
|
@ -95,11 +95,3 @@ namespace scriptable {
|
||||||
class ScriptableMeshPart;
|
class ScriptableMeshPart;
|
||||||
using ScriptableMeshPartPointer = QPointer<ScriptableMeshPart>;
|
using ScriptableMeshPartPointer = QPointer<ScriptableMeshPart>;
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(glm::uint32)
|
|
||||||
Q_DECLARE_METATYPE(QVector<glm::uint32>)
|
|
||||||
Q_DECLARE_METATYPE(NestableType)
|
|
||||||
Q_DECLARE_METATYPE(scriptable::MeshPointer)
|
|
||||||
Q_DECLARE_METATYPE(scriptable::WeakMeshPointer)
|
|
||||||
Q_DECLARE_METATYPE(scriptable::ModelProviderPointer)
|
|
||||||
|
|
||||||
|
|
|
@ -85,4 +85,8 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(glm::uint32)
|
||||||
|
Q_DECLARE_METATYPE(QVector<glm::uint32>)
|
||||||
|
Q_DECLARE_METATYPE(NestableType)
|
||||||
|
|
||||||
#endif // hifi_GraphicsScriptingInterface_h
|
#endif // hifi_GraphicsScriptingInterface_h
|
||||||
|
|
|
@ -118,7 +118,7 @@ bool scriptable::ScriptableMesh::setVertexAttributes(glm::uint32 vertexIndex, co
|
||||||
return buffer_helpers::mesh::setVertexAttributes(getMeshPointer(), vertexIndex, attributes);
|
return buffer_helpers::mesh::setVertexAttributes(getMeshPointer(), vertexIndex, attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int scriptable::ScriptableMesh::_getSlotNumber(const QString& attributeName) const {
|
int scriptable::ScriptableMesh::getSlotNumber(const QString& attributeName) const {
|
||||||
if (auto mesh = getMeshPointer()) {
|
if (auto mesh = getMeshPointer()) {
|
||||||
return buffer_helpers::ATTRIBUTES.value(attributeName, -1);
|
return buffer_helpers::ATTRIBUTES.value(attributeName, -1);
|
||||||
}
|
}
|
||||||
|
@ -142,9 +142,9 @@ QVariantMap scriptable::ScriptableMesh::getBufferFormats() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scriptable::ScriptableMesh::removeAttribute(const QString& attributeName) {
|
bool scriptable::ScriptableMesh::removeAttribute(const QString& attributeName) {
|
||||||
auto slot = isValid() ? _getSlotNumber(attributeName) : -1;
|
auto slot = isValid() ? getSlotNumber(attributeName) : -1;
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
if (slot == gpu::Stream::POSITION) {
|
if (slot == gpu::Stream::POSITION) {
|
||||||
context()->throwError("cannot remove .position attribute");
|
context()->throwError("cannot remove .position attribute");
|
||||||
|
@ -158,7 +158,7 @@ bool scriptable::ScriptableMesh::removeAttribute(const QString& attributeName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::uint32 scriptable::ScriptableMesh::addAttribute(const QString& attributeName, const QVariant& defaultValue) {
|
glm::uint32 scriptable::ScriptableMesh::addAttribute(const QString& attributeName, const QVariant& defaultValue) {
|
||||||
auto slot = isValid() ? _getSlotNumber(attributeName) : -1;
|
auto slot = isValid() ? getSlotNumber(attributeName) : -1;
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -187,7 +187,7 @@ glm::uint32 scriptable::ScriptableMesh::addAttribute(const QString& attributeNam
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::uint32 scriptable::ScriptableMesh::fillAttribute(const QString& attributeName, const QVariant& value) {
|
glm::uint32 scriptable::ScriptableMesh::fillAttribute(const QString& attributeName, const QVariant& value) {
|
||||||
auto slot = isValid() ? _getSlotNumber(attributeName) : -1;
|
auto slot = isValid() ? getSlotNumber(attributeName) : -1;
|
||||||
if (slot < 0) {
|
if (slot < 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -218,7 +218,7 @@ QVariantList scriptable::ScriptableMesh::queryVertexAttributes(QVariant selector
|
||||||
if (!isValidIndex(0, attributeName)) {
|
if (!isValidIndex(0, attributeName)) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
auto slotNum = _getSlotNumber(attributeName);
|
auto slotNum = getSlotNumber(attributeName);
|
||||||
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
||||||
glm::uint32 numElements = (glm::uint32)bufferView.getNumElements();
|
glm::uint32 numElements = (glm::uint32)bufferView.getNumElements();
|
||||||
for (glm::uint32 i = 0; i < numElements; i++) {
|
for (glm::uint32 i = 0; i < numElements; i++) {
|
||||||
|
@ -231,7 +231,7 @@ QVariant scriptable::ScriptableMesh::getVertexProperty(glm::uint32 vertexIndex,
|
||||||
if (!isValidIndex(vertexIndex, attributeName)) {
|
if (!isValidIndex(vertexIndex, attributeName)) {
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
auto slotNum = _getSlotNumber(attributeName);
|
auto slotNum = getSlotNumber(attributeName);
|
||||||
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
||||||
return buffer_helpers::getValue<QVariant>(bufferView, vertexIndex, qUtf8Printable(attributeName));
|
return buffer_helpers::getValue<QVariant>(bufferView, vertexIndex, qUtf8Printable(attributeName));
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ bool scriptable::ScriptableMesh::setVertexProperty(glm::uint32 vertexIndex, cons
|
||||||
if (!isValidIndex(vertexIndex, attributeName)) {
|
if (!isValidIndex(vertexIndex, attributeName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto slotNum = _getSlotNumber(attributeName);
|
auto slotNum = getSlotNumber(attributeName);
|
||||||
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
||||||
return buffer_helpers::setValue(bufferView, vertexIndex, value);
|
return buffer_helpers::setValue(bufferView, vertexIndex, value);
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ bool scriptable::ScriptableMesh::isValidIndex(glm::uint32 vertexIndex, const QSt
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!attributeName.isEmpty()) {
|
if (!attributeName.isEmpty()) {
|
||||||
auto slotNum = _getSlotNumber(attributeName);
|
auto slotNum = getSlotNumber(attributeName);
|
||||||
if (slotNum < 0) {
|
if (slotNum < 0) {
|
||||||
if (context()) {
|
if (context()) {
|
||||||
context()->throwError(QString("invalid attributeName=%1").arg(attributeName));
|
context()->throwError(QString("invalid attributeName=%1").arg(attributeName));
|
||||||
|
|
|
@ -74,9 +74,8 @@ namespace scriptable {
|
||||||
QVector<scriptable::ScriptableMeshPartPointer> getMeshParts() const;
|
QVector<scriptable::ScriptableMeshPartPointer> getMeshParts() const;
|
||||||
QVariantMap getMeshExtents() const;
|
QVariantMap getMeshExtents() const;
|
||||||
|
|
||||||
// TODO: remove Q_INVOKABLE (curently exposed for debugging )
|
|
||||||
Q_INVOKABLE int _getSlotNumber(const QString& attributeName) const;
|
|
||||||
operator bool() const { return !weakMesh.expired(); }
|
operator bool() const { return !weakMesh.expired(); }
|
||||||
|
int getSlotNumber(const QString& attributeName) const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
const scriptable::ScriptableModelPointer getParentModel() const { return qobject_cast<scriptable::ScriptableModel*>(model); }
|
const scriptable::ScriptableModelPointer getParentModel() const { return qobject_cast<scriptable::ScriptableModel*>(model); }
|
||||||
|
|
|
@ -57,7 +57,7 @@ bool scriptable::ScriptableMeshPart::setVertexProperty(glm::uint32 vertexIndex,
|
||||||
if (!isValidIndex(vertexIndex, attributeName)) {
|
if (!isValidIndex(vertexIndex, attributeName)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto slotNum = parentMesh->_getSlotNumber(attributeName);
|
auto slotNum = parentMesh->getSlotNumber(attributeName);
|
||||||
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
const auto& bufferView = buffer_helpers::mesh::getBufferView(getMeshPointer(), static_cast<gpu::Stream::Slot>(slotNum));
|
||||||
return buffer_helpers::setValue(bufferView, vertexIndex, value);
|
return buffer_helpers::setValue(bufferView, vertexIndex, value);
|
||||||
}
|
}
|
||||||
|
@ -369,7 +369,7 @@ bool scriptable::ScriptableMeshPart::setIndices(const QVector<glm::uint32>& indi
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
glm::uint32 len = indices.size();
|
glm::uint32 len = indices.size();
|
||||||
if (len != getNumVertices()) {
|
if (len != getNumIndices()) {
|
||||||
context()->throwError(QString("setIndices: currently new indicies must be assign 1:1 across old indicies (indicies.size()=%1, numIndices=%2)")
|
context()->throwError(QString("setIndices: currently new indicies must be assign 1:1 across old indicies (indicies.size()=%1, numIndices=%2)")
|
||||||
.arg(len).arg(getNumIndices()));
|
.arg(len).arg(getNumIndices()));
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -44,8 +44,6 @@ namespace scriptable {
|
||||||
scriptable::ScriptableModelPointer cloneModel(const QVariantMap& options = QVariantMap());
|
scriptable::ScriptableModelPointer cloneModel(const QVariantMap& options = QVariantMap());
|
||||||
QString toString() const;
|
QString toString() const;
|
||||||
|
|
||||||
// QScriptEngine-specific wrappers
|
|
||||||
//glm::uint32 forEachMeshVertexAttribute(QScriptValue callback);
|
|
||||||
protected:
|
protected:
|
||||||
glm::uint32 getNumMeshes() { return meshes.size(); }
|
glm::uint32 getNumMeshes() { return meshes.size(); }
|
||||||
|
|
||||||
|
@ -54,5 +52,4 @@ namespace scriptable {
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(scriptable::ScriptableModelPointer)
|
Q_DECLARE_METATYPE(scriptable::ScriptableModelPointer)
|
||||||
Q_DECLARE_METATYPE(scriptable::ScriptableModelBase)
|
Q_DECLARE_METATYPE(QVector<scriptable::ScriptableModelPointer>)
|
||||||
Q_DECLARE_METATYPE(scriptable::ScriptableModelBasePointer)
|
|
||||||
|
|
|
@ -604,15 +604,20 @@ bool Model::replaceScriptableModelMeshPart(scriptable::ScriptableModelBasePointe
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
const render::ScenePointer& scene = AbstractViewStateInterface::instance()->getMain3DScene();
|
||||||
|
|
||||||
meshIndex = meshIndex >= 0 ? meshIndex : 0;
|
meshIndex = max(meshIndex, 0);
|
||||||
partIndex = partIndex >= 0 ? partIndex : 0;
|
partIndex = max(partIndex, 0);
|
||||||
|
|
||||||
if (meshIndex >= meshes.size()) {
|
if (meshIndex >= (int)meshes.size()) {
|
||||||
qDebug() << meshIndex << "meshIndex >= newModel.meshes.size()" << meshes.size();
|
qDebug() << meshIndex << "meshIndex >= newModel.meshes.size()" << meshes.size();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mesh = meshes[meshIndex].getMeshPointer();
|
auto mesh = meshes[meshIndex].getMeshPointer();
|
||||||
|
|
||||||
|
if (partIndex >= (int)mesh->getNumParts()) {
|
||||||
|
qDebug() << partIndex << "partIndex >= mesh->getNumParts()" << mesh->getNumParts();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
{
|
{
|
||||||
// update visual geometry
|
// update visual geometry
|
||||||
render::Transaction transaction;
|
render::Transaction transaction;
|
||||||
|
|
Loading…
Reference in a new issue