mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 00:13:10 +02:00
Merge branch 'master' of https://github.com/highfidelity/hifi
This commit is contained in:
commit
a6ce721586
13 changed files with 91 additions and 45 deletions
|
@ -291,7 +291,7 @@ int OctreeSendThread::packetDistributor(OctreeQueryNode* nodeData, bool viewFrus
|
|||
}
|
||||
|
||||
// calculate max number of packets that can be sent during this interval
|
||||
int clientMaxPacketsPerInterval = std::max(1, (nodeData->getMaxOctreePacketsPerSecond() / INTERVALS_PER_SECOND));
|
||||
int clientMaxPacketsPerInterval = std::max(1, (nodeData->getMaxQueryPacketsPerSecond() / INTERVALS_PER_SECOND));
|
||||
int maxPacketsPerInterval = std::min(clientMaxPacketsPerInterval, _myServer->getPacketsPerClientPerInterval());
|
||||
|
||||
int truePacketsSent = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@ var ANGULAR_DAMPING_RATE = 0.40;
|
|||
var SCREEN_TO_METERS = 0.001;
|
||||
var currentPosition, currentVelocity, cameraEntityDistance, currentRotation;
|
||||
var velocityTowardTarget, desiredVelocity, addedVelocity, newVelocity, dPosition, camYaw, distanceToTarget, targetPosition;
|
||||
var originalGravity;
|
||||
var originalGravity = {x: 0, y: 0, z: 0};
|
||||
var shouldRotate = false;
|
||||
var dQ, theta, axisAngle, dT;
|
||||
var angularVelocity = {
|
||||
|
@ -56,6 +56,15 @@ var dropLine = Overlays.addOverlay("line3d", {
|
|||
});
|
||||
|
||||
|
||||
function vectorIsZero(v) {
|
||||
return v.x == 0 && v.y == 0 && v.z == 0;
|
||||
}
|
||||
|
||||
function vectorToString(v) {
|
||||
return "(" + v.x + ", " + v.y + ", " + v.z + ")"
|
||||
}
|
||||
|
||||
|
||||
function mousePressEvent(event) {
|
||||
if (!event.isLeftButton) {
|
||||
return;
|
||||
|
@ -67,10 +76,16 @@ function mousePressEvent(event) {
|
|||
var props = Entities.getEntityProperties(grabbedEntity)
|
||||
isGrabbing = true;
|
||||
originalGravity = props.gravity;
|
||||
print("mouse-press setting originalGravity " + originalGravity + " " + vectorToString(originalGravity));
|
||||
targetPosition = props.position;
|
||||
currentPosition = props.position;
|
||||
currentVelocity = props.velocity;
|
||||
updateDropLine(targetPosition);
|
||||
|
||||
Entities.editEntity(grabbedEntity, {
|
||||
gravity: {x: 0, y: 0, z: 0}
|
||||
});
|
||||
|
||||
Audio.playSound(grabSound, {
|
||||
position: props.position,
|
||||
volume: 0.4
|
||||
|
@ -99,9 +114,20 @@ function mouseReleaseEvent() {
|
|||
if (isGrabbing) {
|
||||
isGrabbing = false;
|
||||
|
||||
Entities.editEntity(grabbedEntity, {
|
||||
gravity: originalGravity
|
||||
});
|
||||
// only restore the original gravity if it's not zero. This is to avoid...
|
||||
// 1. interface A grabs an entity and locally saves off its gravity
|
||||
// 2. interface A sets the entity's gravity to zero
|
||||
// 3. interface B grabs the entity and saves off its gravity (which is zero)
|
||||
// 4. interface A releases the entity and puts the original gravity back
|
||||
// 5. interface B releases the entity and puts the original gravity back (to zero)
|
||||
if (!vectorIsZero(originalGravity)) {
|
||||
print("mouse-release restoring originalGravity" + vectorToString(originalGravity));
|
||||
Entities.editEntity(grabbedEntity, {
|
||||
gravity: originalGravity
|
||||
});
|
||||
} else {
|
||||
print("mouse-release not restoring originalGravity of zero");
|
||||
}
|
||||
|
||||
Overlays.editOverlay(dropLine, {
|
||||
visible: false
|
||||
|
@ -117,6 +143,13 @@ function mouseReleaseEvent() {
|
|||
|
||||
function mouseMoveEvent(event) {
|
||||
if (isGrabbing) {
|
||||
// see if something added/restored gravity
|
||||
var props = Entities.getEntityProperties(grabbedEntity);
|
||||
if (!vectorIsZero(props.gravity)) {
|
||||
originalGravity = props.gravity;
|
||||
print("mouse-move adopting originalGravity" + vectorToString(originalGravity));
|
||||
}
|
||||
|
||||
deltaMouse.x = event.x - prevMouse.x;
|
||||
if (!moveUpDown) {
|
||||
deltaMouse.z = event.y - prevMouse.y;
|
||||
|
@ -211,8 +244,7 @@ function update(deltaTime) {
|
|||
|
||||
Entities.editEntity(grabbedEntity, {
|
||||
velocity: newVelocity,
|
||||
angularVelocity: angularVelocity,
|
||||
gravity: {x: 0, y: 0, z: 0}
|
||||
angularVelocity: angularVelocity
|
||||
})
|
||||
updateDropLine(targetPosition);
|
||||
}
|
||||
|
|
|
@ -184,6 +184,8 @@ const QString CHECK_VERSION_URL = "https://highfidelity.com/latestVersion.xml";
|
|||
const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
|
||||
|
||||
const QString DEFAULT_SCRIPTS_JS_URL = "http://s3.amazonaws.com/hifi-public/scripts/defaultScripts.js";
|
||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
class MyNativeEventFilter : public QAbstractNativeEventFilter {
|
||||
|
@ -336,7 +338,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) :
|
|||
_isVSyncOn(true),
|
||||
_aboutToQuit(false),
|
||||
_notifiedPacketVersionMismatchThisDomain(false),
|
||||
_domainConnectionRefusals(QList<QString>())
|
||||
_domainConnectionRefusals(QList<QString>()),
|
||||
_maxOctreePPS(maxOctreePacketsPerSecond.get())
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
installNativeEventFilter(&MyNativeEventFilter::getInstance());
|
||||
|
@ -2685,7 +2688,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
int perServerPPS = 0;
|
||||
const int SMALL_BUDGET = 10;
|
||||
int perUnknownServer = SMALL_BUDGET;
|
||||
int totalPPS = _octreeQuery.getMaxOctreePacketsPerSecond();
|
||||
int totalPPS = getMaxOctreePacketsPerSecond();
|
||||
|
||||
// determine PPS based on number of servers
|
||||
if (inViewServers >= 1) {
|
||||
|
@ -2748,7 +2751,7 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
}
|
||||
|
||||
if (inView) {
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(perServerPPS);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS);
|
||||
} else if (unknownView) {
|
||||
if (wantExtraDebugging) {
|
||||
qCDebug(interfaceapp) << "no known jurisdiction for node " << *node << ", give it budget of "
|
||||
|
@ -2772,9 +2775,9 @@ void Application::queryOctree(NodeType_t serverType, PacketType packetType, Node
|
|||
qCDebug(interfaceapp) << "Using regular camera position for node" << *node;
|
||||
}
|
||||
}
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(perUnknownServer);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer);
|
||||
} else {
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(0);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(0);
|
||||
}
|
||||
// set up the packet for sending...
|
||||
unsigned char* endOfQueryPacket = queryPacket;
|
||||
|
@ -4650,3 +4653,14 @@ PickRay Application::computePickRay() const {
|
|||
bool Application::hasFocus() const {
|
||||
return _glWidget->hasFocus();
|
||||
}
|
||||
|
||||
void Application::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||
if (maxOctreePPS != _maxOctreePPS) {
|
||||
_maxOctreePPS = maxOctreePPS;
|
||||
maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
}
|
||||
}
|
||||
|
||||
int Application::getMaxOctreePacketsPerSecond() {
|
||||
return _maxOctreePPS;
|
||||
}
|
||||
|
|
|
@ -344,6 +344,9 @@ public:
|
|||
bool canAcceptURL(const QString& url);
|
||||
bool acceptURL(const QString& url);
|
||||
|
||||
void setMaxOctreePacketsPerSecond(int maxOctreePPS);
|
||||
int getMaxOctreePacketsPerSecond();
|
||||
|
||||
signals:
|
||||
|
||||
/// Fired when we're simulating; allows external parties to hook in.
|
||||
|
@ -662,6 +665,8 @@ private:
|
|||
|
||||
QList<QString> _domainConnectionRefusals;
|
||||
glm::uvec2 _renderResolution;
|
||||
|
||||
int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
};
|
||||
|
||||
#endif // hifi_Application_h
|
||||
|
|
|
@ -168,7 +168,7 @@ void PreferencesDialog::loadPreferences() {
|
|||
|
||||
ui.avatarScaleSpin->setValue(myAvatar->getScale());
|
||||
|
||||
ui.maxOctreePPSSpin->setValue(qApp->getOctreeQuery().getMaxOctreePacketsPerSecond());
|
||||
ui.maxOctreePPSSpin->setValue(qApp->getMaxOctreePacketsPerSecond());
|
||||
|
||||
ui.oculusUIAngularSizeSpin->setValue(qApp->getApplicationOverlay().getHmdUIAngularSize());
|
||||
|
||||
|
@ -228,7 +228,7 @@ void PreferencesDialog::savePreferences() {
|
|||
|
||||
faceshift->setHostname(ui.faceshiftHostnameEdit->text());
|
||||
|
||||
qApp->getOctreeQuery().setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value());
|
||||
qApp->setMaxOctreePacketsPerSecond(ui.maxOctreePPSSpin->value());
|
||||
|
||||
qApp->getApplicationOverlay().setHmdUIAngularSize(ui.oculusUIAngularSizeSpin->value());
|
||||
|
||||
|
|
|
@ -142,7 +142,9 @@ QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorTe
|
|||
QUrl url(scriptMaybeURLorText);
|
||||
|
||||
// If the url is not valid, this must be script text...
|
||||
if (!url.isValid()) {
|
||||
// We document "direct injection" scripts as starting with "(function...", and that would never be a valid url.
|
||||
// But QUrl thinks it is.
|
||||
if (!url.isValid() || scriptMaybeURLorText.startsWith("(")) {
|
||||
isURL = false;
|
||||
return scriptMaybeURLorText;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "NetworkLogging.h"
|
||||
#include "DataServerAccountInfo.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "NetworkLogging.h"
|
||||
|
||||
#include "RSAKeypairGenerator.h"
|
||||
#ifndef __GNUC__
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -186,7 +186,7 @@ void OctreeHeadlessViewer::queryOctree() {
|
|||
}
|
||||
|
||||
if (inView) {
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(perServerPPS);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(perServerPPS);
|
||||
if (wantExtraDebugging) {
|
||||
qCDebug(octree) << "inView for node " << *node << ", give it budget of " << perServerPPS;
|
||||
}
|
||||
|
@ -213,9 +213,9 @@ void OctreeHeadlessViewer::queryOctree() {
|
|||
qCDebug(octree) << "Using regular camera position for node" << *node;
|
||||
}
|
||||
}
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(perUnknownServer);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(perUnknownServer);
|
||||
} else {
|
||||
_octreeQuery.setMaxOctreePacketsPerSecond(0);
|
||||
_octreeQuery.setMaxQueryPacketsPerSecond(0);
|
||||
}
|
||||
// set up the packet for sending...
|
||||
unsigned char* endOfQueryPacket = queryPacket;
|
||||
|
|
|
@ -11,25 +11,15 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PacketHeaders.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "OctreeConstants.h"
|
||||
#include "OctreeQuery.h"
|
||||
|
||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||
|
||||
OctreeQuery::OctreeQuery() {
|
||||
_maxOctreePPS = maxOctreePacketsPerSecond.get();
|
||||
_maxQueryPPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
}
|
||||
|
||||
void OctreeQuery::setMaxOctreePacketsPerSecond(int maxOctreePPS) {
|
||||
if (maxOctreePPS != _maxOctreePPS) {
|
||||
_maxOctreePPS = maxOctreePPS;
|
||||
maxOctreePacketsPerSecond.set(_maxOctreePPS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
||||
unsigned char* bufferStart = destinationBuffer;
|
||||
|
||||
|
@ -59,8 +49,8 @@ int OctreeQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
*destinationBuffer++ = bitItems;
|
||||
|
||||
// desired Max Octree PPS
|
||||
memcpy(destinationBuffer, &_maxOctreePPS, sizeof(_maxOctreePPS));
|
||||
destinationBuffer += sizeof(_maxOctreePPS);
|
||||
memcpy(destinationBuffer, &_maxQueryPPS, sizeof(_maxQueryPPS));
|
||||
destinationBuffer += sizeof(_maxQueryPPS);
|
||||
|
||||
// desired voxelSizeScale
|
||||
memcpy(destinationBuffer, &_octreeElementSizeScale, sizeof(_octreeElementSizeScale));
|
||||
|
@ -103,8 +93,8 @@ int OctreeQuery::parseData(const QByteArray& packet) {
|
|||
_wantCompression = oneAtBit(bitItems, WANT_COMPRESSION);
|
||||
|
||||
// desired Max Octree PPS
|
||||
memcpy(&_maxOctreePPS, sourceBuffer, sizeof(_maxOctreePPS));
|
||||
sourceBuffer += sizeof(_maxOctreePPS);
|
||||
memcpy(&_maxQueryPPS, sourceBuffer, sizeof(_maxQueryPPS));
|
||||
sourceBuffer += sizeof(_maxQueryPPS);
|
||||
|
||||
// desired _octreeElementSizeScale
|
||||
memcpy(&_octreeElementSizeScale, sourceBuffer, sizeof(_octreeElementSizeScale));
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
bool getWantLowResMoving() const { return _wantLowResMoving; }
|
||||
bool getWantOcclusionCulling() const { return _wantOcclusionCulling; }
|
||||
bool getWantCompression() const { return _wantCompression; }
|
||||
int getMaxOctreePacketsPerSecond() const { return _maxOctreePPS; }
|
||||
int getMaxQueryPacketsPerSecond() const { return _maxQueryPPS; }
|
||||
float getOctreeSizeScale() const { return _octreeElementSizeScale; }
|
||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||
|
||||
|
@ -86,7 +86,7 @@ public slots:
|
|||
void setWantDelta(bool wantDelta) { _wantDelta = wantDelta; }
|
||||
void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; }
|
||||
void setWantCompression(bool wantCompression) { _wantCompression = wantCompression; }
|
||||
void setMaxOctreePacketsPerSecond(int maxOctreePPS);
|
||||
void setMaxQueryPacketsPerSecond(int maxQueryPPS) { _maxQueryPPS = maxQueryPPS; }
|
||||
void setOctreeSizeScale(float octreeSizeScale) { _octreeElementSizeScale = octreeSizeScale; }
|
||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
||||
|
||||
|
@ -106,7 +106,7 @@ protected:
|
|||
bool _wantLowResMoving = true;
|
||||
bool _wantOcclusionCulling = false;
|
||||
bool _wantCompression = false;
|
||||
int _maxOctreePPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
int _maxQueryPPS = DEFAULT_MAX_OCTREE_PPS;
|
||||
float _octreeElementSizeScale = DEFAULT_OCTREE_SIZE_SCALE; /// used for LOD calculations
|
||||
int _boundaryLevelAdjust = 0; /// used for LOD calculations
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ MenuItemProperties::MenuItemProperties() :
|
|||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(false),
|
||||
isChecked(false)
|
||||
isChecked(false),
|
||||
isSeparator(false)
|
||||
{
|
||||
};
|
||||
|
||||
MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const QString& shortcutKey, bool checkable, bool checked) :
|
||||
const QString& shortcutKey, bool checkable, bool checked, bool separator) :
|
||||
menuName(menuName),
|
||||
menuItemName(menuItemName),
|
||||
shortcutKey(shortcutKey),
|
||||
|
@ -38,12 +39,13 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m
|
|||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(checkable),
|
||||
isChecked(checked)
|
||||
isChecked(checked),
|
||||
isSeparator(separator)
|
||||
{
|
||||
}
|
||||
|
||||
MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable, bool checked) :
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable, bool checked, bool separator) :
|
||||
menuName(menuName),
|
||||
menuItemName(menuItemName),
|
||||
shortcutKey(""),
|
||||
|
@ -53,7 +55,8 @@ MenuItemProperties::MenuItemProperties(const QString& menuName, const QString& m
|
|||
beforeItem(""),
|
||||
afterItem(""),
|
||||
isCheckable(checkable),
|
||||
isChecked(checked)
|
||||
isChecked(checked),
|
||||
isSeparator(separator)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ class MenuItemProperties {
|
|||
public:
|
||||
MenuItemProperties();
|
||||
MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false);
|
||||
const QString& shortcutKey = QString(""), bool checkable = false, bool checked = false, bool separator = false);
|
||||
MenuItemProperties(const QString& menuName, const QString& menuItemName,
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false);
|
||||
const KeyEvent& shortcutKeyEvent, bool checkable = false, bool checked = false, bool separator = false);
|
||||
|
||||
QString menuName;
|
||||
QString menuItemName;
|
||||
|
|
Loading…
Reference in a new issue