Code style: made some little things more conformant with the coding standards and the rest of the codebase.

https://github.com/vircadia/vircadia/blob/master/CODING_STANDARD.md
This commit is contained in:
Phil Palmer 2020-12-23 19:00:05 -05:00
parent 8b839fe71b
commit a489e9ddca
3 changed files with 13 additions and 16 deletions

View file

@ -5562,8 +5562,8 @@ MyAvatar::FollowHelper::FollowHelper() {
} }
void MyAvatar::FollowHelper::deactivate() { void MyAvatar::FollowHelper::deactivate() {
for (uint i = 0, e = static_cast<uint>(CharacterController::FollowType::Count); i < e; ++i) { for (uint i = 0; i < static_cast<uint>(CharacterController::FollowType::Count); i++) {
deactivate((CharacterController::FollowType)i); deactivate(static_cast<CharacterController::FollowType>(i));
} }
} }
@ -5588,8 +5588,8 @@ bool MyAvatar::FollowHelper::isActive(CharacterController::FollowType type) cons
} }
bool MyAvatar::FollowHelper::isActive() const { bool MyAvatar::FollowHelper::isActive() const {
for (uint i = 0, e = static_cast<uint>(CharacterController::FollowType::Count); i < e; ++i) { for (uint i = 0; i < static_cast<uint>(CharacterController::FollowType::Count); i++) {
if (isActive((CharacterController::FollowType)i)) { if (isActive(static_cast<CharacterController::FollowType>(i))) {
return true; return true;
} }
} }
@ -5597,12 +5597,12 @@ bool MyAvatar::FollowHelper::isActive() const {
} }
void MyAvatar::FollowHelper::decrementTimeRemaining(float dt) { void MyAvatar::FollowHelper::decrementTimeRemaining(float dt) {
for (uint i = 0, e = static_cast<uint>(CharacterController::FollowType::Count); i < e; ++i) { for (auto& time : _timeRemaining) {
if (_timeRemaining[i] == CharacterController::FOLLOW_TIME_IMMEDIATE_SNAP) { if (time == CharacterController::FOLLOW_TIME_IMMEDIATE_SNAP) {
_timeRemaining[i] = 0.f; time = 0.0f;
} }
else { else {
_timeRemaining[i] -= dt; time -= dt;
} }
} }
} }
@ -5612,13 +5612,14 @@ bool MyAvatar::FollowHelper::shouldActivateRotation(const MyAvatar& myAvatar,
const glm::mat4& desiredBodyMatrix, const glm::mat4& desiredBodyMatrix,
const glm::mat4& currentBodyMatrix, const glm::mat4& currentBodyMatrix,
bool& shouldSnapOut) const { bool& shouldSnapOut) const {
shouldSnapOut = false;
// If hips are under direct control (tracked), they give our desired body rotation and we snap to it every frame. // If hips are under direct control (tracked), they give our desired body rotation and we snap to it every frame.
if (myAvatar.areHipsTracked()) { if (myAvatar.areHipsTracked()) {
shouldSnapOut = true; shouldSnapOut = true;
return true; return true;
} }
else {
shouldSnapOut = false;
}
const float FOLLOW_ROTATION_THRESHOLD = cosf(myAvatar.getRotationThreshold()); const float FOLLOW_ROTATION_THRESHOLD = cosf(myAvatar.getRotationThreshold());
glm::vec2 bodyFacing = getFacingDir2D(currentBodyMatrix); glm::vec2 bodyFacing = getFacingDir2D(currentBodyMatrix);
@ -5875,7 +5876,6 @@ glm::mat4 MyAvatar::FollowHelper::postPhysicsUpdate(MyAvatar& myAvatar, const gl
setTranslation(newBodyMat, extractTranslation(myAvatar.deriveBodyFromHMDSensor())); setTranslation(newBodyMat, extractTranslation(myAvatar.deriveBodyFromHMDSensor()));
} }
} }
return newBodyMat; return newBodyMat;
} else { } else {
return currentBodyMatrix; return currentBodyMatrix;

View file

@ -2716,7 +2716,7 @@ void Rig::computeAvatarBoundingCapsule(
// HACK by convention our Avatars are always modeled such that y=0 (GEOMETRY_GROUND_Y) is the ground plane. // HACK by convention our Avatars are always modeled such that y=0 (GEOMETRY_GROUND_Y) is the ground plane.
// add the ground point so that our avatars will always have bounding volumes that are flush with the ground // add the ground point so that our avatars will always have bounding volumes that are flush with the ground
// even if they do not have legs (default robot) // even if they do not have legs (default robot)
totalExtents.addPoint(glm::vec3(0.f, GEOMETRY_GROUND_Y, 0.f)); totalExtents.addPoint(glm::vec3(0.0f, GEOMETRY_GROUND_Y, 0.0f));
// To reduce the radius of the bounding capsule to be tight with the torso, we only consider joints // To reduce the radius of the bounding capsule to be tight with the torso, we only consider joints
// from the head to the hips when computing the rest of the bounding capsule. // from the head to the hips when computing the rest of the bounding capsule.

View file

@ -368,10 +368,8 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
btVector3 startPos = bodyTransform.getOrigin(); btVector3 startPos = bodyTransform.getOrigin();
btVector3 deltaPos = _followDesiredBodyTransform.getOrigin() - startPos; btVector3 deltaPos = _followDesiredBodyTransform.getOrigin() - startPos;
btVector3 linearDisplacement(0, 0, 0); btVector3 linearDisplacement(0.0f, 0.0f, 0.0f);
{ {
linearDisplacement.setZero();
const float horizontalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Horizontal)]; const float horizontalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Horizontal)];
const float verticalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Vertical)]; const float verticalTime = _followTimeRemainingPerType[static_cast<uint>(FollowType::Vertical)];
@ -452,7 +450,6 @@ void CharacterController::playerStep(btCollisionWorld* collisionWorld, btScalar
} }
_rigidBody->setWorldTransform(btTransform(endRot, endPos)); _rigidBody->setWorldTransform(btTransform(endRot, endPos));
} }
_followTime += dt; _followTime += dt;
if (_steppingUp) { if (_steppingUp) {