Merge branch 'master' of github.com:highfidelity/hifi into motor-action

This commit is contained in:
Seth Alves 2017-05-12 10:31:55 -07:00
commit fabcd7e8e0
7 changed files with 75 additions and 13 deletions

View file

@ -238,8 +238,25 @@ Column {
stackShadowNarrowing: root.stackShadowNarrowing;
shadowHeight: root.stackedCardShadowHeight;
hoverThunk: function () { scroll.currentIndex = index; }
unhoverThunk: function () { scroll.currentIndex = -1; }
hoverThunk: function () { scrollToIndex(index); }
unhoverThunk: function () { scrollToIndex(-1); }
}
}
NumberAnimation {
id: anim;
target: scroll;
property: "contentX";
duration: 250;
}
function scrollToIndex(index) {
anim.running = false;
var pos = scroll.contentX;
var destPos;
scroll.positionViewAtIndex(index, ListView.Contain);
destPos = scroll.contentX;
anim.from = pos;
anim.to = destPos;
scroll.currentIndex = index;
anim.running = true;
}
}

View file

@ -14,7 +14,7 @@
class OtherAvatar : public Avatar {
public:
explicit OtherAvatar(QThread* thread, RigPointer rig = nullptr);
void instantiableAvatar() {};
virtual void instantiableAvatar() override {};
};
#endif // hifi_OtherAvatar_h

View file

@ -383,6 +383,7 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) {
} else if (mipFormat == gpu::Element::COLOR_RGBA_32) {
compressionOptions.setFormat(nvtt::Format_RGBA);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(32,
0x000000FF,
0x0000FF00,
@ -393,6 +394,7 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) {
} else if (mipFormat == gpu::Element::COLOR_BGRA_32) {
compressionOptions.setFormat(nvtt::Format_RGBA);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(32,
0x00FF0000,
0x0000FF00,
@ -403,6 +405,7 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) {
} else if (mipFormat == gpu::Element::COLOR_SRGBA_32) {
compressionOptions.setFormat(nvtt::Format_RGBA);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(32,
0x000000FF,
0x0000FF00,
@ -411,6 +414,7 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) {
} else if (mipFormat == gpu::Element::COLOR_SBGRA_32) {
compressionOptions.setFormat(nvtt::Format_RGBA);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(32,
0x00FF0000,
0x0000FF00,
@ -419,11 +423,13 @@ void generateMips(gpu::Texture* texture, QImage& image, int face = -1) {
} else if (mipFormat == gpu::Element::COLOR_R_8) {
compressionOptions.setFormat(nvtt::Format_RGB);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(8, 0, 0, 0);
} else if (mipFormat == gpu::Element::VEC2NU8_XY) {
inputOptions.setNormalMap(true);
compressionOptions.setFormat(nvtt::Format_RGBA);
compressionOptions.setPixelType(nvtt::PixelType_UnsignedNorm);
compressionOptions.setPitchAlignment(4);
compressionOptions.setPixelFormat(8, 8, 0, 0);
} else {
qCWarning(imagelogging) << "Unknown mip format";

View file

@ -71,7 +71,7 @@ public:
void addSample(T sample) {
if (numSamples > 0) {
average = (sample * WEIGHTING) + (average * ONE_MINUS_WEIGHTING);
average = (sample * (T)WEIGHTING) + (average * (T)ONE_MINUS_WEIGHTING);
} else {
average = sample;
}

View file

@ -66,7 +66,7 @@ static glm::mat4 computeOffset(glm::mat4 defaultToReferenceMat, glm::mat4 defaul
}
static bool sortPucksYPosition(std::pair<uint32_t, controller::Pose> firstPuck, std::pair<uint32_t, controller::Pose> secondPuck) {
return (firstPuck.second.translation.y < firstPuck.second.translation.y);
return (firstPuck.second.translation.y < secondPuck.second.translation.y);
}
bool ViveControllerManager::isSupported() const {
@ -245,6 +245,7 @@ void ViveControllerManager::InputDevice::calibrateOrUncalibrate(const controller
}
void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibrationData& inputCalibration) {
qDebug() << "Puck Calibration: Starting...";
// convert the hmd head from sensor space to avatar space
glm::mat4 hmdSensorFlippedMat = inputCalibration.hmdSensorMat * Matrices::Y_180;
glm::mat4 sensorToAvatarMat = glm::inverse(inputCalibration.avatarMat) * inputCalibration.sensorToWorldMat;
@ -264,18 +265,24 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
glm::mat4 defaultToReferenceMat = currentHead * glm::inverse(inputCalibration.defaultHeadMat);
int puckCount = (int)_validTrackedObjects.size();
qDebug() << "Puck Calibration: " << puckCount << " pucks found for calibration";
_config = _preferedConfig;
if (_config != Config::Auto && puckCount < MIN_PUCK_COUNT) {
qDebug() << "Puck Calibration: Failed: Could not meet the minimal # of pucks";
uncalibrate();
return;
} else if (_config == Config::Auto){
if (puckCount == MIN_PUCK_COUNT) {
_config = Config::Feet;
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
} else if (puckCount == MIN_FEET_AND_HIPS) {
_config = Config::FeetAndHips;
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
} else if (puckCount >= MIN_FEET_HIPS_CHEST) {
_config = Config::FeetHipsAndChest;
qDebug() << "Puck Calibration: Auto Config: " << configToString(_config) << " configuration";
} else {
qDebug() << "Puck Calibration: Auto Config Failed: Could not meet the minimal # of pucks";
uncalibrate();
return;
}
@ -283,8 +290,6 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
std::sort(_validTrackedObjects.begin(), _validTrackedObjects.end(), sortPucksYPosition);
auto& firstFoot = _validTrackedObjects[FIRST_FOOT];
auto& secondFoot = _validTrackedObjects[SECOND_FOOT];
controller::Pose& firstFootPose = firstFoot.second;
@ -314,10 +319,12 @@ void ViveControllerManager::InputDevice::calibrate(const controller::InputCalibr
_jointToPuckMap[controller::SPINE2] = _validTrackedObjects[CHEST].first;
_pucksOffset[_validTrackedObjects[CHEST].first] = computeOffset(defaultToReferenceMat, inputCalibration.defaultSpine2, _validTrackedObjects[CHEST].second);
} else {
qDebug() << "Puck Calibration: " << configToString(_config) << " Config Failed: Could not meet the minimal # of pucks";
uncalibrate();
return;
}
_calibrated = true;
qDebug() << "PuckCalibration: " << configToString(_config) << " Configuration Successful";
}
void ViveControllerManager::InputDevice::uncalibrate() {
@ -575,9 +582,9 @@ void ViveControllerManager::InputDevice::saveSettings() const {
settings.endGroup();
}
QString ViveControllerManager::InputDevice::configToString() {
QString ViveControllerManager::InputDevice::configToString(Config config) {
QString currentConfig;
switch (_preferedConfig) {
switch (config) {
case Config::Auto:
currentConfig = "Auto";
break;
@ -615,7 +622,7 @@ void ViveControllerManager::InputDevice::createPreferences() {
static const QString VIVE_PUCKS_CONFIG = "Vive Pucks Configuration";
{
auto getter = [this]()->QString { return configToString(); };
auto getter = [this]()->QString { return configToString(_preferedConfig); };
auto setter = [this](const QString& value) { setConfigFromString(value); saveSettings(); };
auto preference = new ComboBoxPreference(VIVE_PUCKS_CONFIG, "Configuration", getter, setter);
QStringList list = (QStringList() << "Auto" << "Feet" << "FeetAndHips" << "FeetHipsAndChest");

View file

@ -126,7 +126,7 @@ private:
bool _timeTilCalibrationSet { false };
mutable std::recursive_mutex _lock;
QString configToString();
QString configToString(Config config);
void setConfigFromString(const QString& value);
void loadSettings();
void saveSettings() const;

View file

@ -198,7 +198,7 @@
}
var animationData = {};
function updateAnimationData() {
function updateAnimationData(verticalOffset) {
// all we are doing here is moving the right hand to a spot
// that is in front of and a bit above the hips. Basing how
// far in front as scaling with the avatar's height (say hips
@ -209,6 +209,9 @@
offset = 0.8 * MyAvatar.getAbsoluteJointTranslationInObjectFrame(headIndex).y;
}
animationData.rightHandPosition = Vec3.multiply(offset, {x: -0.25, y: 0.8, z: 1.3});
if (verticalOffset) {
animationData.rightHandPosition.y += verticalOffset;
}
animationData.rightHandRotation = Quat.fromPitchYawRollDegrees(90, 0, 90);
}
function shakeHandsAnimation() {
@ -347,7 +350,32 @@
}
return false;
}
function findNearestAvatar() {
// We only look some max distance away (much larger than the handshake distance, but still...)
var minDistance = MAX_AVATAR_DISTANCE * 20;
var closestAvatar;
AvatarList.getAvatarIdentifiers().forEach(function (id) {
var avatar = AvatarList.getAvatar(id);
if (avatar && avatar.sessionUUID != MyAvatar.sessionUUID) {
var currentDistance = Vec3.distance(avatar.position, MyAvatar.position);
if (minDistance > currentDistance) {
minDistance = currentDistance;
closestAvatar = avatar;
}
}
});
return closestAvatar;
}
function adjustAnimationHeight() {
var avatar = findNearestAvatar();
if (avatar) {
var myHeadIndex = MyAvatar.getJointIndex("Head");
var otherHeadIndex = avatar.getJointIndex("Head");
var diff = (avatar.getJointPosition(otherHeadIndex).y - MyAvatar.getJointPosition(myHeadIndex).y) / 2;
print("head height difference: " + diff);
updateAnimationData(diff);
}
}
function findNearestWaitingAvatar() {
var handPosition = getHandPosition(MyAvatar, currentHandJointIndex);
var minDistance = MAX_AVATAR_DISTANCE;
@ -436,6 +464,10 @@
handStringMessageSend({
key: "waiting",
});
// potentially adjust height of handshake
if (fromKeyboard) {
adjustAnimationHeight();
}
lookForWaitingAvatar();
}
}