mirror of
https://github.com/overte-org/overte.git
synced 2025-06-17 14:00:14 +02:00
vec3FromScriptValue replacement attempt
This commit is contained in:
parent
3a207507bf
commit
dba0925a1c
12 changed files with 133 additions and 10 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include <PickManager.h>
|
#include <PickManager.h>
|
||||||
#include <ScriptEngine.h>
|
#include <ScriptEngine.h>
|
||||||
#include <ScriptEngineCast.h>
|
#include <ScriptEngineCast.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
|
|
||||||
#include <RenderableWebEntityItem.h>
|
#include <RenderableWebEntityItem.h>
|
||||||
#include "VariantMapToScriptValue.h"
|
#include "VariantMapToScriptValue.h"
|
||||||
|
@ -1143,9 +1144,14 @@ ScriptValue RayToOverlayIntersectionResultToScriptValue(ScriptEngine* engine, co
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
obj.setProperty("face", boxFaceToString(value.face));
|
obj.setProperty("face", boxFaceToString(value.face));
|
||||||
|
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
ScriptValue intersection = vec3ToScriptValueFast(engine, value.intersection);
|
||||||
|
ScriptValue surfaceNormal = vec3ToScriptValueFast(engine, value.surfaceNormal);
|
||||||
|
#else
|
||||||
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
||||||
obj.setProperty("intersection", intersection);
|
|
||||||
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
||||||
|
#endif
|
||||||
|
obj.setProperty("intersection", intersection);
|
||||||
obj.setProperty("surfaceNormal", surfaceNormal);
|
obj.setProperty("surfaceNormal", surfaceNormal);
|
||||||
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1160,11 +1166,19 @@ bool RayToOverlayIntersectionResultFromScriptValue(const ScriptValue& object, Ra
|
||||||
|
|
||||||
ScriptValue intersection = object.property("intersection");
|
ScriptValue intersection = object.property("intersection");
|
||||||
if (intersection.isValid()) {
|
if (intersection.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(intersection, value.intersection);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(intersection, value.intersection);
|
vec3FromScriptValue(intersection, value.intersection);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
||||||
if (surfaceNormal.isValid()) {
|
if (surfaceNormal.isValid()) {
|
||||||
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
|
||||||
|
#else
|
||||||
|
vec3FromScriptValue(intersection, value.intersection);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <ScriptValueIterator.h>
|
#include <ScriptValueIterator.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
|
|
||||||
const AnimVariant AnimVariant::False = AnimVariant();
|
const AnimVariant AnimVariant::False = AnimVariant();
|
||||||
|
|
||||||
|
@ -42,7 +43,11 @@ ScriptValue AnimVariantMap::animVariantMapToScriptValue(ScriptEngine* engine, co
|
||||||
target.setProperty(name, value.getString());
|
target.setProperty(name, value.getString());
|
||||||
break;
|
break;
|
||||||
case AnimVariant::Type::Vec3:
|
case AnimVariant::Type::Vec3:
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
target.setProperty(name, vec3ToScriptValueFast(engine, value.getVec3()));
|
||||||
|
#else
|
||||||
target.setProperty(name, vec3ToScriptValue(engine, value.getVec3()));
|
target.setProperty(name, vec3ToScriptValue(engine, value.getVec3()));
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case AnimVariant::Type::Quat:
|
case AnimVariant::Type::Quat:
|
||||||
target.setProperty(name, quatToScriptValue(engine, value.getQuat()));
|
target.setProperty(name, quatToScriptValue(engine, value.getQuat()));
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <ScriptValueIterator.h>
|
#include <ScriptValueIterator.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
#include <ScriptEngine.h>
|
#include <ScriptEngine.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
|
|
||||||
#include "AudioLogging.h"
|
#include "AudioLogging.h"
|
||||||
|
|
||||||
|
@ -37,7 +38,11 @@ AudioInjectorOptions::AudioInjectorOptions() :
|
||||||
ScriptValue injectorOptionsToScriptValue(ScriptEngine* engine, const AudioInjectorOptions& injectorOptions) {
|
ScriptValue injectorOptionsToScriptValue(ScriptEngine* engine, const AudioInjectorOptions& injectorOptions) {
|
||||||
ScriptValue obj = engine->newObject();
|
ScriptValue obj = engine->newObject();
|
||||||
if (injectorOptions.positionSet) {
|
if (injectorOptions.positionSet) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
obj.setProperty("position", vec3ToScriptValueFast(engine, injectorOptions.position));
|
||||||
|
#else
|
||||||
obj.setProperty("position", vec3ToScriptValue(engine, injectorOptions.position));
|
obj.setProperty("position", vec3ToScriptValue(engine, injectorOptions.position));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
obj.setProperty("volume", injectorOptions.volume);
|
obj.setProperty("volume", injectorOptions.volume);
|
||||||
obj.setProperty("loop", injectorOptions.loop);
|
obj.setProperty("loop", injectorOptions.loop);
|
||||||
|
@ -84,7 +89,11 @@ bool injectorOptionsFromScriptValue(const ScriptValue& object, AudioInjectorOpti
|
||||||
it->next();
|
it->next();
|
||||||
|
|
||||||
if (it->name() == "position") {
|
if (it->name() == "position") {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(object.property("position"), injectorOptions.position);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(object.property("position"), injectorOptions.position);
|
vec3FromScriptValue(object.property("position"), injectorOptions.position);
|
||||||
|
#endif
|
||||||
injectorOptions.positionSet = true;
|
injectorOptions.positionSet = true;
|
||||||
} else if (it->name() == "orientation") {
|
} else if (it->name() == "orientation") {
|
||||||
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
|
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#include <ScriptManager.h>
|
#include <ScriptManager.h>
|
||||||
#include <ScriptValueIterator.h>
|
#include <ScriptValueIterator.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
#include <ShapeInfo.h>
|
#include <ShapeInfo.h>
|
||||||
#include <AudioHelpers.h>
|
#include <AudioHelpers.h>
|
||||||
#include <Profile.h>
|
#include <Profile.h>
|
||||||
|
@ -3184,10 +3185,18 @@ ScriptValue RayToAvatarIntersectionResultToScriptValue(ScriptEngine* engine, con
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
Q_ASSERT(value.face < 7);
|
Q_ASSERT(value.face < 7);
|
||||||
obj.setProperty("face", boxFaceToString(value.face));
|
obj.setProperty("face", boxFaceToString(value.face));
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
ScriptValue intersection = vec3ToScriptValueFast(engine, value.intersection);
|
||||||
|
#else
|
||||||
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
||||||
|
#endif
|
||||||
|
|
||||||
obj.setProperty("intersection", intersection);
|
obj.setProperty("intersection", intersection);
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
ScriptValue surfaceNormal = vec3ToScriptValueFast(engine, value.surfaceNormal);
|
||||||
|
#else
|
||||||
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
||||||
|
#endif
|
||||||
obj.setProperty("surfaceNormal", surfaceNormal);
|
obj.setProperty("surfaceNormal", surfaceNormal);
|
||||||
obj.setProperty("jointIndex", value.jointIndex);
|
obj.setProperty("jointIndex", value.jointIndex);
|
||||||
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
||||||
|
@ -3204,11 +3213,19 @@ bool RayToAvatarIntersectionResultFromScriptValue(const ScriptValue& object, Ray
|
||||||
|
|
||||||
ScriptValue intersection = object.property("intersection");
|
ScriptValue intersection = object.property("intersection");
|
||||||
if (intersection.isValid()) {
|
if (intersection.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(intersection, value.intersection);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(intersection, value.intersection);
|
vec3FromScriptValue(intersection, value.intersection);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
||||||
if (surfaceNormal.isValid()) {
|
if (surfaceNormal.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
|
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
value.jointIndex = object.property("jointIndex").toInt32();
|
value.jointIndex = object.property("jointIndex").toInt32();
|
||||||
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include <RegisteredMetaTypes.h>
|
#include <RegisteredMetaTypes.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
|
|
||||||
namespace controller {
|
namespace controller {
|
||||||
|
|
||||||
|
@ -44,10 +45,18 @@ namespace controller {
|
||||||
*/
|
*/
|
||||||
ScriptValue Pose::toScriptValue(ScriptEngine* engine, const Pose& pose) {
|
ScriptValue Pose::toScriptValue(ScriptEngine* engine, const Pose& pose) {
|
||||||
ScriptValue obj = engine->newObject();
|
ScriptValue obj = engine->newObject();
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
obj.setProperty("translation", vec3ToScriptValueFast(engine, pose.translation));
|
||||||
|
//V8TODO: Optimize
|
||||||
|
obj.setProperty("rotation", quatToScriptValue(engine, pose.rotation));
|
||||||
|
obj.setProperty("velocity", vec3ToScriptValueFast(engine, pose.velocity));
|
||||||
|
obj.setProperty("angularVelocity", vec3ToScriptValueFast(engine, pose.angularVelocity));
|
||||||
|
#else
|
||||||
obj.setProperty("translation", vec3ToScriptValue(engine, pose.translation));
|
obj.setProperty("translation", vec3ToScriptValue(engine, pose.translation));
|
||||||
obj.setProperty("rotation", quatToScriptValue(engine, pose.rotation));
|
obj.setProperty("rotation", quatToScriptValue(engine, pose.rotation));
|
||||||
obj.setProperty("velocity", vec3ToScriptValue(engine, pose.velocity));
|
obj.setProperty("velocity", vec3ToScriptValue(engine, pose.velocity));
|
||||||
obj.setProperty("angularVelocity", vec3ToScriptValue(engine, pose.angularVelocity));
|
obj.setProperty("angularVelocity", vec3ToScriptValue(engine, pose.angularVelocity));
|
||||||
|
#endif
|
||||||
obj.setProperty("valid", pose.valid);
|
obj.setProperty("valid", pose.valid);
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -61,10 +70,18 @@ namespace controller {
|
||||||
rotation.isValid() &&
|
rotation.isValid() &&
|
||||||
velocity.isValid() &&
|
velocity.isValid() &&
|
||||||
angularVelocity.isValid()) {
|
angularVelocity.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(translation, pose.translation);
|
||||||
|
//V8TODO: optimize
|
||||||
|
quatFromScriptValue(rotation, pose.rotation);
|
||||||
|
vec3FromScriptValueFast(velocity, pose.velocity);
|
||||||
|
vec3FromScriptValueFast(angularVelocity, pose.angularVelocity);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(translation, pose.translation);
|
vec3FromScriptValue(translation, pose.translation);
|
||||||
quatFromScriptValue(rotation, pose.rotation);
|
quatFromScriptValue(rotation, pose.rotation);
|
||||||
vec3FromScriptValue(velocity, pose.velocity);
|
vec3FromScriptValue(velocity, pose.velocity);
|
||||||
vec3FromScriptValue(angularVelocity, pose.angularVelocity);
|
vec3FromScriptValue(angularVelocity, pose.angularVelocity);
|
||||||
|
#endif
|
||||||
pose.valid = true;
|
pose.valid = true;
|
||||||
} else {
|
} else {
|
||||||
pose.valid = false;
|
pose.valid = false;
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <ScriptEngineLogging.h>
|
#include <ScriptEngineLogging.h>
|
||||||
#include <ScriptManager.h>
|
#include <ScriptManager.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
#include <OBJWriter.h>
|
#include <OBJWriter.h>
|
||||||
|
|
||||||
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
|
||||||
|
@ -203,7 +204,11 @@ ScriptValue ModelScriptingInterface::getVertex(MeshProxy* meshProxy, int vertexI
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 pos = vertexBufferView.get<glm::vec3>(vertexIndex);
|
glm::vec3 pos = vertexBufferView.get<glm::vec3>(vertexIndex);
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
return vec3ToScriptValueFast(_modelScriptEngine.get(), pos);
|
||||||
|
#else
|
||||||
return vec3ToScriptValue(_modelScriptEngine.get(), pos);
|
return vec3ToScriptValue(_modelScriptEngine.get(), pos);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <ScriptEngine.h>
|
#include <ScriptEngine.h>
|
||||||
#include <ScriptValue.h>
|
#include <ScriptValue.h>
|
||||||
#include <ScriptValueUtils.h>
|
#include <ScriptValueUtils.h>
|
||||||
|
#include <v8/FastScriptValueUtils.h>
|
||||||
|
|
||||||
#define APPEND_ENTITY_PROPERTY(P,V) \
|
#define APPEND_ENTITY_PROPERTY(P,V) \
|
||||||
if (requestedProperties.getHasProperty(P)) { \
|
if (requestedProperties.getHasProperty(P)) { \
|
||||||
|
@ -105,7 +106,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::vec2& v) { return vec2ToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::vec2& v) { return vec2ToScriptValue(e, v); }
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::vec3& v) { return vec3ToScriptValueFast(e, v); }
|
||||||
|
#else
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::vec3& v) { return vec3ToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::vec3& v) { return vec3ToScriptValue(e, v); }
|
||||||
|
#endif
|
||||||
inline ScriptValue vec3Color_convertScriptValue(ScriptEngine* e, const glm::vec3& v) { return vec3ColorToScriptValue(e, v); }
|
inline ScriptValue vec3Color_convertScriptValue(ScriptEngine* e, const glm::vec3& v) { return vec3ColorToScriptValue(e, v); }
|
||||||
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::u8vec3& v) { return u8vec3ToScriptValue(e, v); }
|
inline ScriptValue convertScriptValue(ScriptEngine* e, const glm::u8vec3& v) { return u8vec3ToScriptValue(e, v); }
|
||||||
inline ScriptValue u8vec3Color_convertScriptValue(ScriptEngine* e, const glm::u8vec3& v) { return u8vec3ColorToScriptValue(e, v); }
|
inline ScriptValue u8vec3Color_convertScriptValue(ScriptEngine* e, const glm::u8vec3& v) { return u8vec3ColorToScriptValue(e, v); }
|
||||||
|
@ -255,14 +260,22 @@ inline glm::vec2 vec2_convertFromScriptValue(const ScriptValue& v, bool& isValid
|
||||||
inline glm::vec3 vec3_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
inline glm::vec3 vec3_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
glm::vec3 vec3;
|
glm::vec3 vec3;
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(v, vec3);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(v, vec3);
|
vec3FromScriptValue(v, vec3);
|
||||||
|
#endif
|
||||||
return vec3;
|
return vec3;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline glm::vec3 vec3Color_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
inline glm::vec3 vec3Color_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
|
||||||
isValid = true;
|
isValid = true;
|
||||||
glm::vec3 vec3;
|
glm::vec3 vec3;
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(v, vec3);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(v, vec3);
|
vec3FromScriptValue(v, vec3);
|
||||||
|
#endif
|
||||||
return vec3;
|
return vec3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1698,9 +1698,14 @@ ScriptValue RayToEntityIntersectionResultToScriptValue(ScriptEngine* engine, con
|
||||||
obj.setProperty("face", boxFaceToString(value.face));
|
obj.setProperty("face", boxFaceToString(value.face));
|
||||||
Q_ASSERT(value.face < 7);
|
Q_ASSERT(value.face < 7);
|
||||||
|
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
ScriptValue intersection = vec3ToScriptValueFast(engine, value.intersection);
|
||||||
|
ScriptValue surfaceNormal = vec3ToScriptValueFast(engine, value.surfaceNormal);
|
||||||
|
#else
|
||||||
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
|
||||||
obj.setProperty("intersection", intersection);
|
|
||||||
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
|
||||||
|
#endif
|
||||||
|
obj.setProperty("intersection", intersection);
|
||||||
obj.setProperty("surfaceNormal", surfaceNormal);
|
obj.setProperty("surfaceNormal", surfaceNormal);
|
||||||
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1717,11 +1722,19 @@ bool RayToEntityIntersectionResultFromScriptValue(const ScriptValue& object, Ray
|
||||||
|
|
||||||
ScriptValue intersection = object.property("intersection");
|
ScriptValue intersection = object.property("intersection");
|
||||||
if (intersection.isValid()) {
|
if (intersection.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(intersection, value.intersection);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(intersection, value.intersection);
|
vec3FromScriptValue(intersection, value.intersection);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
ScriptValue surfaceNormal = object.property("surfaceNormal");
|
||||||
if (surfaceNormal.isValid()) {
|
if (surfaceNormal.isValid()) {
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
|
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
value.extraInfo = object.property("extraInfo").toVariant().toMap();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "ScriptEngine.h"
|
#include "ScriptEngine.h"
|
||||||
#include "ScriptValue.h"
|
#include "ScriptValue.h"
|
||||||
#include "ScriptValueUtils.h"
|
#include "ScriptValueUtils.h"
|
||||||
|
#include "v8/FastScriptValueUtils.h"
|
||||||
|
|
||||||
static bool areFlagsSet(uint32_t flags, uint32_t mask) {
|
static bool areFlagsSet(uint32_t flags, uint32_t mask) {
|
||||||
return (flags & mask) != 0;
|
return (flags & mask) != 0;
|
||||||
|
@ -231,10 +232,18 @@ bool PointerEvent::fromScriptValue(const ScriptValue& object, PointerEvent& even
|
||||||
ScriptValue id = object.property("id");
|
ScriptValue id = object.property("id");
|
||||||
event._id = id.isNumber() ? (uint32_t)id.toNumber() : 0;
|
event._id = id.isNumber() ? (uint32_t)id.toNumber() : 0;
|
||||||
|
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
//V8TODO: optimize
|
||||||
|
vec2FromScriptValue(object.property("pos2D"), event._pos2D);
|
||||||
|
vec3FromScriptValueFast(object.property("pos3D"), event._pos3D);
|
||||||
|
vec3FromScriptValueFast(object.property("normal"), event._normal);
|
||||||
|
vec3FromScriptValueFast(object.property("direction"), event._direction);
|
||||||
|
#else
|
||||||
vec2FromScriptValue(object.property("pos2D"), event._pos2D);
|
vec2FromScriptValue(object.property("pos2D"), event._pos2D);
|
||||||
vec3FromScriptValue(object.property("pos3D"), event._pos3D);
|
vec3FromScriptValue(object.property("pos3D"), event._pos3D);
|
||||||
vec3FromScriptValue(object.property("normal"), event._normal);
|
vec3FromScriptValue(object.property("normal"), event._normal);
|
||||||
vec3FromScriptValue(object.property("direction"), event._direction);
|
vec3FromScriptValue(object.property("direction"), event._direction);
|
||||||
|
#endif
|
||||||
|
|
||||||
ScriptValue button = object.property("button");
|
ScriptValue button = object.property("button");
|
||||||
QString buttonStr = type.isString() ? button.toString() : "NoButtons";
|
QString buttonStr = type.isString() ? button.toString() : "NoButtons";
|
||||||
|
|
|
@ -33,12 +33,7 @@
|
||||||
#include "ScriptEngineCast.h"
|
#include "ScriptEngineCast.h"
|
||||||
#include "ScriptValueIterator.h"
|
#include "ScriptValueIterator.h"
|
||||||
#include "ScriptEngineLogging.h"
|
#include "ScriptEngineLogging.h"
|
||||||
|
|
||||||
#define CONVERSIONS_OPTIMIZED_FOR_V8
|
|
||||||
|
|
||||||
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
|
||||||
#include "v8/FastScriptValueUtils.h"
|
#include "v8/FastScriptValueUtils.h"
|
||||||
#endif
|
|
||||||
|
|
||||||
bool isListOfStrings(const ScriptValue& arg) {
|
bool isListOfStrings(const ScriptValue& arg) {
|
||||||
if (!arg.isArray()) {
|
if (!arg.isArray()) {
|
||||||
|
@ -136,7 +131,11 @@ ScriptValue qVector3DToScriptValue(ScriptEngine* engine, const QVector3D& qVecto
|
||||||
|
|
||||||
bool qVector3DFromScriptValue(const ScriptValue& object, QVector3D& qVector3D) {
|
bool qVector3DFromScriptValue(const ScriptValue& object, QVector3D& qVector3D) {
|
||||||
glm::vec3 vec3;
|
glm::vec3 vec3;
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
if (vec3FromScriptValueFast(object, vec3)) {
|
||||||
|
#else
|
||||||
if (vec3FromScriptValue(object, vec3)) {
|
if (vec3FromScriptValue(object, vec3)) {
|
||||||
|
#endif
|
||||||
qVector3D.setX(vec3.x);
|
qVector3D.setX(vec3.x);
|
||||||
qVector3D.setY(vec3.y);
|
qVector3D.setY(vec3.y);
|
||||||
qVector3D.setZ(vec3.z);
|
qVector3D.setZ(vec3.z);
|
||||||
|
@ -485,7 +484,11 @@ QVector<glm::vec3> qVectorVec3FromScriptValue(const ScriptValue& array) {
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
glm::vec3 newVec3 = glm::vec3();
|
glm::vec3 newVec3 = glm::vec3();
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(array.property(i), newVec3);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(array.property(i), newVec3);
|
vec3FromScriptValue(array.property(i), newVec3);
|
||||||
|
#endif
|
||||||
newVector << newVec3;
|
newVector << newVec3;
|
||||||
}
|
}
|
||||||
return newVector;
|
return newVector;
|
||||||
|
@ -496,7 +499,11 @@ bool qVectorVec3FromScriptValue(const ScriptValue& array, QVector<glm::vec3>& ve
|
||||||
|
|
||||||
for (int i = 0; i < length; i++) {
|
for (int i = 0; i < length; i++) {
|
||||||
glm::vec3 newVec3 = glm::vec3();
|
glm::vec3 newVec3 = glm::vec3();
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
vec3FromScriptValueFast(array.property(i), newVec3);
|
||||||
|
#else
|
||||||
vec3FromScriptValue(array.property(i), newVec3);
|
vec3FromScriptValue(array.property(i), newVec3);
|
||||||
|
#endif
|
||||||
vector << newVec3;
|
vector << newVec3;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "ScriptEngine.h"
|
#include "ScriptEngine.h"
|
||||||
#include "ScriptValueUtils.h"
|
#include "ScriptValueUtils.h"
|
||||||
#include "ScriptValue.h"
|
#include "ScriptValue.h"
|
||||||
|
#include "v8/FastScriptValueUtils.h"
|
||||||
|
|
||||||
SpatialEvent::SpatialEvent() :
|
SpatialEvent::SpatialEvent() :
|
||||||
locTranslation(0.0f),
|
locTranslation(0.0f),
|
||||||
|
@ -38,10 +39,19 @@ SpatialEvent::SpatialEvent(const SpatialEvent& event) {
|
||||||
ScriptValue SpatialEvent::toScriptValue(ScriptEngine* engine, const SpatialEvent& event) {
|
ScriptValue SpatialEvent::toScriptValue(ScriptEngine* engine, const SpatialEvent& event) {
|
||||||
ScriptValue obj = engine->newObject();
|
ScriptValue obj = engine->newObject();
|
||||||
|
|
||||||
|
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
obj.setProperty("locTranslation", vec3ToScriptValueFast(engine, event.locTranslation) );
|
||||||
|
//V8TODO: optimize
|
||||||
|
obj.setProperty("locRotation", quatToScriptValue(engine, event.locRotation) );
|
||||||
|
obj.setProperty("absTranslation", vec3ToScriptValueFast(engine, event.absTranslation));
|
||||||
|
//V8TODO: optimize
|
||||||
|
obj.setProperty("absRotation", quatToScriptValue(engine, event.absRotation));
|
||||||
|
#else
|
||||||
obj.setProperty("locTranslation", vec3ToScriptValue(engine, event.locTranslation) );
|
obj.setProperty("locTranslation", vec3ToScriptValue(engine, event.locTranslation) );
|
||||||
obj.setProperty("locRotation", quatToScriptValue(engine, event.locRotation) );
|
obj.setProperty("locRotation", quatToScriptValue(engine, event.locRotation) );
|
||||||
obj.setProperty("absTranslation", vec3ToScriptValue(engine, event.absTranslation));
|
obj.setProperty("absTranslation", vec3ToScriptValue(engine, event.absTranslation));
|
||||||
obj.setProperty("absRotation", quatToScriptValue(engine, event.absRotation));
|
obj.setProperty("absRotation", quatToScriptValue(engine, event.absRotation));
|
||||||
|
#endif
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
|
|
||||||
// Contains V8-specific implementations of th
|
// Contains V8-specific implementations of the function converting Overte datatypes to and from script values.
|
||||||
|
// These are used instead of generic implementations if CONVERSIONS_OPTIMIZED_FOR_V8 is defined.
|
||||||
|
// V8-specific implementations can make script engine several times faster.
|
||||||
|
|
||||||
#ifndef overte_FastScriptValueUtils_h
|
#ifndef overte_FastScriptValueUtils_h
|
||||||
#define overte_FastScriptValueUtils_h
|
#define overte_FastScriptValueUtils_h
|
||||||
|
@ -19,6 +21,8 @@
|
||||||
|
|
||||||
#include "../ScriptValue.h"
|
#include "../ScriptValue.h"
|
||||||
|
|
||||||
|
#define CONVERSIONS_OPTIMIZED_FOR_V8
|
||||||
|
|
||||||
ScriptValue vec3ToScriptValueFast(ScriptEngine* engine, const glm::vec3& vec3);
|
ScriptValue vec3ToScriptValueFast(ScriptEngine* engine, const glm::vec3& vec3);
|
||||||
|
|
||||||
bool vec3FromScriptValueFast(const ScriptValue& object, glm::vec3& vec3);
|
bool vec3FromScriptValueFast(const ScriptValue& object, glm::vec3& vec3);
|
||||||
|
|
Loading…
Reference in a new issue