Merge pull request #9571 from hyperlogic/bug-fix/tablet-ui-no-domain

Tablet should work even when not connected to any domain.
This commit is contained in:
Anthony Thibault 2017-02-02 17:49:40 -08:00 committed by GitHub
commit 3a36410f7c
4 changed files with 25 additions and 21 deletions

View file

@ -281,7 +281,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
APPEND_ENTITY_PROPERTY(PROP_HREF, getHref()); APPEND_ENTITY_PROPERTY(PROP_HREF, getHref());
APPEND_ENTITY_PROPERTY(PROP_DESCRIPTION, getDescription()); APPEND_ENTITY_PROPERTY(PROP_DESCRIPTION, getDescription());
APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, getActionData()); APPEND_ENTITY_PROPERTY(PROP_ACTION_DATA, getActionData());
APPEND_ENTITY_PROPERTY(PROP_PARENT_ID, getParentID());
// convert AVATAR_SELF_ID to actual sessionUUID.
QUuid actualParentID = getParentID();
if (actualParentID == AVATAR_SELF_ID) {
auto nodeList = DependencyManager::get<NodeList>();
actualParentID = nodeList->getSessionUUID();
}
APPEND_ENTITY_PROPERTY(PROP_PARENT_ID, actualParentID);
APPEND_ENTITY_PROPERTY(PROP_PARENT_JOINT_INDEX, getParentJointIndex()); APPEND_ENTITY_PROPERTY(PROP_PARENT_JOINT_INDEX, getParentJointIndex());
APPEND_ENTITY_PROPERTY(PROP_QUERY_AA_CUBE, getQueryAACube()); APPEND_ENTITY_PROPERTY(PROP_QUERY_AA_CUBE, getQueryAACube());
APPEND_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, getLastEditedBy()); APPEND_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, getLastEditedBy());

View file

@ -190,11 +190,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
propertiesWithSimID.setOwningAvatarID(myNodeID); propertiesWithSimID.setOwningAvatarID(myNodeID);
} }
if (propertiesWithSimID.getParentID() == AVATAR_SELF_ID) {
qCDebug(entities) << "ERROR: Cannot set entity parent ID to the local-only MyAvatar ID";
propertiesWithSimID.setParentID(QUuid());
}
auto dimensions = propertiesWithSimID.getDimensions(); auto dimensions = propertiesWithSimID.getDimensions();
float volume = dimensions.x * dimensions.y * dimensions.z; float volume = dimensions.x * dimensions.y * dimensions.z;
auto density = propertiesWithSimID.getDensity(); auto density = propertiesWithSimID.getDensity();
@ -372,9 +367,6 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
if (!scriptSideProperties.parentIDChanged()) { if (!scriptSideProperties.parentIDChanged()) {
properties.setParentID(entity->getParentID()); properties.setParentID(entity->getParentID());
} else if (scriptSideProperties.getParentID() == AVATAR_SELF_ID) {
qCDebug(entities) << "ERROR: Cannot set entity parent ID to the local-only MyAvatar ID";
properties.setParentID(QUuid());
} }
if (!scriptSideProperties.parentJointIndexChanged()) { if (!scriptSideProperties.parentJointIndexChanged()) {
properties.setParentJointIndex(entity->getParentJointIndex()); properties.setParentJointIndex(entity->getParentJointIndex());

View file

@ -143,6 +143,7 @@ var ONE_VEC = {
}; };
var NULL_UUID = "{00000000-0000-0000-0000-000000000000}"; var NULL_UUID = "{00000000-0000-0000-0000-000000000000}";
var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}";
var DEFAULT_REGISTRATION_POINT = { x: 0.5, y: 0.5, z: 0.5 }; var DEFAULT_REGISTRATION_POINT = { x: 0.5, y: 0.5, z: 0.5 };
var INCHES_TO_METERS = 1.0 / 39.3701; var INCHES_TO_METERS = 1.0 / 39.3701;
@ -895,9 +896,7 @@ function MyController(hand) {
if (!SHOW_GRAB_POINT_SPHERE) { if (!SHOW_GRAB_POINT_SPHERE) {
return; return;
} }
if (!MyAvatar.sessionUUID) {
return;
}
if (!this.grabPointSphere) { if (!this.grabPointSphere) {
this.grabPointSphere = Overlays.addOverlay("sphere", { this.grabPointSphere = Overlays.addOverlay("sphere", {
localPosition: getGrabPointSphereOffset(this.handToController()), localPosition: getGrabPointSphereOffset(this.handToController()),
@ -909,7 +908,7 @@ function MyController(hand) {
visible: true, visible: true,
ignoreRayIntersection: true, ignoreRayIntersection: true,
drawInFront: false, drawInFront: false,
parentID: MyAvatar.sessionUUID, parentID: AVATAR_SELF_ID,
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
"_CONTROLLER_RIGHTHAND" : "_CONTROLLER_RIGHTHAND" :
"_CONTROLLER_LEFTHAND") "_CONTROLLER_LEFTHAND")
@ -961,9 +960,6 @@ function MyController(hand) {
if (this.stylus) { if (this.stylus) {
return; return;
} }
if (!MyAvatar.sessionUUID) {
return;
}
var stylusProperties = { var stylusProperties = {
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx", url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
@ -977,7 +973,7 @@ function MyController(hand) {
visible: true, visible: true,
ignoreRayIntersection: true, ignoreRayIntersection: true,
drawInFront: false, drawInFront: false,
parentID: MyAvatar.sessionUUID, parentID: AVATAR_SELF_ID,
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND") "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND")
@ -2341,7 +2337,7 @@ function MyController(hand) {
} }
var reparentProps = { var reparentProps = {
parentID: MyAvatar.sessionUUID, parentID: AVATAR_SELF_ID,
parentJointIndex: handJointIndex, parentJointIndex: handJointIndex,
velocity: {x: 0, y: 0, z: 0}, velocity: {x: 0, y: 0, z: 0},
angularVelocity: {x: 0, y: 0, z: 0} angularVelocity: {x: 0, y: 0, z: 0}
@ -2478,7 +2474,7 @@ function MyController(hand) {
if (this.state == STATE_HOLD && now - this.lastUnequipCheckTime > MSECS_PER_SEC * CHECK_TOO_FAR_UNEQUIP_TIME) { if (this.state == STATE_HOLD && now - this.lastUnequipCheckTime > MSECS_PER_SEC * CHECK_TOO_FAR_UNEQUIP_TIME) {
this.lastUnequipCheckTime = now; this.lastUnequipCheckTime = now;
if (props.parentID == MyAvatar.sessionUUID) { if (props.parentID == AVATAR_SELF_ID) {
var handPosition; var handPosition;
if (this.ignoreIK) { if (this.ignoreIK) {
handPosition = getControllerWorldLocation(this.handToController(), false).position; handPosition = getControllerWorldLocation(this.handToController(), false).position;
@ -3019,7 +3015,7 @@ function MyController(hand) {
}; };
this.thisHandIsParent = function(props) { this.thisHandIsParent = function(props) {
if (props.parentID != MyAvatar.sessionUUID) { if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== AVATAR_SELF_ID) {
return false; return false;
} }
@ -3053,16 +3049,21 @@ function MyController(hand) {
// find children of avatar's hand joint // find children of avatar's hand joint
var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand"); var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand");
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex); var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, handJointIndex));
// find children of faux controller joint // find children of faux controller joint
var controllerJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? var controllerJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
"_CONTROLLER_RIGHTHAND" : "_CONTROLLER_RIGHTHAND" :
"_CONTROLLER_LEFTHAND"); "_CONTROLLER_LEFTHAND");
children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerJointIndex)); children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerJointIndex));
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, controllerJointIndex));
// find children of faux camera-relative controller joint // find children of faux camera-relative controller joint
var controllerCRJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? var controllerCRJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" : "_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND"); "_CAMERA_RELATIVE_CONTROLLER_LEFTHAND");
children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerCRJointIndex)); children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerCRJointIndex));
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, controllerCRJointIndex));
children.forEach(function(childID) { children.forEach(function(childID) {
if (childID !== _this.stylus) { if (childID !== _this.stylus) {

View file

@ -24,6 +24,8 @@ var CAMERA_MATRIX = -7;
var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0}; var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0};
var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 }; var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 };
var INCHES_TO_METERS = 1 / 39.3701; var INCHES_TO_METERS = 1 / 39.3701;
var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}";
var TABLET_URL = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx";
var NO_HANDS = -1; var NO_HANDS = -1;
// will need to be recaclulated if dimensions of fbx model change. // will need to be recaclulated if dimensions of fbx model change.
@ -103,7 +105,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
"grabbableKey": {"grabbable": true} "grabbableKey": {"grabbable": true}
}), }),
dimensions: {x: this.width, y: this.height, z: this.depth}, dimensions: {x: this.width, y: this.height, z: this.depth},
parentID: MyAvatar.sessionUUID parentID: AVATAR_SELF_ID
}; };
// compute position, rotation & parentJointIndex of the tablet // compute position, rotation & parentJointIndex of the tablet
@ -316,6 +318,7 @@ WebTablet.prototype.register = function() {
WebTablet.prototype.cleanUpOldTabletsOnJoint = function(jointIndex) { WebTablet.prototype.cleanUpOldTabletsOnJoint = function(jointIndex) {
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, jointIndex); var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, jointIndex);
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, jointIndex));
print("cleanup " + children); print("cleanup " + children);
children.forEach(function(childID) { children.forEach(function(childID) {
var props = Entities.getEntityProperties(childID, ["name"]); var props = Entities.getEntityProperties(childID, ["name"]);