mirror of
https://github.com/overte-org/overte.git
synced 2025-04-25 03:54:09 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into rationalize-rig-settings
This commit is contained in:
commit
841e23e29d
8 changed files with 113 additions and 160 deletions
|
@ -144,7 +144,7 @@ controller.prototype.checkPointer = function() {
|
|||
Script.setTimeout(function() {
|
||||
var props = Entities.getEntityProperties(self.pointer);
|
||||
Entities.editEntity(self.pointer, {
|
||||
lifetime: props.age + EXTRA_TIME
|
||||
lifetime: props.age + EXTRA_TIME + LIFETIME
|
||||
});
|
||||
self.checkPointer();
|
||||
}, POINTER_CHECK_TIME);
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
(function() {
|
||||
Script.include("../libraries/utils.js");
|
||||
// Script.include("../libraries/utils.js");
|
||||
//Need absolute path for now, for testing before PR merge and s3 cloning. Will change post-merge
|
||||
Script.include("https://hifi-public.s3.amazonaws.com/scripts/libraries/utils.js");
|
||||
GRAB_FRAME_USER_DATA_KEY = "grabFrame";
|
||||
this.userData = {};
|
||||
|
||||
|
@ -18,13 +20,14 @@
|
|||
|
||||
var self = this;
|
||||
|
||||
var stopSetting = JSON.stringify({
|
||||
running: false
|
||||
});
|
||||
var startSetting = JSON.stringify({
|
||||
running: true
|
||||
});
|
||||
|
||||
var timeSinceLastMoved = 0;
|
||||
var RESET_TIME_THRESHOLD = 5;
|
||||
var DISTANCE_FROM_HOME_THRESHOLD = 0.5;
|
||||
var HOME_POSITION = {
|
||||
x: 549.12,
|
||||
y: 495.555,
|
||||
z: 503.77
|
||||
};
|
||||
this.getUserData = function() {
|
||||
|
||||
|
||||
|
@ -40,14 +43,26 @@
|
|||
}
|
||||
|
||||
this.update = function(deltaTime) {
|
||||
self.properties = Entities.getEntityProperties(self.entityId);
|
||||
self.getUserData();
|
||||
self.properties = Entities.getEntityProperties(self.entityId);
|
||||
|
||||
if (Vec3.length(self.properties.velocity) < 0.1 && Vec3.distance(HOME_POSITION, self.properties.position) > DISTANCE_FROM_HOME_THRESHOLD) {
|
||||
timeSinceLastMoved += deltaTime;
|
||||
if (timeSinceLastMoved > RESET_TIME_THRESHOLD) {
|
||||
self.reset();
|
||||
timeSinceLastMoved = 0;
|
||||
}
|
||||
} else {
|
||||
timeSinceLastMoved = 0;
|
||||
}
|
||||
|
||||
if (self.userData.grabKey && self.userData.grabKey.activated === true) {
|
||||
if (self.activated !== true) {
|
||||
//We were just grabbed, so create a particle system
|
||||
self.grab();
|
||||
Entities.editEntity(self.paintStream, {
|
||||
animationSettings: startSetting
|
||||
});
|
||||
self.activated = true;
|
||||
}
|
||||
//Move emitter to where entity is always when its activated
|
||||
self.sprayStream();
|
||||
|
@ -59,6 +74,54 @@
|
|||
}
|
||||
}
|
||||
|
||||
this.grab = function() {
|
||||
self.activated = true;
|
||||
var animationSettings = JSON.stringify({
|
||||
fps: 30,
|
||||
loop: true,
|
||||
firstFrame: 1,
|
||||
lastFrame: 10000,
|
||||
running: true
|
||||
});
|
||||
|
||||
this.paintStream = Entities.addEntity({
|
||||
type: "ParticleEffect",
|
||||
animationSettings: animationSettings,
|
||||
position: this.properties.position,
|
||||
textures: "https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png",
|
||||
emitVelocity: ZERO_VEC,
|
||||
emitAcceleration: ZERO_VEC,
|
||||
velocitySpread: {
|
||||
x: .02,
|
||||
y: .02,
|
||||
z: 0.02
|
||||
},
|
||||
emitRate: 100,
|
||||
particleRadius: 0.01,
|
||||
color: {
|
||||
red: 170,
|
||||
green: 20,
|
||||
blue: 150
|
||||
},
|
||||
lifetime: 500, //probably wont be holding longer than this straight
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.letGo = function() {
|
||||
self.activated = false;
|
||||
Entities.deleteEntity(this.paintStream);
|
||||
}
|
||||
|
||||
this.reset = function() {
|
||||
Entities.editEntity(self.entityId, {
|
||||
position: HOME_POSITION,
|
||||
rotation: Quat.fromPitchYawRollDegrees(0, 0, 0),
|
||||
angularVelocity: ZERO_VEC,
|
||||
velocity: ZERO_VEC
|
||||
});
|
||||
}
|
||||
|
||||
this.sprayStream = function() {
|
||||
var forwardVec = Quat.getFront(self.properties.rotation);
|
||||
forwardVec = Vec3.multiplyQbyV(Quat.fromPitchYawRollDegrees(0, 90, 0), forwardVec);
|
||||
|
@ -134,9 +197,9 @@
|
|||
blue: randInt(190, 250)
|
||||
},
|
||||
dimensions: {
|
||||
x: 5,
|
||||
y: 5,
|
||||
z: 5
|
||||
x: 50,
|
||||
y: 50,
|
||||
z: 50
|
||||
},
|
||||
lifetime: 100
|
||||
});
|
||||
|
@ -167,41 +230,8 @@
|
|||
}
|
||||
setEntityCustomData(GRAB_FRAME_USER_DATA_KEY, this.entityId, data);
|
||||
}
|
||||
this.initialize();
|
||||
}
|
||||
|
||||
this.initialize = function() {
|
||||
var animationSettings = JSON.stringify({
|
||||
fps: 30,
|
||||
loop: true,
|
||||
firstFrame: 1,
|
||||
lastFrame: 10000,
|
||||
running: false
|
||||
});
|
||||
|
||||
this.paintStream = Entities.addEntity({
|
||||
type: "ParticleEffect",
|
||||
animationSettings: animationSettings,
|
||||
position: this.properties.position,
|
||||
textures: "https://raw.githubusercontent.com/ericrius1/SantasLair/santa/assets/smokeparticle.png",
|
||||
emitVelocity: ZERO_VEC,
|
||||
emitAcceleration: ZERO_VEC,
|
||||
velocitySpread: {
|
||||
x: .02,
|
||||
y: .02,
|
||||
z: 0.02
|
||||
},
|
||||
emitRate: 100,
|
||||
particleRadius: 0.01,
|
||||
color: {
|
||||
red: 170,
|
||||
green: 20,
|
||||
blue: 150
|
||||
},
|
||||
lifespan: 5,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
this.unload = function() {
|
||||
Script.update.disconnect(this.update);
|
||||
|
|
|
@ -8,67 +8,31 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
var scriptURL = "entityScripts/sprayPaintCan.js";
|
||||
//Just temporarily using my own bucket here so others can test the entity. Once PR is tested and merged, then the entity script will appear in its proper place in S3, and I wil switch it
|
||||
var scriptURL = "https://hifi-public.s3.amazonaws.com/eric/scripts/sprayPaintCan.js?=v1";
|
||||
var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
|
||||
var center = Vec3.sum(MyAvatar.position, Vec3.multiply(1, Quat.getFront(Camera.getOrientation())));
|
||||
|
||||
var paintGun = Entities.addEntity({
|
||||
var sprayCan = Entities.addEntity({
|
||||
type: "Model",
|
||||
modelURL: "https://hifi-public.s3.amazonaws.com/eric/models/sprayGun.fbx?=v4",
|
||||
position: center,
|
||||
name: "spraycan",
|
||||
modelURL: modelURL,
|
||||
position: {x: 549.12, y:495.55, z:503.77},
|
||||
rotation: {x: 0, y: 0, z: 0, w: 1},
|
||||
dimensions: {
|
||||
x: 0.03,
|
||||
y: 0.15,
|
||||
z: 0.34
|
||||
x: 0.07,
|
||||
y: 0.17,
|
||||
z: 0.07
|
||||
},
|
||||
collisionsWillMove: true,
|
||||
shapeType: 'box',
|
||||
script: scriptURL
|
||||
});
|
||||
|
||||
var whiteboard = Entities.addEntity({
|
||||
type: "Box",
|
||||
position: center,
|
||||
dimensions: {
|
||||
x: 2,
|
||||
y: 1.5,
|
||||
z: .01
|
||||
},
|
||||
rotation: orientationOf(Vec3.subtract(MyAvatar.position, center)),
|
||||
color: {
|
||||
red: 250,
|
||||
green: 250,
|
||||
blue: 250
|
||||
},
|
||||
// visible: false
|
||||
script: scriptURL,
|
||||
gravity: {x: 0, y: -0.5, z: 0},
|
||||
velocity: {x: 0, y: -1, z: 0}
|
||||
});
|
||||
|
||||
function cleanup() {
|
||||
Entities.deleteEntity(paintGun);
|
||||
Entities.deleteEntity(whiteboard);
|
||||
Entities.deleteEntity(sprayCan);
|
||||
}
|
||||
|
||||
|
||||
Script.scriptEnding.connect(cleanup);
|
||||
|
||||
|
||||
function orientationOf(vector) {
|
||||
var Y_AXIS = {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
};
|
||||
var X_AXIS = {
|
||||
x: 1,
|
||||
y: 0,
|
||||
z: 0
|
||||
};
|
||||
|
||||
var theta = 0.0;
|
||||
|
||||
var RAD_TO_DEG = 180.0 / Math.PI;
|
||||
var direction, yaw, pitch;
|
||||
direction = Vec3.normalize(vector);
|
||||
yaw = Quat.angleAxis(Math.atan2(direction.x, direction.z) * RAD_TO_DEG, Y_AXIS);
|
||||
pitch = Quat.angleAxis(Math.asin(-direction.y) * RAD_TO_DEG, X_AXIS);
|
||||
return Quat.multiply(yaw, pitch);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,6 @@ QScriptValue EntityTreeRenderer::loadEntityScript(EntityItemPointer entity, bool
|
|||
QString scriptContents = loadScriptContents(entityScript, isURL, isPending, url, reload);
|
||||
|
||||
if (isPending && isPreload && isURL) {
|
||||
//qDebug() << "attempted to load script, isPending, _waitingOnPreload.insert() url:" << url << "entityID:" << entityID;
|
||||
_waitingOnPreload.insert(url, entityID);
|
||||
}
|
||||
|
||||
|
@ -325,8 +324,7 @@ void EntityTreeRenderer::update() {
|
|||
QScriptValueList currentClickingEntityArgs = createMouseEventArgs(_currentClickingOnEntityID, _lastMouseEvent);
|
||||
QScriptValue currentClickingEntity = loadEntityScript(_currentClickingOnEntityID);
|
||||
if (currentClickingEntity.property("holdingClickOnEntity").isValid()) {
|
||||
//qDebug() << "About to call holdingClickOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("holdingClickOnEntity", currentClickingEntity, currentClickingEntityArgs);
|
||||
currentClickingEntity.property("holdingClickOnEntity").call(currentClickingEntity, currentClickingEntityArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,9 +363,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
QScriptValue entityScript = loadEntityScript(entityID);
|
||||
if (entityScript.property("leaveEntity").isValid()) {
|
||||
|
||||
//qDebug() << "About to call leaveEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("leaveEntity", entityScript, entityArgs);
|
||||
entityScript.property("leaveEntity").call(entityScript, entityArgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -380,8 +376,7 @@ void EntityTreeRenderer::checkEnterLeaveEntities() {
|
|||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
QScriptValue entityScript = loadEntityScript(entityID);
|
||||
if (entityScript.property("enterEntity").isValid()) {
|
||||
//qDebug() << "About to call enterEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("enterEntity", entityScript, entityArgs);
|
||||
entityScript.property("enterEntity").call(entityScript, entityArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -400,8 +395,7 @@ void EntityTreeRenderer::leaveAllEntities() {
|
|||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
QScriptValue entityScript = loadEntityScript(entityID);
|
||||
if (entityScript.property("leaveEntity").isValid()) {
|
||||
//qDebug() << "About to call leaveEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("leaveEntity", entityScript, entityArgs);
|
||||
entityScript.property("leaveEntity").call(entityScript, entityArgs);
|
||||
}
|
||||
}
|
||||
_currentEntitiesInside.clear();
|
||||
|
@ -857,7 +851,7 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event, unsigned int device
|
|||
bool precisionPicking = !_dontDoPrecisionPicking;
|
||||
RayToEntityIntersectionResult rayPickResult = findRayIntersectionWorker(ray, Octree::Lock, precisionPicking);
|
||||
if (rayPickResult.intersects) {
|
||||
qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID;
|
||||
//qCDebug(entitiesrenderer) << "mousePressEvent over entity:" << rayPickResult.entityID;
|
||||
|
||||
QString urlString = rayPickResult.properties.getHref();
|
||||
QUrl url = QUrl(urlString, QUrl::StrictMode);
|
||||
|
@ -871,15 +865,13 @@ void EntityTreeRenderer::mousePressEvent(QMouseEvent* event, unsigned int device
|
|||
QScriptValueList entityScriptArgs = createMouseEventArgs(rayPickResult.entityID, event, deviceID);
|
||||
QScriptValue entityScript = loadEntityScript(rayPickResult.entity);
|
||||
if (entityScript.property("mousePressOnEntity").isValid()) {
|
||||
//qDebug() << "About to call mousePressOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("mousePressOnEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("mousePressOnEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
|
||||
_currentClickingOnEntityID = rayPickResult.entityID;
|
||||
emit clickDownOnEntity(_currentClickingOnEntityID, MouseEvent(*event, deviceID));
|
||||
if (entityScript.property("clickDownOnEntity").isValid()) {
|
||||
//qDebug() << "About to call clickDownOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("clickDownOnEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("clickDownOnEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
} else {
|
||||
emit mousePressOffEntity(rayPickResult, event, deviceID);
|
||||
|
@ -905,7 +897,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int devi
|
|||
QScriptValueList entityScriptArgs = createMouseEventArgs(rayPickResult.entityID, event, deviceID);
|
||||
QScriptValue entityScript = loadEntityScript(rayPickResult.entity);
|
||||
if (entityScript.property("mouseReleaseOnEntity").isValid()) {
|
||||
_entitiesScriptEngine->callScriptMethod("mouseReleaseOnEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("mouseReleaseOnEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -917,8 +909,7 @@ void EntityTreeRenderer::mouseReleaseEvent(QMouseEvent* event, unsigned int devi
|
|||
QScriptValueList currentClickingEntityArgs = createMouseEventArgs(_currentClickingOnEntityID, event, deviceID);
|
||||
QScriptValue currentClickingEntity = loadEntityScript(_currentClickingOnEntityID);
|
||||
if (currentClickingEntity.property("clickReleaseOnEntity").isValid()) {
|
||||
//qDebug() << "About to call clickReleaseOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("clickReleaseOnEntity", currentClickingEntity, currentClickingEntityArgs);
|
||||
currentClickingEntity.property("clickReleaseOnEntity").call(currentClickingEntity, currentClickingEntityArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -946,13 +937,11 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
// load the entity script if needed...
|
||||
QScriptValue entityScript = loadEntityScript(rayPickResult.entity);
|
||||
if (entityScript.property("mouseMoveEvent").isValid()) {
|
||||
//qDebug() << "About to call mouseMoveEvent() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("mouseMoveEvent", entityScript, entityScriptArgs);
|
||||
entityScript.property("mouseMoveEvent").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
emit mouseMoveOnEntity(rayPickResult, event, deviceID);
|
||||
if (entityScript.property("mouseMoveOnEntity").isValid()) {
|
||||
//qDebug() << "About to call mouseMoveOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("mouseMoveOnEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("mouseMoveOnEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
|
||||
// handle the hover logic...
|
||||
|
@ -966,9 +955,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
|
||||
QScriptValue currentHoverEntity = loadEntityScript(_currentHoverOverEntityID);
|
||||
if (currentHoverEntity.property("hoverLeaveEntity").isValid()) {
|
||||
//qDebug() << "About to call hoverLeaveEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("hoverLeaveEntity", currentHoverEntity, currentHoverEntityArgs);
|
||||
|
||||
currentHoverEntity.property("hoverLeaveEntity").call(currentHoverEntity, currentHoverEntityArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -977,8 +964,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
if (rayPickResult.entityID != _currentHoverOverEntityID) {
|
||||
emit hoverEnterEntity(rayPickResult.entityID, MouseEvent(*event, deviceID));
|
||||
if (entityScript.property("hoverEnterEntity").isValid()) {
|
||||
//qDebug() << "About to call hoverEnterEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("hoverEnterEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("hoverEnterEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -986,8 +972,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
// we should send our hover over event
|
||||
emit hoverOverEntity(rayPickResult.entityID, MouseEvent(*event, deviceID));
|
||||
if (entityScript.property("hoverOverEntity").isValid()) {
|
||||
//qDebug() << "About to call hoverOverEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("hoverOverEntity", entityScript, entityScriptArgs);
|
||||
entityScript.property("hoverOverEntity").call(entityScript, entityScriptArgs);
|
||||
}
|
||||
|
||||
// remember what we're hovering over
|
||||
|
@ -1004,8 +989,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
|
||||
QScriptValue currentHoverEntity = loadEntityScript(_currentHoverOverEntityID);
|
||||
if (currentHoverEntity.property("hoverLeaveEntity").isValid()) {
|
||||
//qDebug() << "About to call hoverLeaveEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("hoverLeaveEntity", currentHoverEntity, currentHoverEntityArgs);
|
||||
currentHoverEntity.property("hoverLeaveEntity").call(currentHoverEntity, currentHoverEntityArgs);
|
||||
}
|
||||
|
||||
_currentHoverOverEntityID = UNKNOWN_ENTITY_ID; // makes it the unknown ID
|
||||
|
@ -1021,8 +1005,7 @@ void EntityTreeRenderer::mouseMoveEvent(QMouseEvent* event, unsigned int deviceI
|
|||
|
||||
QScriptValue currentClickingEntity = loadEntityScript(_currentClickingOnEntityID);
|
||||
if (currentClickingEntity.property("holdingClickOnEntity").isValid()) {
|
||||
//qDebug() << "About to call holdingClickOnEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("holdingClickOnEntity", currentClickingEntity, currentClickingEntityArgs);
|
||||
currentClickingEntity.property("holdingClickOnEntity").call(currentClickingEntity, currentClickingEntityArgs);
|
||||
}
|
||||
}
|
||||
_lastMouseEvent = MouseEvent(*event, deviceID);
|
||||
|
@ -1077,8 +1060,7 @@ void EntityTreeRenderer::checkAndCallPreload(const EntityItemID& entityID, const
|
|||
QScriptValue entityScript = loadEntityScript(entityID, true, reload); // is preload!
|
||||
if (entityScript.property("preload").isValid()) {
|
||||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
//qDebug() << "About to call preload() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("preload", entityScript, entityArgs);
|
||||
entityScript.property("preload").call(entityScript, entityArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1088,8 +1070,7 @@ void EntityTreeRenderer::checkAndCallUnload(const EntityItemID& entityID) {
|
|||
QScriptValue entityScript = getPreviouslyLoadedEntityScript(entityID);
|
||||
if (entityScript.property("unload").isValid()) {
|
||||
QScriptValueList entityArgs = createEntityArgs(entityID);
|
||||
//qDebug() << "About to call unload() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("unload", entityScript, entityArgs);
|
||||
entityScript.property("unload").call(entityScript, entityArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1174,9 +1155,7 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
|||
args << idA.toScriptValue(_entitiesScriptEngine);
|
||||
args << idB.toScriptValue(_entitiesScriptEngine);
|
||||
args << collisionToScriptValue(_entitiesScriptEngine, collision);
|
||||
|
||||
//qDebug() << "About to call collisionWithEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("collisionWithEntity", entityScriptA, args);
|
||||
entityScriptA.property("collisionWithEntity").call(entityScriptA, args);
|
||||
}
|
||||
|
||||
emit collisionWithEntity(idB, idA, collision);
|
||||
|
@ -1186,9 +1165,7 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
|
|||
args << idB.toScriptValue(_entitiesScriptEngine);
|
||||
args << idA.toScriptValue(_entitiesScriptEngine);
|
||||
args << collisionToScriptValue(_entitiesScriptEngine, collision);
|
||||
|
||||
//qDebug() << "About to call collisionWithEntity() current thread:" << QThread::currentThread() << "entities thread:" << _entitiesScriptEngine->thread();
|
||||
_entitiesScriptEngine->callScriptMethod("collisionWithEntity", entityScriptB, args);
|
||||
entityScriptB.property("collisionWithEntity").call(entityScriptA, args);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,6 @@ void ScriptCache::scriptDownloaded() {
|
|||
qCDebug(scriptengine) << "Done downloading script at:" << url.toString();
|
||||
|
||||
foreach(ScriptUser* user, scriptUsers) {
|
||||
// FIXME - I sometimes get a crash deep below here inside of Qt while evaluating the script
|
||||
user->scriptContentsAvailable(url, _scriptCache[url]);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -261,20 +261,6 @@ bool ScriptEngine::setScriptContents(const QString& scriptContents, const QStrin
|
|||
return true;
|
||||
}
|
||||
|
||||
void ScriptEngine::callScriptMethod(QString methodName, QScriptValue script, QScriptValueList args) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this,
|
||||
"callScriptMethod",
|
||||
Q_ARG(QString, methodName),
|
||||
Q_ARG(QScriptValue, script),
|
||||
Q_ARG(QScriptValueList, args));
|
||||
return;
|
||||
}
|
||||
|
||||
//qDebug() << "About to call " << methodName << "() current thread : " << QThread::currentThread() << "engine thread : " << thread();
|
||||
script.property(methodName).call(script, args);
|
||||
}
|
||||
|
||||
void ScriptEngine::loadURL(const QUrl& scriptURL, bool reload) {
|
||||
if (_isRunning) {
|
||||
return;
|
||||
|
|
|
@ -65,8 +65,6 @@ public:
|
|||
int numArguments = -1);
|
||||
|
||||
Q_INVOKABLE void setIsAvatar(bool isAvatar);
|
||||
Q_INVOKABLE void callScriptMethod(QString methodName, QScriptValue script, QScriptValueList args);
|
||||
|
||||
bool isAvatar() const { return _isAvatar; }
|
||||
|
||||
void setAvatarData(AvatarData* avatarData, const QString& objectName);
|
||||
|
|
|
@ -26,8 +26,7 @@ static int quatMetaTypeId = qRegisterMetaType<glm::quat>();
|
|||
static int xColorMetaTypeId = qRegisterMetaType<xColor>();
|
||||
static int pickRayMetaTypeId = qRegisterMetaType<PickRay>();
|
||||
static int collisionMetaTypeId = qRegisterMetaType<Collision>();
|
||||
static int qMapURLStringMetaTypeId = qRegisterMetaType<QMap<QUrl, QString>>();
|
||||
static int qScriptValueListMetaTypeId = qRegisterMetaType<QScriptValueList>("QScriptValueList");
|
||||
static int qMapURLStringMetaTypeId = qRegisterMetaType<QMap<QUrl,QString>>();
|
||||
|
||||
void registerMetaTypes(QScriptEngine* engine) {
|
||||
qScriptRegisterMetaType(engine, vec4toScriptValue, vec4FromScriptValue);
|
||||
|
|
Loading…
Reference in a new issue