mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:43:31 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into tablet-ui-edit-js
This commit is contained in:
commit
66d44ac6f0
3 changed files with 48 additions and 48 deletions
|
@ -2000,6 +2000,11 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto currentBasis = getRecordingBasis();
|
||||||
|
if (!currentBasis) {
|
||||||
|
currentBasis = std::make_shared<Transform>(Transform::fromJson(json[JSON_AVATAR_BASIS]));
|
||||||
|
}
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_RELATIVE)) {
|
if (json.contains(JSON_AVATAR_RELATIVE)) {
|
||||||
// During playback you can either have the recording basis set to the avatar current state
|
// During playback you can either have the recording basis set to the avatar current state
|
||||||
// meaning that all playback is relative to this avatars starting position, or
|
// meaning that all playback is relative to this avatars starting position, or
|
||||||
|
@ -2008,15 +2013,14 @@ void AvatarData::fromJson(const QJsonObject& json, bool useFrameSkeleton) {
|
||||||
// The first is more useful for playing back recordings on your own avatar, while
|
// The first is more useful for playing back recordings on your own avatar, while
|
||||||
// the latter is more useful for playing back other avatars within your scene.
|
// the latter is more useful for playing back other avatars within your scene.
|
||||||
|
|
||||||
auto currentBasis = getRecordingBasis();
|
|
||||||
if (!currentBasis) {
|
|
||||||
currentBasis = std::make_shared<Transform>(Transform::fromJson(json[JSON_AVATAR_BASIS]));
|
|
||||||
}
|
|
||||||
|
|
||||||
auto relativeTransform = Transform::fromJson(json[JSON_AVATAR_RELATIVE]);
|
auto relativeTransform = Transform::fromJson(json[JSON_AVATAR_RELATIVE]);
|
||||||
auto worldTransform = currentBasis->worldTransform(relativeTransform);
|
auto worldTransform = currentBasis->worldTransform(relativeTransform);
|
||||||
setPosition(worldTransform.getTranslation());
|
setPosition(worldTransform.getTranslation());
|
||||||
setOrientation(worldTransform.getRotation());
|
setOrientation(worldTransform.getRotation());
|
||||||
|
} else {
|
||||||
|
// We still set the position in the case that there is no movement.
|
||||||
|
setPosition(currentBasis->getTranslation());
|
||||||
|
setOrientation(currentBasis->getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.contains(JSON_AVATAR_SCALE)) {
|
if (json.contains(JSON_AVATAR_SCALE)) {
|
||||||
|
|
|
@ -310,24 +310,24 @@ function getFingerWorldLocation(hand) {
|
||||||
|
|
||||||
// Object assign polyfill
|
// Object assign polyfill
|
||||||
if (typeof Object.assign != 'function') {
|
if (typeof Object.assign != 'function') {
|
||||||
Object.assign = function(target, varArgs) {
|
Object.assign = function(target, varArgs) {
|
||||||
'use strict';
|
'use strict';
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
throw new TypeError('Cannot convert undefined or null to object');
|
throw new TypeError('Cannot convert undefined or null to object');
|
||||||
}
|
|
||||||
var to = Object(target);
|
|
||||||
for (var index = 1; index < arguments.length; index++) {
|
|
||||||
var nextSource = arguments[index];
|
|
||||||
if (nextSource != null) {
|
|
||||||
for (var nextKey in nextSource) {
|
|
||||||
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
||||||
to[nextKey] = nextSource[nextKey];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
var to = Object(target);
|
||||||
}
|
for (var index = 1; index < arguments.length; index++) {
|
||||||
return to;
|
var nextSource = arguments[index];
|
||||||
};
|
if (nextSource != null) {
|
||||||
|
for (var nextKey in nextSource) {
|
||||||
|
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
||||||
|
to[nextKey] = nextSource[nextKey];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return to;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function distanceBetweenPointAndEntityBoundingBox(point, entityProps) {
|
function distanceBetweenPointAndEntityBoundingBox(point, entityProps) {
|
||||||
|
@ -1609,16 +1609,16 @@ function MyController(hand) {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
this.entityIsCloneable = function(entityID) {
|
this.entityIsCloneable = function(entityID) {
|
||||||
var entityProps = entityPropertiesCache.getGrabbableProps(entityID);
|
var entityProps = entityPropertiesCache.getGrabbableProps(entityID);
|
||||||
var props = entityPropertiesCache.getProps(entityID);
|
var props = entityPropertiesCache.getProps(entityID);
|
||||||
if (!props) {
|
if (!props) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entityProps.hasOwnProperty("cloneable")) {
|
if (entityProps.hasOwnProperty("cloneable")) {
|
||||||
return entityProps.cloneable;
|
return entityProps.cloneable;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.entityIsGrabbable = function(entityID) {
|
this.entityIsGrabbable = function(entityID) {
|
||||||
var grabbableProps = entityPropertiesCache.getGrabbableProps(entityID);
|
var grabbableProps = entityPropertiesCache.getGrabbableProps(entityID);
|
||||||
|
@ -2330,7 +2330,7 @@ function MyController(hand) {
|
||||||
// Can't set state of other controller to STATE_DISTANCE_HOLDING because then either:
|
// Can't set state of other controller to STATE_DISTANCE_HOLDING because then either:
|
||||||
// (a) The entity would jump to line up with the formerly rotating controller's orientation, or
|
// (a) The entity would jump to line up with the formerly rotating controller's orientation, or
|
||||||
// (b) The grab beam would need an orientation offset to the controller's true orientation.
|
// (b) The grab beam would need an orientation offset to the controller's true orientation.
|
||||||
// Neither of these options is good, so instead set STATE_SEARCHING and subsequently let the formerly distance
|
// Neither of these options is good, so instead set STATE_SEARCHING and subsequently let the formerly distance
|
||||||
// rotating controller start distance holding the entity if it happens to be pointing at the entity.
|
// rotating controller start distance holding the entity if it happens to be pointing at the entity.
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -2702,31 +2702,29 @@ function MyController(hand) {
|
||||||
var userData = JSON.parse(grabbedProperties.userData);
|
var userData = JSON.parse(grabbedProperties.userData);
|
||||||
var grabInfo = userData.grabbableKey;
|
var grabInfo = userData.grabbableKey;
|
||||||
if (grabInfo && grabInfo.cloneable) {
|
if (grabInfo && grabInfo.cloneable) {
|
||||||
// Check if
|
var worldEntities = Entities.findEntities(MyAvatar.position, 50);
|
||||||
var worldEntities = Entities.findEntitiesInBox(Vec3.subtract(MyAvatar.position, {x:25,y:25, z:25}), {x:50, y: 50, z: 50})
|
|
||||||
var count = 0;
|
var count = 0;
|
||||||
worldEntities.forEach(function(item) {
|
worldEntities.forEach(function(item) {
|
||||||
var item = Entities.getEntityProperties(item, ["name"]);
|
var item = Entities.getEntityProperties(item, ["name"]);
|
||||||
if (item.name === grabbedProperties.name) {
|
if (item.name.indexOf('-clone-' + grabbedProperties.id) !== -1) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var limit = grabInfo.cloneLimit ? grabInfo.cloneLimit : 0;
|
||||||
|
if (count >= limit && limit !== 0) {
|
||||||
|
delete limit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var cloneableProps = Entities.getEntityProperties(grabbedProperties.id);
|
var cloneableProps = Entities.getEntityProperties(grabbedProperties.id);
|
||||||
|
cloneableProps.name = cloneableProps.name + '-clone-' + grabbedProperties.id;
|
||||||
var lifetime = grabInfo.cloneLifetime ? grabInfo.cloneLifetime : 300;
|
var lifetime = grabInfo.cloneLifetime ? grabInfo.cloneLifetime : 300;
|
||||||
var limit = grabInfo.cloneLimit ? grabInfo.cloneLimit : 10;
|
|
||||||
var dynamic = grabInfo.cloneDynamic ? grabInfo.cloneDynamic : false;
|
var dynamic = grabInfo.cloneDynamic ? grabInfo.cloneDynamic : false;
|
||||||
var cUserData = Object.assign({}, userData);
|
var cUserData = Object.assign({}, userData);
|
||||||
var cProperties = Object.assign({}, cloneableProps);
|
var cProperties = Object.assign({}, cloneableProps);
|
||||||
isClone = true;
|
isClone = true;
|
||||||
|
|
||||||
if (count > limit) {
|
|
||||||
delete cloneableProps;
|
|
||||||
delete lifetime;
|
|
||||||
delete cUserData;
|
|
||||||
delete cProperties;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
delete cUserData.grabbableKey.cloneLifetime;
|
delete cUserData.grabbableKey.cloneLifetime;
|
||||||
delete cUserData.grabbableKey.cloneable;
|
delete cUserData.grabbableKey.cloneable;
|
||||||
delete cUserData.grabbableKey.cloneDynamic;
|
delete cUserData.grabbableKey.cloneDynamic;
|
||||||
|
|
|
@ -879,7 +879,7 @@ function loaded() {
|
||||||
elCloneable.checked = false;
|
elCloneable.checked = false;
|
||||||
elCloneableDynamic.checked = false;
|
elCloneableDynamic.checked = false;
|
||||||
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
|
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
|
||||||
elCloneableLimit.value = 10;
|
elCloneableLimit.value = 0;
|
||||||
elCloneableLifetime.value = 300;
|
elCloneableLifetime.value = 300;
|
||||||
|
|
||||||
var parsedUserData = {}
|
var parsedUserData = {}
|
||||||
|
@ -899,8 +899,6 @@ function loaded() {
|
||||||
if ("cloneable" in parsedUserData["grabbableKey"]) {
|
if ("cloneable" in parsedUserData["grabbableKey"]) {
|
||||||
elCloneable.checked = parsedUserData["grabbableKey"].cloneable;
|
elCloneable.checked = parsedUserData["grabbableKey"].cloneable;
|
||||||
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
|
elCloneableGroup.style.display = elCloneable.checked ? "block": "none";
|
||||||
elCloneableLimit.value = elCloneable.checked ? 10: 0;
|
|
||||||
elCloneableLifetime.value = elCloneable.checked ? 300: 0;
|
|
||||||
elCloneableDynamic.checked = parsedUserData["grabbableKey"].cloneDynamic ? parsedUserData["grabbableKey"].cloneDynamic : properties.dynamic;
|
elCloneableDynamic.checked = parsedUserData["grabbableKey"].cloneDynamic ? parsedUserData["grabbableKey"].cloneDynamic : properties.dynamic;
|
||||||
elDynamic.checked = elCloneable.checked ? false: properties.dynamic;
|
elDynamic.checked = elCloneable.checked ? false: properties.dynamic;
|
||||||
if (elCloneable.checked) {
|
if (elCloneable.checked) {
|
||||||
|
@ -908,7 +906,7 @@ function loaded() {
|
||||||
elCloneableLifetime.value = parsedUserData["grabbableKey"].cloneLifetime ? parsedUserData["grabbableKey"].cloneLifetime : 300;
|
elCloneableLifetime.value = parsedUserData["grabbableKey"].cloneLifetime ? parsedUserData["grabbableKey"].cloneLifetime : 300;
|
||||||
}
|
}
|
||||||
if ("cloneLimit" in parsedUserData["grabbableKey"]) {
|
if ("cloneLimit" in parsedUserData["grabbableKey"]) {
|
||||||
elCloneableLimit.value = parsedUserData["grabbableKey"].cloneLimit ? parsedUserData["grabbableKey"].cloneLimit : 10;
|
elCloneableLimit.value = parsedUserData["grabbableKey"].cloneLimit ? parsedUserData["grabbableKey"].cloneLimit : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue