Merge remote-tracking branch 'upstream/master' into defaultScripts

This commit is contained in:
James B. Pollack 2016-04-26 16:16:56 -07:00
commit afb2342781
12 changed files with 106 additions and 51 deletions

View file

@ -3104,10 +3104,8 @@ void Application::updateMyAvatarLookAtPosition() {
} else { } else {
// I am not looking at anyone else, so just look forward // I am not looking at anyone else, so just look forward
if (isHMD) { if (isHMD) {
glm::mat4 headPose = myAvatar->getHMDSensorMatrix(); glm::mat4 worldHMDMat = myAvatar->getSensorToWorldMatrix() * myAvatar->getHMDSensorMatrix();
glm::quat headRotation = glm::quat_cast(headPose); lookAtSpot = transformPoint(worldHMDMat, glm::vec3(0.0f, 0.0f, -TREE_SCALE));
lookAtSpot = myAvatar->getPosition() +
myAvatar->getOrientation() * (headRotation * glm::vec3(0.0f, 0.0f, -TREE_SCALE));
} else { } else {
lookAtSpot = myAvatar->getHead()->getEyePosition() + lookAtSpot = myAvatar->getHead()->getEyePosition() +
(myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE)); (myAvatar->getHead()->getFinalOrientationInWorldFrame() * glm::vec3(0.0f, 0.0f, -TREE_SCALE));

View file

@ -235,7 +235,12 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) {
return AvatarData::toByteArray(cullSmallChanges, sendAll); return AvatarData::toByteArray(cullSmallChanges, sendAll);
} }
void MyAvatar::reset(bool andReload) { void MyAvatar::reset(bool andRecenter) {
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "reset", Q_ARG(bool, andRecenter));
return;
}
// Reset dynamic state. // Reset dynamic state.
_wasPushing = _isPushing = _isBraking = false; _wasPushing = _isPushing = _isBraking = false;
@ -245,7 +250,7 @@ void MyAvatar::reset(bool andReload) {
_targetVelocity = glm::vec3(0.0f); _targetVelocity = glm::vec3(0.0f);
setThrust(glm::vec3(0.0f)); setThrust(glm::vec3(0.0f));
if (andReload) { if (andRecenter) {
// derive the desired body orientation from the *old* hmd orientation, before the sensor reset. // derive the desired body orientation from the *old* hmd orientation, before the sensor reset.
auto newBodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation.. auto newBodySensorMatrix = deriveBodyFromHMDSensor(); // Based on current cached HMD position/rotation..
@ -317,6 +322,37 @@ void MyAvatar::update(float deltaTime) {
} }
currentEnergy = max(0.0f, min(currentEnergy,1.0f)); currentEnergy = max(0.0f, min(currentEnergy,1.0f));
emit energyChanged(currentEnergy); emit energyChanged(currentEnergy);
updateEyeContactTarget(deltaTime);
}
void MyAvatar::updateEyeContactTarget(float deltaTime) {
_eyeContactTargetTimer -= deltaTime;
if (_eyeContactTargetTimer < 0.0f) {
const float CHANCE_OF_CHANGING_TARGET = 0.01f;
if (randFloat() < CHANCE_OF_CHANGING_TARGET) {
float const FIFTY_FIFTY_CHANCE = 0.5f;
float const EYE_TO_MOUTH_CHANCE = 0.25f;
switch (_eyeContactTarget) {
case LEFT_EYE:
_eyeContactTarget = (randFloat() < EYE_TO_MOUTH_CHANCE) ? MOUTH : RIGHT_EYE;
break;
case RIGHT_EYE:
_eyeContactTarget = (randFloat() < EYE_TO_MOUTH_CHANCE) ? MOUTH : LEFT_EYE;
break;
case MOUTH:
default:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? RIGHT_EYE : LEFT_EYE;
break;
}
const float EYE_TARGET_DELAY_TIME = 0.33f;
_eyeContactTargetTimer = EYE_TARGET_DELAY_TIME;
}
}
} }
extern QByteArray avatarStateToFrame(const AvatarData* _avatar); extern QByteArray avatarStateToFrame(const AvatarData* _avatar);
@ -944,22 +980,6 @@ void MyAvatar::clearLookAtTargetAvatar() {
} }
eyeContactTarget MyAvatar::getEyeContactTarget() { eyeContactTarget MyAvatar::getEyeContactTarget() {
float const CHANCE_OF_CHANGING_TARGET = 0.01f;
if (randFloat() < CHANCE_OF_CHANGING_TARGET) {
float const FIFTY_FIFTY_CHANCE = 0.5f;
switch (_eyeContactTarget) {
case LEFT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? MOUTH : RIGHT_EYE;
break;
case RIGHT_EYE:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? LEFT_EYE : MOUTH;
break;
case MOUTH:
_eyeContactTarget = (randFloat() < FIFTY_FIFTY_CHANCE) ? RIGHT_EYE : LEFT_EYE;
break;
}
}
return _eyeContactTarget; return _eyeContactTarget;
} }

View file

@ -93,7 +93,7 @@ public:
AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; } AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; }
AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; } AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; }
void reset(bool andReload = false); Q_INVOKABLE void reset(bool andRecenter = false);
void update(float deltaTime); void update(float deltaTime);
void preRender(RenderArgs* renderArgs); void preRender(RenderArgs* renderArgs);
@ -331,6 +331,8 @@ private:
bool cameraInsideHead() const; bool cameraInsideHead() const;
void updateEyeContactTarget(float deltaTime);
// These are made private for MyAvatar so that you will use the "use" methods instead // These are made private for MyAvatar so that you will use the "use" methods instead
virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override; virtual void setSkeletonModelURL(const QUrl& skeletonModelURL) override;
@ -371,6 +373,7 @@ private:
float _oculusYawOffset; float _oculusYawOffset;
eyeContactTarget _eyeContactTarget; eyeContactTarget _eyeContactTarget;
float _eyeContactTargetTimer { 0.0f };
glm::vec3 _trackedHeadPosition; glm::vec3 _trackedHeadPosition;

View file

@ -292,6 +292,8 @@ void AssetMappingModel::refresh() {
} else { } else {
emit errorGettingMappings(request->getErrorString()); emit errorGettingMappings(request->getErrorString());
} }
request->deleteLater();
}); });
request->start(); request->start();

View file

@ -1459,10 +1459,12 @@ void EntityTree::trackIncomingEntityLastEdited(quint64 lastEditedTime, int bytes
void EntityTree::callLoader(EntityItemID entityID) { void EntityTree::callLoader(EntityItemID entityID) {
// this is used to bounce from the networking thread to the main thread // this is used to bounce from the networking thread to the main thread
EntityItemPointer entity = findEntityByEntityItemID(entityID); this->withWriteLock([&] {
if (entity) { EntityItemPointer entity = findEntityByEntityItemID(entityID);
entity->loader(); if (entity) {
} entity->loader();
}
});
} }
int EntityTree::getJointIndex(const QUuid& entityID, const QString& name) const { int EntityTree::getJointIndex(const QUuid& entityID, const QString& name) const {

View file

@ -10,9 +10,9 @@
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
HIFI_PUBLIC_BUCKET = "http://s3.amazonaws.com/hifi-public/"; HIFI_PUBLIC_BUCKET = 'http://s3.amazonaws.com/hifi-public/';
Script.include("../../libraries/toolBars.js"); Script.include('../../libraries/toolBars.js');
const DEFAULT_NUM_LAYERS = 16; const DEFAULT_NUM_LAYERS = 16;
const DEFAULT_BASE_DIMENSION = { x: 7, y: 2, z: 7 }; const DEFAULT_BASE_DIMENSION = { x: 7, y: 2, z: 7 };
@ -30,6 +30,8 @@ const DEFAULT_RESTITUTION = 0.0;
const DEFAULT_SPAWN_DISTANCE = 3; const DEFAULT_SPAWN_DISTANCE = 3;
const DEFAULT_BLOCK_YAW_OFFSET = 45; const DEFAULT_BLOCK_YAW_OFFSET = 45;
const PLANKY_LIFETIME = 3600; // 1 hour (3600 seconds)
var editMode = false; var editMode = false;
const BUTTON_DIMENSIONS = {width: 49, height: 49}; const BUTTON_DIMENSIONS = {width: 49, height: 49};
@ -51,13 +53,17 @@ SettingsWindow = function() {
this.plankyStack = null; this.plankyStack = null;
this.webWindow = null; this.webWindow = null;
this.init = function(plankyStack) { this.init = function(plankyStack) {
_this.webWindow = new OverlayWebWindow('Planky', Script.resolvePath('../../html/plankySettings.html'), 255, 500, true); _this.webWindow = new OverlayWebWindow({
title: 'Planky',
source: Script.resolvePath('../../html/plankySettings.html'),
toolWindow: true
});
_this.webWindow.setVisible(false); _this.webWindow.setVisible(false);
_this.webWindow.eventBridge.webEventReceived.connect(_this.onWebEventReceived); _this.webWindow.webEventReceived.connect(_this.onWebEventReceived);
_this.plankyStack = plankyStack; _this.plankyStack = plankyStack;
}; };
this.sendData = function(data) { this.sendData = function(data) {
_this.webWindow.eventBridge.emitScriptEvent(JSON.stringify(data)); _this.webWindow.emitScriptEvent(JSON.stringify(data));
}; };
this.onWebEventReceived = function(data) { this.onWebEventReceived = function(data) {
data = JSON.parse(data); data = JSON.parse(data);
@ -188,7 +194,8 @@ PlankyStack = function() {
dimensions: _this.options.baseDimension, dimensions: _this.options.baseDimension,
position: Vec3.sum(_this.basePosition, {y: -(_this.options.baseDimension.y / 2)}), position: Vec3.sum(_this.basePosition, {y: -(_this.options.baseDimension.y / 2)}),
rotation: _this.baseRotation, rotation: _this.baseRotation,
shapeType: 'box' shapeType: 'box',
lifetime: PLANKY_LIFETIME
}); });
return; return;
} }
@ -254,7 +261,8 @@ PlankyStack = function() {
density: _this.options.density, density: _this.options.density,
velocity: {x: 0, y: 0, z: 0}, velocity: {x: 0, y: 0, z: 0},
angularVelocity: Quat.fromPitchYawRollDegrees(0, 0, 0), angularVelocity: Quat.fromPitchYawRollDegrees(0, 0, 0),
collisionless: true collisionless: true,
lifetime: PLANKY_LIFETIME
}; };
_this.planks.forEach(function(plank, index, object) { _this.planks.forEach(function(plank, index, object) {
if (plank.layer === layer && plank.row === row) { if (plank.layer === layer && plank.row === row) {
@ -304,6 +312,7 @@ var settingsWindow = new SettingsWindow();
var plankyStack = new PlankyStack(); var plankyStack = new PlankyStack();
settingsWindow.init(plankyStack); settingsWindow.init(plankyStack);
// This function is used to get the ideal y-location for a floor
function grabLowestJointY() { function grabLowestJointY() {
var jointNames = MyAvatar.getJointNames(); var jointNames = MyAvatar.getJointNames();
var floorY = MyAvatar.position.y; var floorY = MyAvatar.position.y;

View file

@ -3,11 +3,15 @@
<head> <head>
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript" src="jquery-2.1.4.min.js"></script> <script type="text/javascript" src="jquery-2.1.4.min.js"></script>
<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"></script>
<script type="text/javascript" src="eventBridgeLoader.js"></script>
<script type="text/javascript"> <script type="text/javascript">
var properties = []; var properties = [];
function sendWebEvent(data) {
EventBridge.emitWebEvent(JSON.stringify(data)); var sendWebEvent = function(data) {
console.log('sendWebEvent not initialized.');
} }
PropertyInput = function(key, label, value, attributes) { PropertyInput = function(key, label, value, attributes) {
this.key = key; this.key = key;
this.label = label; this.label = label;
@ -93,7 +97,7 @@ function addHeader(label) {
$('#properties-list').append($('<div>').addClass('section-header').append($('<label>').text(label))); $('#properties-list').append($('<div>').addClass('section-header').append($('<label>').text(label)));
} }
$(function() { $(function() {
addHeader('Stack Settings'); addHeader('Stack Settings');
properties['numLayers'] = new NumberInput('numLayers', 'Layers', 17, {'min': 0, 'max': 300, 'step': 1}); properties['numLayers'] = new NumberInput('numLayers', 'Layers', 17, {'min': 0, 'max': 300, 'step': 1});
properties['blocksPerLayer'] = new NumberInput('blocksPerLayer', 'Blocks per layer', 4, {'min': 1, 'max': 100, 'step': 1}); properties['blocksPerLayer'] = new NumberInput('blocksPerLayer', 'Blocks per layer', 4, {'min': 1, 'max': 100, 'step': 1});
@ -120,7 +124,8 @@ $(function() {
.append($('<input>').val('factory reset').attr('type', 'button').on('click', function() { sendWebEvent({action: 'factory-reset'}); })) .append($('<input>').val('factory reset').attr('type', 'button').on('click', function() { sendWebEvent({action: 'factory-reset'}); }))
.append($('<input>').val('save as default').attr('type', 'button').on('click', function() { sendWebEvent({action: 'save-default'}); })) .append($('<input>').val('save as default').attr('type', 'button').on('click', function() { sendWebEvent({action: 'save-default'}); }))
.append($('<input>').val('cleanup planky').attr('type', 'button').on('click', function() { sendWebEvent({action: 'cleanup'}); })); .append($('<input>').val('cleanup planky').attr('type', 'button').on('click', function() { sendWebEvent({action: 'cleanup'}); }));
if (window.EventBridge !== undefined) {
openEventBridge(function() {
EventBridge.scriptEventReceived.connect(function(data) { EventBridge.scriptEventReceived.connect(function(data) {
data = JSON.parse(data); data = JSON.parse(data);
if (data.action == 'load') { if (data.action == 'load') {
@ -129,12 +134,15 @@ $(function() {
}); });
} }
}); });
} sendWebEvent = function(data) {
sendWebEvent({action: 'loaded'}); EventBridge.emitWebEvent(JSON.stringify(data));
};
sendWebEvent({action: 'loaded'});
});
}); });
</script> </script>
</head> </head>
<body class="properties"> <body class="properties">
<div id="properties-list"></div> <div id="properties-list"></div>
</body> </body>
</html> </html>

View file

@ -196,6 +196,7 @@ function goActive() {
} }
MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting. MyAvatar.setEnableMeshVisible(true); // IWBNI we respected Developer->Avatar->Draw Mesh setting.
stopAwayAnimation(); stopAwayAnimation();
MyAvatar.reset(true);
hideOverlay(); hideOverlay();
// restore overlays state to what it was when we went "away" // restore overlays state to what it was when we went "away"

View file

@ -26,6 +26,7 @@ var directoryWindow = new OverlayWebWindow({
var toolHeight = 50; var toolHeight = 50;
var toolWidth = 50; var toolWidth = 50;
var TOOLBAR_MARGIN_Y = 25;
function showDirectory() { function showDirectory() {
@ -52,11 +53,14 @@ var toolBar = (function() {
browseDirectoryButton; browseDirectoryButton;
function initialize() { function initialize() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) { toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.directory.toolbar", function(windowDimensions, toolbar) {
return { return {
x: windowDimensions.x - 8 - toolbar.width, x: windowDimensions.x / 2,
y: 50 y: windowDimensions.y
}; };
}, {
x: -2 * toolWidth,
y: -TOOLBAR_MARGIN_Y - toolHeight
}); });
browseDirectoryButton = toolBar.addTool({ browseDirectoryButton = toolBar.addTool({
imageURL: toolIconUrl + "directory-01.svg", imageURL: toolIconUrl + "directory-01.svg",

View file

@ -53,6 +53,7 @@ selectionManager.addEventListener(function() {
var toolIconUrl = Script.resolvePath("assets/images/tools/"); var toolIconUrl = Script.resolvePath("assets/images/tools/");
var toolHeight = 50; var toolHeight = 50;
var toolWidth = 50; var toolWidth = 50;
var TOOLBAR_MARGIN_Y = 25;
var DEGREES_TO_RADIANS = Math.PI / 180.0; var DEGREES_TO_RADIANS = Math.PI / 180.0;
var RADIANS_TO_DEGREES = 180.0 / Math.PI; var RADIANS_TO_DEGREES = 180.0 / Math.PI;
@ -179,11 +180,14 @@ var toolBar = (function() {
newParticleButton newParticleButton
function initialize() { function initialize() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) { toolBar = new ToolBar(0, 0, ToolBar.HORIZONTAL, "highfidelity.edit.toolbar", function(windowDimensions, toolbar) {
return { return {
x: windowDimensions.x - 8 - toolbar.width, x: windowDimensions.x / 2,
y: (windowDimensions.y - toolbar.height) / 2 y: windowDimensions.y
}; };
}, {
x: toolWidth,
y: -TOOLBAR_MARGIN_Y - toolHeight
}); });
activeButton = toolBar.addTool({ activeButton = toolBar.addTool({

View file

@ -26,6 +26,7 @@ var examplesWindow = new OverlayWebWindow({
var toolHeight = 50; var toolHeight = 50;
var toolWidth = 50; var toolWidth = 50;
var TOOLBAR_MARGIN_Y = 25;
function showExamples(marketplaceID) { function showExamples(marketplaceID) {
@ -57,11 +58,14 @@ var toolBar = (function() {
browseExamplesButton; browseExamplesButton;
function initialize() { function initialize() {
toolBar = new ToolBar(0, 0, ToolBar.VERTICAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) { toolBar = new ToolBar(0, 0, ToolBar.HORIXONTAL, "highfidelity.examples.toolbar", function(windowDimensions, toolbar) {
return { return {
x: windowDimensions.x - 8 - toolbar.width, x: windowDimensions.x / 2,
y: 135 y: windowDimensions.y
}; };
}, {
x: -toolWidth / 2,
y: -TOOLBAR_MARGIN_Y - toolHeight
}); });
browseExamplesButton = toolBar.addTool({ browseExamplesButton = toolBar.addTool({
imageURL: toolIconUrl + "examples-01.svg", imageURL: toolIconUrl + "examples-01.svg",

View file

@ -28,7 +28,7 @@ You can make your home yours by uploading your own models and scripts.
</p> </p>
<p> <p>
<em>To see how,</em> <a target="_blank" href="https://docs.highfidelity.com/docs/the-basics">check out 'The Basics'</a> <em>To get started exploring and creating,</em> <a target="_blank" href="https://docs.highfidelity.com/docs/explore">check out our Quick-start Guide</a>
</p> </p>
</div> </div>
<div class="column center"> <div class="column center">