Revert "vec3FromScriptValue replacement attempt"

This reverts commit 584e4be008.
This commit is contained in:
ksuprynowicz 2023-04-01 17:30:02 +02:00
parent dba0925a1c
commit 43939290b2
12 changed files with 10 additions and 133 deletions

View file

@ -32,7 +32,6 @@
#include <PickManager.h>
#include <ScriptEngine.h>
#include <ScriptEngineCast.h>
#include <v8/FastScriptValueUtils.h>
#include <RenderableWebEntityItem.h>
#include "VariantMapToScriptValue.h"
@ -1144,14 +1143,9 @@ ScriptValue RayToOverlayIntersectionResultToScriptValue(ScriptEngine* engine, co
obj.setProperty("distance", value.distance);
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 surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
#endif
obj.setProperty("intersection", intersection);
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
obj.setProperty("surfaceNormal", surfaceNormal);
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
return obj;
@ -1166,19 +1160,11 @@ bool RayToOverlayIntersectionResultFromScriptValue(const ScriptValue& object, Ra
ScriptValue intersection = object.property("intersection");
if (intersection.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(intersection, value.intersection);
#else
vec3FromScriptValue(intersection, value.intersection);
#endif
}
ScriptValue surfaceNormal = object.property("surfaceNormal");
if (surfaceNormal.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
#else
vec3FromScriptValue(intersection, value.intersection);
#endif
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
}
value.extraInfo = object.property("extraInfo").toVariant().toMap();
return true;

View file

@ -17,7 +17,6 @@
#include <QThread>
#include <ScriptValueIterator.h>
#include <ScriptValueUtils.h>
#include <v8/FastScriptValueUtils.h>
const AnimVariant AnimVariant::False = AnimVariant();
@ -43,11 +42,7 @@ ScriptValue AnimVariantMap::animVariantMapToScriptValue(ScriptEngine* engine, co
target.setProperty(name, value.getString());
break;
case AnimVariant::Type::Vec3:
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
target.setProperty(name, vec3ToScriptValueFast(engine, value.getVec3()));
#else
target.setProperty(name, vec3ToScriptValue(engine, value.getVec3()));
#endif
break;
case AnimVariant::Type::Quat:
target.setProperty(name, quatToScriptValue(engine, value.getQuat()));

View file

@ -16,7 +16,6 @@
#include <ScriptValueIterator.h>
#include <ScriptValueUtils.h>
#include <ScriptEngine.h>
#include <v8/FastScriptValueUtils.h>
#include "AudioLogging.h"
@ -38,11 +37,7 @@ AudioInjectorOptions::AudioInjectorOptions() :
ScriptValue injectorOptionsToScriptValue(ScriptEngine* engine, const AudioInjectorOptions& injectorOptions) {
ScriptValue obj = engine->newObject();
if (injectorOptions.positionSet) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
obj.setProperty("position", vec3ToScriptValueFast(engine, injectorOptions.position));
#else
obj.setProperty("position", vec3ToScriptValue(engine, injectorOptions.position));
#endif
}
obj.setProperty("volume", injectorOptions.volume);
obj.setProperty("loop", injectorOptions.loop);
@ -89,11 +84,7 @@ bool injectorOptionsFromScriptValue(const ScriptValue& object, AudioInjectorOpti
it->next();
if (it->name() == "position") {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(object.property("position"), injectorOptions.position);
#else
vec3FromScriptValue(object.property("position"), injectorOptions.position);
#endif
injectorOptions.positionSet = true;
} else if (it->name() == "orientation") {
quatFromScriptValue(object.property("orientation"), injectorOptions.orientation);

View file

@ -42,7 +42,6 @@
#include <ScriptManager.h>
#include <ScriptValueIterator.h>
#include <ScriptValueUtils.h>
#include <v8/FastScriptValueUtils.h>
#include <ShapeInfo.h>
#include <AudioHelpers.h>
#include <Profile.h>
@ -3185,18 +3184,10 @@ ScriptValue RayToAvatarIntersectionResultToScriptValue(ScriptEngine* engine, con
obj.setProperty("distance", value.distance);
Q_ASSERT(value.face < 7);
obj.setProperty("face", boxFaceToString(value.face));
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
ScriptValue intersection = vec3ToScriptValueFast(engine, value.intersection);
#else
ScriptValue intersection = vec3ToScriptValue(engine, value.intersection);
#endif
obj.setProperty("intersection", intersection);
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
ScriptValue surfaceNormal = vec3ToScriptValueFast(engine, value.surfaceNormal);
#else
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
#endif
obj.setProperty("surfaceNormal", surfaceNormal);
obj.setProperty("jointIndex", value.jointIndex);
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
@ -3213,19 +3204,11 @@ bool RayToAvatarIntersectionResultFromScriptValue(const ScriptValue& object, Ray
ScriptValue intersection = object.property("intersection");
if (intersection.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(intersection, value.intersection);
#else
vec3FromScriptValue(intersection, value.intersection);
#endif
}
ScriptValue surfaceNormal = object.property("surfaceNormal");
if (surfaceNormal.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
#else
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
#endif
}
value.jointIndex = object.property("jointIndex").toInt32();
value.extraInfo = object.property("extraInfo").toVariant().toMap();

View file

@ -15,7 +15,6 @@
#include <RegisteredMetaTypes.h>
#include <ScriptValueUtils.h>
#include <v8/FastScriptValueUtils.h>
namespace controller {
@ -45,18 +44,10 @@ namespace controller {
*/
ScriptValue Pose::toScriptValue(ScriptEngine* engine, const Pose& pose) {
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("rotation", quatToScriptValue(engine, pose.rotation));
obj.setProperty("velocity", vec3ToScriptValue(engine, pose.velocity));
obj.setProperty("angularVelocity", vec3ToScriptValue(engine, pose.angularVelocity));
#endif
obj.setProperty("valid", pose.valid);
return obj;
}
@ -70,18 +61,10 @@ namespace controller {
rotation.isValid() &&
velocity.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);
quatFromScriptValue(rotation, pose.rotation);
vec3FromScriptValue(velocity, pose.velocity);
vec3FromScriptValue(angularVelocity, pose.angularVelocity);
#endif
pose.valid = true;
} else {
pose.valid = false;

View file

@ -18,7 +18,6 @@
#include <ScriptEngineLogging.h>
#include <ScriptManager.h>
#include <ScriptValueUtils.h>
#include <v8/FastScriptValueUtils.h>
#include <OBJWriter.h>
STATIC_SCRIPT_TYPES_INITIALIZER((+[](ScriptManager* manager){
@ -204,11 +203,7 @@ ScriptValue ModelScriptingInterface::getVertex(MeshProxy* meshProxy, int vertexI
}
glm::vec3 pos = vertexBufferView.get<glm::vec3>(vertexIndex);
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
return vec3ToScriptValueFast(_modelScriptEngine.get(), pos);
#else
return vec3ToScriptValue(_modelScriptEngine.get(), pos);
#endif
}

View file

@ -20,7 +20,6 @@
#include <ScriptEngine.h>
#include <ScriptValue.h>
#include <ScriptValueUtils.h>
#include <v8/FastScriptValueUtils.h>
#define APPEND_ENTITY_PROPERTY(P,V) \
if (requestedProperties.getHasProperty(P)) { \
@ -106,11 +105,7 @@
}
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); }
#endif
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 u8vec3Color_convertScriptValue(ScriptEngine* e, const glm::u8vec3& v) { return u8vec3ColorToScriptValue(e, v); }
@ -260,22 +255,14 @@ inline glm::vec2 vec2_convertFromScriptValue(const ScriptValue& v, bool& isValid
inline glm::vec3 vec3_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
isValid = true;
glm::vec3 vec3;
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(v, vec3);
#else
vec3FromScriptValue(v, vec3);
#endif
return vec3;
}
inline glm::vec3 vec3Color_convertFromScriptValue(const ScriptValue& v, bool& isValid) {
isValid = true;
glm::vec3 vec3;
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(v, vec3);
#else
vec3FromScriptValue(v, vec3);
#endif
return vec3;
}

View file

@ -1698,14 +1698,9 @@ ScriptValue RayToEntityIntersectionResultToScriptValue(ScriptEngine* engine, con
obj.setProperty("face", boxFaceToString(value.face));
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 surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
#endif
obj.setProperty("intersection", intersection);
ScriptValue surfaceNormal = vec3ToScriptValue(engine, value.surfaceNormal);
obj.setProperty("surfaceNormal", surfaceNormal);
obj.setProperty("extraInfo", engine->toScriptValue(value.extraInfo));
return obj;
@ -1722,19 +1717,11 @@ bool RayToEntityIntersectionResultFromScriptValue(const ScriptValue& object, Ray
ScriptValue intersection = object.property("intersection");
if (intersection.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(intersection, value.intersection);
#else
vec3FromScriptValue(intersection, value.intersection);
#endif
}
ScriptValue surfaceNormal = object.property("surfaceNormal");
if (surfaceNormal.isValid()) {
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(surfaceNormal, value.surfaceNormal);
#else
vec3FromScriptValue(surfaceNormal, value.surfaceNormal);
#endif
}
value.extraInfo = object.property("extraInfo").toVariant().toMap();
return true;

View file

@ -17,7 +17,6 @@
#include "ScriptEngine.h"
#include "ScriptValue.h"
#include "ScriptValueUtils.h"
#include "v8/FastScriptValueUtils.h"
static bool areFlagsSet(uint32_t flags, uint32_t mask) {
return (flags & mask) != 0;
@ -232,18 +231,10 @@ bool PointerEvent::fromScriptValue(const ScriptValue& object, PointerEvent& even
ScriptValue id = object.property("id");
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);
vec3FromScriptValue(object.property("pos3D"), event._pos3D);
vec3FromScriptValue(object.property("normal"), event._normal);
vec3FromScriptValue(object.property("direction"), event._direction);
#endif
ScriptValue button = object.property("button");
QString buttonStr = type.isString() ? button.toString() : "NoButtons";

View file

@ -33,7 +33,12 @@
#include "ScriptEngineCast.h"
#include "ScriptValueIterator.h"
#include "ScriptEngineLogging.h"
#define CONVERSIONS_OPTIMIZED_FOR_V8
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
#include "v8/FastScriptValueUtils.h"
#endif
bool isListOfStrings(const ScriptValue& arg) {
if (!arg.isArray()) {
@ -131,11 +136,7 @@ ScriptValue qVector3DToScriptValue(ScriptEngine* engine, const QVector3D& qVecto
bool qVector3DFromScriptValue(const ScriptValue& object, QVector3D& qVector3D) {
glm::vec3 vec3;
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
if (vec3FromScriptValueFast(object, vec3)) {
#else
if (vec3FromScriptValue(object, vec3)) {
#endif
qVector3D.setX(vec3.x);
qVector3D.setY(vec3.y);
qVector3D.setZ(vec3.z);
@ -484,11 +485,7 @@ QVector<glm::vec3> qVectorVec3FromScriptValue(const ScriptValue& array) {
for (int i = 0; i < length; i++) {
glm::vec3 newVec3 = glm::vec3();
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(array.property(i), newVec3);
#else
vec3FromScriptValue(array.property(i), newVec3);
#endif
newVector << newVec3;
}
return newVector;
@ -499,11 +496,7 @@ bool qVectorVec3FromScriptValue(const ScriptValue& array, QVector<glm::vec3>& ve
for (int i = 0; i < length; i++) {
glm::vec3 newVec3 = glm::vec3();
#ifdef CONVERSIONS_OPTIMIZED_FOR_V8
vec3FromScriptValueFast(array.property(i), newVec3);
#else
vec3FromScriptValue(array.property(i), newVec3);
#endif
vector << newVec3;
}
return true;

View file

@ -17,7 +17,6 @@
#include "ScriptEngine.h"
#include "ScriptValueUtils.h"
#include "ScriptValue.h"
#include "v8/FastScriptValueUtils.h"
SpatialEvent::SpatialEvent() :
locTranslation(0.0f),
@ -39,20 +38,11 @@ SpatialEvent::SpatialEvent(const SpatialEvent& event) {
ScriptValue SpatialEvent::toScriptValue(ScriptEngine* engine, const SpatialEvent& event) {
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("locRotation", quatToScriptValue(engine, event.locRotation) );
obj.setProperty("absTranslation", vec3ToScriptValue(engine, event.absTranslation));
obj.setProperty("absRotation", quatToScriptValue(engine, event.absRotation));
#endif
return obj;
}

View file

@ -9,9 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
// 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.
// Contains V8-specific implementations of th
#ifndef overte_FastScriptValueUtils_h
#define overte_FastScriptValueUtils_h
@ -21,8 +19,6 @@
#include "../ScriptValue.h"
#define CONVERSIONS_OPTIMIZED_FOR_V8
ScriptValue vec3ToScriptValueFast(ScriptEngine* engine, const glm::vec3& vec3);
bool vec3FromScriptValueFast(const ScriptValue& object, glm::vec3& vec3);