mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-08-25 09:10:44 +02:00
Merge branch 'master' of github.com:highfidelity/hifi into model-scripting
This commit is contained in:
commit
9881dd261a
18 changed files with 142 additions and 64 deletions
|
@ -54,7 +54,10 @@ FocusScope {
|
|||
onEntered: iconColorOverlay.color = "#1fc6a6";
|
||||
onExited: iconColorOverlay.color = "#ffffff";
|
||||
// navigate back to root level menu
|
||||
onClicked: buildMenu();
|
||||
onClicked: {
|
||||
buildMenu();
|
||||
tabletRoot.playButtonClickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,10 +82,12 @@ FocusScope {
|
|||
onEntered: breadcrumbText.color = "#1fc6a6";
|
||||
onExited: breadcrumbText.color = "#34a2c7";
|
||||
// navigate back to parent level menu if there is one
|
||||
onClicked:
|
||||
onClicked: {
|
||||
if (breadcrumbText.text !== "Menu") {
|
||||
menuPopperUpper.closeLastMenu();
|
||||
}
|
||||
tabletRoot.playButtonClickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,10 @@ FocusScope {
|
|||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onEntered: listView.currentIndex = index
|
||||
onClicked: root.selected(item)
|
||||
onClicked: {
|
||||
root.selected(item)
|
||||
tabletRoot.playButtonClickSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -541,6 +541,9 @@ Q_GUI_EXPORT void qt_gl_set_global_share_context(QOpenGLContext *context);
|
|||
|
||||
Setting::Handle<int> sessionRunTime{ "sessionRunTime", 0 };
|
||||
|
||||
const float DEFAULT_HMD_TABLET_SCALE_PERCENT = 100.0f;
|
||||
const float DEFAULT_DESKTOP_TABLET_SCALE_PERCENT = 75.0f;
|
||||
|
||||
Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bool runServer, QString runServerPathOption) :
|
||||
QApplication(argc, argv),
|
||||
_shouldRunServer(runServer),
|
||||
|
@ -558,6 +561,8 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
_mirrorViewRect(QRect(MIRROR_VIEW_LEFT_PADDING, MIRROR_VIEW_TOP_PADDING, MIRROR_VIEW_WIDTH, MIRROR_VIEW_HEIGHT)),
|
||||
_previousScriptLocation("LastScriptLocation", DESKTOP_LOCATION),
|
||||
_fieldOfView("fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES),
|
||||
_hmdTabletScale("hmdTabletScale", DEFAULT_HMD_TABLET_SCALE_PERCENT),
|
||||
_desktopTabletScale("desktopTabletScale", DEFAULT_DESKTOP_TABLET_SCALE_PERCENT),
|
||||
_constrainToolbarPosition("toolbar/constrainToolbarToCenterX", true),
|
||||
_scaleMirror(1.0f),
|
||||
_rotateMirror(0.0f),
|
||||
|
@ -2319,6 +2324,14 @@ void Application::setFieldOfView(float fov) {
|
|||
}
|
||||
}
|
||||
|
||||
void Application::setHMDTabletScale(float hmdTabletScale) {
|
||||
_hmdTabletScale.set(hmdTabletScale);
|
||||
}
|
||||
|
||||
void Application::setDesktopTabletScale(float desktopTabletScale) {
|
||||
_desktopTabletScale.set(desktopTabletScale);
|
||||
}
|
||||
|
||||
void Application::setSettingConstrainToolbarPosition(bool setting) {
|
||||
_constrainToolbarPosition.set(setting);
|
||||
DependencyManager::get<OffscreenUi>()->setConstrainToolbarToCenterX(setting);
|
||||
|
|
|
@ -210,6 +210,11 @@ public:
|
|||
float getFieldOfView() { return _fieldOfView.get(); }
|
||||
void setFieldOfView(float fov);
|
||||
|
||||
float getHMDTabletScale() { return _hmdTabletScale.get(); }
|
||||
void setHMDTabletScale(float hmdTabletScale);
|
||||
float getDesktopTabletScale() { return _desktopTabletScale.get(); }
|
||||
void setDesktopTabletScale(float desktopTabletScale);
|
||||
|
||||
float getSettingConstrainToolbarPosition() { return _constrainToolbarPosition.get(); }
|
||||
void setSettingConstrainToolbarPosition(bool setting);
|
||||
|
||||
|
@ -541,6 +546,8 @@ private:
|
|||
|
||||
Setting::Handle<QString> _previousScriptLocation;
|
||||
Setting::Handle<float> _fieldOfView;
|
||||
Setting::Handle<float> _hmdTabletScale;
|
||||
Setting::Handle<float> _desktopTabletScale;
|
||||
Setting::Handle<bool> _constrainToolbarPosition;
|
||||
|
||||
float _scaleMirror;
|
||||
|
|
|
@ -70,10 +70,27 @@ void setupPreferences() {
|
|||
}
|
||||
|
||||
// UI
|
||||
static const QString UI_CATEGORY { "UI" };
|
||||
{
|
||||
auto getter = []()->bool { return qApp->getSettingConstrainToolbarPosition(); };
|
||||
auto setter = [](bool value) { qApp->setSettingConstrainToolbarPosition(value); };
|
||||
preferences->addPreference(new CheckPreference("UI", "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||
preferences->addPreference(new CheckPreference(UI_CATEGORY, "Constrain Toolbar Position to Horizontal Center", getter, setter));
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getHMDTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setHMDTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(UI_CATEGORY, "HMD Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
{
|
||||
auto getter = []()->float { return qApp->getDesktopTabletScale(); };
|
||||
auto setter = [](float value) { qApp->setDesktopTabletScale(value); };
|
||||
auto preference = new SpinnerPreference(UI_CATEGORY, "Desktop Tablet Scale %", getter, setter);
|
||||
preference->setMin(20);
|
||||
preference->setMax(500);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
|
||||
// Snapshots
|
||||
|
|
|
@ -281,7 +281,15 @@ OctreeElement::AppendState EntityItem::appendEntityData(OctreePacketData* packet
|
|||
APPEND_ENTITY_PROPERTY(PROP_HREF, getHref());
|
||||
APPEND_ENTITY_PROPERTY(PROP_DESCRIPTION, getDescription());
|
||||
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_QUERY_AA_CUBE, getQueryAACube());
|
||||
APPEND_ENTITY_PROPERTY(PROP_LAST_EDITED_BY, getLastEditedBy());
|
||||
|
|
|
@ -190,11 +190,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
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();
|
||||
float volume = dimensions.x * dimensions.y * dimensions.z;
|
||||
auto density = propertiesWithSimID.getDensity();
|
||||
|
@ -223,17 +218,6 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties
|
|||
}
|
||||
}
|
||||
|
||||
if (_bidOnSimulationOwnership) {
|
||||
// This Node is creating a new object. If it's in motion, set this Node as the simulator.
|
||||
auto nodeList = DependencyManager::get<NodeList>();
|
||||
const QUuid myNodeID = nodeList->getSessionUUID();
|
||||
|
||||
// and make note of it now, so we can act on it right away.
|
||||
propertiesWithSimID.setSimulationOwner(myNodeID, SCRIPT_POKE_SIMULATION_PRIORITY);
|
||||
entity->setSimulationOwner(myNodeID, SCRIPT_POKE_SIMULATION_PRIORITY);
|
||||
entity->rememberHasSimulationOwnershipBid();
|
||||
}
|
||||
|
||||
entity->setLastBroadcast(usecTimestampNow());
|
||||
propertiesWithSimID.setLastEdited(entity->getLastEdited());
|
||||
} else {
|
||||
|
@ -372,9 +356,6 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties&
|
|||
|
||||
if (!scriptSideProperties.parentIDChanged()) {
|
||||
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()) {
|
||||
properties.setParentJointIndex(entity->getParentJointIndex());
|
||||
|
|
|
@ -934,7 +934,7 @@ void EntityTree::initEntityEditFilterEngine(QScriptEngine* engine, std::function
|
|||
_hasEntityEditFilter = true;
|
||||
}
|
||||
|
||||
bool EntityTree::filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged) {
|
||||
bool EntityTree::filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged, bool isAdd) {
|
||||
if (!_entityEditFilterEngine) {
|
||||
propertiesOut = propertiesIn;
|
||||
wasChanged = false; // not changed
|
||||
|
@ -953,6 +953,7 @@ bool EntityTree::filterProperties(EntityItemProperties& propertiesIn, EntityItem
|
|||
auto in = QJsonValue::fromVariant(inputValues.toVariant()); // grab json copy now, because the inputValues might be side effected by the filter.
|
||||
QScriptValueList args;
|
||||
args << inputValues;
|
||||
args << isAdd;
|
||||
|
||||
QScriptValue result = _entityEditFilterFunction.call(_nullObjectForFilter, args);
|
||||
if (_entityEditFilterHadUncaughtExceptions()) {
|
||||
|
@ -989,6 +990,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
}
|
||||
|
||||
int processedBytes = 0;
|
||||
bool isAdd = false;
|
||||
// we handle these types of "edit" packets
|
||||
switch (message.getType()) {
|
||||
case PacketType::EntityErase: {
|
||||
|
@ -998,6 +1000,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
}
|
||||
|
||||
case PacketType::EntityAdd:
|
||||
isAdd = true; // fall through to next case
|
||||
case PacketType::EntityEdit: {
|
||||
quint64 startDecode = 0, endDecode = 0;
|
||||
quint64 startLookup = 0, endLookup = 0;
|
||||
|
@ -1040,7 +1043,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
}
|
||||
|
||||
// If this was an add, we also want to tell the client that sent this edit that the entity was not added.
|
||||
if (message.getType() == PacketType::EntityAdd) {
|
||||
if (isAdd) {
|
||||
QWriteLocker locker(&_recentlyDeletedEntitiesLock);
|
||||
_recentlyDeletedEntityItemIDs.insert(usecTimestampNow(), entityItemID);
|
||||
validEditPacket = passedWhiteList;
|
||||
|
@ -1050,7 +1053,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
}
|
||||
}
|
||||
|
||||
if ((message.getType() == PacketType::EntityAdd ||
|
||||
if ((isAdd ||
|
||||
(message.getType() == PacketType::EntityEdit && properties.lifetimeChanged())) &&
|
||||
!senderNode->getCanRez() && senderNode->getCanRezTmp()) {
|
||||
// this node is only allowed to rez temporary entities. if need be, cap the lifetime.
|
||||
|
@ -1068,9 +1071,11 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
startFilter = usecTimestampNow();
|
||||
bool wasChanged = false;
|
||||
// Having (un)lock rights bypasses the filter.
|
||||
bool allowed = senderNode->isAllowedEditor() || filterProperties(properties, properties, wasChanged);
|
||||
bool allowed = senderNode->isAllowedEditor() || filterProperties(properties, properties, wasChanged, isAdd);
|
||||
if (!allowed) {
|
||||
auto timestamp = properties.getLastEdited();
|
||||
properties = EntityItemProperties();
|
||||
properties.setLastEdited(timestamp);
|
||||
}
|
||||
if (!allowed || wasChanged) {
|
||||
bumpTimestamp(properties);
|
||||
|
@ -1110,7 +1115,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
|||
existingEntity->markAsChangedOnServer();
|
||||
endUpdate = usecTimestampNow();
|
||||
_totalUpdates++;
|
||||
} else if (message.getType() == PacketType::EntityAdd) {
|
||||
} else if (isAdd) {
|
||||
bool failedAdd = !allowed;
|
||||
if (!allowed) {
|
||||
qCDebug(entities) << "Filtered entity add. ID:" << entityItemID;
|
||||
|
|
|
@ -357,7 +357,7 @@ protected:
|
|||
|
||||
float _maxTmpEntityLifetime { DEFAULT_MAX_TMP_ENTITY_LIFETIME };
|
||||
|
||||
bool filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged);
|
||||
bool filterProperties(EntityItemProperties& propertiesIn, EntityItemProperties& propertiesOut, bool& wasChanged, bool isAdd);
|
||||
bool _hasEntityEditFilter{ false };
|
||||
QScriptEngine* _entityEditFilterEngine{};
|
||||
QScriptValue _entityEditFilterFunction{};
|
||||
|
|
|
@ -52,6 +52,7 @@ std::atomic<size_t> DECIMATED_TEXTURE_COUNT { 0 };
|
|||
std::atomic<size_t> RECTIFIED_TEXTURE_COUNT { 0 };
|
||||
|
||||
QImage processSourceImage(const QImage& srcImage, bool cubemap) {
|
||||
PROFILE_RANGE(resource_parse, "processSourceImage");
|
||||
const uvec2 srcImageSize = toGlm(srcImage.size());
|
||||
uvec2 targetSize = srcImageSize;
|
||||
|
||||
|
@ -72,7 +73,8 @@ QImage processSourceImage(const QImage& srcImage, bool cubemap) {
|
|||
}
|
||||
|
||||
if (targetSize != srcImageSize) {
|
||||
qDebug(modelLog) << "Resizing texture from " << srcImageSize.x << "x" << srcImageSize.y << " to " << targetSize.x << "x" << targetSize.y;
|
||||
PROFILE_RANGE(resource_parse, "processSourceImage Rectify");
|
||||
qCDebug(modelLog) << "Resizing texture from " << srcImageSize.x << "x" << srcImageSize.y << " to " << targetSize.x << "x" << targetSize.y;
|
||||
return srcImage.scaled(fromGlm(targetSize));
|
||||
}
|
||||
|
||||
|
@ -109,6 +111,7 @@ void TextureMap::setLightmapOffsetScale(float offset, float scale) {
|
|||
}
|
||||
|
||||
const QImage TextureUsage::process2DImageColor(const QImage& srcImage, bool& validAlpha, bool& alphaAsMask) {
|
||||
PROFILE_RANGE(resource_parse, "process2DImageColor");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
validAlpha = false;
|
||||
alphaAsMask = true;
|
||||
|
@ -201,6 +204,7 @@ const QImage& image, bool isLinear, bool doCompress) {
|
|||
|
||||
void generateMips(gpu::Texture* texture, QImage& image, gpu::Element formatMip) {
|
||||
#if CPU_MIPMAPS
|
||||
PROFILE_RANGE(resource_parse, "generateMips");
|
||||
auto numMips = texture->evalNumMips();
|
||||
for (uint16 level = 1; level < numMips; ++level) {
|
||||
QSize mipSize(texture->evalMipWidth(level), texture->evalMipHeight(level));
|
||||
|
@ -214,6 +218,7 @@ void generateMips(gpu::Texture* texture, QImage& image, gpu::Element formatMip)
|
|||
|
||||
void generateFaceMips(gpu::Texture* texture, QImage& image, gpu::Element formatMip, uint8 face) {
|
||||
#if CPU_MIPMAPS
|
||||
PROFILE_RANGE(resource_parse, "generateFaceMips");
|
||||
auto numMips = texture->evalNumMips();
|
||||
for (uint16 level = 1; level < numMips; ++level) {
|
||||
QSize mipSize(texture->evalMipWidth(level), texture->evalMipHeight(level));
|
||||
|
@ -226,6 +231,7 @@ void generateFaceMips(gpu::Texture* texture, QImage& image, gpu::Element formatM
|
|||
}
|
||||
|
||||
gpu::Texture* TextureUsage::process2DTextureColorFromImage(const QImage& srcImage, const std::string& srcImageName, bool isLinear, bool doCompress, bool generateMips) {
|
||||
PROFILE_RANGE(resource_parse, "process2DTextureColorFromImage");
|
||||
bool validAlpha = false;
|
||||
bool alphaAsMask = true;
|
||||
QImage image = process2DImageColor(srcImage, validAlpha, alphaAsMask);
|
||||
|
@ -277,6 +283,7 @@ gpu::Texture* TextureUsage::createLightmapTextureFromImage(const QImage& srcImag
|
|||
|
||||
|
||||
gpu::Texture* TextureUsage::createNormalTextureFromNormalImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||
PROFILE_RANGE(resource_parse, "createNormalTextureFromNormalImage");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
|
||||
if (image.format() != QImage::Format_RGB888) {
|
||||
|
@ -311,6 +318,7 @@ double mapComponent(double sobelValue) {
|
|||
}
|
||||
|
||||
gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||
PROFILE_RANGE(resource_parse, "createNormalTextureFromBumpImage");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
|
||||
if (image.format() != QImage::Format_RGB888) {
|
||||
|
@ -383,6 +391,7 @@ gpu::Texture* TextureUsage::createNormalTextureFromBumpImage(const QImage& srcIm
|
|||
}
|
||||
|
||||
gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||
PROFILE_RANGE(resource_parse, "createRoughnessTextureFromImage");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
if (!image.hasAlphaChannel()) {
|
||||
if (image.format() != QImage::Format_RGB888) {
|
||||
|
@ -417,6 +426,7 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromImage(const QImage& srcIma
|
|||
}
|
||||
|
||||
gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||
PROFILE_RANGE(resource_parse, "createRoughnessTextureFromGlossImage");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
if (!image.hasAlphaChannel()) {
|
||||
if (image.format() != QImage::Format_RGB888) {
|
||||
|
@ -455,6 +465,7 @@ gpu::Texture* TextureUsage::createRoughnessTextureFromGlossImage(const QImage& s
|
|||
}
|
||||
|
||||
gpu::Texture* TextureUsage::createMetallicTextureFromImage(const QImage& srcImage, const std::string& srcImageName) {
|
||||
PROFILE_RANGE(resource_parse, "createMetallicTextureFromImage");
|
||||
QImage image = processSourceImage(srcImage, false);
|
||||
if (!image.hasAlphaChannel()) {
|
||||
if (image.format() != QImage::Format_RGB888) {
|
||||
|
|
|
@ -203,7 +203,11 @@ void EntityMotionState::getWorldTransform(btTransform& worldTrans) const {
|
|||
BT_PROFILE("kinematicIntegration");
|
||||
// This is physical kinematic motion which steps strictly by the subframe count
|
||||
// of the physics simulation and uses full gravity for acceleration.
|
||||
_entity->setAcceleration(_entity->getGravity());
|
||||
if (_entity->hasAncestorOfType(NestableType::Avatar)) {
|
||||
_entity->setAcceleration(glm::vec3(0.0f));
|
||||
} else {
|
||||
_entity->setAcceleration(_entity->getGravity());
|
||||
}
|
||||
uint32_t thisStep = ObjectMotionState::getWorldSimulationStep();
|
||||
float dt = (thisStep - _lastKinematicStep) * PHYSICS_ENGINE_FIXED_SUBSTEP;
|
||||
_entity->stepKinematicMotion(dt);
|
||||
|
|
|
@ -150,11 +150,11 @@ void MeshPartPayload::bindMaterial(gpu::Batch& batch, const ShapePipeline::Locat
|
|||
if (!enableTextures) {
|
||||
batch.setResourceTexture(ShapePipeline::Slot::ALBEDO, textureCache->getWhiteTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::ROUGHNESS, textureCache->getWhiteTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::NORMAL, nullptr);
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::METALLIC, nullptr);
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::OCCLUSION, nullptr);
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::SCATTERING, nullptr);
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::EMISSIVE_LIGHTMAP, nullptr);
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::NORMAL, textureCache->getBlueTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::METALLIC, textureCache->getBlackTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::OCCLUSION, textureCache->getWhiteTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::SCATTERING, textureCache->getWhiteTexture());
|
||||
batch.setResourceTexture(ShapePipeline::Slot::MAP::EMISSIVE_LIGHTMAP, textureCache->getBlackTexture());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -143,6 +143,7 @@ var ONE_VEC = {
|
|||
};
|
||||
|
||||
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 INCHES_TO_METERS = 1.0 / 39.3701;
|
||||
|
@ -895,9 +896,7 @@ function MyController(hand) {
|
|||
if (!SHOW_GRAB_POINT_SPHERE) {
|
||||
return;
|
||||
}
|
||||
if (!MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.grabPointSphere) {
|
||||
this.grabPointSphere = Overlays.addOverlay("sphere", {
|
||||
localPosition: getGrabPointSphereOffset(this.handToController()),
|
||||
|
@ -909,7 +908,7 @@ function MyController(hand) {
|
|||
visible: true,
|
||||
ignoreRayIntersection: true,
|
||||
drawInFront: false,
|
||||
parentID: MyAvatar.sessionUUID,
|
||||
parentID: AVATAR_SELF_ID,
|
||||
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
||||
"_CONTROLLER_RIGHTHAND" :
|
||||
"_CONTROLLER_LEFTHAND")
|
||||
|
@ -961,9 +960,6 @@ function MyController(hand) {
|
|||
if (this.stylus) {
|
||||
return;
|
||||
}
|
||||
if (!MyAvatar.sessionUUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
var stylusProperties = {
|
||||
url: Script.resourcesPath() + "meshes/tablet-stylus-fat.fbx",
|
||||
|
@ -977,7 +973,7 @@ function MyController(hand) {
|
|||
visible: true,
|
||||
ignoreRayIntersection: true,
|
||||
drawInFront: false,
|
||||
parentID: MyAvatar.sessionUUID,
|
||||
parentID: AVATAR_SELF_ID,
|
||||
parentJointIndex: MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
||||
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
|
||||
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND")
|
||||
|
@ -2341,7 +2337,7 @@ function MyController(hand) {
|
|||
}
|
||||
|
||||
var reparentProps = {
|
||||
parentID: MyAvatar.sessionUUID,
|
||||
parentID: AVATAR_SELF_ID,
|
||||
parentJointIndex: handJointIndex,
|
||||
velocity: {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) {
|
||||
this.lastUnequipCheckTime = now;
|
||||
|
||||
if (props.parentID == MyAvatar.sessionUUID) {
|
||||
if (props.parentID == AVATAR_SELF_ID) {
|
||||
var handPosition;
|
||||
if (this.ignoreIK) {
|
||||
handPosition = getControllerWorldLocation(this.handToController(), false).position;
|
||||
|
@ -2572,7 +2568,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.maybeScale = function(props) {
|
||||
if (!objectScalingEnabled) {
|
||||
if (!objectScalingEnabled || this.isTablet(this.grabbedEntity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2911,7 +2907,7 @@ function MyController(hand) {
|
|||
var pos3D = intersectInfo.point;
|
||||
|
||||
if (this.state == STATE_OVERLAY_STYLUS_TOUCHING &&
|
||||
!this.deadspotExpired &&
|
||||
!this.tabletStabbed &&
|
||||
intersectInfo.distance < WEB_STYLUS_LENGTH / 2.0 + WEB_TOUCH_TOO_CLOSE) {
|
||||
// they've stabbed the tablet, don't send events until they pull back
|
||||
this.tabletStabbed = true;
|
||||
|
@ -2919,8 +2915,15 @@ function MyController(hand) {
|
|||
this.tabletStabbedPos3D = pos3D;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.tabletStabbed) {
|
||||
return;
|
||||
var origin = {x: this.tabletStabbedPos2D.x, y: this.tabletStabbedPos2D.y, z: 0};
|
||||
var point = {x: pos2D.x, y: pos2D.y, z: 0};
|
||||
var offset = Vec3.distance(origin, point);
|
||||
var radius = 0.05;
|
||||
if (offset < radius) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Overlays.keyboardFocusOverlay != this.grabbedOverlay) {
|
||||
|
@ -3012,7 +3015,7 @@ function MyController(hand) {
|
|||
};
|
||||
|
||||
this.thisHandIsParent = function(props) {
|
||||
if (props.parentID != MyAvatar.sessionUUID) {
|
||||
if (props.parentID !== MyAvatar.sessionUUID && props.parentID !== AVATAR_SELF_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3046,16 +3049,21 @@ function MyController(hand) {
|
|||
// find children of avatar's hand joint
|
||||
var handJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ? "RightHand" : "LeftHand");
|
||||
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, handJointIndex);
|
||||
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, handJointIndex));
|
||||
|
||||
// find children of faux controller joint
|
||||
var controllerJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
||||
"_CONTROLLER_RIGHTHAND" :
|
||||
"_CONTROLLER_LEFTHAND");
|
||||
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
|
||||
var controllerCRJointIndex = MyAvatar.getJointIndex(this.hand === RIGHT_HAND ?
|
||||
"_CAMERA_RELATIVE_CONTROLLER_RIGHTHAND" :
|
||||
"_CAMERA_RELATIVE_CONTROLLER_LEFTHAND");
|
||||
children = children.concat(Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, controllerCRJointIndex));
|
||||
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, controllerCRJointIndex));
|
||||
|
||||
children.forEach(function(childID) {
|
||||
if (childID !== _this.stylus) {
|
||||
|
|
|
@ -210,7 +210,10 @@ var toolBar = (function () {
|
|||
var button = toolBar.addButton({
|
||||
objectName: name,
|
||||
imageURL: imageUrl,
|
||||
buttonState: 1,
|
||||
imageOffOut: 1,
|
||||
imageOffIn: 2,
|
||||
imageOnOut: 0,
|
||||
imageOnIn: 2,
|
||||
alpha: 0.9,
|
||||
visible: true
|
||||
});
|
||||
|
|
|
@ -24,14 +24,14 @@ var CAMERA_MATRIX = -7;
|
|||
var ROT_Y_180 = {x: 0, y: 1, z: 0, w: 0};
|
||||
var TABLET_TEXTURE_RESOLUTION = { x: 480, y: 706 };
|
||||
var INCHES_TO_METERS = 1 / 39.3701;
|
||||
var NO_HANDS = -1;
|
||||
|
||||
var AVATAR_SELF_ID = "{00000000-0000-0000-0000-000000000001}";
|
||||
var TABLET_URL = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx";
|
||||
var NO_HANDS = -1;
|
||||
|
||||
// will need to be recaclulated if dimensions of fbx model change.
|
||||
var TABLET_NATURAL_DIMENSIONS = {x: 33.797, y: 50.129, z: 2.269};
|
||||
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-close.png";
|
||||
var TABLET_MODEL_PATH = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx";
|
||||
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-close.png";
|
||||
var TABLET_MODEL_PATH = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx";
|
||||
// returns object with two fields:
|
||||
// * position - position in front of the user
|
||||
// * rotation - rotation of entity so it faces the user.
|
||||
|
@ -95,7 +95,12 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
var tabletScaleFactor = this.width / TABLET_NATURAL_DIMENSIONS.x;
|
||||
this.height = TABLET_NATURAL_DIMENSIONS.y * tabletScaleFactor;
|
||||
this.depth = TABLET_NATURAL_DIMENSIONS.z * tabletScaleFactor;
|
||||
this.dpi = dpi || DEFAULT_DPI;
|
||||
|
||||
if (dpi) {
|
||||
this.dpi = dpi;
|
||||
} else {
|
||||
this.dpi = DEFAULT_DPI * (DEFAULT_WIDTH / this.width);
|
||||
}
|
||||
|
||||
var tabletProperties = {
|
||||
name: "WebTablet Tablet",
|
||||
|
@ -105,7 +110,7 @@ WebTablet = function (url, width, dpi, hand, clientOnly) {
|
|||
"grabbableKey": {"grabbable": true}
|
||||
}),
|
||||
dimensions: {x: this.width, y: this.height, z: this.depth},
|
||||
parentID: MyAvatar.sessionUUID
|
||||
parentID: AVATAR_SELF_ID
|
||||
};
|
||||
|
||||
// compute position, rotation & parentJointIndex of the tablet
|
||||
|
@ -252,12 +257,14 @@ WebTablet.prototype.geometryChanged = function (geometry) {
|
|||
// calclulate the appropriate position of the tablet in world space, such that it fits in the center of the screen.
|
||||
// with a bit of padding on the top and bottom.
|
||||
WebTablet.prototype.calculateWorldAttitudeRelativeToCamera = function () {
|
||||
var DEFAULT_DESKTOP_TABLET_SCALE = 75;
|
||||
var DESKTOP_TABLET_SCALE = Settings.getValue("desktopTabletScale") || DEFAULT_DESKTOP_TABLET_SCALE;
|
||||
var fov = (Settings.getValue('fieldOfView') || DEFAULT_VERTICAL_FIELD_OF_VIEW) * (Math.PI / 180);
|
||||
var MAX_PADDING_FACTOR = 2.2;
|
||||
var PADDING_FACTOR = Math.min(Window.innerHeight / TABLET_TEXTURE_RESOLUTION.y, MAX_PADDING_FACTOR);
|
||||
var TABLET_HEIGHT = (TABLET_TEXTURE_RESOLUTION.y / this.dpi) * INCHES_TO_METERS;
|
||||
var WEB_ENTITY_Z_OFFSET = (this.depth / 2);
|
||||
var dist = (PADDING_FACTOR * TABLET_HEIGHT) / (2 * Math.tan(fov / 2)) - WEB_ENTITY_Z_OFFSET;
|
||||
var dist = (PADDING_FACTOR * TABLET_HEIGHT) / (2 * Math.tan(fov / 2) * (DESKTOP_TABLET_SCALE / 100)) - WEB_ENTITY_Z_OFFSET;
|
||||
return {
|
||||
position: Vec3.sum(Camera.position, Vec3.multiply(dist, Quat.getFront(Camera.orientation))),
|
||||
rotation: Quat.multiply(Camera.orientation, ROT_Y_180)
|
||||
|
@ -318,6 +325,7 @@ WebTablet.prototype.register = function() {
|
|||
|
||||
WebTablet.prototype.cleanUpOldTabletsOnJoint = function(jointIndex) {
|
||||
var children = Entities.getChildrenIDsOfJoint(MyAvatar.sessionUUID, jointIndex);
|
||||
children = children.concat(Entities.getChildrenIDsOfJoint(AVATAR_SELF_ID, jointIndex));
|
||||
print("cleanup " + children);
|
||||
children.forEach(function(childID) {
|
||||
var props = Entities.getEntityProperties(childID, ["name"]);
|
||||
|
@ -335,6 +343,7 @@ WebTablet.prototype.cleanUpOldTablets = function() {
|
|||
this.cleanUpOldTabletsOnJoint(SENSOR_TO_ROOM_MATRIX);
|
||||
this.cleanUpOldTabletsOnJoint(CAMERA_MATRIX);
|
||||
this.cleanUpOldTabletsOnJoint(65529);
|
||||
this.cleanUpOldTabletsOnJoint(65534);
|
||||
};
|
||||
|
||||
WebTablet.prototype.unregister = function() {
|
||||
|
@ -357,7 +366,7 @@ WebTablet.prototype.getPosition = function () {
|
|||
|
||||
WebTablet.prototype.mousePressEvent = function (event) {
|
||||
var pickRay = Camera.computePickRay(event.x, event.y);
|
||||
var entityPickResults = Entities.findRayIntersection(pickRay, true); // non-accurate picking
|
||||
var entityPickResults = Entities.findRayIntersection(pickRay, true, [this.tabletEntityID]); // non-accurate picking
|
||||
if (entityPickResults.intersects && entityPickResults.entityID === this.tabletEntityID) {
|
||||
var overlayPickResults = Overlays.findRayIntersection(pickRay);
|
||||
if (overlayPickResults.intersects && overlayPickResults.overlayID === HMD.homeButtonID) {
|
||||
|
|
|
@ -19,7 +19,7 @@ var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace";
|
|||
var MARKETPLACE_URL_INITIAL = MARKETPLACE_URL + "?"; // Append "?" to signal injected script that it's the initial page.
|
||||
var MARKETPLACES_URL = Script.resolvePath("../html/marketplaces.html");
|
||||
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
||||
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
||||
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
||||
|
||||
// Event bridge messages.
|
||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
||||
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
||||
(function() {
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
|
@ -30,4 +30,4 @@ var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-
|
|||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
})
|
||||
}());
|
||||
}());
|
||||
|
|
|
@ -24,7 +24,11 @@
|
|||
function showTabletUI() {
|
||||
tabletShown = true;
|
||||
print("show tablet-ui");
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", null, null, activeHand, true);
|
||||
|
||||
var DEFAULT_WIDTH = 0.4375;
|
||||
var DEFAULT_HMD_TABLET_SCALE = 100;
|
||||
var HMD_TABLET_SCALE = Settings.getValue("hmdTabletScale") || DEFAULT_HMD_TABLET_SCALE;
|
||||
UIWebTablet = new WebTablet("qml/hifi/tablet/TabletRoot.qml", DEFAULT_WIDTH * (HMD_TABLET_SCALE / 100), null, activeHand, true);
|
||||
UIWebTablet.register();
|
||||
HMD.tabletID = UIWebTablet.tabletEntityID;
|
||||
HMD.homeButtonID = UIWebTablet.homeButtonEntity;
|
||||
|
|
Loading…
Reference in a new issue