mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 23:29:39 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into fix-include-race
This commit is contained in:
commit
db99295989
27 changed files with 379 additions and 143 deletions
|
@ -512,12 +512,19 @@ void AvatarMixer::domainSettingsRequestComplete() {
|
|||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
nodeList->addNodeTypeToInterestSet(NodeType::Agent);
|
||||
|
||||
nodeList->linkedDataCreateCallback = [] (Node* node) {
|
||||
node->setLinkedData(std::unique_ptr<AvatarMixerClientData> { new AvatarMixerClientData });
|
||||
};
|
||||
|
||||
// parse the settings to pull out the values we need
|
||||
parseDomainServerSettings(nodeList->getDomainHandler().getSettingsObject());
|
||||
|
||||
float domainMinimumScale = _domainMinimumScale;
|
||||
float domainMaximumScale = _domainMaximumScale;
|
||||
|
||||
nodeList->linkedDataCreateCallback = [domainMinimumScale, domainMaximumScale] (Node* node) {
|
||||
auto clientData = std::unique_ptr<AvatarMixerClientData> { new AvatarMixerClientData };
|
||||
clientData->getAvatar().setDomainMinimumScale(domainMinimumScale);
|
||||
clientData->getAvatar().setDomainMaximumScale(domainMaximumScale);
|
||||
|
||||
node->setLinkedData(std::move(clientData));
|
||||
};
|
||||
|
||||
// start the broadcastThread
|
||||
_broadcastThread.start();
|
||||
|
@ -549,4 +556,22 @@ void AvatarMixer::parseDomainServerSettings(const QJsonObject& domainSettings) {
|
|||
|
||||
_maxKbpsPerNode = nodeBandwidthValue.toDouble(DEFAULT_NODE_SEND_BANDWIDTH) * KILO_PER_MEGA;
|
||||
qDebug() << "The maximum send bandwidth per node is" << _maxKbpsPerNode << "kbps.";
|
||||
|
||||
const QString AVATARS_SETTINGS_KEY = "avatars";
|
||||
|
||||
static const QString MIN_SCALE_OPTION = "min_avatar_scale";
|
||||
float settingMinScale = domainSettings[AVATARS_SETTINGS_KEY].toObject()[MIN_SCALE_OPTION].toDouble(MIN_AVATAR_SCALE);
|
||||
_domainMinimumScale = glm::clamp(settingMinScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE);
|
||||
|
||||
static const QString MAX_SCALE_OPTION = "max_avatar_scale";
|
||||
float settingMaxScale = domainSettings[AVATARS_SETTINGS_KEY].toObject()[MAX_SCALE_OPTION].toDouble(MAX_AVATAR_SCALE);
|
||||
_domainMaximumScale = glm::clamp(settingMaxScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE);
|
||||
|
||||
// make sure that the domain owner didn't flip min and max
|
||||
if (_domainMinimumScale > _domainMaximumScale) {
|
||||
std::swap(_domainMinimumScale, _domainMaximumScale);
|
||||
}
|
||||
|
||||
qDebug() << "This domain requires a minimum avatar scale of" << _domainMinimumScale
|
||||
<< "and a maximum avatar scale of" << _domainMaximumScale;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@ private:
|
|||
|
||||
float _maxKbpsPerNode = 0.0f;
|
||||
|
||||
float _domainMinimumScale { MIN_AVATAR_SCALE };
|
||||
float _domainMaximumScale { MAX_AVATAR_SCALE };
|
||||
|
||||
QTimer* _broadcastTimer = nullptr;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <AvatarData.h>
|
||||
#include <ScriptEngine.h>
|
||||
|
||||
class ScriptableAvatar : public AvatarData, public Dependency{
|
||||
class ScriptableAvatar : public AvatarData, public Dependency {
|
||||
Q_OBJECT
|
||||
public:
|
||||
|
||||
|
@ -39,4 +39,4 @@ private:
|
|||
std::shared_ptr<AnimSkeleton> _animSkeleton;
|
||||
};
|
||||
|
||||
#endif // hifi_ScriptableAvatar_h
|
||||
#endif // hifi_ScriptableAvatar_h
|
||||
|
|
|
@ -866,6 +866,29 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "avatars",
|
||||
"label": "Avatars",
|
||||
"assignment-types": [1, 2],
|
||||
"settings": [
|
||||
{
|
||||
"name": "min_avatar_scale",
|
||||
"type": "double",
|
||||
"label": "Minimum Avatar Scale",
|
||||
"help": "Limits the scale of avatars in your domain. Must be at least 0.005.",
|
||||
"placeholder": 0.25,
|
||||
"default": 0.25
|
||||
},
|
||||
{
|
||||
"name": "max_avatar_scale",
|
||||
"type": "double",
|
||||
"label": "Maximum Avatar Scale",
|
||||
"help": "Limits the scale of avatars in your domain. Cannot be greater than 1000.",
|
||||
"placeholder": 3.0,
|
||||
"default": 3.0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "audio_env",
|
||||
"label": "Audio Environment",
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
{ "from": "GamePad.LY", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateZ" },
|
||||
{ "from": "GamePad.LX", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" },
|
||||
|
||||
{ "from": "GamePad.LT", "to": "Standard.LTClick",
|
||||
{ "from": "GamePad.LT", "to": "Standard.LTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
},
|
||||
{ "from": "GamePad.LT", "to": "Standard.LT" },
|
||||
{ "from": "GamePad.LB", "to": "Standard.LB" },
|
||||
{ "from": "GamePad.LT", "to": "Standard.LT" },
|
||||
{ "from": "GamePad.LB", "to": "Standard.LB" },
|
||||
{ "from": "GamePad.LS", "to": "Standard.LS" },
|
||||
|
||||
|
||||
|
@ -27,34 +27,34 @@
|
|||
|
||||
{ "from": "GamePad.RX", "to": "Actions.Yaw" },
|
||||
|
||||
{ "from": "GamePad.RY",
|
||||
"to": "Actions.VERTICAL_UP",
|
||||
"filters":
|
||||
{ "from": "GamePad.RY",
|
||||
"to": "Actions.VERTICAL_UP",
|
||||
"filters":
|
||||
[
|
||||
{ "type": "deadZone", "min": 0.95 },
|
||||
"invert"
|
||||
]
|
||||
},
|
||||
},
|
||||
|
||||
{ "from": "GamePad.RT", "to": "Standard.RTClick",
|
||||
{ "from": "GamePad.RT", "to": "Standard.RTClick",
|
||||
"peek": true,
|
||||
"filters": [ { "type": "hysteresis", "min": 0.85, "max": 0.9 } ]
|
||||
},
|
||||
{ "from": "GamePad.RT", "to": "Standard.RT" },
|
||||
{ "from": "GamePad.RB", "to": "Standard.RB" },
|
||||
{ "from": "GamePad.RT", "to": "Standard.RT" },
|
||||
{ "from": "GamePad.RB", "to": "Standard.RB" },
|
||||
{ "from": "GamePad.RS", "to": "Standard.RS" },
|
||||
|
||||
{ "from": "GamePad.Start", "to": "Actions.CycleCamera" },
|
||||
{ "from": "GamePad.Back", "to": "Actions.ContextMenu" },
|
||||
{ "from": "GamePad.Back", "to": "Standard.Start" },
|
||||
|
||||
{ "from": "GamePad.DU", "to": "Standard.DU" },
|
||||
{ "from": "GamePad.DD", "to": "Standard.DD" },
|
||||
{ "from": "GamePad.DD", "to": "Standard.DD" },
|
||||
{ "from": "GamePad.DL", "to": "Standard.DL" },
|
||||
{ "from": "GamePad.DR", "to": "Standard.DR" },
|
||||
{ "from": "GamePad.DR", "to": "Standard.DR" },
|
||||
|
||||
{ "from": [ "GamePad.Y" ], "to": "Standard.RightPrimaryThumb", "peek": true },
|
||||
{ "from": "GamePad.A", "to": "Standard.A" },
|
||||
{ "from": "GamePad.B", "to": "Standard.B" },
|
||||
{ "from": "GamePad.A", "to": "Standard.A" },
|
||||
{ "from": "GamePad.B", "to": "Standard.B" },
|
||||
{ "from": "GamePad.X", "to": "Standard.X" },
|
||||
{ "from": "GamePad.Y", "to": "Standard.Y" }
|
||||
]
|
||||
|
|
|
@ -396,15 +396,6 @@ Menu::Menu() {
|
|||
});
|
||||
}
|
||||
|
||||
// Developer > Render > Enable Incremental Texture Transfer
|
||||
{
|
||||
auto action = addCheckableActionToQMenuAndActionHash(renderOptionsMenu, MenuOption::IncrementalTextureTransfer, 0, gpu::Texture::getEnableIncrementalTextureTransfers());
|
||||
connect(action, &QAction::triggered, [&](bool checked) {
|
||||
qDebug() << "[TEXTURE TRANSFER SUPPORT] --- Enable Incremental Texture Transfer menu option:" << checked;
|
||||
gpu::Texture::setEnableIncrementalTextureTransfers(checked);
|
||||
});
|
||||
}
|
||||
|
||||
#else
|
||||
qDebug() << "[TEXTURE TRANSFER SUPPORT] Incremental Texture Transfer and Dynamic Texture Management not supported on this platform.";
|
||||
#endif
|
||||
|
|
|
@ -112,7 +112,6 @@ namespace MenuOption {
|
|||
const QString FrameTimer = "Show Timer";
|
||||
const QString FullscreenMirror = "Mirror";
|
||||
const QString Help = "Help...";
|
||||
const QString IncrementalTextureTransfer = "Enable Incremental Texture Transfer";
|
||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||
const QString IndependentMode = "Independent Mode";
|
||||
const QString ActionMotorControl = "Enable Default Motor Control";
|
||||
|
|
|
@ -165,16 +165,17 @@ AABox Avatar::getBounds() const {
|
|||
|
||||
void Avatar::animateScaleChanges(float deltaTime) {
|
||||
float currentScale = getUniformScale();
|
||||
if (currentScale != _targetScale) {
|
||||
// use exponential decay toward _targetScale
|
||||
auto desiredScale = getDomainLimitedScale();
|
||||
if (currentScale != desiredScale) {
|
||||
// use exponential decay toward the domain limit clamped scale
|
||||
const float SCALE_ANIMATION_TIMESCALE = 0.5f;
|
||||
float blendFactor = glm::clamp(deltaTime / SCALE_ANIMATION_TIMESCALE, 0.0f, 1.0f);
|
||||
float animatedScale = (1.0f - blendFactor) * currentScale + blendFactor * _targetScale;
|
||||
float animatedScale = (1.0f - blendFactor) * currentScale + blendFactor * desiredScale;
|
||||
|
||||
// snap to the end when we get close enough
|
||||
const float MIN_RELATIVE_SCALE_ERROR = 0.03f;
|
||||
if (fabsf(_targetScale - currentScale) / _targetScale < MIN_RELATIVE_SCALE_ERROR) {
|
||||
animatedScale = _targetScale;
|
||||
if (fabsf(desiredScale - currentScale) / desiredScale < MIN_RELATIVE_SCALE_ERROR) {
|
||||
animatedScale = desiredScale;
|
||||
}
|
||||
|
||||
setScale(glm::vec3(animatedScale)); // avatar scale is uniform
|
||||
|
|
|
@ -152,7 +152,7 @@ bool AvatarActionHold::getTarget(float deltaTimeStep, glm::quat& rotation, glm::
|
|||
Transform avatarTransform;
|
||||
auto myAvatar = DependencyManager::get<AvatarManager>()->getMyAvatar();
|
||||
avatarTransform = myAvatar->getTransform();
|
||||
palmPosition = avatarTransform.transform(pose.getTranslation() / myAvatar->getTargetScale());
|
||||
palmPosition = avatarTransform.transform(pose.getTranslation() / myAvatar->getDomainLimitedScale());
|
||||
palmRotation = avatarTransform.getRotation() * pose.getRotation();
|
||||
} else {
|
||||
glm::vec3 avatarRigidBodyPosition;
|
||||
|
|
|
@ -130,6 +130,15 @@ MyAvatar::MyAvatar(RigPointer rig) :
|
|||
connect(DependencyManager::get<AddressManager>().data(), &AddressManager::locationChangeRequired,
|
||||
this, static_cast<SlotType>(&MyAvatar::goToLocation));
|
||||
|
||||
// handle scale constraints imposed on us by the domain-server
|
||||
auto& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
|
||||
|
||||
// when we connect to a domain and retrieve its settings, we restrict our max/min scale based on those settings
|
||||
connect(&domainHandler, &DomainHandler::settingsReceived, this, &MyAvatar::restrictScaleFromDomainSettings);
|
||||
|
||||
// when we leave a domain we lift whatever restrictions that domain may have placed on our scale
|
||||
connect(&domainHandler, &DomainHandler::disconnectedFromDomain, this, &MyAvatar::clearScaleRestriction);
|
||||
|
||||
_characterController.setEnabled(true);
|
||||
|
||||
_bodySensorMatrix = deriveBodyFromHMDSensor();
|
||||
|
@ -1823,25 +1832,104 @@ bool findAvatarAvatarPenetration(const glm::vec3 positionA, float radiusA, float
|
|||
return false;
|
||||
}
|
||||
|
||||
void MyAvatar::increaseSize() {
|
||||
if ((1.0f + SCALING_RATIO) * _targetScale < MAX_AVATAR_SCALE) {
|
||||
_targetScale *= (1.0f + SCALING_RATIO);
|
||||
qCDebug(interfaceapp, "Changed scale to %f", (double)_targetScale);
|
||||
// There can be a separation between the _targetScale and the actual scale of the rendered avatar in a domain.
|
||||
// When the avatar enters a domain where their target scale is not allowed according to the min/max
|
||||
// we do not change their saved target scale. Instead, we use getDomainLimitedScale() to render the avatar
|
||||
// at a domain appropriate size. When the avatar leaves the limiting domain, we'll return them to their previous target scale.
|
||||
// While connected to a domain that limits avatar scale if the user manually changes their avatar scale, we change
|
||||
// target scale to match the new scale they have chosen. When they leave the domain they will not return to the scale they were
|
||||
// before they entered the limiting domain.
|
||||
|
||||
void MyAvatar::clampTargetScaleToDomainLimits() {
|
||||
// when we're about to change the target scale because the user has asked to increase or decrease their scale,
|
||||
// we first make sure that we're starting from a target scale that is allowed by the current domain
|
||||
|
||||
auto clampedTargetScale = glm::clamp(_targetScale, _domainMinimumScale, _domainMaximumScale);
|
||||
|
||||
if (clampedTargetScale != _targetScale) {
|
||||
qCDebug(interfaceapp, "Clamped scale to %f since original target scale %f was not allowed by domain",
|
||||
clampedTargetScale, _targetScale);
|
||||
|
||||
setTargetScale(clampedTargetScale);
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::clampScaleChangeToDomainLimits(float desiredScale) {
|
||||
auto clampedTargetScale = glm::clamp(desiredScale, _domainMinimumScale, _domainMaximumScale);
|
||||
|
||||
if (clampedTargetScale != desiredScale) {
|
||||
qCDebug(interfaceapp, "Forcing scale to %f since %f is not allowed by domain",
|
||||
clampedTargetScale, desiredScale);
|
||||
}
|
||||
|
||||
setTargetScale(clampedTargetScale);
|
||||
qCDebug(interfaceapp, "Changed scale to %f", _targetScale);
|
||||
}
|
||||
|
||||
void MyAvatar::increaseSize() {
|
||||
// make sure we're starting from an allowable scale
|
||||
clampTargetScaleToDomainLimits();
|
||||
|
||||
// calculate what our new scale should be
|
||||
float updatedTargetScale = _targetScale * (1.0f + SCALING_RATIO);
|
||||
|
||||
// attempt to change to desired scale (clamped to the domain limits)
|
||||
clampScaleChangeToDomainLimits(updatedTargetScale);
|
||||
}
|
||||
|
||||
void MyAvatar::decreaseSize() {
|
||||
if (MIN_AVATAR_SCALE < (1.0f - SCALING_RATIO) * _targetScale) {
|
||||
_targetScale *= (1.0f - SCALING_RATIO);
|
||||
qCDebug(interfaceapp, "Changed scale to %f", (double)_targetScale);
|
||||
}
|
||||
// make sure we're starting from an allowable scale
|
||||
clampTargetScaleToDomainLimits();
|
||||
|
||||
// calculate what our new scale should be
|
||||
float updatedTargetScale = _targetScale * (1.0f - SCALING_RATIO);
|
||||
|
||||
// attempt to change to desired scale (clamped to the domain limits)
|
||||
clampScaleChangeToDomainLimits(updatedTargetScale);
|
||||
}
|
||||
|
||||
void MyAvatar::resetSize() {
|
||||
_targetScale = 1.0f;
|
||||
qCDebug(interfaceapp, "Reset scale to %f", (double)_targetScale);
|
||||
// attempt to reset avatar size to the default (clamped to domain limits)
|
||||
const float DEFAULT_AVATAR_SCALE = 1.0f;
|
||||
|
||||
clampScaleChangeToDomainLimits(DEFAULT_AVATAR_SCALE);
|
||||
}
|
||||
|
||||
void MyAvatar::restrictScaleFromDomainSettings(const QJsonObject& domainSettingsObject) {
|
||||
// pull out the minimum and maximum scale and set them to restrict our scale
|
||||
|
||||
static const QString AVATAR_SETTINGS_KEY = "avatars";
|
||||
auto avatarsObject = domainSettingsObject[AVATAR_SETTINGS_KEY].toObject();
|
||||
|
||||
static const QString MIN_SCALE_OPTION = "min_avatar_scale";
|
||||
float settingMinScale = avatarsObject[MIN_SCALE_OPTION].toDouble(MIN_AVATAR_SCALE);
|
||||
setDomainMinimumScale(settingMinScale);
|
||||
|
||||
static const QString MAX_SCALE_OPTION = "max_avatar_scale";
|
||||
float settingMaxScale = avatarsObject[MAX_SCALE_OPTION].toDouble(MAX_AVATAR_SCALE);
|
||||
setDomainMaximumScale(settingMaxScale);
|
||||
|
||||
// make sure that the domain owner didn't flip min and max
|
||||
if (_domainMinimumScale > _domainMaximumScale) {
|
||||
std::swap(_domainMinimumScale, _domainMaximumScale);
|
||||
}
|
||||
|
||||
qCDebug(interfaceapp, "This domain requires a minimum avatar scale of %f and a maximum avatar scale of %f",
|
||||
_domainMinimumScale, _domainMaximumScale);
|
||||
|
||||
// debug to log if this avatar's scale in this domain will be clamped
|
||||
auto clampedScale = glm::clamp(_targetScale, _domainMinimumScale, _domainMaximumScale);
|
||||
|
||||
if (_targetScale != clampedScale) {
|
||||
qCDebug(interfaceapp, "Avatar scale will be clamped to %f because %f is not allowed by current domain",
|
||||
clampedScale, _targetScale);
|
||||
}
|
||||
}
|
||||
|
||||
void MyAvatar::clearScaleRestriction() {
|
||||
_domainMinimumScale = MIN_AVATAR_SCALE;
|
||||
_domainMaximumScale = MAX_AVATAR_SCALE;
|
||||
}
|
||||
|
||||
void MyAvatar::goToLocation(const QVariant& propertiesVar) {
|
||||
qCDebug(interfaceapp, "MyAvatar QML goToLocation");
|
||||
|
|
|
@ -292,6 +292,9 @@ public slots:
|
|||
bool shouldFaceLocation = false);
|
||||
void goToLocation(const QVariant& properties);
|
||||
|
||||
void restrictScaleFromDomainSettings(const QJsonObject& domainSettingsObject);
|
||||
void clearScaleRestriction();
|
||||
|
||||
// Set/Get update the thrust that will move the avatar around
|
||||
void addThrust(glm::vec3 newThrust) { _thrust += newThrust; };
|
||||
glm::vec3 getThrust() { return _thrust; };
|
||||
|
@ -369,6 +372,8 @@ private:
|
|||
virtual void updatePalms() override {}
|
||||
void lateUpdatePalms();
|
||||
|
||||
void clampTargetScaleToDomainLimits();
|
||||
void clampScaleChangeToDomainLimits(float desiredScale);
|
||||
|
||||
float _driveKeys[MAX_DRIVE_KEYS];
|
||||
bool _wasPushing;
|
||||
|
|
|
@ -126,6 +126,23 @@ void MenuScriptingInterface::setIsOptionChecked(const QString& menuOption, bool
|
|||
Q_ARG(bool, isChecked));
|
||||
}
|
||||
|
||||
bool MenuScriptingInterface::isMenuEnabled(const QString& menuOption) {
|
||||
if (QThread::currentThread() == qApp->thread()) {
|
||||
return Menu::getInstance()->isOptionChecked(menuOption);
|
||||
}
|
||||
bool result;
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "isMenuEnabled", Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, result),
|
||||
Q_ARG(const QString&, menuOption));
|
||||
return result;
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::setMenuEnabled(const QString& menuOption, bool isChecked) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "setMenuEnabled",
|
||||
Q_ARG(const QString&, menuOption),
|
||||
Q_ARG(bool, isChecked));
|
||||
}
|
||||
|
||||
void MenuScriptingInterface::triggerOption(const QString& menuOption) {
|
||||
QMetaObject::invokeMethod(Menu::getInstance(), "triggerOption", Q_ARG(const QString&, menuOption));
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ public slots:
|
|||
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
||||
|
||||
void triggerOption(const QString& menuOption);
|
||||
|
||||
bool isMenuEnabled(const QString& menuName);
|
||||
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||
|
||||
signals:
|
||||
void menuItemEvent(const QString& menuItem);
|
||||
|
|
|
@ -210,7 +210,7 @@ QByteArray AvatarData::toByteArray(bool cullSmallChanges, bool sendAll) {
|
|||
packFloatAngleToTwoByte((uint8_t*)(header->localOrientation + 0), bodyEulerAngles.y);
|
||||
packFloatAngleToTwoByte((uint8_t*)(header->localOrientation + 1), bodyEulerAngles.x);
|
||||
packFloatAngleToTwoByte((uint8_t*)(header->localOrientation + 2), bodyEulerAngles.z);
|
||||
packFloatRatioToTwoByte((uint8_t*)(&header->scale), _targetScale);
|
||||
packFloatRatioToTwoByte((uint8_t*)(&header->scale), getDomainLimitedScale());
|
||||
header->lookAtPosition[0] = _headData->_lookAtPosition.x;
|
||||
header->lookAtPosition[1] = _headData->_lookAtPosition.y;
|
||||
header->lookAtPosition[2] = _headData->_lookAtPosition.z;
|
||||
|
@ -516,7 +516,7 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) {
|
|||
}
|
||||
return buffer.size();
|
||||
}
|
||||
_targetScale = std::max(MIN_AVATAR_SCALE, std::min(MAX_AVATAR_SCALE, scale));
|
||||
setTargetScale(scale);
|
||||
|
||||
glm::vec3 lookAt = glm::vec3(header->lookAtPosition[0], header->lookAtPosition[1], header->lookAtPosition[2]);
|
||||
if (isNaN(lookAt)) {
|
||||
|
@ -1439,7 +1439,7 @@ QJsonObject AvatarData::toJson() const {
|
|||
if (!success) {
|
||||
qDebug() << "Warning -- AvatarData::toJson couldn't get avatar transform";
|
||||
}
|
||||
avatarTransform.setScale(getTargetScale());
|
||||
avatarTransform.setScale(getDomainLimitedScale());
|
||||
if (recordingBasis) {
|
||||
root[JSON_AVATAR_BASIS] = Transform::toJson(*recordingBasis);
|
||||
// Find the relative transform
|
||||
|
@ -1451,7 +1451,7 @@ QJsonObject AvatarData::toJson() const {
|
|||
root[JSON_AVATAR_RELATIVE] = Transform::toJson(avatarTransform);
|
||||
}
|
||||
|
||||
auto scale = getTargetScale();
|
||||
auto scale = getDomainLimitedScale();
|
||||
if (scale != 1.0f) {
|
||||
root[JSON_AVATAR_SCALE] = scale;
|
||||
}
|
||||
|
|
|
@ -243,6 +243,12 @@ public:
|
|||
void setTargetScale(float targetScale);
|
||||
void setTargetScaleVerbose(float targetScale);
|
||||
|
||||
float getDomainLimitedScale() const { return glm::clamp(_targetScale, _domainMinimumScale, _domainMaximumScale); }
|
||||
void setDomainMinimumScale(float domainMinimumScale)
|
||||
{ _domainMinimumScale = glm::clamp(domainMinimumScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE); }
|
||||
void setDomainMaximumScale(float domainMaximumScale)
|
||||
{ _domainMaximumScale = glm::clamp(domainMaximumScale, MIN_AVATAR_SCALE, MAX_AVATAR_SCALE); }
|
||||
|
||||
// Hand State
|
||||
Q_INVOKABLE void setHandState(char s) { _handState = s; }
|
||||
Q_INVOKABLE char getHandState() const { return _handState; }
|
||||
|
@ -377,6 +383,8 @@ protected:
|
|||
|
||||
// Body scale
|
||||
float _targetScale;
|
||||
float _domainMinimumScale { MIN_AVATAR_SCALE };
|
||||
float _domainMaximumScale { MAX_AVATAR_SCALE };
|
||||
|
||||
// Hand state (are we grabbing something or not)
|
||||
char _handState;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "GLHelpers.h"
|
||||
|
||||
// Minimum gl version required is 4.1
|
||||
#define MINIMUM_GL_VERSION 0x0401
|
||||
|
||||
OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
||||
|
@ -75,15 +76,26 @@ QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
|||
// - major_number.minor_number
|
||||
// - major_number.minor_number.release_number
|
||||
// Reference: https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glGetString.xml
|
||||
const QString version { "version" };
|
||||
QString glVersion = glData[version].toString();
|
||||
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||
int majorNumber = versionParts[0].toInt();
|
||||
int minorNumber = versionParts[1].toInt();
|
||||
int minimumMajorNumber = (MINIMUM_GL_VERSION >> 16);
|
||||
|
||||
int minimumMajorNumber = (MINIMUM_GL_VERSION >> 8) & 0xFF;
|
||||
int minimumMinorNumber = (MINIMUM_GL_VERSION & 0xFF);
|
||||
valid = (majorNumber > minimumMajorNumber
|
||||
|| (majorNumber == minimumMajorNumber && minorNumber >= minimumMinorNumber));
|
||||
int majorNumber = 0;
|
||||
int minorNumber = 0;
|
||||
const QString version { "version" };
|
||||
if (glData.contains(version)) {
|
||||
QString glVersion = glData[version].toString();
|
||||
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||
if (versionParts.size() >= 2) {
|
||||
majorNumber = versionParts[0].toInt();
|
||||
minorNumber = versionParts[1].toInt();
|
||||
valid = (majorNumber > minimumMajorNumber
|
||||
|| (majorNumber == minimumMajorNumber && minorNumber >= minimumMinorNumber));
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
} else {
|
||||
valid = false;
|
||||
}
|
||||
|
||||
// Prompt user if below minimum
|
||||
if (!valid) {
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
#include "../gl/GLBackend.h"
|
||||
#include "../gl/GLTexture.h"
|
||||
|
||||
#define INCREMENTAL_TRANSFER 0
|
||||
|
||||
namespace gpu { namespace gl45 {
|
||||
|
||||
using namespace gpu::gl;
|
||||
|
@ -56,6 +58,7 @@ public:
|
|||
GLint pageDimensionsIndex { 0 };
|
||||
};
|
||||
|
||||
#if INCREMENTAL_TRANSFER
|
||||
struct TransferState {
|
||||
TransferState(GL45Texture& texture);
|
||||
uvec3 currentPageSize() const;
|
||||
|
@ -74,6 +77,10 @@ public:
|
|||
uvec3 mipOffset;
|
||||
const uint8_t* srcPointer { nullptr };
|
||||
};
|
||||
protected:
|
||||
TransferState _transferState;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void updateMips() override;
|
||||
void stripToMip(uint16_t newMinMip);
|
||||
|
@ -91,7 +98,6 @@ public:
|
|||
void derez();
|
||||
|
||||
SparseInfo _sparseInfo;
|
||||
TransferState _transferState;
|
||||
uint32_t _allocatedPages { 0 };
|
||||
uint32_t _lastMipAllocatedPages { 0 };
|
||||
uint16_t _mipOffset { 0 };
|
||||
|
|
|
@ -162,6 +162,8 @@ void GL45Backend::initTextureManagementStage() {
|
|||
}
|
||||
}
|
||||
|
||||
#if INCREMENTAL_TRANSFER
|
||||
|
||||
using TransferState = GL45Backend::GL45Texture::TransferState;
|
||||
|
||||
TransferState::TransferState(GL45Texture& texture) : texture(texture) {
|
||||
|
@ -246,6 +248,7 @@ void TransferState::populatePage(std::vector<uint8_t>& buffer) {
|
|||
uvec3 TransferState::currentPageSize() const {
|
||||
return glm::clamp(mipDimensions - mipOffset, uvec3(1), texture._sparseInfo.pageDimensions);
|
||||
}
|
||||
#endif
|
||||
|
||||
GLuint GL45Texture::allocate(const Texture& texture) {
|
||||
GLuint result;
|
||||
|
@ -258,11 +261,19 @@ GLuint GL45Backend::getTextureID(const TexturePointer& texture, bool transfer) {
|
|||
}
|
||||
|
||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, GLuint externalId)
|
||||
: GLTexture(backend, texture, externalId), _sparseInfo(*this), _transferState(*this) {
|
||||
: GLTexture(backend, texture, externalId), _sparseInfo(*this)
|
||||
#if INCREMENTAL_TRANSFER
|
||||
, _transferState(*this)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
GL45Texture::GL45Texture(const std::weak_ptr<GLBackend>& backend, const Texture& texture, bool transferrable)
|
||||
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this), _transferState(*this) {
|
||||
: GLTexture(backend, texture, allocate(texture), transferrable), _sparseInfo(*this)
|
||||
#if INCREMENTAL_TRANSFER
|
||||
, _transferState(*this)
|
||||
#endif
|
||||
{
|
||||
|
||||
auto theBackend = _backend.lock();
|
||||
if (_transferrable && theBackend && theBackend->isTextureManagementSparseEnabled()) {
|
||||
|
@ -375,39 +386,40 @@ void GL45Texture::updateSize() const {
|
|||
void GL45Texture::startTransfer() {
|
||||
Parent::startTransfer();
|
||||
_sparseInfo.update();
|
||||
#if INCREMENTAL_TRANSFER
|
||||
_transferState.updateMip();
|
||||
#endif
|
||||
}
|
||||
|
||||
bool GL45Texture::continueTransfer() {
|
||||
if (!Texture::getEnableIncrementalTextureTransfers()) {
|
||||
size_t maxFace = GL_TEXTURE_CUBE_MAP == _target ? CUBE_NUM_FACES : 1;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) {
|
||||
auto size = _gpuObject.evalMipDimensions(mipLevel);
|
||||
if (_sparseInfo.sparse && mipLevel <= _sparseInfo.maxSparseLevel) {
|
||||
glTexturePageCommitmentEXT(_id, mipLevel, 0, 0, face, size.x, size.y, 1, GL_TRUE);
|
||||
_allocatedPages += _sparseInfo.getPageCount(size);
|
||||
}
|
||||
if (_gpuObject.isStoredMipFaceAvailable(mipLevel, face)) {
|
||||
auto mip = _gpuObject.accessStoredMipFace(mipLevel, face);
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), mip->getFormat());
|
||||
if (GL_TEXTURE_2D == _target) {
|
||||
glTextureSubImage2D(_id, mipLevel, 0, 0, size.x, size.y, texelFormat.format, texelFormat.type, mip->readData());
|
||||
} else if (GL_TEXTURE_CUBE_MAP == _target) {
|
||||
// DSA ARB does not work on AMD, so use EXT
|
||||
// glTextureSubImage3D(_id, mipLevel, 0, 0, face, size.x, size.y, 1, texelFormat.format, texelFormat.type, mip->readData());
|
||||
auto target = CUBE_FACE_LAYOUT[face];
|
||||
glTextureSubImage2DEXT(_id, target, mipLevel, 0, 0, size.x, size.y, texelFormat.format, texelFormat.type, mip->readData());
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
#if !INCREMENTAL_TRANSFER
|
||||
size_t maxFace = GL_TEXTURE_CUBE_MAP == _target ? CUBE_NUM_FACES : 1;
|
||||
for (uint8_t face = 0; face < maxFace; ++face) {
|
||||
for (uint16_t mipLevel = _minMip; mipLevel <= _maxMip; ++mipLevel) {
|
||||
auto size = _gpuObject.evalMipDimensions(mipLevel);
|
||||
if (_sparseInfo.sparse && mipLevel <= _sparseInfo.maxSparseLevel) {
|
||||
glTexturePageCommitmentEXT(_id, mipLevel, 0, 0, face, size.x, size.y, 1, GL_TRUE);
|
||||
_allocatedPages += _sparseInfo.getPageCount(size);
|
||||
}
|
||||
if (_gpuObject.isStoredMipFaceAvailable(mipLevel, face)) {
|
||||
auto mip = _gpuObject.accessStoredMipFace(mipLevel, face);
|
||||
GLTexelFormat texelFormat = GLTexelFormat::evalGLTexelFormat(_gpuObject.getTexelFormat(), mip->getFormat());
|
||||
if (GL_TEXTURE_2D == _target) {
|
||||
glTextureSubImage2D(_id, mipLevel, 0, 0, size.x, size.y, texelFormat.format, texelFormat.type, mip->readData());
|
||||
} else if (GL_TEXTURE_CUBE_MAP == _target) {
|
||||
// DSA ARB does not work on AMD, so use EXT
|
||||
// glTextureSubImage3D(_id, mipLevel, 0, 0, face, size.x, size.y, 1, texelFormat.format, texelFormat.type, mip->readData());
|
||||
auto target = CUBE_FACE_LAYOUT[face];
|
||||
glTextureSubImage2DEXT(_id, target, mipLevel, 0, 0, size.x, size.y, texelFormat.format, texelFormat.type, mip->readData());
|
||||
} else {
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
(void)CHECK_GL_ERROR();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
#else
|
||||
static std::vector<uint8_t> buffer;
|
||||
if (buffer.empty()) {
|
||||
buffer.resize(DEFAULT_PAGE_BUFFER_SIZE);
|
||||
|
@ -458,6 +470,7 @@ bool GL45Texture::continueTransfer() {
|
|||
_lastMipAllocatedPages = _allocatedPages;
|
||||
}
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
void GL45Texture::finishTransfer() {
|
||||
|
|
|
@ -35,18 +35,15 @@ std::atomic<Texture::Size> Texture::_allowedCPUMemoryUsage { 0 };
|
|||
|
||||
|
||||
#define MIN_CORES_FOR_INCREMENTAL_TEXTURES 5
|
||||
bool recommendedIncrementalTransfers = (QThread::idealThreadCount() >= MIN_CORES_FOR_INCREMENTAL_TEXTURES);
|
||||
bool recommendedSparseTextures = recommendedIncrementalTransfers;
|
||||
bool recommendedSparseTextures = (QThread::idealThreadCount() >= MIN_CORES_FOR_INCREMENTAL_TEXTURES);
|
||||
|
||||
std::atomic<bool> Texture::_enableSparseTextures { recommendedIncrementalTransfers };
|
||||
std::atomic<bool> Texture::_enableIncrementalTextureTransfers { recommendedSparseTextures };
|
||||
std::atomic<bool> Texture::_enableSparseTextures { recommendedSparseTextures };
|
||||
|
||||
struct ReportTextureState {
|
||||
ReportTextureState() {
|
||||
qDebug() << "[TEXTURE TRANSFER SUPPORT]"
|
||||
<< "\n\tidealThreadCount:" << QThread::idealThreadCount()
|
||||
<< "\n\tRECOMMENDED enableSparseTextures:" << recommendedSparseTextures
|
||||
<< "\n\tRECOMMENDED enableIncrementalTextures:" << recommendedIncrementalTransfers;
|
||||
<< "\n\tRECOMMENDED enableSparseTextures:" << recommendedSparseTextures;
|
||||
}
|
||||
} report;
|
||||
|
||||
|
@ -59,16 +56,6 @@ void Texture::setEnableSparseTextures(bool enabled) {
|
|||
#endif
|
||||
}
|
||||
|
||||
void Texture::setEnableIncrementalTextureTransfers(bool enabled) {
|
||||
#ifdef Q_OS_WIN
|
||||
qDebug() << "[TEXTURE TRANSFER SUPPORT] SETTING - Enable Incremental Texture Transfer:" << enabled;
|
||||
_enableIncrementalTextureTransfers = enabled;
|
||||
#else
|
||||
qDebug() << "[TEXTURE TRANSFER SUPPORT] Incremental Texture Transfer not supported on this platform.";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Texture::updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize) {
|
||||
if (prevObjectSize == newObjectSize) {
|
||||
return;
|
||||
|
@ -84,10 +71,6 @@ bool Texture::getEnableSparseTextures() {
|
|||
return _enableSparseTextures.load();
|
||||
}
|
||||
|
||||
bool Texture::getEnableIncrementalTextureTransfers() {
|
||||
return _enableIncrementalTextureTransfers.load();
|
||||
}
|
||||
|
||||
uint32_t Texture::getTextureCPUCount() {
|
||||
return _textureCPUCount.load();
|
||||
}
|
||||
|
|
|
@ -143,10 +143,8 @@ class Texture : public Resource {
|
|||
static std::atomic<uint32_t> _textureCPUCount;
|
||||
static std::atomic<Size> _textureCPUMemoryUsage;
|
||||
static std::atomic<Size> _allowedCPUMemoryUsage;
|
||||
static void updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
static std::atomic<bool> _enableSparseTextures;
|
||||
static std::atomic<bool> _enableIncrementalTextureTransfers;
|
||||
static void updateTextureCPUMemoryUsage(Size prevObjectSize, Size newObjectSize);
|
||||
|
||||
public:
|
||||
static uint32_t getTextureCPUCount();
|
||||
|
@ -162,10 +160,7 @@ public:
|
|||
static void setAllowedGPUMemoryUsage(Size size);
|
||||
|
||||
static bool getEnableSparseTextures();
|
||||
static bool getEnableIncrementalTextureTransfers();
|
||||
|
||||
static void setEnableSparseTextures(bool enabled);
|
||||
static void setEnableIncrementalTextureTransfers(bool enabled);
|
||||
|
||||
using ExternalRecycler = std::function<void(uint32, void*)>;
|
||||
using ExternalIdAndFence = std::pair<uint32, void*>;
|
||||
|
|
|
@ -272,27 +272,17 @@ void DomainHandler::setIsConnected(bool isConnected) {
|
|||
}
|
||||
|
||||
void DomainHandler::requestDomainSettings() {
|
||||
// TODO: the nodes basically lock if they don't get a response - add a timeout to this so that they at least restart
|
||||
// if they can't get settings
|
||||
|
||||
NodeType_t owningNodeType = DependencyManager::get<NodeList>()->getOwnerType();
|
||||
if (owningNodeType == NodeType::Agent) {
|
||||
// for now the agent nodes don't need any domain settings
|
||||
_settingsObject = QJsonObject();
|
||||
emit settingsReceived(_settingsObject);
|
||||
} else {
|
||||
qCDebug(networking) << "Requesting settings from domain server";
|
||||
|
||||
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
||||
|
||||
auto packet = NLPacket::create(PacketType::DomainSettingsRequest, sizeof(assignmentType), true, false);
|
||||
packet->writePrimitive(assignmentType);
|
||||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
nodeList->sendPacket(std::move(packet), _sockAddr);
|
||||
|
||||
_settingsTimer.start();
|
||||
}
|
||||
qCDebug(networking) << "Requesting settings from domain server";
|
||||
|
||||
Assignment::Type assignmentType = Assignment::typeForNodeType(DependencyManager::get<NodeList>()->getOwnerType());
|
||||
|
||||
auto packet = NLPacket::create(PacketType::DomainSettingsRequest, sizeof(assignmentType), true, false);
|
||||
packet->writePrimitive(assignmentType);
|
||||
|
||||
auto nodeList = DependencyManager::get<LimitedNodeList>();
|
||||
nodeList->sendPacket(std::move(packet), _sockAddr);
|
||||
|
||||
_settingsTimer.start();
|
||||
}
|
||||
|
||||
void DomainHandler::processSettingsPacketList(QSharedPointer<ReceivedMessage> packetList) {
|
||||
|
|
|
@ -428,6 +428,25 @@ bool Menu::menuExists(const QString& menuName) {
|
|||
return false;
|
||||
}
|
||||
|
||||
bool Menu::isMenuEnabled(const QString& menuName) {
|
||||
QAction* action = getMenuAction(menuName);
|
||||
|
||||
// only proceed if the menu actually exists
|
||||
if (action) {
|
||||
return action->isEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Menu::setMenuEnabled(const QString& menuName, bool isEnabled) {
|
||||
QAction* action = getMenuAction(menuName);
|
||||
|
||||
// only proceed if the menu actually exists
|
||||
if (action) {
|
||||
action->setEnabled(isEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
void Menu::addSeparator(const QString& menuName, const QString& separatorName, const QString& grouping) {
|
||||
MenuWrapper* menuObj = getMenu(menuName);
|
||||
if (menuObj) {
|
||||
|
|
|
@ -106,6 +106,9 @@ public slots:
|
|||
bool isOptionChecked(const QString& menuOption) const;
|
||||
void setIsOptionChecked(const QString& menuOption, bool isChecked);
|
||||
|
||||
bool isMenuEnabled(const QString& menuName);
|
||||
void setMenuEnabled(const QString& menuName, bool isEnabled);
|
||||
|
||||
bool getGroupingIsVisible(const QString& grouping);
|
||||
void setGroupingIsVisible(const QString& grouping, bool isVisible); /// NOTE: the "" grouping is always visible
|
||||
|
||||
|
|
|
@ -331,7 +331,7 @@ controller::Pose openVrControllerPoseToHandPose(bool isLeftHand, const mat4& mat
|
|||
#define FAILED_MIN_SPEC_OVERLAY_FRIENDLY_NAME "Minimum specifications for SteamVR not met"
|
||||
#define FAILED_MIN_SPEC_UPDATE_INTERVAL_MS 10
|
||||
#define FAILED_MIN_SPEC_AUTO_QUIT_INTERVAL_MS (MSECS_PER_SECOND * 30)
|
||||
#define MIN_CORES_SPEC 5
|
||||
#define MIN_CORES_SPEC 3
|
||||
|
||||
void showMinSpecWarning() {
|
||||
auto vrSystem = acquireOpenVrSystem();
|
||||
|
|
|
@ -203,6 +203,32 @@ function overlayFromWorldPoint(point) {
|
|||
return { x: horizontalPixels, y: verticalPixels };
|
||||
}
|
||||
|
||||
var gamePad = Controller.findDevice("GamePad");
|
||||
function activeHudPoint2dGamePad() {
|
||||
if (!HMD.active) {
|
||||
return;
|
||||
}
|
||||
var headPosition = MyAvatar.getHeadPosition();
|
||||
var headDirection = Quat.getUp(Quat.multiply(MyAvatar.headOrientation, Quat.angleAxis(-90, { x: 1, y: 0, z: 0 })));
|
||||
|
||||
var hudPoint3d = calculateRayUICollisionPoint(headPosition, headDirection);
|
||||
|
||||
if (!hudPoint3d) {
|
||||
if (Menu.isOptionChecked("Overlays")) { // With our hud resetting strategy, hudPoint3d should be valid here
|
||||
print('Controller is parallel to HUD'); // so let us know that our assumptions are wrong.
|
||||
}
|
||||
return;
|
||||
}
|
||||
var hudPoint2d = overlayFromWorldPoint(hudPoint3d);
|
||||
|
||||
// We don't know yet if we'll want to make the cursor or laser visble, but we need to move it to see if
|
||||
// it's pointing at a QML tool (aka system overlay).
|
||||
setReticlePosition(hudPoint2d);
|
||||
|
||||
return hudPoint2d;
|
||||
}
|
||||
|
||||
|
||||
function activeHudPoint2d(activeHand) { // if controller is valid, update reticle position and answer 2d point. Otherwise falsey.
|
||||
var controllerPose = getControllerWorldLocation(activeHand, true); // note: this will return head pose if hand pose is invalid (third eye)
|
||||
if (!controllerPose.valid) {
|
||||
|
@ -210,7 +236,7 @@ function activeHudPoint2d(activeHand) { // if controller is valid, update reticl
|
|||
}
|
||||
var controllerPosition = controllerPose.position;
|
||||
var controllerDirection = Quat.getUp(controllerPose.rotation);
|
||||
|
||||
|
||||
var hudPoint3d = calculateRayUICollisionPoint(controllerPosition, controllerDirection);
|
||||
if (!hudPoint3d) {
|
||||
if (Menu.isOptionChecked("Overlays")) { // With our hud resetting strategy, hudPoint3d should be valid here
|
||||
|
@ -405,7 +431,7 @@ clickMapping.from(rightTrigger.full).when(isPointingAtOverlayStartedNonFullTrigg
|
|||
clickMapping.from(leftTrigger.full).when(isPointingAtOverlayStartedNonFullTrigger(leftTrigger)).to(Controller.Actions.ReticleClick);
|
||||
// The following is essentially like Left and Right versions of
|
||||
// clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(Controller.Actions.ContextMenu);
|
||||
// except that we first update the reticle position from the appropriate hand position, before invoking the ContextMenu.
|
||||
// except that we first update the reticle position from the appropriate hand position, before invoking the .
|
||||
var wantsMenu = 0;
|
||||
clickMapping.from(function () { return wantsMenu; }).to(Controller.Actions.ContextMenu);
|
||||
clickMapping.from(Controller.Standard.RightSecondaryThumb).peek().to(function (clicked) {
|
||||
|
@ -420,6 +446,13 @@ clickMapping.from(Controller.Standard.LeftSecondaryThumb).peek().to(function (cl
|
|||
}
|
||||
wantsMenu = clicked;
|
||||
});
|
||||
clickMapping.from(Controller.Standard.Start).peek().to(function (clicked) {
|
||||
if (clicked) {
|
||||
activeHudPoint2dGamePad();
|
||||
}
|
||||
|
||||
wantsMenu = clicked;
|
||||
});
|
||||
clickMapping.from(Controller.Hardware.Keyboard.RightMouseClicked).peek().to(function () {
|
||||
// Allow the reticle depth to be set correctly:
|
||||
// Wait a tick for the context menu to be displayed, and then simulate a (non-hand-controller) mouse move
|
||||
|
@ -472,13 +505,16 @@ function update() {
|
|||
expireMouseCursor();
|
||||
clearSystemLaser();
|
||||
}
|
||||
|
||||
updateSeeking(true);
|
||||
if (!handControllerLockOut.expired(now)) {
|
||||
return off(); // Let them use mouse in peace.
|
||||
}
|
||||
|
||||
if (!Menu.isOptionChecked("First Person")) {
|
||||
return off(); // What to do? menus can be behind hand!
|
||||
}
|
||||
|
||||
if ((!Window.hasFocus() && !HMD.active) || !Reticle.allowMouseCapture) {
|
||||
// In desktop it's pretty clear when another app is on top. In that case we bail, because
|
||||
// hand controllers might be sputtering "valid" data and that will keep someone from deliberately
|
||||
|
@ -487,14 +523,18 @@ function update() {
|
|||
// other apps anyway. So in that case, we DO keep going even though we're not on top. (Fogbugz 1831.)
|
||||
return off(); // Don't mess with other apps or paused mouse activity
|
||||
}
|
||||
|
||||
leftTrigger.update();
|
||||
rightTrigger.update();
|
||||
if (!activeTrigger.state) {
|
||||
return off(); // No trigger
|
||||
}
|
||||
|
||||
if (getGrabCommunications()) {
|
||||
return off();
|
||||
}
|
||||
|
||||
|
||||
var hudPoint2d = activeHudPoint2d(activeHand);
|
||||
if (!hudPoint2d) {
|
||||
return off();
|
||||
|
|
|
@ -24,10 +24,16 @@ var desktopMenuItemName = "Desktop";
|
|||
|
||||
var toolBar = Toolbars.getToolbar("com.highfidelity.interface.toolbar.system");
|
||||
var button;
|
||||
// Independent and Entity mode make people sick. Third Person and Mirror have traps that we need to work through.
|
||||
// Disable them in hmd.
|
||||
var desktopOnlyViews = ['Third Person', 'Mirror', 'Independent Mode', 'Entity Mode'];
|
||||
function onHmdChanged(isHmd) {
|
||||
button.writeProperty('buttonState', isHmd ? 0 : 1);
|
||||
button.writeProperty('defaultState', isHmd ? 0 : 1);
|
||||
button.writeProperty('hoverState', isHmd ? 2 : 3);
|
||||
desktopOnlyViews.forEach(function (view) {
|
||||
Menu.setMenuEnabled("View>" + view, !isHmd);
|
||||
});
|
||||
}
|
||||
function onClicked(){
|
||||
var isDesktop = Menu.isOptionChecked(desktopMenuItemName);
|
||||
|
|
|
@ -228,7 +228,7 @@ var usersWindow = (function () {
|
|||
|
||||
var WINDOW_WIDTH = 260,
|
||||
WINDOW_MARGIN = 12,
|
||||
WINDOW_BASE_MARGIN = 6, // A little less is needed in order look correct
|
||||
WINDOW_BASE_MARGIN = 24, // A little less is needed in order look correct
|
||||
WINDOW_FONT = {
|
||||
size: 12
|
||||
},
|
||||
|
@ -253,11 +253,17 @@ var usersWindow = (function () {
|
|||
windowPane,
|
||||
windowHeading,
|
||||
|
||||
// Margin on the left and right side of the window to keep
|
||||
// it from getting too close to the edge of the screen which
|
||||
// is unclickable.
|
||||
WINDOW_MARGIN_X = 20,
|
||||
|
||||
// Window border is similar to that of edit.js.
|
||||
WINDOW_BORDER_WIDTH = WINDOW_WIDTH + 2 * WINDOW_BASE_MARGIN,
|
||||
WINDOW_BORDER_TOP_MARGIN = 2 * WINDOW_BASE_MARGIN,
|
||||
WINDOW_BORDER_BOTTOM_MARGIN = WINDOW_BASE_MARGIN,
|
||||
WINDOW_BORDER_LEFT_MARGIN = WINDOW_BASE_MARGIN,
|
||||
WINDOW_MARGIN_HALF = WINDOW_MARGIN / 2,
|
||||
WINDOW_BORDER_WIDTH = WINDOW_WIDTH + 2 * WINDOW_MARGIN_HALF,
|
||||
WINDOW_BORDER_TOP_MARGIN = 2 * WINDOW_MARGIN_HALF,
|
||||
WINDOW_BORDER_BOTTOM_MARGIN = WINDOW_MARGIN_HALF,
|
||||
WINDOW_BORDER_LEFT_MARGIN = WINDOW_MARGIN_HALF,
|
||||
WINDOW_BORDER_RADIUS = 4,
|
||||
WINDOW_BORDER_COLOR = { red: 255, green: 255, blue: 255 },
|
||||
WINDOW_BORDER_ALPHA = 0.5,
|
||||
|
@ -450,7 +456,7 @@ var usersWindow = (function () {
|
|||
}
|
||||
|
||||
function saturateWindowPosition() {
|
||||
windowPosition.x = Math.max(0, Math.min(viewport.x - WINDOW_WIDTH, windowPosition.x));
|
||||
windowPosition.x = Math.max(WINDOW_MARGIN_X, Math.min(viewport.x - WINDOW_WIDTH - WINDOW_MARGIN_X, windowPosition.x));
|
||||
windowPosition.y = Math.max(windowMinimumHeight, Math.min(viewport.y, windowPosition.y));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue