code review feedback

This commit is contained in:
Anthony J. Thibault 2017-05-11 10:54:15 -07:00
parent 147d067c4e
commit a14fa5dab9
4 changed files with 13 additions and 14 deletions

View file

@ -734,21 +734,21 @@ void AnimInverseKinematics::initConstraints() {
std::vector<glm::vec3> swungDirections; std::vector<glm::vec3> swungDirections;
float deltaTheta = PI / 4.0f; float deltaTheta = PI / 4.0f;
float theta = 0.0f; float theta = 0.0f;
swungDirections.push_back(glm::vec3(cosf(theta), -0.25f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), -0.25f, sinf(theta)));
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), 0.0f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), 0.0f, sinf(theta)));
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), 0.25f, sinf(theta))); // posterior swungDirections.push_back(glm::vec3(mirror * cosf(theta), 0.25f, sinf(theta))); // posterior
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), 0.0f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), 0.0f, sinf(theta)));
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), -0.25f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), -0.25f, sinf(theta)));
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), -0.5f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), -0.5f, sinf(theta)));
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), -0.5f, sinf(theta))); // anterior swungDirections.push_back(glm::vec3(mirror * cosf(theta), -0.5f, sinf(theta))); // anterior
theta += deltaTheta; theta += deltaTheta;
swungDirections.push_back(glm::vec3(cosf(theta), -0.5f, sinf(theta))); swungDirections.push_back(glm::vec3(mirror * cosf(theta), -0.5f, sinf(theta)));
std::vector<float> minDots; std::vector<float> minDots;
for (size_t i = 0; i < swungDirections.size(); i++) { for (size_t i = 0; i < swungDirections.size(); i++) {

View file

@ -37,16 +37,15 @@ glm::quat averageQuats(size_t numQuats, const glm::quat* quats) {
if (numQuats == 0) { if (numQuats == 0) {
return glm::quat(); return glm::quat();
} }
float alpha = 1.0f / (float)numQuats; glm::quat accum = quats[0];
glm::quat accum(0, 0, 0, 0);
glm::quat firstRot = quats[0]; glm::quat firstRot = quats[0];
for (size_t i = 0; i < numQuats; i++) { for (size_t i = 1; i < numQuats; i++) {
glm::quat rot = quats[i]; glm::quat rot = quats[i];
float dot = glm::dot(firstRot, rot); float dot = glm::dot(firstRot, rot);
if (dot < 0.0f) { if (dot < 0.0f) {
rot = -rot; rot = -rot;
} }
accum += alpha * rot; accum += rot;
} }
return glm::normalize(accum); return glm::normalize(accum);
} }

View file

@ -941,7 +941,7 @@ void Rig::updateAnimationStateHandlers() { // called on avatar update thread (wh
} }
} }
void Rig::updateAnimations(float deltaTime, glm::mat4 rootTransform, glm::mat4 rigToWorldTransform) { void Rig::updateAnimations(float deltaTime, const glm::mat4& rootTransform, const glm::mat4& rigToWorldTransform) {
PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0); PROFILE_RANGE_EX(simulation_animation_detail, __FUNCTION__, 0xffff00ff, 0);
PerformanceTimer perfTimer("updateAnimations"); PerformanceTimer perfTimer("updateAnimations");

View file

@ -162,7 +162,7 @@ public:
void computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState); void computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState);
// Regardless of who started the animations or how many, update the joints. // Regardless of who started the animations or how many, update the joints.
void updateAnimations(float deltaTime, glm::mat4 rootTransform, glm::mat4 rigToWorldTransform); void updateAnimations(float deltaTime, const glm::mat4& rootTransform, const glm::mat4& rigToWorldTransform);
// legacy // legacy
void inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::quat& targetRotation, float priority, void inverseKinematics(int endIndex, glm::vec3 targetPosition, const glm::quat& targetRotation, float priority,