Remove const from variable declarations as suggested in the review.

Suggested here: https://github.com/vircadia/vircadia/pull/928/files#r549830690

The ones I've left are either
- values known at compile time, eg. const float MIN_LENGTH_FOR_NORMALIZE = 0.061f;
- consts that were already there in the previous code, eg. const float MAX_DISPLACEMENT = 0.5f * _radius;
This commit is contained in:
Phil Palmer 2020-12-29 19:31:35 -05:00
parent d49cdfff6b
commit 8c7c91ed6f
5 changed files with 25 additions and 25 deletions

View file

@ -3823,31 +3823,31 @@ glm::vec3 MyAvatar::calculateScaledDirection() {
// Determine if we're head or controller relative... // Determine if we're head or controller relative...
glm::vec3 forward, right; glm::vec3 forward, right;
const int movementReference = getMovementReference(); int movementReference = getMovementReference();
CameraMode cameraMode = qApp->getCamera().getMode(); CameraMode cameraMode = qApp->getCamera().getMode();
bool vectorsAreInAvatarFrame = true; bool vectorsAreInAvatarFrame = true;
bool removeLocalYComponent = false; bool removeLocalYComponent = false;
const bool HMDHandRelativeMovement = bool HMDHandRelativeMovement =
qApp->isHMDMode() && (movementReference == LocomotionRelativeMovementMode::MOVEMENT_HAND_RELATIVE || qApp->isHMDMode() && (movementReference == LocomotionRelativeMovementMode::MOVEMENT_HAND_RELATIVE ||
movementReference == LocomotionRelativeMovementMode::MOVEMENT_HAND_RELATIVE_LEVELED); movementReference == LocomotionRelativeMovementMode::MOVEMENT_HAND_RELATIVE_LEVELED);
const bool desktopLookatOrSelfieMode = bool desktopLookatOrSelfieMode =
!qApp->isHMDMode() && (cameraMode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || cameraMode == CAMERA_MODE_LOOK_AT || !qApp->isHMDMode() && (cameraMode == CAMERA_MODE_FIRST_PERSON_LOOK_AT || cameraMode == CAMERA_MODE_LOOK_AT ||
cameraMode == CAMERA_MODE_SELFIE); cameraMode == CAMERA_MODE_SELFIE);
const bool hoveringOrCollisionless = _characterController.getState() == CharacterController::State::Hover || bool hoveringOrCollisionless = _characterController.getState() == CharacterController::State::Hover ||
_characterController.computeCollisionMask() == BULLET_COLLISION_MASK_COLLISIONLESS; _characterController.computeCollisionMask() == BULLET_COLLISION_MASK_COLLISIONLESS;
if (HMDHandRelativeMovement) { if (HMDHandRelativeMovement) {
const controller::Action directionHand = controller::Action directionHand =
(getDominantHand() == DOMINANT_RIGHT_HAND) ? controller::Action::LEFT_HAND : controller::Action::RIGHT_HAND; (getDominantHand() == DOMINANT_RIGHT_HAND) ? controller::Action::LEFT_HAND : controller::Action::RIGHT_HAND;
const controller::Pose handPoseInAvatarFrame = getControllerPoseInAvatarFrame(directionHand); controller::Pose handPoseInAvatarFrame = getControllerPoseInAvatarFrame(directionHand);
if (handPoseInAvatarFrame.isValid()) { if (handPoseInAvatarFrame.isValid()) {
const glm::vec3 controllerForward(0.0f, 1.0f, 0.0f); glm::vec3 controllerForward(0.0f, 1.0f, 0.0f);
const glm::vec3 controllerRight(0.0f, 0.0f, (directionHand == controller::Action::LEFT_HAND) ? 1.0f : -1.0f); glm::vec3 controllerRight(0.0f, 0.0f, (directionHand == controller::Action::LEFT_HAND) ? 1.0f : -1.0f);
forward = (handPoseInAvatarFrame.rotation * controllerForward); forward = (handPoseInAvatarFrame.rotation * controllerForward);
right = (handPoseInAvatarFrame.rotation * controllerRight); right = (handPoseInAvatarFrame.rotation * controllerRight);
@ -3887,7 +3887,7 @@ glm::vec3 MyAvatar::calculateScaledDirection() {
auto removeYAndNormalize = [](glm::vec3& vector) { auto removeYAndNormalize = [](glm::vec3& vector) {
vector.y = 0.f; vector.y = 0.f;
// Normalize if the remaining components are large enough to get a reliable direction. // Normalize if the remaining components are large enough to get a reliable direction.
const float length = glm::length(vector); float length = glm::length(vector);
const float MIN_LENGTH_FOR_NORMALIZE = 0.061f; // sin(3.5 degrees) const float MIN_LENGTH_FOR_NORMALIZE = 0.061f; // sin(3.5 degrees)
if (length > MIN_LENGTH_FOR_NORMALIZE) { if (length > MIN_LENGTH_FOR_NORMALIZE) {
vector /= length; vector /= length;
@ -4843,16 +4843,16 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor(const bool forceFollowYPos) const {
glm::vec3 headToNeck = headOrientation * Quaternions::Y_180 * (localNeck - localHead); glm::vec3 headToNeck = headOrientation * Quaternions::Y_180 * (localNeck - localHead);
glm::vec3 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck; glm::vec3 neckToRoot = headOrientationYawOnly * Quaternions::Y_180 * -localNeck;
const float worldToSensorScale = getUserEyeHeight() / getEyeHeight(); float worldToSensorScale = getUserEyeHeight() / getEyeHeight();
glm::vec3 bodyPos = headPosition + worldToSensorScale * (headToNeck + neckToRoot); glm::vec3 bodyPos = headPosition + worldToSensorScale * (headToNeck + neckToRoot);
glm::quat bodyQuat; glm::quat bodyQuat;
const controller::Pose hipsControllerPose = getControllerPoseInSensorFrame(controller::Action::HIPS); controller::Pose hipsControllerPose = getControllerPoseInSensorFrame(controller::Action::HIPS);
if (hipsControllerPose.isValid()) { if (hipsControllerPose.isValid()) {
const glm::quat hipsOrientation = hipsControllerPose.rotation * Quaternions::Y_180; glm::quat hipsOrientation = hipsControllerPose.rotation * Quaternions::Y_180;
const glm::quat hipsOrientationYawOnly = cancelOutRollAndPitch(hipsOrientation); glm::quat hipsOrientationYawOnly = cancelOutRollAndPitch(hipsOrientation);
const glm::vec3 hipsPos = hipsControllerPose.getTranslation(); glm::vec3 hipsPos = hipsControllerPose.getTranslation();
bodyPos.x = hipsPos.x; bodyPos.x = hipsPos.x;
bodyPos.z = hipsPos.z; bodyPos.z = hipsPos.z;
@ -4863,7 +4863,7 @@ glm::mat4 MyAvatar::deriveBodyFromHMDSensor(const bool forceFollowYPos) const {
if (!forceFollowYPos && !getHMDCrouchRecenterEnabled()) { if (!forceFollowYPos && !getHMDCrouchRecenterEnabled()) {
// Set the body's vertical position as if it were standing in its T-pose. // Set the body's vertical position as if it were standing in its T-pose.
const float userToRigScale = getUserEyeHeight() / getUnscaledEyeHeight(); float userToRigScale = getUserEyeHeight() / getUnscaledEyeHeight();
bodyPos.y = userToRigScale * rig.getUnscaledHipsHeight(); bodyPos.y = userToRigScale * rig.getUnscaledHipsHeight();
} }

View file

@ -65,7 +65,7 @@ static AnimPose computeHipsInSensorFrame(MyAvatar* myAvatar, bool isFlying) {
return result; return result;
} }
const bool useCenterOfGravityModel = bool useCenterOfGravityModel =
myAvatar->getCenterOfGravityModelEnabled() && !isFlying && !myAvatar->getIsInWalkingState() && myAvatar->getCenterOfGravityModelEnabled() && !isFlying && !myAvatar->getIsInWalkingState() &&
!myAvatar->getIsInSittingState() && myAvatar->getHMDLeanRecenterEnabled() && !myAvatar->getIsInSittingState() && myAvatar->getHMDLeanRecenterEnabled() &&
(myAvatar->getAllowAvatarLeaningPreference() != MyAvatar::AllowAvatarLeaningPreference::AlwaysNoRecenter) && (myAvatar->getAllowAvatarLeaningPreference() != MyAvatar::AllowAvatarLeaningPreference::AlwaysNoRecenter) &&

View file

@ -422,11 +422,11 @@ void setupPreferences() {
preferences->addPreference(preference); preferences->addPreference(preference);
} }
{ {
const IntPreference::Getter getter = [myAvatar]() -> int { IntPreference::Getter getter = [myAvatar]() -> int {
return static_cast<int>(myAvatar->getAllowAvatarStandingPreference()); return static_cast<int>(myAvatar->getAllowAvatarStandingPreference());
}; };
const IntPreference::Setter setter = [myAvatar](const int& value) { IntPreference::Setter setter = [myAvatar](const int& value) {
myAvatar->setAllowAvatarStandingPreference(static_cast<MyAvatar::AllowAvatarStandingPreference>(value)); myAvatar->setAllowAvatarStandingPreference(static_cast<MyAvatar::AllowAvatarStandingPreference>(value));
}; };
@ -440,11 +440,11 @@ void setupPreferences() {
preferences->addPreference(preference); preferences->addPreference(preference);
} }
{ {
const IntPreference::Getter getter = [myAvatar]() -> int { IntPreference::Getter getter = [myAvatar]() -> int {
return static_cast<int>(myAvatar->getAllowAvatarLeaningPreference()); return static_cast<int>(myAvatar->getAllowAvatarLeaningPreference());
}; };
const IntPreference::Setter setter = [myAvatar](const int& value) { IntPreference::Setter setter = [myAvatar](const int& value) {
myAvatar->setAllowAvatarLeaningPreference(static_cast<MyAvatar::AllowAvatarLeaningPreference>(value)); myAvatar->setAllowAvatarLeaningPreference(static_cast<MyAvatar::AllowAvatarLeaningPreference>(value));
}; };

View file

@ -2805,9 +2805,9 @@ float Rig::getUnscaledEyeHeight() const {
// Get the vertical position of the hips joint, in the rig coordinate frame, ignoring the avatar scale. // Get the vertical position of the hips joint, in the rig coordinate frame, ignoring the avatar scale.
float Rig::getUnscaledHipsHeight() const { float Rig::getUnscaledHipsHeight() const {
// This factor can be used to scale distances in the geometry frame into the unscaled rig frame. // This factor can be used to scale distances in the geometry frame into the unscaled rig frame.
const float scaleFactor = GetScaleFactorGeometryToUnscaledRig(); float scaleFactor = GetScaleFactorGeometryToUnscaledRig();
const int hipsJoint = indexOfJoint("Hips"); int hipsJoint = indexOfJoint("Hips");
// Values from the skeleton are in the geometry coordinate frame. // Values from the skeleton are in the geometry coordinate frame.
if (hipsJoint >= 0) { if (hipsJoint >= 0) {

View file

@ -370,8 +370,8 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
btVector3 linearDisplacement(0.0f, 0.0f, 0.0f); btVector3 linearDisplacement(0.0f, 0.0f, 0.0f);
{ {
const float horizontalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Horizontal)]; float horizontalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Horizontal)];
const float verticalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Vertical)]; float verticalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Vertical)];
if (horizontalTime == FOLLOW_TIME_IMMEDIATE_SNAP) { if (horizontalTime == FOLLOW_TIME_IMMEDIATE_SNAP) {
linearDisplacement.setX(deltaPos.x()); linearDisplacement.setX(deltaPos.x());
@ -402,7 +402,7 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
// startRot as default rotation // startRot as default rotation
btQuaternion endRot = startRot; btQuaternion endRot = startRot;
const float rotationTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Rotation)]; float rotationTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Rotation)];
if (rotationTime > MINIMUM_TIME_REMAINING) { if (rotationTime > MINIMUM_TIME_REMAINING) {
btQuaternion desiredRot = _followDesiredBodyTransform.getRotation(); btQuaternion desiredRot = _followDesiredBodyTransform.getRotation();