History

change Model api in anticipation of more than just PolyVox being able to give meshes to javascript

Seth Alves committed 9 years ago

Commit ce9bb431 parent b5786be10 files · +52 −59Browse files

Showing the changes to libraries/script-engine/src/ModelScriptingInterface.cpp (1 of 10 files). Show all

Unified · Split

libraries/script-engine/src/ModelScriptingInterface.cpp+1−23
@@ -18,30 +18,8 @@ · 17 unmodified lines
18 18
19ModelScriptingInterface::ModelScriptingInterface(QObject* parent) : QObject(parent) {19ModelScriptingInterface::ModelScriptingInterface(QObject* parent) : QObject(parent) {
20 _modelScriptEngine = qobject_cast<ScriptEngine*>(parent);20 _modelScriptEngine = qobject_cast<ScriptEngine*>(parent);
21}
22
23QScriptValue meshToScriptValue(QScriptEngine* engine, MeshProxy* const &in) {
24 return engine->newQObject(in, QScriptEngine::QtOwnership,
25 QScriptEngine::ExcludeDeleteLater | QScriptEngine::ExcludeChildObjects);
26}
27
28void meshFromScriptValue(const QScriptValue& value, MeshProxy* &out) {
29 out = qobject_cast<MeshProxy*>(value.toQObject());
30}
31
32QScriptValue meshesToScriptValue(QScriptEngine* engine, const MeshProxyList &in) {
33 return engine->toScriptValue(in);
34}
35 21
36void meshesFromScriptValue(const QScriptValue& value, MeshProxyList &out) {22 qScriptRegisterSequenceMetaType<QList<MeshProxy*>>(_modelScriptEngine);
37 QScriptValueIterator itr(value);
38 while(itr.hasNext()) {
39 itr.next();
40 MeshProxy* meshProxy = qscriptvalue_cast<MeshProxyList::value_type>(itr.value());
41 if (meshProxy) {
42 out.append(meshProxy);
43 }
44 }
45}23}
46 24
47QString ModelScriptingInterface::meshToOBJ(MeshProxyList in) {25QString ModelScriptingInterface::meshToOBJ(MeshProxyList in) {