Cache ParabolaPick speed

This commit is contained in:
sabrina-shanman 2018-09-28 16:10:17 -07:00
parent b60a62da8f
commit f3f9976cfb
2 changed files with 5 additions and 2 deletions

View file

@ -19,7 +19,8 @@ ParabolaPick::ParabolaPick(const glm::vec3& position, const glm::vec3& direction
Pick(PickParabola(position, speed * direction, accelerationAxis), filter, maxDistance, enabled),
_rotateAccelerationWithAvatar(rotateAccelerationWithAvatar),
_rotateAccelerationWithParent(rotateAccelerationWithParent),
_scaleWithParent(scaleWithParent) {
_scaleWithParent(scaleWithParent),
_speed(speed) {
}
PickParabola ParabolaPick::getMathematicalPick() const {
@ -39,7 +40,7 @@ PickParabola ParabolaPick::getMathematicalPick() const {
velocity = currentParentTransform.transformDirection(velocity);
} else {
glm::vec3 transformedVelocity = currentParentTransform.transformDirection(velocity);
velocity = glm::normalize(transformedVelocity) * glm::distance(velocity, Vectors::ZERO);
velocity = glm::normalize(transformedVelocity) * _speed;
}
glm::vec3 acceleration = _mathPick.acceleration;
if (_rotateAccelerationWithAvatar) {

View file

@ -89,6 +89,8 @@ protected:
bool _rotateAccelerationWithAvatar;
bool _rotateAccelerationWithParent;
bool _scaleWithParent;
// Cached magnitude of _mathPick.velocity
float _speed;
};
#endif // hifi_ParabolaPick_h