mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 01:24:36 +02:00
forgot a file
This commit is contained in:
parent
ba0c9e405a
commit
bb1c556c91
1 changed files with 54 additions and 0 deletions
54
libraries/model/src/model/MeshProxy.cpp
Normal file
54
libraries/model/src/model/MeshProxy.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
//
|
||||||
|
// MeshProxy.cpp
|
||||||
|
// libraries/model/src/model/
|
||||||
|
//
|
||||||
|
// Created by Seth Alves on 2017-3-22.
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "MeshProxy.h"
|
||||||
|
|
||||||
|
|
||||||
|
QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in) {
|
||||||
|
return engine->newQObject(in, QScriptEngine::QtOwnership,
|
||||||
|
QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) {
|
||||||
|
out = qobject_cast<MeshProxy*>(value.toQObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) {
|
||||||
|
// QScriptValueList result;
|
||||||
|
QScriptValue result = engine->newArray();
|
||||||
|
int i = 0;
|
||||||
|
foreach (MeshProxy* const meshProxy, in) {
|
||||||
|
qDebug() << "meshesToScriptValue adding mesh: " << (void*)meshProxy;
|
||||||
|
// result.setProperty(i++, QScriptValue(engine, meshProxy));
|
||||||
|
result.setProperty(i++, meshToScriptValue(engine, meshProxy));
|
||||||
|
// result.setProperty(QString::number(i++), QScriptValue(meshProxy));
|
||||||
|
// result[i] = QScriptValue(meshProxy);
|
||||||
|
// result << QScriptValue(meshProxy);
|
||||||
|
}
|
||||||
|
// result.setProperty("length", i);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out) {
|
||||||
|
QScriptValueIterator itr(value);
|
||||||
|
|
||||||
|
qDebug() << "in meshesFromScriptValue, value.length =" << value.property("length").toInt32();
|
||||||
|
|
||||||
|
while(itr.hasNext()) {
|
||||||
|
itr.next();
|
||||||
|
MeshProxy* meshProxy = qscriptvalue_cast<MeshProxyList::value_type>(itr.value());
|
||||||
|
if (meshProxy) {
|
||||||
|
out.append(meshProxy);
|
||||||
|
} else {
|
||||||
|
qDebug() << "null meshProxy";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue