Showing the changes to libraries/shared/src/RegisteredMetaTypes.cpp (1 of 11 files). Show all
Unified · Split
| @@ -16,6 +16,7 @@ static int vec2MetaTypeId = qRegisterMetaType<glm::vec2>(); · 15 unmodified lines | |||
| 16 | static int quatMetaTypeId = qRegisterMetaType<glm::quat>(); | 16 | static int quatMetaTypeId = qRegisterMetaType<glm::quat>(); |
| 17 | static int xColorMetaTypeId = qRegisterMetaType<xColor>(); | 17 | static int xColorMetaTypeId = qRegisterMetaType<xColor>(); |
| 18 | static int pickRayMetaTypeId = qRegisterMetaType<PickRay>(); | 18 | static int pickRayMetaTypeId = qRegisterMetaType<PickRay>(); |
| 19 | static int collisionMetaTypeId = qRegisterMetaType<CollisionInfo>(); | ||
| 19 | 20 | ||
| 20 | void registerMetaTypes(QScriptEngine* engine) { | 21 | void registerMetaTypes(QScriptEngine* engine) { |
| 21 | qScriptRegisterMetaType(engine, vec4toScriptValue, vec4FromScriptValue); | 22 | qScriptRegisterMetaType(engine, vec4toScriptValue, vec4FromScriptValue); |
| @@ -24,6 +25,7 @@ void registerMetaTypes(QScriptEngine* engine) { · 2 unmodified lines | |||
| 24 | qScriptRegisterMetaType(engine, quatToScriptValue, quatFromScriptValue); | 25 | qScriptRegisterMetaType(engine, quatToScriptValue, quatFromScriptValue); |
| 25 | qScriptRegisterMetaType(engine, xColorToScriptValue, xColorFromScriptValue); | 26 | qScriptRegisterMetaType(engine, xColorToScriptValue, xColorFromScriptValue); |
| 26 | qScriptRegisterMetaType(engine, pickRayToScriptValue, pickRayFromScriptValue); | 27 | qScriptRegisterMetaType(engine, pickRayToScriptValue, pickRayFromScriptValue); |
| 28 | qScriptRegisterMetaType(engine, collisionToScriptValue, collisionFromScriptValue); | ||
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | QScriptValue vec4toScriptValue(QScriptEngine* engine, const glm::vec4& vec4) { | 31 | QScriptValue vec4toScriptValue(QScriptEngine* engine, const glm::vec4& vec4) { |
| @@ -122,3 +124,14 @@ void pickRayFromScriptValue(const QScriptValue& object, PickRay& pickRay) { · 92 unmodified lines | |||
| 122 | } | 124 | } |
| 123 | } | 125 | } |
| 124 | 126 | ||
| 127 | QScriptValue collisionToScriptValue(QScriptEngine* engine, const CollisionInfo& collision) { | ||
| 128 | QScriptValue obj = engine->newObject(); | ||
| 129 | obj.setProperty("penetration", vec3toScriptValue(engine, collision._penetration)); | ||
| 130 | obj.setProperty("contactPoint", vec3toScriptValue(engine, collision._contactPoint)); | ||
| 131 | return obj; | ||
| 132 | } | ||
| 133 | |||
| 134 | void collisionFromScriptValue(const QScriptValue &object, CollisionInfo& collision) { | ||
| 135 | // TODO: implement this when we know what it means to accept collision events from JS | ||
| 136 | } | ||
| 137 | |||