mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 05:26:32 +02:00
merge pull #1499
This commit is contained in:
commit
e18ae78ce1
5 changed files with 36 additions and 11 deletions
|
@ -200,7 +200,6 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// Compute instantaneous acceleration
|
||||
float forwardAcceleration = glm::length(glm::dot(getBodyFrontDirection(), getVelocity() - oldVelocity)) / deltaTime;
|
||||
const float ACCELERATION_PITCH_DECAY = 0.4f;
|
||||
const float ACCELERATION_YAW_DECAY = 0.4f;
|
||||
const float ACCELERATION_PULL_THRESHOLD = 0.2f;
|
||||
const float OCULUS_ACCELERATION_PULL_THRESHOLD = 1.0f;
|
||||
const int OCULUS_YAW_OFFSET_THRESHOLD = 10;
|
||||
|
@ -210,8 +209,8 @@ void MyAvatar::simulate(float deltaTime, Transmitter* transmitter) {
|
|||
// you start moving, but don't do this with an HMD like the Oculus.
|
||||
if (!OculusManager::isConnected()) {
|
||||
if (forwardAcceleration > ACCELERATION_PULL_THRESHOLD) {
|
||||
_head.setPitch(_head.getPitch() * (1.f - forwardAcceleration * ACCELERATION_PITCH_DECAY * deltaTime));
|
||||
_head.setYaw(_head.getYaw() * (1.f - forwardAcceleration * ACCELERATION_YAW_DECAY * deltaTime));
|
||||
_head.setMousePitch(_head.getMousePitch() * qMax(0.0f,
|
||||
(1.f - forwardAcceleration * ACCELERATION_PITCH_DECAY * deltaTime)));
|
||||
}
|
||||
} else if (fabsf(forwardAcceleration) > OCULUS_ACCELERATION_PULL_THRESHOLD
|
||||
&& fabs(_head.getYaw()) > OCULUS_YAW_OFFSET_THRESHOLD) {
|
||||
|
|
|
@ -95,6 +95,7 @@ void Faceshift::reset() {
|
|||
void Faceshift::updateFakeCoefficients(float leftBlink, float rightBlink, float browUp,
|
||||
float jawOpen, std::vector<float>& coefficients) const {
|
||||
coefficients.resize(max((int)coefficients.size(), _jawOpenIndex + 1));
|
||||
qFill(coefficients.begin(), coefficients.end(), 0.0f);
|
||||
coefficients[_leftBlinkIndex] = leftBlink;
|
||||
coefficients[_rightBlinkIndex] = rightBlink;
|
||||
coefficients[_browUpCenterIndex] = browUp;
|
||||
|
|
|
@ -13,7 +13,9 @@
|
|||
#include "Application.h"
|
||||
#include "SixenseManager.h"
|
||||
|
||||
SixenseManager::SixenseManager() {
|
||||
using namespace std;
|
||||
|
||||
SixenseManager::SixenseManager() : _lastMovement(0) {
|
||||
#ifdef HAVE_SIXENSE
|
||||
sixenseInit();
|
||||
#endif
|
||||
|
@ -98,6 +100,12 @@ void SixenseManager::update(float deltaTime) {
|
|||
palm->setRawVelocity(rawVelocity); // meters/sec
|
||||
palm->setRawPosition(position);
|
||||
|
||||
// use the velocity to determine whether there's any movement (if the hand isn't new)
|
||||
const float MOVEMENT_SPEED_THRESHOLD = 0.05f;
|
||||
if (glm::length(rawVelocity) > MOVEMENT_SPEED_THRESHOLD && foundHand) {
|
||||
_lastMovement = usecTimestampNow();
|
||||
}
|
||||
|
||||
// initialize the "finger" based on the direction
|
||||
FingerData finger(palm, &hand);
|
||||
finger.setActive(true);
|
||||
|
@ -118,6 +126,14 @@ void SixenseManager::update(float deltaTime) {
|
|||
palm->getFingers().push_back(finger);
|
||||
palm->getFingers().push_back(finger);
|
||||
}
|
||||
|
||||
// if the controllers haven't been moved in a while, disable
|
||||
const int MOVEMENT_DISABLE_DURATION = 30 * 1000 * 1000;
|
||||
if (usecTimestampNow() - _lastMovement > MOVEMENT_DISABLE_DURATION) {
|
||||
for (vector<PalmData>::iterator it = hand.getPalms().begin(); it != hand.getPalms().end(); it++) {
|
||||
it->setActive(false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ public:
|
|||
public slots:
|
||||
|
||||
void setFilter(bool filter);
|
||||
|
||||
private:
|
||||
|
||||
uint64_t _lastMovement;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__SixenseManager__) */
|
||||
|
|
|
@ -548,17 +548,18 @@ public:
|
|||
};
|
||||
|
||||
void appendModelIDs(const QString& parentID, const QMultiHash<QString, QString>& childMap,
|
||||
QHash<QString, FBXModel>& models, QVector<QString>& modelIDs) {
|
||||
if (models.contains(parentID)) {
|
||||
QHash<QString, FBXModel>& models, QSet<QString>& remainingModels, QVector<QString>& modelIDs) {
|
||||
if (remainingModels.contains(parentID)) {
|
||||
modelIDs.append(parentID);
|
||||
remainingModels.remove(parentID);
|
||||
}
|
||||
int parentIndex = modelIDs.size() - 1;
|
||||
foreach (const QString& childID, childMap.values(parentID)) {
|
||||
if (models.contains(childID)) {
|
||||
if (remainingModels.contains(childID)) {
|
||||
FBXModel& model = models[childID];
|
||||
if (model.parentIndex == -1) {
|
||||
model.parentIndex = parentIndex;
|
||||
appendModelIDs(childID, childMap, models, modelIDs);
|
||||
appendModelIDs(childID, childMap, models, remainingModels, modelIDs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1101,8 +1102,12 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
|
||||
// get the list of models in depth-first traversal order
|
||||
QVector<QString> modelIDs;
|
||||
if (!models.isEmpty()) {
|
||||
QString top = models.constBegin().key();
|
||||
QSet<QString> remainingModels;
|
||||
for (QHash<QString, FBXModel>::const_iterator model = models.constBegin(); model != models.constEnd(); model++) {
|
||||
remainingModels.insert(model.key());
|
||||
}
|
||||
while (!remainingModels.isEmpty()) {
|
||||
QString top = *remainingModels.constBegin();
|
||||
forever {
|
||||
foreach (const QString& name, parentMap.values(top)) {
|
||||
if (models.contains(name)) {
|
||||
|
@ -1115,7 +1120,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
|
|||
|
||||
outerContinue: ;
|
||||
}
|
||||
appendModelIDs(top, childMap, models, modelIDs);
|
||||
appendModelIDs(top, childMap, models, remainingModels, modelIDs);
|
||||
}
|
||||
|
||||
// convert the models to joints
|
||||
|
|
Loading…
Reference in a new issue