Merge branch 'master' of github.com:highfidelity/hifi into head-controller

This commit is contained in:
Seth Alves 2017-05-25 15:14:14 -07:00
commit 3c90177421
5 changed files with 77 additions and 34 deletions

View file

@ -1379,6 +1379,8 @@ function addTableRow(row) {
var setting_name = table.attr("name"); var setting_name = table.attr("name");
row.addClass(Settings.DATA_ROW_CLASS + " " + Settings.NEW_ROW_CLASS); row.addClass(Settings.DATA_ROW_CLASS + " " + Settings.NEW_ROW_CLASS);
var focusChanged = false;
_.each(row.children(), function(element) { _.each(row.children(), function(element) {
if ($(element).hasClass("numbered")) { if ($(element).hasClass("numbered")) {
// Index row // Index row
@ -1429,6 +1431,11 @@ function addTableRow(row) {
}); });
} }
if (!focusChanged) {
input.focus();
focusChanged = true;
}
if (isCheckbox) { if (isCheckbox) {
$(input).find("input").attr("data-changed", "true"); $(input).find("input").attr("data-changed", "true");
} else { } else {

View file

@ -1091,22 +1091,40 @@ void EntityTreeRenderer::entityCollisionWithEntity(const EntityItemID& idA, cons
// trigger scripted collision sounds and events for locally owned objects // trigger scripted collision sounds and events for locally owned objects
EntityItemPointer entityA = entityTree->findEntityByEntityItemID(idA); EntityItemPointer entityA = entityTree->findEntityByEntityItemID(idA);
if ((bool)entityA && myNodeID == entityA->getSimulatorID()) {
playEntityCollisionSound(entityA, collision);
emit collisionWithEntity(idA, idB, collision);
if (_entitiesScriptEngine) {
_entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision);
}
}
EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB); EntityItemPointer entityB = entityTree->findEntityByEntityItemID(idB);
if ((bool)entityB && myNodeID == entityB->getSimulatorID()) { if ((bool)entityA && (bool)entityB) {
playEntityCollisionSound(entityB, collision); QUuid entityASimulatorID = entityA->getSimulatorID();
// since we're swapping A and B we need to send the inverted collision QUuid entityBSimulatorID = entityB->getSimulatorID();
Collision invertedCollision(collision); bool entityAIsDynamic = entityA->getDynamic();
invertedCollision.invert(); bool entityBIsDynamic = entityB->getDynamic();
emit collisionWithEntity(idB, idA, invertedCollision);
if (_entitiesScriptEngine) { #ifdef WANT_DEBUG
_entitiesScriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision); bool bothEntitiesStatic = !entityAIsDynamic && !entityBIsDynamic;
if (bothEntitiesStatic) {
qCDebug(entities) << "A collision has occurred between two static entities!";
qCDebug(entities) << "Entity A ID:" << entityA->getID();
qCDebug(entities) << "Entity B ID:" << entityB->getID();
}
assert(!bothEntitiesStatic);
#endif
if ((myNodeID == entityASimulatorID && entityAIsDynamic) || (myNodeID == entityBSimulatorID && (!entityAIsDynamic || entityASimulatorID.isNull()))) {
playEntityCollisionSound(entityA, collision);
emit collisionWithEntity(idA, idB, collision);
if (_entitiesScriptEngine) {
_entitiesScriptEngine->callEntityScriptMethod(idA, "collisionWithEntity", idB, collision);
}
}
if ((myNodeID == entityBSimulatorID && entityBIsDynamic) || (myNodeID == entityASimulatorID && (!entityBIsDynamic || entityBSimulatorID.isNull()))) {
playEntityCollisionSound(entityB, collision);
// since we're swapping A and B we need to send the inverted collision
Collision invertedCollision(collision);
invertedCollision.invert();
emit collisionWithEntity(idB, idA, invertedCollision);
if (_entitiesScriptEngine) {
_entitiesScriptEngine->callEntityScriptMethod(idB, "collisionWithEntity", idA, invertedCollision);
}
} }
} }
} }

View file

@ -210,9 +210,12 @@ public:
}; };
glm::mat4 getGlobalTransform(const QMultiMap<QString, QString>& _connectionParentMap, glm::mat4 getGlobalTransform(const QMultiMap<QString, QString>& _connectionParentMap,
const QHash<QString, FBXModel>& models, QString nodeID, bool mixamoHack) { const QHash<QString, FBXModel>& models, QString nodeID, bool mixamoHack, const QString& url) {
glm::mat4 globalTransform; glm::mat4 globalTransform;
QVector<QString> visitedNodes; // Used to prevent following a cycle
while (!nodeID.isNull()) { while (!nodeID.isNull()) {
visitedNodes.append(nodeID); // Append each node we visit
const FBXModel& model = models.value(nodeID); const FBXModel& model = models.value(nodeID);
globalTransform = glm::translate(model.translation) * model.preTransform * glm::mat4_cast(model.preRotation * globalTransform = glm::translate(model.translation) * model.preTransform * glm::mat4_cast(model.preRotation *
model.rotation * model.postRotation) * model.postTransform * globalTransform; model.rotation * model.postRotation) * model.postTransform * globalTransform;
@ -223,6 +226,11 @@ glm::mat4 getGlobalTransform(const QMultiMap<QString, QString>& _connectionParen
QList<QString> parentIDs = _connectionParentMap.values(nodeID); QList<QString> parentIDs = _connectionParentMap.values(nodeID);
nodeID = QString(); nodeID = QString();
foreach (const QString& parentID, parentIDs) { foreach (const QString& parentID, parentIDs) {
if (visitedNodes.contains(parentID)) {
qCWarning(modelformat) << "Ignoring loop detected in FBX connection map for" << url;
continue;
}
if (models.contains(parentID)) { if (models.contains(parentID)) {
nodeID = parentID; nodeID = parentID;
break; break;
@ -347,10 +355,18 @@ void addBlendshapes(const ExtractedBlendshape& extracted, const QList<WeightedIn
} }
QString getTopModelID(const QMultiMap<QString, QString>& connectionParentMap, QString getTopModelID(const QMultiMap<QString, QString>& connectionParentMap,
const QHash<QString, FBXModel>& models, const QString& modelID) { const QHash<QString, FBXModel>& models, const QString& modelID, const QString& url) {
QString topID = modelID; QString topID = modelID;
QVector<QString> visitedNodes; // Used to prevent following a cycle
forever { forever {
visitedNodes.append(topID); // Append each node we visit
foreach (const QString& parentID, connectionParentMap.values(topID)) { foreach (const QString& parentID, connectionParentMap.values(topID)) {
if (visitedNodes.contains(parentID)) {
qCWarning(modelformat) << "Ignoring loop detected in FBX connection map for" << url;
continue;
}
if (models.contains(parentID)) { if (models.contains(parentID)) {
topID = parentID; topID = parentID;
goto outerContinue; goto outerContinue;
@ -1307,7 +1323,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
if (!clusters.contains(clusterID)) { if (!clusters.contains(clusterID)) {
continue; continue;
} }
QString topID = getTopModelID(_connectionParentMap, models, _connectionChildMap.value(clusterID)); QString topID = getTopModelID(_connectionParentMap, models, _connectionChildMap.value(clusterID), url);
_connectionChildMap.remove(_connectionParentMap.take(model.key()), model.key()); _connectionChildMap.remove(_connectionParentMap.take(model.key()), model.key());
_connectionParentMap.insert(model.key(), topID); _connectionParentMap.insert(model.key(), topID);
goto outerBreak; goto outerBreak;
@ -1329,7 +1345,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
first = id; first = id;
} }
} }
QString topID = getTopModelID(_connectionParentMap, models, first); QString topID = getTopModelID(_connectionParentMap, models, first, url);
appendModelIDs(_connectionParentMap.value(topID), _connectionChildMap, models, remainingModels, modelIDs); appendModelIDs(_connectionParentMap.value(topID), _connectionChildMap, models, remainingModels, modelIDs);
} }
@ -1511,7 +1527,7 @@ FBXGeometry* FBXReader::extractFBXGeometry(const QVariantHash& mapping, const QS
// accumulate local transforms // accumulate local transforms
QString modelID = models.contains(it.key()) ? it.key() : _connectionParentMap.value(it.key()); QString modelID = models.contains(it.key()) ? it.key() : _connectionParentMap.value(it.key());
glm::mat4 modelTransform = getGlobalTransform(_connectionParentMap, models, modelID, geometry.applicationName == "mixamo.com"); glm::mat4 modelTransform = getGlobalTransform(_connectionParentMap, models, modelID, geometry.applicationName == "mixamo.com", url);
// compute the mesh extents from the transformed vertices // compute the mesh extents from the transformed vertices
foreach (const glm::vec3& vertex, extracted.mesh.vertices) { foreach (const glm::vec3& vertex, extracted.mesh.vertices) {

View file

@ -114,7 +114,8 @@ public:
EntityServerScriptLog, EntityServerScriptLog,
AdjustAvatarSorting, AdjustAvatarSorting,
OctreeFileReplacement, OctreeFileReplacement,
LAST_PACKET_TYPE = OctreeFileReplacement CollisionEventChanges,
LAST_PACKET_TYPE = CollisionEventChanges
}; };
}; };

View file

@ -1036,8 +1036,8 @@ function getControllerJointIndex(hand) {
"_CONTROLLER_RIGHTHAND" : "_CONTROLLER_RIGHTHAND" :
"_CONTROLLER_LEFTHAND"); "_CONTROLLER_LEFTHAND");
} }
return MyAvatar.getJointIndex("Head"); return MyAvatar.getJointIndex("Head");
} }
// global EquipHotspotBuddy instance // global EquipHotspotBuddy instance
@ -1331,7 +1331,7 @@ function MyController(hand) {
if (this.stylus) { if (this.stylus) {
return; return;
} }
var stylusProperties = { var stylusProperties = {
name: "stylus", name: "stylus",
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
@ -2134,7 +2134,7 @@ function MyController(hand) {
return null; return null;
} }
}; };
this.chooseNearEquipHotspotsForFarToNearEquip = function(candidateEntities, distance) { this.chooseNearEquipHotspotsForFarToNearEquip = function(candidateEntities, distance) {
var equippableHotspots = flatten(candidateEntities.map(function(entityID) { var equippableHotspots = flatten(candidateEntities.map(function(entityID) {
return _this.collectEquipHotspots(entityID); return _this.collectEquipHotspots(entityID);
@ -2291,7 +2291,7 @@ function MyController(hand) {
return; return;
} }
} }
if (isInEditMode()) { if (isInEditMode()) {
this.searchIndicatorOn(rayPickInfo.searchRay); this.searchIndicatorOn(rayPickInfo.searchRay);
if (this.triggerSmoothedGrab()) { if (this.triggerSmoothedGrab()) {
@ -2347,10 +2347,11 @@ function MyController(hand) {
var avatar = AvatarList.getAvatar(this.otherGrabbingUUID); var avatar = AvatarList.getAvatar(this.otherGrabbingUUID);
var IN_FRONT_OF_AVATAR = { x: 0, y: 0.2, z: 0.4 }; // Up from hips and in front of avatar. var IN_FRONT_OF_AVATAR = { x: 0, y: 0.2, z: 0.4 }; // Up from hips and in front of avatar.
var startPosition = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.rotation, IN_FRONT_OF_AVATAR)); var startPosition = Vec3.sum(avatar.position, Vec3.multiplyQbyV(avatar.rotation, IN_FRONT_OF_AVATAR));
var finishPisition = Vec3.sum(rayPickInfo.properties.position, // Entity's centroid. var rayHitProps = entityPropertiesCache.getProps(rayPickInfo.entityID);
Vec3.multiplyQbyV(rayPickInfo.properties.rotation , var finishPisition = Vec3.sum(rayHitProps.position, // Entity's centroid.
Vec3.multiplyVbyV(rayPickInfo.properties.dimensions, Vec3.multiplyQbyV(rayHitProps.rotation,
Vec3.subtract(DEFAULT_REGISTRATION_POINT, rayPickInfo.properties.registrationPoint)))); Vec3.multiplyVbyV(rayHitProps.dimensions,
Vec3.subtract(DEFAULT_REGISTRATION_POINT, rayHitProps.registrationPoint))));
this.otherGrabbingLineOn(startPosition, finishPisition, COLORS_GRAB_DISTANCE_HOLD); this.otherGrabbingLineOn(startPosition, finishPisition, COLORS_GRAB_DISTANCE_HOLD);
} else { } else {
this.otherGrabbingLineOff(); this.otherGrabbingLineOff();
@ -3442,14 +3443,14 @@ function MyController(hand) {
}; };
this.offEnter = function() { this.offEnter = function() {
// Reuse the existing search distance if lasers were active since // Reuse the existing search distance if lasers were active since
// they will be shown in OFF state while in edit mode. // they will be shown in OFF state while in edit mode.
var existingSearchDistance = this.searchSphereDistance; var existingSearchDistance = this.searchSphereDistance;
this.release(); this.release();
if (isInEditMode()) { if (isInEditMode()) {
this.searchSphereDistance = existingSearchDistance; this.searchSphereDistance = existingSearchDistance;
} }
}; };
this.entityLaserTouchingEnter = function() { this.entityLaserTouchingEnter = function() {
@ -4154,7 +4155,7 @@ var updateWrapper = function () {
} }
Script.setTimeout(updateWrapper, UPDATE_SLEEP_MS); Script.setTimeout(updateWrapper, UPDATE_SLEEP_MS);
} };
Script.setTimeout(updateWrapper, UPDATE_SLEEP_MS); Script.setTimeout(updateWrapper, UPDATE_SLEEP_MS);
function cleanup() { function cleanup() {