mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 17:00:36 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi into team-teaching
This commit is contained in:
commit
160898ce96
12 changed files with 70 additions and 211 deletions
|
@ -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");
|
||||
|
|
183
examples/look.js
183
examples/look.js
|
@ -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);
|
|
@ -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;
|
||||
|
|
|
@ -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, "<span style='" + RESULT_ERROR_STYLE + "'>" + message.toHtmlEscaped() + "</span>");
|
||||
}
|
||||
|
||||
void JSConsole::handlePrint(const QString& message) {
|
||||
appendMessage("", message);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -79,29 +79,50 @@ void PerformanceTimerRecord::tallyResult(const quint64& now) {
|
|||
// PerformanceTimer
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
std::atomic<bool> PerformanceTimer::_isActive(false);
|
||||
QHash<QThread*, QString> PerformanceTimer::_fullNames;
|
||||
QMap<QString, PerformanceTimerRecord> 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<QString, PerformanceTimerRecord>::iterator recordsItr = _records.begin();
|
||||
QMap<QString, PerformanceTimerRecord>::const_iterator recordsEnd = _records.end();
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "SharedUtil.h"
|
||||
#include "SimpleMovingAverage.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
@ -76,14 +77,18 @@ public:
|
|||
PerformanceTimer(const QString& name);
|
||||
~PerformanceTimer();
|
||||
|
||||
static bool isActive();
|
||||
static void setActive(bool active);
|
||||
|
||||
static const PerformanceTimerRecord& getTimerRecord(const QString& name) { return _records[name]; };
|
||||
static const QMap<QString, PerformanceTimerRecord>& getAllTimerRecords() { return _records; };
|
||||
static void tallyAllTimerRecords();
|
||||
static void dumpAllTimerRecords();
|
||||
|
||||
private:
|
||||
quint64 _start;
|
||||
quint64 _start = 0;
|
||||
QString _name;
|
||||
static std::atomic<bool> _isActive;
|
||||
static QHash<QThread*, QString> _fullNames;
|
||||
static QMap<QString, PerformanceTimerRecord> _records;
|
||||
};
|
||||
|
|
|
@ -255,27 +255,27 @@ VHACDUtilApp::VHACDUtilApp(int argc, char* argv[]) :
|
|||
vHacdDepth = parser.value(vHacdDepthOption).toInt();
|
||||
}
|
||||
|
||||
float vHacdAlpha = 0.05;
|
||||
float vHacdAlpha = 0.05f;
|
||||
if (parser.isSet(vHacdAlphaOption)) {
|
||||
vHacdAlpha = parser.value(vHacdAlphaOption).toFloat();
|
||||
}
|
||||
|
||||
float vHacdBeta = 0.05;
|
||||
float vHacdBeta = 0.05f;
|
||||
if (parser.isSet(vHacdBetaOption)) {
|
||||
vHacdBeta = parser.value(vHacdBetaOption).toFloat();
|
||||
}
|
||||
|
||||
float vHacdGamma = 0.00125;
|
||||
float vHacdGamma = 0.00125f;
|
||||
if (parser.isSet(vHacdGammaOption)) {
|
||||
vHacdGamma = parser.value(vHacdGammaOption).toFloat();
|
||||
}
|
||||
|
||||
float vHacdDelta = 0.05;
|
||||
float vHacdDelta = 0.05f;
|
||||
if (parser.isSet(vHacdDeltaOption)) {
|
||||
vHacdDelta = parser.value(vHacdDeltaOption).toFloat();
|
||||
}
|
||||
|
||||
float vHacdConcavity = 0.0025;
|
||||
float vHacdConcavity = 0.0025f;
|
||||
if (parser.isSet(vHacdConcavityOption)) {
|
||||
vHacdConcavity = parser.value(vHacdConcavityOption).toFloat();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue