diff --git a/examples/defaultScripts.js b/examples/defaultScripts.js
index ff22f68cb5..8f32b80bba 100644
--- a/examples/defaultScripts.js
+++ b/examples/defaultScripts.js
@@ -15,7 +15,6 @@ Script.load("controllers/hydra/hydraMove.js");
Script.load("inspect.js");
Script.load("lobby.js");
Script.load("notifications.js");
-Script.load("look.js");
Script.load("users.js");
Script.load("grab.js");
Script.load("pointer.js");
diff --git a/examples/look.js b/examples/look.js
deleted file mode 100644
index 7adcd054c2..0000000000
--- a/examples/look.js
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-// look.js
-// examples
-//
-// Copyright 2015 High Fidelity, Inc.
-//
-// This is an example script that demonstrates use of the Controller class
-//
-// Distributed under the Apache License, Version 2.0.
-// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
-//
-
-var wantDebugging = false;
-
-
-// Configuration
-var TOUCH_YAW_SCALE = -0.25;
-var TOUCH_PITCH_SCALE = -12.5;
-var FIXED_TOUCH_TIMESTEP = 0.016;
-
-var MOUSE_YAW_SCALE = -0.25;
-var MOUSE_PITCH_SCALE = -12.5;
-var FIXED_MOUSE_TIMESTEP = 0.016;
-
-// Mouse Data
-var alwaysLook = false; // if you want the mouse look to happen only when you click, change this to false
-var isMouseDown = false;
-var lastTouchX = 0;
-var lastTouchY = 0;
-var yawFromTouch = 0;
-var pitchFromTouch = 0;
-
-// Touch Data
-var TIME_BEFORE_GENERATED_END_TOUCH_EVENT = 50; // ms
-var startedTouching = false;
-var lastTouchEvent = 0;
-var lastMouseX = 0;
-var lastMouseY = 0;
-var yawFromMouse = 0;
-var pitchFromMouse = 0;
-
-
-// Mouse Events
-function mousePressEvent(event) {
- if (wantDebugging) {
- print("mousePressEvent event.x,y=" + event.x + ", " + event.y);
- }
- if (event.isRightButton) {
- isMouseDown = true;
- lastMouseX = event.x;
- lastMouseY = event.y;
- }
-}
-
-function mouseReleaseEvent(event) {
- if (wantDebugging) {
- print("mouseReleaseEvent event.x,y=" + event.x + ", " + event.y);
- }
- isMouseDown = false;
-}
-
-function mouseMoveEvent(event) {
- if (wantDebugging) {
- print("mouseMoveEvent event.x,y=" + event.x + ", " + event.y);
- }
-
- if (alwaysLook || isMouseDown) {
- yawFromMouse += ((event.x - lastMouseX) * MOUSE_YAW_SCALE * FIXED_MOUSE_TIMESTEP);
- pitchFromMouse += ((event.y - lastMouseY) * MOUSE_PITCH_SCALE * FIXED_MOUSE_TIMESTEP);
- lastMouseX = event.x;
- lastMouseY = event.y;
- }
-}
-
-// Touch Events
-function touchBeginEvent(event) {
- if (wantDebugging) {
- print("touchBeginEvent event.x,y=" + event.x + ", " + event.y);
- }
- lastTouchX = event.x;
- lastTouchY = event.y;
- yawFromTouch = 0;
- pitchFromTouch = 0;
- startedTouching = true;
- var d = new Date();
- lastTouchEvent = d.getTime();
-}
-
-function touchEndEvent(event) {
- if (wantDebugging) {
- if (event) {
- print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
- } else {
- print("touchEndEvent generated");
- }
- }
- startedTouching = false;
-}
-
-function touchUpdateEvent(event) {
- // print("TOUCH UPDATE");
- if (wantDebugging) {
- print("touchUpdateEvent event.x,y=" + event.x + ", " + event.y);
- }
-
- if (!startedTouching) {
- // handle Qt 5.4.x bug where we get touch update without a touch begin event
- touchBeginEvent(event);
- return;
- }
-
- yawFromTouch += ((event.x - lastTouchX) * TOUCH_YAW_SCALE * FIXED_TOUCH_TIMESTEP);
- pitchFromTouch += ((event.y - lastTouchY) * TOUCH_PITCH_SCALE * FIXED_TOUCH_TIMESTEP);
- lastTouchX = event.x;
- lastTouchY = event.y;
- var d = new Date();
- lastTouchEvent = d.getTime();
-}
-
-
-function update(deltaTime) {
- if (wantDebugging) {
- print("update()...");
- }
-
- if (startedTouching) {
- var d = new Date();
- var sinceLastTouch = d.getTime() - lastTouchEvent;
- if (sinceLastTouch > TIME_BEFORE_GENERATED_END_TOUCH_EVENT) {
- touchEndEvent();
- }
- }
-
- if (yawFromTouch != 0 || yawFromMouse != 0) {
- var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromTouch + yawFromMouse, 0));
-
- if (wantDebugging) {
- print("changing orientation"
- + " [old]MyAvatar.orientation="+MyAvatar.orientation.x + "," + MyAvatar.orientation.y + ","
- + MyAvatar.orientation.z + "," + MyAvatar.orientation.w
- + " newOrientation="+newOrientation.x + "," + newOrientation.y + "," + newOrientation.z + "," + newOrientation.w);
- }
-
- MyAvatar.orientation = newOrientation;
- yawFromTouch = 0;
- yawFromMouse = 0;
- }
-
- if (pitchFromTouch != 0 || pitchFromMouse != 0) {
- var newPitch = MyAvatar.headPitch + pitchFromTouch + pitchFromMouse;
-
- if (wantDebugging) {
- print("changing pitch [old]MyAvatar.headPitch="+MyAvatar.headPitch+ " newPitch="+newPitch);
- }
-
- MyAvatar.headPitch = newPitch;
- pitchFromTouch = 0;
- pitchFromMouse = 0;
- }
-}
-
-
-// Map the mouse events to our functions
-Controller.mousePressEvent.connect(mousePressEvent);
-Controller.mouseMoveEvent.connect(mouseMoveEvent);
-Controller.mouseReleaseEvent.connect(mouseReleaseEvent);
-
-// Map the mouse events to our functions
-Controller.touchBeginEvent.connect(touchBeginEvent);
-Controller.touchUpdateEvent.connect(touchUpdateEvent);
-Controller.touchEndEvent.connect(touchEndEvent);
-
-// disable the standard application for mouse events
-Controller.captureTouchEvents();
-
-function scriptEnding() {
- // re-enabled the standard application for mouse events
- Controller.releaseTouchEvents();
-}
-
-// would be nice to change to update
-Script.update.connect(update);
-Script.scriptEnding.connect(scriptEnding);
diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp
index e3f9216c13..c65de2afb0 100644
--- a/interface/src/ui/ApplicationOverlay.cpp
+++ b/interface/src/ui/ApplicationOverlay.cpp
@@ -979,6 +979,14 @@ void ApplicationOverlay::renderStatsAndLogs() {
glLineWidth(1.0f);
glPointSize(1.0f);
+ // Determine whether to compute timing details
+ bool shouldDisplayTimingDetail = Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails) &&
+ Menu::getInstance()->isOptionChecked(MenuOption::Stats) &&
+ Stats::getInstance()->isExpanded();
+ if (shouldDisplayTimingDetail != PerformanceTimer::isActive()) {
+ PerformanceTimer::setActive(shouldDisplayTimingDetail);
+ }
+
if (Menu::getInstance()->isOptionChecked(MenuOption::Stats)) {
// let's set horizontal offset to give stats some margin to mirror
int horizontalOffset = MIRROR_VIEW_WIDTH + MIRROR_VIEW_LEFT_PADDING * 2;
diff --git a/interface/src/ui/JSConsole.cpp b/interface/src/ui/JSConsole.cpp
index 700781df69..74585df855 100644
--- a/interface/src/ui/JSConsole.cpp
+++ b/interface/src/ui/JSConsole.cpp
@@ -59,6 +59,7 @@ JSConsole::JSConsole(QWidget* parent, ScriptEngine* scriptEngine) :
connect(_scriptEngine, SIGNAL(evaluationFinished(QScriptValue, bool)),
this, SLOT(handleEvalutationFinished(QScriptValue, bool)));
connect(_scriptEngine, SIGNAL(printedMessage(const QString&)), this, SLOT(handlePrint(const QString&)));
+ connect(_scriptEngine, SIGNAL(errorMessage(const QString&)), this, SLOT(handleError(const QString&)));
resizeTextInput();
}
@@ -96,6 +97,10 @@ void JSConsole::handleEvalutationFinished(QScriptValue result, bool isException)
appendMessage(gutter, resultStr);
}
+void JSConsole::handleError(const QString& message) {
+ appendMessage(GUTTER_ERROR, "" + message.toHtmlEscaped() + "");
+}
+
void JSConsole::handlePrint(const QString& message) {
appendMessage("", message);
}
diff --git a/interface/src/ui/JSConsole.h b/interface/src/ui/JSConsole.h
index daeba8ea15..98afdf7bf8 100644
--- a/interface/src/ui/JSConsole.h
+++ b/interface/src/ui/JSConsole.h
@@ -49,6 +49,7 @@ protected slots:
void resizeTextInput();
void handleEvalutationFinished(QScriptValue result, bool isException);
void handlePrint(const QString& message);
+ void handleError(const QString& message);
private:
void appendMessage(const QString& gutter, const QString& message);
diff --git a/interface/src/ui/Stats.cpp b/interface/src/ui/Stats.cpp
index 161eb06f5f..c49208c835 100644
--- a/interface/src/ui/Stats.cpp
+++ b/interface/src/ui/Stats.cpp
@@ -224,9 +224,10 @@ void Stats::display(
lines = 5;
int columnOneWidth = _generalStatsWidth;
- PerformanceTimer::tallyAllTimerRecords(); // do this even if we're not displaying them, so they don't stack up
-
- if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails)) {
+ bool performanceTimerIsActive = PerformanceTimer::isActive();
+ bool displayPerf = _expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails);
+ if (displayPerf && performanceTimerIsActive) {
+ PerformanceTimer::tallyAllTimerRecords(); // do this even if we're not displaying them, so they don't stack up
columnOneWidth = _generalStatsWidth + _pingStatsWidth + _geoStatsWidth; // 3 columns wide...
// we will also include room for 1 line per timing record and a header of 4 lines
@@ -276,7 +277,7 @@ void Stats::display(
// TODO: the display of these timing details should all be moved to JavaScript
- if (_expanded && Menu::getInstance()->isOptionChecked(MenuOption::DisplayDebugTimingDetails)) {
+ if (displayPerf && performanceTimerIsActive) {
bool onlyDisplayTopTen = Menu::getInstance()->isOptionChecked(MenuOption::OnlyDisplayTopTen);
// Timing details...
verticalOffset += STATS_PELS_PER_LINE * 4; // skip 3 lines to be under the other columns
diff --git a/interface/src/ui/Stats.h b/interface/src/ui/Stats.h
index 406496d858..00c1650b71 100644
--- a/interface/src/ui/Stats.h
+++ b/interface/src/ui/Stats.h
@@ -27,6 +27,8 @@ public:
static void drawBackground(unsigned int rgba, int x, int y, int width, int height);
void toggleExpanded();
+ bool isExpanded() { return _expanded; }
+
void checkClick(int mouseX, int mouseY, int mouseDragStartedX, int mouseDragStartedY, int horizontalOffset);
void resetWidth(int width, int horizontalOffset);
void display(const float* color, int horizontalOffset, float fps, int inPacketsPerSecond, int outPacketsPerSecond,
diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp
index 86baacc8a8..859d9853d5 100644
--- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp
+++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp
@@ -1159,7 +1159,7 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
return;
}
// Don't respond to small continuous contacts.
- const float COLLISION_MINUMUM_PENETRATION = 0.005;
+ const float COLLISION_MINUMUM_PENETRATION = 0.005f;
if ((collision.type != CONTACT_EVENT_TYPE_START) && (glm::length(collision.penetration) < COLLISION_MINUMUM_PENETRATION)) {
return;
}
diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp
index e4ef24f109..3101307044 100644
--- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp
+++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp
@@ -25,8 +25,8 @@
#include "EntityTreeRenderer.h"
-const float DPI = 30.47;
-const float METERS_TO_INCHES = 39.3701;
+const float DPI = 30.47f;
+const float METERS_TO_INCHES = 39.3701f;
EntityItem* RenderableWebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
return new RenderableWebEntityItem(entityID, properties);
diff --git a/libraries/shared/src/PerfStat.cpp b/libraries/shared/src/PerfStat.cpp
index 286d257d1f..615330e13f 100644
--- a/libraries/shared/src/PerfStat.cpp
+++ b/libraries/shared/src/PerfStat.cpp
@@ -79,29 +79,50 @@ void PerformanceTimerRecord::tallyResult(const quint64& now) {
// PerformanceTimer
// ----------------------------------------------------------------------------
+std::atomic PerformanceTimer::_isActive(false);
QHash PerformanceTimer::_fullNames;
QMap PerformanceTimer::_records;
-PerformanceTimer::PerformanceTimer(const QString& name) :
- _start(0),
- _name(name)
-{
- QString& fullName = _fullNames[QThread::currentThread()];
- fullName.append("/");
- fullName.append(_name);
- _start = usecTimestampNow();
+PerformanceTimer::PerformanceTimer(const QString& name) {
+ if (_isActive) {
+ _name = name;
+ QString& fullName = _fullNames[QThread::currentThread()];
+ fullName.append("/");
+ fullName.append(_name);
+ _start = usecTimestampNow();
+ }
}
PerformanceTimer::~PerformanceTimer() {
- quint64 elapsedusec = (usecTimestampNow() - _start);
- QString& fullName = _fullNames[QThread::currentThread()];
- PerformanceTimerRecord& namedRecord = _records[fullName];
- namedRecord.accumulateResult(elapsedusec);
- fullName.resize(fullName.size() - (_name.size() + 1));
+ if (_isActive && _start != 0) {
+ quint64 elapsedusec = (usecTimestampNow() - _start);
+ QString& fullName = _fullNames[QThread::currentThread()];
+ PerformanceTimerRecord& namedRecord = _records[fullName];
+ namedRecord.accumulateResult(elapsedusec);
+ fullName.resize(fullName.size() - (_name.size() + 1));
+ }
}
-// static
+// static
+bool PerformanceTimer::isActive() {
+ return _isActive;
+}
+
+// static
+void PerformanceTimer::setActive(bool active) {
+ if (active != _isActive) {
+ _isActive.store(active);
+ if (!active) {
+ _fullNames.clear();
+ _records.clear();
+ }
+
+ qDebug() << "PerformanceTimer has been turned" << ((active) ? "on" : "off");
+ }
+}
+
+// static
void PerformanceTimer::tallyAllTimerRecords() {
QMap::iterator recordsItr = _records.begin();
QMap::const_iterator recordsEnd = _records.end();
diff --git a/libraries/shared/src/PerfStat.h b/libraries/shared/src/PerfStat.h
index 81731abfa9..523bee0808 100644
--- a/libraries/shared/src/PerfStat.h
+++ b/libraries/shared/src/PerfStat.h
@@ -19,6 +19,7 @@
#include "SharedUtil.h"
#include "SimpleMovingAverage.h"
+#include
#include
#include
#include