Merge pull request #6956 from hyperlogic/tony/velocity-fix

MyAvatar: copy body velocity + hmd follow velocity onto avatar
This commit is contained in:
Andrew Meadows 2016-01-27 14:59:46 -08:00
commit 7b5c221ceb
6 changed files with 15 additions and 4 deletions

View file

@ -136,7 +136,7 @@ Item {
Text {
color: root.fontColor;
font.pixelSize: root.fontSize
text: "Velocity: " + root.velocity.toFixed(1)
text: "Speed: " + root.speed.toFixed(1)
}
Text {
color: root.fontColor;

View file

@ -1085,6 +1085,8 @@ void MyAvatar::harvestResultsFromPhysicsSimulation(float deltaTime) {
nextAttitude(position, orientation);
_bodySensorMatrix = _follow.postPhysicsUpdate(*this, _bodySensorMatrix);
setVelocity(_characterController.getLinearVelocity() + _characterController.getFollowVelocity());
// now that physics has adjusted our position, we can update attachements.
Avatar::simulateAttachments(deltaTime);
}

View file

@ -162,7 +162,7 @@ void Stats::updateStats(bool force) {
MyAvatar* myAvatar = avatarManager->getMyAvatar();
glm::vec3 avatarPos = myAvatar->getPosition();
STAT_UPDATE(position, QVector3D(avatarPos.x, avatarPos.y, avatarPos.z));
STAT_UPDATE_FLOAT(velocity, glm::length(myAvatar->getVelocity()), 0.1f);
STAT_UPDATE_FLOAT(speed, glm::length(myAvatar->getVelocity()), 0.1f);
STAT_UPDATE_FLOAT(yaw, myAvatar->getBodyYaw(), 0.1f);
if (_expanded || force) {
SharedNodePointer avatarMixer = nodeList->soloNodeOfType(NodeType::AvatarMixer);

View file

@ -47,7 +47,7 @@ class Stats : public QQuickItem {
STATS_PROPERTY(int, entitiesPing, 0)
STATS_PROPERTY(int, assetPing, 0)
STATS_PROPERTY(QVector3D, position, QVector3D(0, 0, 0) )
STATS_PROPERTY(float, velocity, 0)
STATS_PROPERTY(float, speed, 0)
STATS_PROPERTY(float, yaw, 0)
STATS_PROPERTY(int, avatarMixerInKbps, 0)
STATS_PROPERTY(int, avatarMixerInPps, 0)
@ -138,7 +138,7 @@ signals:
void entitiesPingChanged();
void assetPingChanged();
void positionChanged();
void velocityChanged();
void speedChanged();
void yawChanged();
void avatarMixerInKbpsChanged();
void avatarMixerInPpsChanged();

View file

@ -390,6 +390,14 @@ glm::quat CharacterController::getFollowAngularDisplacement() const {
return bulletToGLM(_followAngularDisplacement);
}
glm::vec3 CharacterController::getFollowVelocity() const {
if (_followTime > 0.0f) {
return bulletToGLM(_followLinearDisplacement) / _followTime;
} else {
return glm::vec3();
}
}
glm::vec3 CharacterController::getLinearVelocity() const {
glm::vec3 velocity(0.0f);
if (_rigidBody) {

View file

@ -71,6 +71,7 @@ public:
float getFollowTime() const { return _followTime; }
glm::vec3 getFollowLinearDisplacement() const;
glm::quat getFollowAngularDisplacement() const;
glm::vec3 getFollowVelocity() const;
glm::vec3 getLinearVelocity() const;