fix a couple of problems related to grabbing tablet while edit.js is active

This commit is contained in:
Seth Alves 2017-02-24 11:34:10 -08:00
parent e43c4c17f5
commit f208f5e2d1
2 changed files with 21 additions and 22 deletions

View file

@ -341,27 +341,26 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
return UNKNOWN_OVERLAY_ID;
}
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysHUD);
i.toBack();
const float LARGE_NEGATIVE_FLOAT = -9999999;
glm::vec3 origin(pointCopy.x, pointCopy.y, LARGE_NEGATIVE_FLOAT);
glm::vec3 direction(0, 0, 1);
BoxFace thisFace;
// BoxFace thisFace;
glm::vec3 thisSurfaceNormal;
float distance;
// float distance;
unsigned int bestStackOrder = 0;
OverlayID bestOverlayID = UNKNOWN_OVERLAY_ID;
while (i.hasPrevious()) {
i.previous();
while (i.hasNext()) {
i.next();
OverlayID thisID = i.key();
if (i.value()->is3D()) {
auto thisOverlay = std::dynamic_pointer_cast<Base3DOverlay>(i.value());
if (thisOverlay && !thisOverlay->getIgnoreRayIntersection()) {
if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace, thisSurfaceNormal)) {
return thisID;
}
}
// auto thisOverlay = std::dynamic_pointer_cast<Base3DOverlay>(i.value());
// if (thisOverlay && !thisOverlay->getIgnoreRayIntersection()) {
// if (thisOverlay->findRayIntersection(origin, direction, distance, thisFace, thisSurfaceNormal)) {
// return thisID;
// }
// }
} else {
auto thisOverlay = std::dynamic_pointer_cast<Overlay2D>(i.value());
if (thisOverlay && thisOverlay->getVisible() && thisOverlay->isLoaded() &&
@ -423,9 +422,8 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionInternal(const PickR
RayToOverlayIntersectionResult result;
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysWorld);
i.toBack();
while (i.hasPrevious()) {
i.previous();
while (i.hasNext()) {
i.next();
OverlayID thisID = i.key();
auto thisOverlay = std::dynamic_pointer_cast<Base3DOverlay>(i.value());
@ -849,9 +847,10 @@ QVector<QUuid> Overlays::findOverlays(const glm::vec3& center, float radius) con
QVector<QUuid> result;
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysWorld);
i.toBack();
while (i.hasPrevious()) {
i.previous();
int checked = 0;
while (i.hasNext()) {
checked++;
i.next();
OverlayID thisID = i.key();
auto overlay = std::dynamic_pointer_cast<Volume3DOverlay>(i.value());
if (overlay && overlay->getVisible() && !overlay->getIgnoreRayIntersection() && overlay->isLoaded()) {

View file

@ -863,7 +863,7 @@ function MyController(hand) {
};
this.setState = function(newState, reason) {
if ((isInEditMode() && this.grabbedEntity !== HMD.tabletID) &&
if ((isInEditMode() && this.grabbedThingID !== HMD.tabletID) &&
(newState !== STATE_OFF &&
newState !== STATE_SEARCHING &&
newState !== STATE_OVERLAY_STYLUS_TOUCHING &&
@ -1446,7 +1446,7 @@ function MyController(hand) {
var okToEquipFromOtherHand = ((this.getOtherHandController().state == STATE_NEAR_GRABBING ||
this.getOtherHandController().state == STATE_DISTANCE_HOLDING) &&
this.getOtherHandController().grabbedEntity == hotspot.entityID);
this.getOtherHandController().grabbedThingID == hotspot.entityID);
var hasParent = true;
if (props.parentID === NULL_UUID) {
hasParent = false;
@ -1666,7 +1666,7 @@ function MyController(hand) {
grabbableOverlays.sort(function(a, b) {
var aPosition = Overlays.getProperty(a, "position");
var aDistance = Vec3.distance(aPosition, handPosition);
var bPosition = Overlays.getProperty(a, "position");
var bPosition = Overlays.getProperty(b, "position");
var bDistance = Vec3.distance(bPosition, handPosition);
return aDistance - bDistance;
});
@ -3352,8 +3352,8 @@ var handleHandMessages = function(channel, message, sender) {
selectedController.release();
var wearableEntity = data.entityID;
entityPropertiesCache.addEntity(wearableEntity);
selectedController.grabbedEntity = wearableEntity;
var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedEntity);
selectedController.grabbedThingID = wearableEntity;
var hotspots = selectedController.collectEquipHotspots(selectedController.grabbedThingID);
if (hotspots.length > 0) {
if (hotspotIndex >= hotspots.length) {
hotspotIndex = 0;