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

This commit is contained in:
Brad Davis 2015-10-14 10:54:32 -07:00
commit f051a84dc6
11 changed files with 1266 additions and 1114 deletions

View file

@ -16,8 +16,9 @@ var scriptURL = Script.resolvePath('wallTarget.js');
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target_collision_hull.obj';
var MINIMUM_MOVE_LENGTH = 0.05;
var RESET_DISTANCE = 0.5;
var RESET_DISTANCE = 1;
var TARGET_USER_DATA_KEY = 'hifi-ping_pong_target';
var NUMBER_OF_TARGETS = 6;
var TARGETS_PER_ROW = 3;
@ -60,6 +61,8 @@ var targets = [];
var originalPositions = [];
var lastPositions = [];
function addTargets() {
var i;
var row = -1;
@ -77,6 +80,7 @@ function addTargets() {
position.y = startPosition.y - (row * VERTICAL_SPACING);
originalPositions.push(position);
lastPositions.push(position);
var targetProperties = {
name: 'Target',
@ -103,7 +107,11 @@ function testTargetDistanceFromStart() {
var distance = Vec3.subtract(originalPosition, currentPosition);
var length = Vec3.length(distance);
if (length > RESET_DISTANCE) {
var moving = Vec3.length(Vec3.subtract(currentPosition, lastPositions[index]));
lastPositions[index] = currentPosition;
if (length > RESET_DISTANCE && moving < MINIMUM_MOVE_LENGTH) {
Entities.deleteEntity(target);
@ -117,10 +125,16 @@ function testTargetDistanceFromStart() {
compoundShapeURL: COLLISION_HULL_URL,
position: originalPositions[index],
rotation: rotation,
script: scriptURL
script: scriptURL,
userData: JSON.stringify({
grabbableKey: {
grabbable: false
}
})
};
targets[index] = Entities.addEntity(targetProperties);
}
});
}
@ -142,7 +156,7 @@ function deleteTargets() {
}
Entities.deletingEntity.connect(deleteEntity);
var distanceCheckInterval = Script.setInterval(testTargetDistanceFromStart, 1000);
var distanceCheckInterval = Script.setInterval(testTargetDistanceFromStart, 500);
addTargets();

View file

@ -1559,7 +1559,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
cursor->setIcon(Cursor::Icon::DEFAULT);
}
} else {
resetSensors();
resetSensors(true);
}
break;
}
@ -3581,7 +3581,7 @@ void Application::renderRearViewMirror(RenderArgs* renderArgs, const QRect& regi
renderArgs->_viewport = originalViewport;
}
void Application::resetSensors() {
void Application::resetSensors(bool andReload) {
DependencyManager::get<Faceshift>()->reset();
DependencyManager::get<DdeFaceTracker>()->reset();
DependencyManager::get<EyeTracker>()->reset();
@ -3593,7 +3593,7 @@ void Application::resetSensors() {
QPoint windowCenter = mainWindow->geometry().center();
_glWidget->cursor().setPos(currentScreen, windowCenter);
getMyAvatar()->reset();
getMyAvatar()->reset(andReload);
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "reset", Qt::QueuedConnection);
}

View file

@ -274,7 +274,7 @@ public slots:
void setRawAvatarUpdateThreading();
void setRawAvatarUpdateThreading(bool isThreaded);
void resetSensors();
void resetSensors(bool andReload = false);
void setActiveFaceTracker();
#ifdef HAVE_IVIEWHMD

View file

@ -461,6 +461,7 @@ Menu::Menu() {
0, false,
&ConnexionClient::getInstance(),
SLOT(toggleConnexion(bool)));
addCheckableActionToQMenuAndActionHash(avatarDebugMenu, MenuOption::ComfortMode, 0, true);
MenuWrapper* handOptionsMenu = developerMenu->addMenu("Hands");
addCheckableActionToQMenuAndActionHash(handOptionsMenu, MenuOption::DisplayHandTargets, 0, false);

View file

@ -159,6 +159,7 @@ namespace MenuOption {
const QString CenterPlayerInView = "Center Player In View";
const QString Chat = "Chat...";
const QString Collisions = "Collisions";
const QString ComfortMode = "Comfort Mode";
const QString Connexion = "Activate 3D Connexion Devices";
const QString Console = "Console...";
const QString ControlWithSpeech = "Control With Speech";

View file

@ -144,7 +144,7 @@ void PluginContainerProxy::unsetFullscreen(const QScreen* avoid) {
void PluginContainerProxy::requestReset() {
// We could signal qApp to sequence this, but it turns out that requestReset is only used from within the main thread anyway.
qApp->resetSensors();
qApp->resetSensors(true);
}
void PluginContainerProxy::showDisplayPluginsTools() {

View file

@ -140,16 +140,18 @@ QByteArray MyAvatar::toByteArray(bool cullSmallChanges, bool sendAll) {
return AvatarData::toByteArray(cullSmallChanges, sendAll);
}
void MyAvatar::reset() {
void MyAvatar::reset(bool andReload) {
// Gather animation mode...
// This should be simpler when we have only graph animations always on.
bool isRig = _rig->getEnableRig();
// seting rig animation to true, below, will clear the graph animation menu item, so grab it now.
bool isGraph = _rig->getEnableAnimGraph() || Menu::getInstance()->isOptionChecked(MenuOption::EnableAnimGraph);
// ... and get to sane configuration where other activity won't bother us.
if (andReload) {
qApp->setRawAvatarUpdateThreading(false);
_rig->disableHands = true;
setEnableRigAnimations(true);
}
// Reset dynamic state.
_wasPushing = _isPushing = _isBraking = _billboardValid = _straighteningLean = false;
@ -158,6 +160,7 @@ void MyAvatar::reset() {
_targetVelocity = glm::vec3(0.0f);
setThrust(glm::vec3(0.0f));
if (andReload) {
// Get fresh data, in case we're really slow and out of wack.
_hmdSensorMatrix = qApp->getHMDSensorPose();
_hmdSensorPosition = extractTranslation(_hmdSensorMatrix);
@ -184,6 +187,7 @@ void MyAvatar::reset() {
_skeletonModel.simulate(0.1f); // non-zero
setEnableRigAnimations(false);
_skeletonModel.simulate(0.1f);
}
if (isRig) {
setEnableRigAnimations(true);
Menu::getInstance()->setIsOptionChecked(MenuOption::EnableRigAnimations, true);
@ -191,8 +195,10 @@ void MyAvatar::reset() {
setEnableAnimGraph(true);
Menu::getInstance()->setIsOptionChecked(MenuOption::EnableAnimGraph, true);
}
if (andReload) {
_rig->disableHands = false;
qApp->setRawAvatarUpdateThreading();
}
}
void MyAvatar::update(float deltaTime) {
@ -1514,7 +1520,15 @@ bool MyAvatar::shouldRenderHead(const RenderArgs* renderArgs) const {
void MyAvatar::updateOrientation(float deltaTime) {
// Smoothly rotate body with arrow keys
float targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
float targetSpeed = 0.0f;
// FIXME - this comfort mode code is a total hack, remove it when we have new input mapping
bool isComfortMode = Menu::getInstance()->isOptionChecked(MenuOption::ComfortMode);
bool isHMDMode = qApp->getAvatarUpdater()->isHMDMode();
if (!isHMDMode || !isComfortMode) {
targetSpeed = (_driveKeys[ROT_LEFT] - _driveKeys[ROT_RIGHT]) * YAW_SPEED;
if (targetSpeed != 0.0f) {
const float ROTATION_RAMP_TIMESCALE = 0.1f;
float blend = deltaTime / ROTATION_RAMP_TIMESCALE;
@ -1537,11 +1551,39 @@ void MyAvatar::updateOrientation(float deltaTime) {
}
}
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
// update body orientation by movement inputs
setOrientation(getOrientation() *
glm::quat(glm::radians(glm::vec3(0.0f, _bodyYawDelta * deltaTime, 0.0f))));
} else {
// Comfort Mode: If you press any of the left/right rotation drive keys or input, you'll
// get an instantaneous 15 degree turn. If you keep holding the key down you'll get another
// snap turn every half second.
_bodyYawDelta = 0.0f;
static quint64 lastPulse = 0;
quint64 now = usecTimestampNow();
quint64 COMFORT_MODE_PULSE_TIMING = USECS_PER_SECOND / 2; // turn once per half second
float driveLeft = _driveKeys[ROT_LEFT];
float driveRight= _driveKeys[ROT_RIGHT];
if ((driveLeft != 0.0f || driveRight != 0.0f) && (now - lastPulse > COMFORT_MODE_PULSE_TIMING)) {
lastPulse = now;
const float SNAP_TURN_DELTA = 15.0f; // degrees
float direction = (driveLeft - driveRight) < 0.0f ? -1.0f : 1.0f;
float turnAmount = direction * SNAP_TURN_DELTA;
// update body orientation by movement inputs
setOrientation(getOrientation() *
glm::quat(glm::radians(glm::vec3(0.0f, turnAmount, 0.0f))));
}
}
getHead()->setBasePitch(getHead()->getBasePitch() + (_driveKeys[ROT_UP] - _driveKeys[ROT_DOWN]) * PITCH_SPEED * deltaTime);
if (qApp->getAvatarUpdater()->isHMDMode()) {
glm::quat orientation = glm::quat_cast(getSensorToWorldMatrix()) * getHMDSensorOrientation();
glm::quat bodyOrientation = getWorldBodyOrientation();

View file

@ -58,7 +58,7 @@ public:
AudioListenerMode getAudioListenerModeCamera() const { return FROM_CAMERA; }
AudioListenerMode getAudioListenerModeCustom() const { return CUSTOM; }
void reset();
void reset(bool andReload = false);
void update(float deltaTime);
void preRender(RenderArgs* renderArgs);

View file

@ -24,7 +24,7 @@ void AssetResourceRequest::doSend() {
// Make request to atp
auto assetClient = DependencyManager::get<AssetClient>();
auto parts = _url.path().split(".", QString::SkipEmptyParts);
auto hash = parts[0];
auto hash = parts.length() > 0 ? parts[0] : "";
auto extension = parts.length() > 1 ? parts[1] : "";
if (hash.length() != SHA256_HASH_HEX_LENGTH) {

View file

@ -319,6 +319,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -378,7 +381,8 @@
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target_collision_hull.obj';
var RESET_DISTANCE = 1;
var MINIMUM_MOVE_LENGTH = 0.05;
var RESET_DISTANCE = 0.5;
var TARGET_USER_DATA_KEY = 'hifi-ping_pong_target';
var NUMBER_OF_TARGETS = 6;
var TARGETS_PER_ROW = 3;
@ -392,7 +396,6 @@
var VERTICAL_SPACING = TARGET_DIMENSIONS.y + 0.5;
var HORIZONTAL_SPACING = TARGET_DIMENSIONS.z + 0.5;
var startPosition = {
x: 548.68,
y: 497.30,
@ -413,6 +416,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
})
});
@ -421,6 +427,8 @@
var originalPositions = [];
var lastPositions = [];
function addTargets() {
var i;
var row = -1;
@ -437,6 +445,7 @@
position.y = startPosition.y - (row * VERTICAL_SPACING);
originalPositions.push(position);
lastPositions.push(position);
var targetProperties = {
name: 'Target',
@ -452,6 +461,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
})
};
@ -468,7 +480,11 @@
var distance = Vec3.subtract(originalPosition, currentPosition);
var length = Vec3.length(distance);
if (length > RESET_DISTANCE) {
var moving = Vec3.length(Vec3.subtract(currentPosition, lastPositions[index]));
lastPositions[index] = currentPosition;
if (length > RESET_DISTANCE && moving < MINIMUM_MOVE_LENGTH) {
Entities.deleteEntity(target);
@ -486,11 +502,14 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
})
};
var target = Entities.addEntity(targetProperties);
targets[index] = target;
targets[index] = Entities.addEntity(targetProperties);
}
});
@ -548,6 +567,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
})
});
@ -583,7 +605,11 @@
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -851,6 +877,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
};
@ -940,6 +969,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -1014,6 +1046,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -1053,6 +1088,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -1090,6 +1128,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});
@ -1126,6 +1167,9 @@
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
})
});

View file

@ -247,7 +247,6 @@ MasterReset = function() {
grabbableKey: {
grabbable: false
}
})
});
@ -292,6 +291,9 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbable: {
invertSolidWhileHeld: true
}
})
});
@ -351,7 +353,8 @@ MasterReset = function() {
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target.fbx';
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/target_collision_hull.obj';
var RESET_DISTANCE = 1;
var MINIMUM_MOVE_LENGTH = 0.05;
var RESET_DISTANCE = 0.5;
var TARGET_USER_DATA_KEY = 'hifi-ping_pong_target';
var NUMBER_OF_TARGETS = 6;
var TARGETS_PER_ROW = 3;
@ -393,6 +396,7 @@ MasterReset = function() {
var targets = [];
var originalPositions = [];
var lastPositions = [];
function addTargets() {
var i;
@ -410,6 +414,7 @@ MasterReset = function() {
position.y = startPosition.y - (row * VERTICAL_SPACING);
originalPositions.push(position);
lastPositions.push(position);
var targetProperties = {
name: 'Target',
@ -425,11 +430,16 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
})
};
var target = Entities.addEntity(targetProperties);
targets.push(target);
}
}
@ -441,7 +451,11 @@ MasterReset = function() {
var distance = Vec3.subtract(originalPosition, currentPosition);
var length = Vec3.length(distance);
if (length > RESET_DISTANCE) {
var moving = Vec3.length(Vec3.subtract(currentPosition, lastPositions[index]));
lastPositions[index] = currentPosition;
if (length > RESET_DISTANCE && moving < MINIMUM_MOVE_LENGTH) {
Entities.deleteEntity(target);
@ -459,11 +473,15 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
}
})
};
var target = Entities.addEntity(targetProperties);
targets[index] = target;
targets[index] = Entities.addEntity(targetProperties);
}
});
@ -490,9 +508,9 @@ MasterReset = function() {
addTargets();
}
}
function createCat(position) {
function createCat(position) {
var modelURL = "http://hifi-public.s3.amazonaws.com/ryan/Dark_Cat.fbx";
var animationURL = "http://hifi-public.s3.amazonaws.com/ryan/sleeping.fbx";
@ -521,13 +539,17 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
grabbable: false
}
}
})
});
}
}
function createFlashlight(position) {
function createFlashlight(position) {
var modelURL = "https://hifi-public.s3.amazonaws.com/models/props/flashlight.fbx";
var flashlight = Entities.addEntity({
@ -556,14 +578,18 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createLights() {
function createLights() {
var modelURL = "http://hifi-public.s3.amazonaws.com/ryan/lightswitch.fbx";
@ -789,11 +815,11 @@ MasterReset = function() {
})
});
}
}
function createDice() {
function createDice() {
var diceProps = {
type: "Model",
modelURL: "http://s3.amazonaws.com/hifi-public/models/props/Dice/goldDie.fbx",
@ -824,23 +850,27 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
};
var dice1 = Entities.addEntity(diceProps);
};
var dice1 = Entities.addEntity(diceProps);
diceProps.position = {
diceProps.position = {
x: 541.05,
y: 494.96,
z: 509.0
};
};
var dice2 = Entities.addEntity(diceProps);
var dice2 = Entities.addEntity(diceProps);
}
}
function createGates() {
function createGates() {
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/ryan/fence.fbx';
var rotation = Quat.fromPitchYawRollDegrees(0, -16, 0);
@ -878,9 +908,9 @@ MasterReset = function() {
}
})
});
}
}
function createPingPongBallGun() {
function createPingPongBallGun() {
var MODEL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun.fbx';
var COLLISION_HULL_URL = 'http://hifi-public.s3.amazonaws.com/models/ping_pong_gun/ping_pong_gun_collision_hull.obj';
@ -913,12 +943,16 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createBasketballHoop() {
function createBasketballHoop() {
var position = {
x: 539.23,
y: 496.13,
@ -955,9 +989,9 @@ MasterReset = function() {
}
})
});
}
}
function createWand(position) {
function createWand(position) {
var WAND_MODEL = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/wand.fbx';
var WAND_COLLISION_SHAPE = 'http://hifi-public.s3.amazonaws.com/james/bubblewand/models/wand/actual_no_top_collision_hull.obj';
@ -987,14 +1021,18 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createBasketBall(position) {
function createBasketBall(position) {
var modelURL = "http://s3.amazonaws.com/hifi-public/models/content/basketball2.fbx";
@ -1026,13 +1064,17 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createDoll(position) {
function createDoll(position) {
var modelURL = "http://hifi-public.s3.amazonaws.com/models/Bboys/bboy2/bboy2.fbx";
var naturalDimensions = {
@ -1063,13 +1105,17 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createSprayCan(position) {
function createSprayCan(position) {
var modelURL = "https://hifi-public.s3.amazonaws.com/eric/models/paintcan.fbx";
@ -1099,13 +1145,17 @@ MasterReset = function() {
userData: JSON.stringify({
resetMe: {
resetMe: true,
},
grabbableKey: {
invertSolidWhileHeld: true
}
}
})
});
}
}
function createPottedPlant(position) {
function createPottedPlant(position) {
var modelURL = "http://hifi-public.s3.amazonaws.com/models/potted_plant/potted_plant.fbx";
var entity = Entities.addEntity({
@ -1140,10 +1190,10 @@ MasterReset = function() {
}
})
});
}
}
function createCombinedArmChair(position) {
function createCombinedArmChair(position) {
var modelURL = "http://hifi-public.s3.amazonaws.com/models/red_arm_chair/combined_chair.fbx";
var RED_ARM_CHAIR_COLLISION_HULL = "http://hifi-public.s3.amazonaws.com/models/red_arm_chair/red_arm_chair_collision_hull.obj";
@ -1184,9 +1234,9 @@ MasterReset = function() {
})
});
}
}
function createBlocks(position) {
function createBlocks(position) {
var baseURL = HIFI_PUBLIC_BUCKET + "models/content/planky/";
var collisionSoundURL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/ToyWoodBlock.L.wav";
var NUM_BLOCKS_PER_COLOR = 4;
@ -1265,14 +1315,14 @@ MasterReset = function() {
}
}
}
}
function cleanup() {
function cleanup() {
deleteAllToys();
}
}
if (shouldDeleteOnEndScript) {
if (shouldDeleteOnEndScript) {
Script.scriptEnding.connect(cleanup);
}
}
};