mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 10:57:25 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
b262096e7c
22 changed files with 700 additions and 447 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
#include <LogUtils.h>
|
||||||
#include <NodeList.h>
|
#include <NodeList.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
@ -36,13 +37,19 @@ int hifiSockAddrMeta = qRegisterMetaType<HifiSockAddr>("HifiSockAddr");
|
||||||
|
|
||||||
AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
AssignmentClient::AssignmentClient(int &argc, char **argv) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
_assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME)
|
_assignmentServerHostname(DEFAULT_ASSIGNMENT_SERVER_HOSTNAME),
|
||||||
|
_shutdownEventListener(this)
|
||||||
{
|
{
|
||||||
|
LogUtils::init();
|
||||||
|
|
||||||
setOrganizationName("High Fidelity");
|
setOrganizationName("High Fidelity");
|
||||||
setOrganizationDomain("highfidelity.io");
|
setOrganizationDomain("highfidelity.io");
|
||||||
setApplicationName("assignment-client");
|
setApplicationName("assignment-client");
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
|
||||||
|
installNativeEventFilter(&_shutdownEventListener);
|
||||||
|
connect(&_shutdownEventListener, SIGNAL(receivedCloseEvent()), SLOT(quit()));
|
||||||
|
|
||||||
// set the logging target to the the CHILD_TARGET_NAME
|
// set the logging target to the the CHILD_TARGET_NAME
|
||||||
Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
Logging::setTargetName(ASSIGNMENT_CLIENT_TARGET_NAME);
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include <QtCore/QCoreApplication>
|
#include <QtCore/QCoreApplication>
|
||||||
|
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
#include "ThreadedAssignment.h"
|
#include "ThreadedAssignment.h"
|
||||||
|
|
||||||
class AssignmentClient : public QCoreApplication {
|
class AssignmentClient : public QCoreApplication {
|
||||||
|
@ -21,6 +22,7 @@ class AssignmentClient : public QCoreApplication {
|
||||||
public:
|
public:
|
||||||
AssignmentClient(int &argc, char **argv);
|
AssignmentClient(int &argc, char **argv);
|
||||||
static const SharedAssignmentPointer& getCurrentAssignment() { return _currentAssignment; }
|
static const SharedAssignmentPointer& getCurrentAssignment() { return _currentAssignment; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void sendAssignmentRequest();
|
void sendAssignmentRequest();
|
||||||
void readPendingDatagrams();
|
void readPendingDatagrams();
|
||||||
|
@ -30,6 +32,7 @@ private slots:
|
||||||
private:
|
private:
|
||||||
Assignment _requestAssignment;
|
Assignment _requestAssignment;
|
||||||
static SharedAssignmentPointer _currentAssignment;
|
static SharedAssignmentPointer _currentAssignment;
|
||||||
|
ShutdownEventListener _shutdownEventListener;
|
||||||
QString _assignmentServerHostname;
|
QString _assignmentServerHostname;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
#include <HifiConfigVariantMap.h>
|
#include <HifiConfigVariantMap.h>
|
||||||
#include <HTTPConnection.h>
|
#include <HTTPConnection.h>
|
||||||
|
#include <LogUtils.h>
|
||||||
#include <PacketHeaders.h>
|
#include <PacketHeaders.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
|
|
||||||
DomainServer::DomainServer(int argc, char* argv[]) :
|
DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
QCoreApplication(argc, argv),
|
QCoreApplication(argc, argv),
|
||||||
|
_shutdownEventListener(this),
|
||||||
_httpManager(DOMAIN_SERVER_HTTP_PORT, QString("%1/resources/web/").arg(QCoreApplication::applicationDirPath()), this),
|
_httpManager(DOMAIN_SERVER_HTTP_PORT, QString("%1/resources/web/").arg(QCoreApplication::applicationDirPath()), this),
|
||||||
_httpsManager(NULL),
|
_httpsManager(NULL),
|
||||||
_allAssignments(),
|
_allAssignments(),
|
||||||
|
@ -46,11 +48,17 @@ DomainServer::DomainServer(int argc, char* argv[]) :
|
||||||
_cookieSessionHash(),
|
_cookieSessionHash(),
|
||||||
_settingsManager()
|
_settingsManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
LogUtils::init();
|
||||||
|
|
||||||
setOrganizationName("High Fidelity");
|
setOrganizationName("High Fidelity");
|
||||||
setOrganizationDomain("highfidelity.io");
|
setOrganizationDomain("highfidelity.io");
|
||||||
setApplicationName("domain-server");
|
setApplicationName("domain-server");
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
|
|
||||||
|
installNativeEventFilter(&_shutdownEventListener);
|
||||||
|
connect(&_shutdownEventListener, SIGNAL(receivedCloseEvent()), SLOT(quit()));
|
||||||
|
|
||||||
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaType<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
qRegisterMetaTypeStreamOperators<DomainServerWebSessionData>("DomainServerWebSessionData");
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QtCore/QStringList>
|
#include <QtCore/QStringList>
|
||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
|
||||||
#include <Assignment.h>
|
#include <Assignment.h>
|
||||||
#include <HTTPSConnection.h>
|
#include <HTTPSConnection.h>
|
||||||
|
@ -26,6 +27,7 @@
|
||||||
|
|
||||||
#include "DomainServerSettingsManager.h"
|
#include "DomainServerSettingsManager.h"
|
||||||
#include "DomainServerWebSessionData.h"
|
#include "DomainServerWebSessionData.h"
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
#include "WalletTransaction.h"
|
#include "WalletTransaction.h"
|
||||||
|
|
||||||
#include "PendingAssignedNodeData.h"
|
#include "PendingAssignedNodeData.h"
|
||||||
|
@ -98,6 +100,8 @@ private:
|
||||||
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
QJsonObject jsonForSocket(const HifiSockAddr& socket);
|
||||||
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
|
||||||
|
|
||||||
|
ShutdownEventListener _shutdownEventListener;
|
||||||
|
|
||||||
HTTPManager _httpManager;
|
HTTPManager _httpManager;
|
||||||
HTTPSManager* _httpsManager;
|
HTTPSManager* _httpsManager;
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ var roll = 0.0;
|
||||||
var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll)
|
var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll)
|
||||||
|
|
||||||
var originalProperties = {
|
var originalProperties = {
|
||||||
|
type: "Model",
|
||||||
position: { x: MyAvatar.position.x,
|
position: { x: MyAvatar.position.x,
|
||||||
y: MyAvatar.position.y,
|
y: MyAvatar.position.y,
|
||||||
z: MyAvatar.position.z },
|
z: MyAvatar.position.z },
|
||||||
|
@ -37,8 +38,8 @@ var originalProperties = {
|
||||||
animationIsPlaying: true,
|
animationIsPlaying: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
var modelID = Models.addModel(originalProperties);
|
var modelID = Entities.addEntity(originalProperties);
|
||||||
print("Models.addModel()... modelID.creatorTokenID = " + modelID.creatorTokenID);
|
print("Entities.addEntity()... modelID.creatorTokenID = " + modelID.creatorTokenID);
|
||||||
|
|
||||||
var isPlaying = true;
|
var isPlaying = true;
|
||||||
var playPauseEveryWhile = 360;
|
var playPauseEveryWhile = 360;
|
||||||
|
@ -48,6 +49,7 @@ var resetFrameEveryWhile = 600;
|
||||||
|
|
||||||
function moveModel(deltaTime) {
|
function moveModel(deltaTime) {
|
||||||
var somethingChanged = false;
|
var somethingChanged = false;
|
||||||
|
print("count= " + count);
|
||||||
if (count % playPauseEveryWhile == 0) {
|
if (count % playPauseEveryWhile == 0) {
|
||||||
isPlaying = !isPlaying;
|
isPlaying = !isPlaying;
|
||||||
print("isPlaying=" + isPlaying);
|
print("isPlaying=" + isPlaying);
|
||||||
|
@ -56,11 +58,11 @@ function moveModel(deltaTime) {
|
||||||
|
|
||||||
if (count % adjustFPSEveryWhile == 0) {
|
if (count % adjustFPSEveryWhile == 0) {
|
||||||
if (animationFPS == 30) {
|
if (animationFPS == 30) {
|
||||||
animationFPS = 30;
|
|
||||||
} else if (animationFPS == 10) {
|
|
||||||
animationFPS = 10;
|
animationFPS = 10;
|
||||||
} else if (animationFPS == 60) {
|
} else if (animationFPS == 10) {
|
||||||
animationFPS = 60;
|
animationFPS = 60;
|
||||||
|
} else if (animationFPS == 60) {
|
||||||
|
animationFPS = 30;
|
||||||
}
|
}
|
||||||
print("animationFPS=" + animationFPS);
|
print("animationFPS=" + animationFPS);
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
|
@ -78,7 +80,7 @@ function moveModel(deltaTime) {
|
||||||
// delete it...
|
// delete it...
|
||||||
if (count == moveUntil) {
|
if (count == moveUntil) {
|
||||||
print("calling Models.deleteModel()");
|
print("calling Models.deleteModel()");
|
||||||
Models.deleteModel(modelID);
|
Entities.deleteEntity(modelID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop it...
|
// stop it...
|
||||||
|
@ -107,7 +109,7 @@ function moveModel(deltaTime) {
|
||||||
resetFrame = false;
|
resetFrame = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Models.editModel(modelID, newProperties);
|
Entities.editEntity(modelID, newProperties);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2828,7 +2828,7 @@ function handeMenuEvent(menuItem) {
|
||||||
|
|
||||||
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
array.push({ label: "Lifetime:", value: properties.lifetime.toFixed(decimals) });
|
||||||
|
|
||||||
if (properties.type == "Box") {
|
if (properties.type == "Box" || properties.type == "Sphere") {
|
||||||
array.push({ label: "Red:", value: properties.color.red });
|
array.push({ label: "Red:", value: properties.color.red });
|
||||||
array.push({ label: "Green:", value: properties.color.green });
|
array.push({ label: "Green:", value: properties.color.green });
|
||||||
array.push({ label: "Blue:", value: properties.color.blue });
|
array.push({ label: "Blue:", value: properties.color.blue });
|
||||||
|
|
230
examples/entitiesButterflyFlock.js
Normal file
230
examples/entitiesButterflyFlock.js
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
//
|
||||||
|
// butterflyFlockTest1.js
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by Adrian McCarlie on August 2, 2014
|
||||||
|
// Modified by Brad Hefta-Gaub to use Entities on Sept. 3, 2014
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// This sample script creates a swarm of butterfly entities that fly around the avatar.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
function getRandomFloat(min, max) {
|
||||||
|
return Math.random() * (max - min) + min;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply vector by scalar
|
||||||
|
function vScalarMult(v, s) {
|
||||||
|
var rval = { x: v.x * s, y: v.y * s, z: v.z * s };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
function printVector(v) {
|
||||||
|
print(v.x + ", " + v.y + ", " + v.z + "\n");
|
||||||
|
}
|
||||||
|
// Create a random vector with individual lengths between a,b
|
||||||
|
function randVector(a, b) {
|
||||||
|
var rval = { x: a + Math.random() * (b - a), y: a + Math.random() * (b - a), z: a + Math.random() * (b - a) };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns a vector which is fraction of the way between a and b
|
||||||
|
function vInterpolate(a, b, fraction) {
|
||||||
|
var rval = { x: a.x + (b.x - a.x) * fraction, y: a.y + (b.y - a.y) * fraction, z: a.z + (b.z - a.z) * fraction };
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
|
||||||
|
var startTimeInSeconds = new Date().getTime() / 1000;
|
||||||
|
|
||||||
|
var lifeTime = 60; // lifetime of the butterflies in seconds!
|
||||||
|
var range = 1.0; // Over what distance in meters do you want the flock to fly around
|
||||||
|
var frame = 0;
|
||||||
|
|
||||||
|
var CHANCE_OF_MOVING = 0.9;
|
||||||
|
var BUTTERFLY_GRAVITY = 0;//-0.06;
|
||||||
|
var BUTTERFLY_FLAP_SPEED = 1.0;
|
||||||
|
var BUTTERFLY_VELOCITY = 0.55;
|
||||||
|
var myPosition = MyAvatar.position;
|
||||||
|
|
||||||
|
var pitch = 0.0;//experimental
|
||||||
|
var yaw = 0.0;//experimental
|
||||||
|
var roll = 0.0; //experimental
|
||||||
|
var rotation = Quat.fromPitchYawRollDegrees(pitch, yaw, roll);//experimental
|
||||||
|
|
||||||
|
// This is our butterfly object
|
||||||
|
function defineButterfly(entityID, targetPosition) {
|
||||||
|
this.entityID = entityID;
|
||||||
|
this.previousFlapOffset = 0;
|
||||||
|
this.targetPosition = targetPosition;
|
||||||
|
this.moving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Array of butterflies
|
||||||
|
var butterflies = [];
|
||||||
|
var numButterflies = 20;
|
||||||
|
function addButterfly() {
|
||||||
|
// Decide the size of butterfly
|
||||||
|
var color = { red: 100, green: 100, blue: 100 };
|
||||||
|
var size = 0;
|
||||||
|
|
||||||
|
var which = Math.random();
|
||||||
|
if (which < 0.2) {
|
||||||
|
size = 0.08;
|
||||||
|
} else if (which < 0.4) {
|
||||||
|
size = 0.09;
|
||||||
|
} else if (which < 0.6) {
|
||||||
|
size = 0.8;
|
||||||
|
} else if (which < 0.8) {
|
||||||
|
size = 0.8;
|
||||||
|
} else {
|
||||||
|
size = 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
myPosition = MyAvatar.position;
|
||||||
|
// if ( frame < numButterflies){
|
||||||
|
// myPosition = {x: myPosition.x, y: myPosition.y, z: myPosition.z };
|
||||||
|
// }
|
||||||
|
|
||||||
|
var properties = {
|
||||||
|
type: "Model",
|
||||||
|
lifetime: lifeTime,
|
||||||
|
position: Vec3.sum(randVector(-range, range), myPosition),
|
||||||
|
velocity: { x: 0, y: 0.0, z: 0 },
|
||||||
|
gravity: { x: 0, y: 1.0, z: 0 },
|
||||||
|
damping: 0.1,
|
||||||
|
radius : size,
|
||||||
|
color: color,
|
||||||
|
rotation: rotation,
|
||||||
|
//animationURL: "http://business.ozblog.me/objects/butterfly/newButterfly6.fbx",
|
||||||
|
//animationIsPlaying: true,
|
||||||
|
modelURL: "http://business.ozblog.me/objects/butterfly/newButterfly6.fbx"
|
||||||
|
};
|
||||||
|
properties.position.z = properties.position.z+1;
|
||||||
|
butterflies.push(new defineButterfly(Entities.addEntity(properties), properties.position));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate the butterflies
|
||||||
|
for (var i = 0; i < numButterflies; i++) {
|
||||||
|
addButterfly();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Main update function
|
||||||
|
function updateButterflies(deltaTime) {
|
||||||
|
// Check to see if we've been running long enough that our butterflies are dead
|
||||||
|
var nowTimeInSeconds = new Date().getTime() / 1000;
|
||||||
|
if ((nowTimeInSeconds - startTimeInSeconds) >= lifeTime) {
|
||||||
|
// print("our butterflies are dying, stop our script");
|
||||||
|
Script.stop();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frame++;
|
||||||
|
// Only update every third frame
|
||||||
|
if ((frame % 3) == 0) {
|
||||||
|
myPosition = MyAvatar.position;
|
||||||
|
|
||||||
|
// Update all the butterflies
|
||||||
|
for (var i = 0; i < numButterflies; i++) {
|
||||||
|
entityID = butterflies[i].entityID;
|
||||||
|
var properties = Entities.getEntityProperties(entityID);
|
||||||
|
|
||||||
|
if (properties.position.y > myPosition.y + getRandomFloat(0.0,0.3)){ //0.3 //ceiling
|
||||||
|
properties.gravity.y = - 3.0;
|
||||||
|
properties.damping.y = 1.0;
|
||||||
|
properties.velocity.y = 0;
|
||||||
|
properties.velocity.x = properties.velocity.x;
|
||||||
|
properties.velocity.z = properties.velocity.z;
|
||||||
|
if (properties.velocity.x < 0.5){
|
||||||
|
butterflies[i].moving = false;
|
||||||
|
}
|
||||||
|
if (properties.velocity.z < 0.5){
|
||||||
|
butterflies[i].moving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties.velocity.y <= -0.2) {
|
||||||
|
properties.velocity.y = 0.22;
|
||||||
|
properties.velocity.x = properties.velocity.x;
|
||||||
|
properties.velocity.z = properties.velocity.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (properties.position.y < myPosition.y - getRandomFloat(0.0,0.3)) { //-0.3 // floor
|
||||||
|
properties.velocity.y = 0.9;
|
||||||
|
properties.gravity.y = - 4.0;
|
||||||
|
properties.velocity.x = properties.velocity.x;
|
||||||
|
properties.velocity.z = properties.velocity.z;
|
||||||
|
if (properties.velocity.x < 0.5){
|
||||||
|
butterflies[i].moving = false;
|
||||||
|
}
|
||||||
|
if (properties.velocity.z < 0.5){
|
||||||
|
butterflies[i].moving = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Begin movement by getting a target
|
||||||
|
if (butterflies[i].moving == false) {
|
||||||
|
if (Math.random() < CHANCE_OF_MOVING) {
|
||||||
|
var targetPosition = Vec3.sum(randVector(-range, range), myPosition);
|
||||||
|
if (targetPosition.x < 0) {
|
||||||
|
targetPosition.x = 0;
|
||||||
|
}
|
||||||
|
if (targetPosition.y < 0) {
|
||||||
|
targetPosition.y = 0;
|
||||||
|
}
|
||||||
|
if (targetPosition.z < 0) {
|
||||||
|
targetPosition.z = 0;
|
||||||
|
}
|
||||||
|
if (targetPosition.x > TREE_SCALE) {
|
||||||
|
targetPosition.x = TREE_SCALE;
|
||||||
|
}
|
||||||
|
if (targetPosition.y > TREE_SCALE) {
|
||||||
|
targetPosition.y = TREE_SCALE;
|
||||||
|
}
|
||||||
|
if (targetPosition.z > TREE_SCALE) {
|
||||||
|
targetPosition.z = TREE_SCALE;
|
||||||
|
}
|
||||||
|
butterflies[i].targetPosition = targetPosition;
|
||||||
|
butterflies[i].moving = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we are moving, move towards the target
|
||||||
|
if (butterflies[i].moving) {
|
||||||
|
|
||||||
|
var holding = properties.velocity.y;
|
||||||
|
|
||||||
|
var desiredVelocity = Vec3.subtract(butterflies[i].targetPosition, properties.position);
|
||||||
|
desiredVelocity = vScalarMult(Vec3.normalize(desiredVelocity), BUTTERFLY_VELOCITY);
|
||||||
|
|
||||||
|
properties.velocity = vInterpolate(properties.velocity, desiredVelocity, 0.2);
|
||||||
|
properties.velocity.y = holding ;
|
||||||
|
|
||||||
|
|
||||||
|
// If we are near the target, we should get a new target
|
||||||
|
if (Vec3.length(Vec3.subtract(properties.position, butterflies[i].targetPosition)) < (properties.radius / 1.0)) {
|
||||||
|
butterflies[i].moving = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var yawRads = Math.atan2(properties.velocity.z, properties.velocity.x);
|
||||||
|
yawRads = yawRads + Math.PI / 2.0;
|
||||||
|
var newOrientation = Quat.fromPitchYawRollRadians(0.0, yawRads, 0.0);
|
||||||
|
properties.rotation = newOrientation;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use a cosine wave offset to make it look like its flapping.
|
||||||
|
var offset = Math.cos(nowTimeInSeconds * BUTTERFLY_FLAP_SPEED) * (properties.radius);
|
||||||
|
properties.position.y = properties.position.y + (offset - butterflies[i].previousFlapOffset);
|
||||||
|
// Change position relative to previous offset.
|
||||||
|
butterflies[i].previousFlapOffset = offset;
|
||||||
|
Entities.editEntity(entityID, properties);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// register the call back so it fires before each data send
|
||||||
|
Script.update.connect(updateButterflies);
|
|
@ -205,7 +205,7 @@ function mousePressEvent(event) {
|
||||||
// Compute trajectories related values
|
// Compute trajectories related values
|
||||||
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
var pickRay = Camera.computePickRay(mouseLastX, mouseLastY);
|
||||||
var voxelIntersection = Voxels.findRayIntersection(pickRay);
|
var voxelIntersection = Voxels.findRayIntersection(pickRay);
|
||||||
var modelIntersection = Models.findRayIntersection(pickRay);
|
var modelIntersection = Entities.findRayIntersection(pickRay);
|
||||||
|
|
||||||
position = Camera.getPosition();
|
position = Camera.getPosition();
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ function mousePressEvent(event) {
|
||||||
|
|
||||||
if (modelIntersection.intersects && modelIntersection.accurate) {
|
if (modelIntersection.intersects && modelIntersection.accurate) {
|
||||||
distance = modelIntersection.distance;
|
distance = modelIntersection.distance;
|
||||||
center = modelIntersection.modelProperties.position;
|
center = modelIntersection.properties.position;
|
||||||
string = "Inspecting model";
|
string = "Inspecting model";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,16 +42,16 @@ function mouseMoveEvent(event) {
|
||||||
print("voxelAt.red/green/blue=" + voxelAt.red + ", " + voxelAt.green + ", " + voxelAt.blue);
|
print("voxelAt.red/green/blue=" + voxelAt.red + ", " + voxelAt.green + ", " + voxelAt.blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
intersection = Models.findRayIntersection(pickRay);
|
intersection = Entities.findRayIntersection(pickRay);
|
||||||
if (!intersection.accurate) {
|
if (!intersection.accurate) {
|
||||||
print(">>> NOTE: intersection not accurate. will try calling Models.findRayIntersectionBlocking()");
|
print(">>> NOTE: intersection not accurate. will try calling Entities.findRayIntersectionBlocking()");
|
||||||
intersection = Models.findRayIntersectionBlocking(pickRay);
|
intersection = Entities.findRayIntersectionBlocking(pickRay);
|
||||||
print(">>> AFTER BLOCKING CALL intersection.accurate=" + intersection.accurate);
|
print(">>> AFTER BLOCKING CALL intersection.accurate=" + intersection.accurate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (intersection.intersects) {
|
if (intersection.intersects) {
|
||||||
print("intersection modelID.id=" + intersection.modelID.id);
|
print("intersection entityID.id=" + intersection.entityID.id);
|
||||||
print("intersection modelProperties.modelURL=" + intersection.modelProperties.modelURL);
|
print("intersection properties.modelURL=" + intersection.properties.modelURL);
|
||||||
print("intersection face=" + intersection.face);
|
print("intersection face=" + intersection.face);
|
||||||
print("intersection distance=" + intersection.distance);
|
print("intersection distance=" + intersection.distance);
|
||||||
print("intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
print("intersection intersection.x/y/z=" + intersection.intersection.x + ", "
|
||||||
|
|
25
examples/twoFallingEntities.js
Normal file
25
examples/twoFallingEntities.js
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// twoFallingEntities.js
|
||||||
|
//
|
||||||
|
// Creates a red 0.2 meter diameter ball right in front of your avatar that lives for 60 seconds
|
||||||
|
//
|
||||||
|
|
||||||
|
var radius = 0.1;
|
||||||
|
var position = Vec3.sum(MyAvatar.position, Quat.getFront(MyAvatar.orientation));
|
||||||
|
var properties = {
|
||||||
|
type: "Sphere",
|
||||||
|
position: position,
|
||||||
|
velocity: { x: 0, y: 0, z: 0},
|
||||||
|
gravity: { x: 0, y: -0.05, z: 0},
|
||||||
|
radius: radius,
|
||||||
|
damping: 0.999,
|
||||||
|
color: { red: 200, green: 0, blue: 0 },
|
||||||
|
lifetime: 60
|
||||||
|
};
|
||||||
|
|
||||||
|
var newEntity = Entities.addEntity(properties);
|
||||||
|
position.x -= radius * 1.0;
|
||||||
|
properties.position = position;
|
||||||
|
var newEntityTwo = Entities.addEntity(properties);
|
||||||
|
|
||||||
|
Script.stop(); // no need to run anymore
|
|
@ -3856,14 +3856,17 @@ void Application::manageRunningScriptsWidgetVisibility(bool shown) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::toggleRunningScriptsWidget() {
|
void Application::toggleRunningScriptsWidget() {
|
||||||
if (_runningScriptsWidgetWasVisible) {
|
if (_runningScriptsWidget->isVisible()) {
|
||||||
|
if (_runningScriptsWidget->hasFocus()) {
|
||||||
_runningScriptsWidget->hide();
|
_runningScriptsWidget->hide();
|
||||||
_runningScriptsWidgetWasVisible = false;
|
|
||||||
} else {
|
} else {
|
||||||
_runningScriptsWidget->setBoundary(QRect(_window->geometry().topLeft(),
|
_runningScriptsWidget->raise();
|
||||||
_window->size()));
|
setActiveWindow(_runningScriptsWidget);
|
||||||
|
_runningScriptsWidget->setFocus();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
_runningScriptsWidget->show();
|
_runningScriptsWidget->show();
|
||||||
_runningScriptsWidgetWasVisible = true;
|
_runningScriptsWidget->setFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,11 @@
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "ScriptsModel.h"
|
#include "ScriptsModel.h"
|
||||||
|
#include "UIUtil.h"
|
||||||
|
|
||||||
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
||||||
FramelessDialog(parent, 0, POSITION_LEFT),
|
QWidget(parent, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint |
|
||||||
|
Qt::WindowCloseButtonHint),
|
||||||
ui(new Ui::RunningScriptsWidget),
|
ui(new Ui::RunningScriptsWidget),
|
||||||
_signalMapper(this),
|
_signalMapper(this),
|
||||||
_proxyModel(this),
|
_proxyModel(this),
|
||||||
|
@ -33,15 +35,6 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
||||||
|
|
||||||
setAttribute(Qt::WA_DeleteOnClose, false);
|
setAttribute(Qt::WA_DeleteOnClose, false);
|
||||||
|
|
||||||
setAllowResize(false);
|
|
||||||
|
|
||||||
ui->hideWidgetButton->setIcon(QIcon(Application::resourcesPath() + "images/close.svg"));
|
|
||||||
ui->reloadAllButton->setIcon(QIcon(Application::resourcesPath() + "images/reload.svg"));
|
|
||||||
ui->stopAllButton->setIcon(QIcon(Application::resourcesPath() + "images/stop.svg"));
|
|
||||||
ui->loadScriptButton->setIcon(QIcon(Application::resourcesPath() + "images/plus-white.svg"));
|
|
||||||
|
|
||||||
ui->recentlyLoadedScriptsArea->hide();
|
|
||||||
|
|
||||||
ui->filterLineEdit->installEventFilter(this);
|
ui->filterLineEdit->installEventFilter(this);
|
||||||
|
|
||||||
connect(&_proxyModel, &QSortFilterProxyModel::modelReset,
|
connect(&_proxyModel, &QSortFilterProxyModel::modelReset,
|
||||||
|
@ -55,12 +48,6 @@ RunningScriptsWidget::RunningScriptsWidget(QWidget* parent) :
|
||||||
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter);
|
connect(ui->filterLineEdit, &QLineEdit::textChanged, this, &RunningScriptsWidget::updateFileFilter);
|
||||||
connect(ui->scriptListView, &QListView::doubleClicked, this, &RunningScriptsWidget::loadScriptFromList);
|
connect(ui->scriptListView, &QListView::doubleClicked, this, &RunningScriptsWidget::loadScriptFromList);
|
||||||
|
|
||||||
_recentlyLoadedScriptsTable = new ScriptsTableWidget(ui->recentlyLoadedScriptsTableWidget);
|
|
||||||
_recentlyLoadedScriptsTable->setColumnCount(1);
|
|
||||||
_recentlyLoadedScriptsTable->setColumnWidth(0, 265);
|
|
||||||
|
|
||||||
connect(ui->hideWidgetButton, &QPushButton::clicked,
|
|
||||||
Application::getInstance(), &Application::toggleRunningScriptsWidget);
|
|
||||||
connect(ui->reloadAllButton, &QPushButton::clicked,
|
connect(ui->reloadAllButton, &QPushButton::clicked,
|
||||||
Application::getInstance(), &Application::reloadAllScripts);
|
Application::getInstance(), &Application::reloadAllScripts);
|
||||||
connect(ui->stopAllButton, &QPushButton::clicked,
|
connect(ui->stopAllButton, &QPushButton::clicked,
|
||||||
|
@ -163,7 +150,15 @@ void RunningScriptsWidget::showEvent(QShowEvent* event) {
|
||||||
ui->filterLineEdit->setFocus();
|
ui->filterLineEdit->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
FramelessDialog::showEvent(event);
|
const QRect parentGeometry = parentWidget()->geometry();
|
||||||
|
int titleBarHeight = UIUtil::getWindowTitleBarHeight(this);
|
||||||
|
int menuBarHeight = Menu::getInstance()->geometry().height();
|
||||||
|
int topMargin = titleBarHeight + menuBarHeight;
|
||||||
|
|
||||||
|
setGeometry(parentGeometry.topLeft().x(), parentGeometry.topLeft().y() + topMargin,
|
||||||
|
size().width(), parentWidget()->height() - topMargin);
|
||||||
|
|
||||||
|
QWidget::showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningScriptsWidget::selectFirstInList() {
|
void RunningScriptsWidget::selectFirstInList() {
|
||||||
|
@ -189,19 +184,18 @@ bool RunningScriptsWidget::eventFilter(QObject* sender, QEvent* event) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FramelessDialog::eventFilter(sender, event);
|
return QWidget::eventFilter(sender, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningScriptsWidget::keyPressEvent(QKeyEvent *keyEvent) {
|
void RunningScriptsWidget::keyPressEvent(QKeyEvent *keyEvent) {
|
||||||
if (keyEvent->key() == Qt::Key_Escape) {
|
if (keyEvent->key() == Qt::Key_Escape) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
FramelessDialog::keyPressEvent(keyEvent);
|
QWidget::keyPressEvent(keyEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningScriptsWidget::scriptStopped(const QString& scriptName) {
|
void RunningScriptsWidget::scriptStopped(const QString& scriptName) {
|
||||||
// _recentlyLoadedScripts.prepend(scriptName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunningScriptsWidget::allScriptsStopped() {
|
void RunningScriptsWidget::allScriptsStopped() {
|
||||||
|
|
|
@ -25,8 +25,7 @@ namespace Ui {
|
||||||
class RunningScriptsWidget;
|
class RunningScriptsWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RunningScriptsWidget : public FramelessDialog
|
class RunningScriptsWidget : public QWidget {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RunningScriptsWidget(QWidget* parent = NULL);
|
explicit RunningScriptsWidget(QWidget* parent = NULL);
|
||||||
|
|
|
@ -7,29 +7,24 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>324</width>
|
<width>324</width>
|
||||||
<height>971</height>
|
<height>643</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Running Scripts</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">* {
|
<string notr="true">* { font-family: Helvetica, Arial, sans-serif; }</string>
|
||||||
font-family: Helvetica, Arial, sans-serif;
|
|
||||||
}
|
|
||||||
QWidget {
|
|
||||||
background: #f7f7f7;
|
|
||||||
}</string>
|
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>20</number>
|
<number>14</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>20</number>
|
<number>14</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
|
@ -38,23 +33,22 @@ QWidget {
|
||||||
<widget class="QWidget" name="header" native="true">
|
<widget class="QWidget" name="header" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="widgetTitle">
|
<widget class="QLabel" name="widgetTitle">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">color: #0e7077;
|
<string notr="true">color: #0e7077;
|
||||||
font-size: 20px;
|
font-size: 20px;</string>
|
||||||
background: transparent;</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><span style=" font-size:18px;">Running Scripts</span></p></body></html></string>
|
<string>Running Scripts</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="margin">
|
<property name="margin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -77,28 +71,6 @@ background: transparent;</string>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QPushButton" name="hideWidgetButton">
|
|
||||||
<property name="cursor">
|
|
||||||
<cursorShape>PointingHandCursor</cursorShape>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">border: 0</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string/>
|
|
||||||
</property>
|
|
||||||
<property name="iconSize">
|
|
||||||
<size>
|
|
||||||
<width>16</width>
|
|
||||||
<height>16</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="flat">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -132,6 +104,24 @@ background: transparent;</string>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widget_3" native="true">
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="currentlyRunningLabel">
|
<widget class="QLabel" name="currentlyRunningLabel">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -146,13 +136,16 @@ background: transparent;</string>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">color: #0e7077;
|
<string notr="true">color: #0e7077;
|
||||||
font: bold 16px;
|
font: bold 16px;
|
||||||
background: transparent;</string>
|
</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600;">Currently running</span></p></body></html></string>
|
<string>Currently Running</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_3">
|
<spacer name="verticalSpacer_3">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -177,49 +170,24 @@ background: transparent;</string>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<property name="styleSheet">
|
||||||
<property name="spacing">
|
<string notr="true">reloadStopButtonArea { padding: 0 }</string>
|
||||||
<number>24</number>
|
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="reloadAllButton">
|
<widget class="QPushButton" name="reloadAllButton">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>111</width>
|
|
||||||
<height>35</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="cursor">
|
|
||||||
<cursorShape>PointingHandCursor</cursorShape>
|
|
||||||
</property>
|
|
||||||
<property name="autoFillBackground">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background: #0e7077;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 4px;
|
|
||||||
font: bold 14px;
|
|
||||||
padding-top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reload all</string>
|
<string>Reload all</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -227,28 +195,6 @@ padding-top: 3px;</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="stopAllButton">
|
<widget class="QPushButton" name="stopAllButton">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>111</width>
|
|
||||||
<height>35</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="cursor">
|
|
||||||
<cursorShape>PointingHandCursor</cursorShape>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background: #0e7077;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 4px;
|
|
||||||
font: bold 14px;
|
|
||||||
padding-top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Stop all</string>
|
<string>Stop all</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -261,8 +207,8 @@ padding-top: 3px;</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="sizeHint" stdset="0">
|
||||||
<size>
|
<size>
|
||||||
<width>40</width>
|
<width>0</width>
|
||||||
<height>20</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
|
@ -271,50 +217,23 @@ padding-top: 3px;</string>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="verticalSpacer_4">
|
<widget class="QWidget" name="widget_4" native="true">
|
||||||
<property name="orientation">
|
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||||
<enum>Qt::Vertical</enum>
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeType">
|
<property name="leftMargin">
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
<property name="topMargin">
|
||||||
<size>
|
<number>0</number>
|
||||||
<width>20</width>
|
|
||||||
<height>8</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
<property name="rightMargin">
|
||||||
</item>
|
<number>6</number>
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="noRunningScriptsLabel">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">font: 14px;</string>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="bottomMargin">
|
||||||
<string>There are no scripts currently running.</string>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer_2">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>10</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="runningScriptsList">
|
<widget class="QScrollArea" name="runningScriptsList">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -382,81 +301,20 @@ padding-top: 3px;</string>
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="recentlyLoadedScriptsArea" native="true">
|
<widget class="QLabel" name="noRunningScriptsLabel">
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>0</width>
|
|
||||||
<height>100</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>16777215</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
|
||||||
<property name="spacing">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="leftMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="topMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="rightMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="bottomMargin">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="recentlyLoadedLabel">
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">color: #0e7077;
|
|
||||||
font: bold 16px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string><html><head/><body><p><span style=" font-weight:600;">Recently loaded</span></p></body></html></string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="noRecentlyLoadedLabel">
|
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">font: 14px;</string>
|
<string notr="true">font: 14px;</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>There are no recently loaded scripts.</string>
|
<string>There are no scripts currently running.</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<widget class="QWidget" name="recentlyLoadedScriptsTableWidget" native="true">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>1</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>284</width>
|
|
||||||
<height>0</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background: transparent;
|
|
||||||
font-size: 14px;</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -476,9 +334,6 @@ font-size: 14px;</string>
|
||||||
<height>300</height>
|
<height>300</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
|
@ -502,16 +357,16 @@ font-size: 14px;</string>
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="rightMargin">
|
<property name="rightMargin">
|
||||||
<number>0</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>15</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
@ -539,28 +394,6 @@ font: bold 16px;</string>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="loadScriptButton">
|
<widget class="QPushButton" name="loadScriptButton">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>111</width>
|
|
||||||
<height>35</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="cursor">
|
|
||||||
<cursorShape>PointingHandCursor</cursorShape>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background: #0e7077;
|
|
||||||
color: #fff;
|
|
||||||
border-radius: 4px;
|
|
||||||
font: bold 14px;
|
|
||||||
padding-top: 3px;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Load script</string>
|
<string>Load script</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -570,13 +403,22 @@ padding-top: 3px;</string>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="filterLineEdit">
|
<widget class="QWidget" name="widget_2" native="true">
|
||||||
<property name="styleSheet">
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
<string notr="true">border: 1px solid rgb(128, 128, 128);
|
<property name="leftMargin">
|
||||||
border-radius: 2px;
|
<number>6</number>
|
||||||
padding: 4px;
|
|
||||||
background-color: white;</string>
|
|
||||||
</property>
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="filterLineEdit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
|
@ -588,40 +430,8 @@ background-color: white;</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<spacer name="verticalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeType">
|
|
||||||
<enum>QSizePolicy::Fixed</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>6</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="scriptListView">
|
<widget class="QListView" name="scriptListView">
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">QListView {
|
|
||||||
border: 1px solid rgb(128, 128, 128);
|
|
||||||
border-radius: 2px;
|
|
||||||
}
|
|
||||||
QListView::item {
|
|
||||||
padding-top: 2px;
|
|
||||||
padding-bottom: 2px;
|
|
||||||
}</string>
|
|
||||||
</property>
|
|
||||||
<property name="frameShape">
|
|
||||||
<enum>QFrame::Box</enum>
|
|
||||||
</property>
|
|
||||||
<property name="frameShadow">
|
|
||||||
<enum>QFrame::Plain</enum>
|
|
||||||
</property>
|
|
||||||
<property name="verticalScrollBarPolicy">
|
<property name="verticalScrollBarPolicy">
|
||||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -635,6 +445,9 @@ QListView::item {
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//
|
//
|
||||||
// EntityScriptingInterface.cpp
|
// EntityScriptingInterface.cpp
|
||||||
// libraries/models/src
|
// libraries/entities/src
|
||||||
//
|
//
|
||||||
// Created by Brad Hefta-Gaub on 12/6/13.
|
// Created by Brad Hefta-Gaub on 12/6/13.
|
||||||
// Copyright 2013 High Fidelity, Inc.
|
// Copyright 2013 High Fidelity, Inc.
|
||||||
|
@ -19,7 +19,6 @@ EntityScriptingInterface::EntityScriptingInterface() :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
void EntityScriptingInterface::queueEntityMessage(PacketType packetType,
|
||||||
EntityItemID entityID, const EntityItemProperties& properties) {
|
EntityItemID entityID, const EntityItemProperties& properties) {
|
||||||
getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
|
getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties);
|
||||||
|
@ -35,7 +34,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro
|
||||||
// queue the packet
|
// queue the packet
|
||||||
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
queueEntityMessage(PacketTypeEntityAddOrEdit, id, properties);
|
||||||
|
|
||||||
// If we have a local model tree set, then also update it.
|
// If we have a local entity tree set, then also update it.
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
_entityTree->addEntity(id, properties);
|
_entityTree->addEntity(id, properties);
|
||||||
|
@ -93,20 +92,20 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(EntityItemID
|
||||||
EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
|
EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const EntityItemProperties& properties) {
|
||||||
EntityItemID actualID = entityID;
|
EntityItemID actualID = entityID;
|
||||||
|
|
||||||
// if the model is unknown, attempt to look it up
|
// if the entity is unknown, attempt to look it up
|
||||||
if (!entityID.isKnownID) {
|
if (!entityID.isKnownID) {
|
||||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if at this point, we know the id, send the update to the model server
|
// if at this point, we know the id, send the update to the entity server
|
||||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||||
entityID.id = actualID.id;
|
entityID.id = actualID.id;
|
||||||
entityID.isKnownID = true;
|
entityID.isKnownID = true;
|
||||||
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
queueEntityMessage(PacketTypeEntityAddOrEdit, entityID, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a local model tree set, then also update it. We can do this even if we don't know
|
// If we have a local entity tree set, then also update it. We can do this even if we don't know
|
||||||
// the actual id, because we can edit out local models just with creatorTokenID
|
// the actual id, because we can edit out local entities just with creatorTokenID
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
_entityTree->updateEntity(entityID, properties);
|
_entityTree->updateEntity(entityID, properties);
|
||||||
|
@ -119,19 +118,19 @@ void EntityScriptingInterface::deleteEntity(EntityItemID entityID) {
|
||||||
|
|
||||||
EntityItemID actualID = entityID;
|
EntityItemID actualID = entityID;
|
||||||
|
|
||||||
// if the model is unknown, attempt to look it up
|
// if the entity is unknown, attempt to look it up
|
||||||
if (!entityID.isKnownID) {
|
if (!entityID.isKnownID) {
|
||||||
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
actualID = EntityItemID::getIDfromCreatorTokenID(entityID.creatorTokenID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if at this point, we know the id, send the update to the model server
|
// if at this point, we know the id, send the update to the entity server
|
||||||
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
if (actualID.id != UNKNOWN_ENTITY_ID) {
|
||||||
entityID.id = actualID.id;
|
entityID.id = actualID.id;
|
||||||
entityID.isKnownID = true;
|
entityID.isKnownID = true;
|
||||||
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
getEntityPacketSender()->queueEraseEntityMessage(entityID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a local model tree set, then also update it.
|
// If we have a local entity tree set, then also update it.
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForWrite();
|
_entityTree->lockForWrite();
|
||||||
_entityTree->deleteEntity(entityID);
|
_entityTree->deleteEntity(entityID);
|
||||||
|
@ -167,12 +166,12 @@ QVector<EntityItemID> EntityScriptingInterface::findEntities(const glm::vec3& ce
|
||||||
QVector<EntityItemID> result;
|
QVector<EntityItemID> result;
|
||||||
if (_entityTree) {
|
if (_entityTree) {
|
||||||
_entityTree->lockForRead();
|
_entityTree->lockForRead();
|
||||||
QVector<const EntityItem*> models;
|
QVector<const EntityItem*> entities;
|
||||||
_entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, models);
|
_entityTree->findEntities(center/(float)TREE_SCALE, radius/(float)TREE_SCALE, entities);
|
||||||
_entityTree->unlock();
|
_entityTree->unlock();
|
||||||
|
|
||||||
foreach (const EntityItem* model, models) {
|
foreach (const EntityItem* entity, entities) {
|
||||||
EntityItemID thisEntityItemID(model->getID(), UNKNOWN_ENTITY_TOKEN, true);
|
EntityItemID thisEntityItemID(entity->getID(), UNKNOWN_ENTITY_TOKEN, true);
|
||||||
result << thisEntityItemID;
|
result << thisEntityItemID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -219,11 +218,11 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
||||||
QScriptValue obj = engine->newObject();
|
QScriptValue obj = engine->newObject();
|
||||||
obj.setProperty("intersects", value.intersects);
|
obj.setProperty("intersects", value.intersects);
|
||||||
obj.setProperty("accurate", value.accurate);
|
obj.setProperty("accurate", value.accurate);
|
||||||
QScriptValue modelItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
QScriptValue entityItemValue = EntityItemIDtoScriptValue(engine, value.entityID);
|
||||||
obj.setProperty("entityID", modelItemValue);
|
obj.setProperty("entityID", entityItemValue);
|
||||||
|
|
||||||
QScriptValue modelPropertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
QScriptValue propertiesValue = EntityItemPropertiesToScriptValue(engine, value.properties);
|
||||||
obj.setProperty("properties", modelPropertiesValue);
|
obj.setProperty("properties", propertiesValue);
|
||||||
|
|
||||||
obj.setProperty("distance", value.distance);
|
obj.setProperty("distance", value.distance);
|
||||||
|
|
||||||
|
@ -262,13 +261,13 @@ QScriptValue RayToEntityIntersectionResultToScriptValue(QScriptEngine* engine, c
|
||||||
void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
|
void RayToEntityIntersectionResultFromScriptValue(const QScriptValue& object, RayToEntityIntersectionResult& value) {
|
||||||
value.intersects = object.property("intersects").toVariant().toBool();
|
value.intersects = object.property("intersects").toVariant().toBool();
|
||||||
value.accurate = object.property("accurate").toVariant().toBool();
|
value.accurate = object.property("accurate").toVariant().toBool();
|
||||||
QScriptValue modelIDValue = object.property("entityID");
|
QScriptValue entityIDValue = object.property("entityID");
|
||||||
if (modelIDValue.isValid()) {
|
if (entityIDValue.isValid()) {
|
||||||
EntityItemIDfromScriptValue(modelIDValue, value.entityID);
|
EntityItemIDfromScriptValue(entityIDValue, value.entityID);
|
||||||
}
|
}
|
||||||
QScriptValue modelPropertiesValue = object.property("properties");
|
QScriptValue entityPropertiesValue = object.property("properties");
|
||||||
if (modelPropertiesValue.isValid()) {
|
if (entityPropertiesValue.isValid()) {
|
||||||
EntityItemPropertiesFromScriptValue(modelPropertiesValue, value.properties);
|
EntityItemPropertiesFromScriptValue(entityPropertiesValue, value.properties);
|
||||||
}
|
}
|
||||||
value.distance = object.property("distance").toVariant().toFloat();
|
value.distance = object.property("distance").toVariant().toFloat();
|
||||||
|
|
||||||
|
|
|
@ -175,7 +175,16 @@ bool UpdateEntityOperator::preRecursion(OctreeElement* element) {
|
||||||
|
|
||||||
// if we are the existing containing element, then we can just do the update of the entity properties
|
// if we are the existing containing element, then we can just do the update of the entity properties
|
||||||
if (entityTreeElement == _containingElement) {
|
if (entityTreeElement == _containingElement) {
|
||||||
assert(!_removeOld); // We shouldn't be in a remove old case and also be the new best fit
|
|
||||||
|
// TODO: We shouldn't be in a remove old case and also be the new best fit. This indicates that
|
||||||
|
// we have some kind of a logic error in this operator. But, it can handle it properly by setting
|
||||||
|
// the new properties for the entity and moving on. Still going to output a warning that if we
|
||||||
|
// see consistently we will want to address this.
|
||||||
|
if (_removeOld) {
|
||||||
|
qDebug() << "UNEXPECTED - UpdateEntityOperator - "
|
||||||
|
"we thought we needed to removeOld, but the old entity is our best fit.";
|
||||||
|
_removeOld = false;
|
||||||
|
}
|
||||||
|
|
||||||
// set the entity properties and mark our element as changed.
|
// set the entity properties and mark our element as changed.
|
||||||
_existingEntity->setProperties(_properties);
|
_existingEntity->setProperties(_properties);
|
||||||
|
|
24
libraries/shared/src/LogUtils.cpp
Normal file
24
libraries/shared/src/LogUtils.cpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// LogUtils.cpp
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "LogUtils.h"
|
||||||
|
|
||||||
|
void LogUtils::init() {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// Windows applications buffer stdout/err hard when not run from a terminal,
|
||||||
|
// making assignment clients run from the Stack Manager application not flush
|
||||||
|
// log messages.
|
||||||
|
// This will disable the buffering. If this becomes a performance issue,
|
||||||
|
// an alternative is to call fflush(...) periodically.
|
||||||
|
setbuf(stdout, NULL);
|
||||||
|
setbuf(stderr, NULL);
|
||||||
|
#endif
|
||||||
|
}
|
20
libraries/shared/src/LogUtils.h
Normal file
20
libraries/shared/src/LogUtils.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//
|
||||||
|
// LogUtils.h
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_LogUtils_h
|
||||||
|
#define hifi_LogUtils_h
|
||||||
|
|
||||||
|
class LogUtils {
|
||||||
|
public:
|
||||||
|
static void init();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_LogUtils_h
|
31
libraries/shared/src/ShutdownEventListener.cpp
Normal file
31
libraries/shared/src/ShutdownEventListener.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
//
|
||||||
|
// ShutdownEventListener.cpp
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "ShutdownEventListener.h"
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ShutdownEventListener::ShutdownEventListener(QObject* parent) : QObject(parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ShutdownEventListener::nativeEventFilter(const QByteArray &eventType, void* msg, long* result) {
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
if (eventType == "windows_generic_MSG") {
|
||||||
|
MSG* message = (MSG*)msg;
|
||||||
|
if (message->message == WM_CLOSE) {
|
||||||
|
emit receivedCloseEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return true;
|
||||||
|
}
|
29
libraries/shared/src/ShutdownEventListener.h
Normal file
29
libraries/shared/src/ShutdownEventListener.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// ShutdownEventListener.h
|
||||||
|
// libraries/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/03/14.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_ShutdownEventListener_h
|
||||||
|
#define hifi_ShutdownEventListener_h
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QAbstractNativeEventFilter>
|
||||||
|
|
||||||
|
class ShutdownEventListener : public QObject, public QAbstractNativeEventFilter {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ShutdownEventListener(QObject* parent = NULL);
|
||||||
|
|
||||||
|
virtual bool nativeEventFilter(const QByteArray& eventType, void* message, long* result);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void receivedCloseEvent();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_ShutdownEventListener_h
|
29
libraries/shared/src/UIUtil.cpp
Normal file
29
libraries/shared/src/UIUtil.cpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// UIUtil.cpp
|
||||||
|
// library/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/02/2014.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <QStyle>
|
||||||
|
#include <QStyleOptionTitleBar>
|
||||||
|
|
||||||
|
#include "UIUtil.h"
|
||||||
|
|
||||||
|
int UIUtil::getWindowTitleBarHeight(const QWidget* window) {
|
||||||
|
QStyleOptionTitleBar options;
|
||||||
|
options.titleBarState = 1;
|
||||||
|
options.titleBarFlags = Qt::Window;
|
||||||
|
int titleBarHeight = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options, window);
|
||||||
|
|
||||||
|
#if defined(Q_OS_MAC)
|
||||||
|
// The height on OSX is 4 pixels too tall
|
||||||
|
titleBarHeight -= 4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return titleBarHeight;
|
||||||
|
}
|
24
libraries/shared/src/UIUtil.h
Normal file
24
libraries/shared/src/UIUtil.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
//
|
||||||
|
// UIUtil.h
|
||||||
|
// library/shared/src
|
||||||
|
//
|
||||||
|
// Created by Ryan Huffman on 09/02/2014.
|
||||||
|
// Copyright 2014 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef hifi_UIUtil_h
|
||||||
|
#define hifi_UIUtil_h
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class UIUtil {
|
||||||
|
public:
|
||||||
|
static int getWindowTitleBarHeight(const QWidget* window);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_UIUtil_h
|
Loading…
Reference in a new issue