From cd43d05038adfd1be37ebe29fffad62fbec8a392 Mon Sep 17 00:00:00 2001 From: Jeongseok Lee Date: Tue, 7 Jan 2025 09:37:12 -0800 Subject: [PATCH] drjit::sqr -> drjit::square --- momentum/character_solver/simd_collision_error_function.cpp | 6 +++--- momentum/character_solver/simd_normal_error_function.cpp | 6 +++--- momentum/character_solver/simd_plane_error_function.cpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/momentum/character_solver/simd_collision_error_function.cpp b/momentum/character_solver/simd_collision_error_function.cpp index e33dba6d..921b0ab7 100644 --- a/momentum/character_solver/simd_collision_error_function.cpp +++ b/momentum/character_solver/simd_collision_error_function.cpp @@ -273,7 +273,7 @@ double SimdCollisionErrorFunctionT::getError( const Packet radius = (radius_i.x() * (1.0f - t_i) + radius_i.y() * t_i) + (radius_j.x() * (1.0f - t_j) + radius_j.y() * t_j); - drjit::masked(error, mask) += drjit::sqr(drjit::maximum(radius - distance, 0)); + drjit::masked(error, mask) += drjit::square(drjit::maximum(radius - distance, 0)); } } @@ -331,7 +331,7 @@ double SimdCollisionErrorFunctionT::getGradient( const Packet wgt = -2.0f * kCollisionWeight * this->weight_ * overlapFraction; drjit::masked(error, finalMask) += - kCollisionWeight * this->weight_ * drjit::sqr(radius - distance); + kCollisionWeight * this->weight_ * drjit::square(radius - distance); const size_t iJoint = collisionGeometry_[iCol].parent; for (uint32_t k = 0; k < kSimdPacketSize; ++k) { @@ -519,7 +519,7 @@ double SimdCollisionErrorFunctionT::getJacobian( } drjit::masked(error, finalMask) += - kCollisionWeight * this->weight_ * drjit::sqr(radius - distance); + kCollisionWeight * this->weight_ * drjit::square(radius - distance); // calculate collision resolve direction. this is what we need to push joint parent i in. // the direction for joint parent j is the inverse diff --git a/momentum/character_solver/simd_normal_error_function.cpp b/momentum/character_solver/simd_normal_error_function.cpp index aabc981d..5e6ebf50 100644 --- a/momentum/character_solver/simd_normal_error_function.cpp +++ b/momentum/character_solver/simd_normal_error_function.cpp @@ -154,7 +154,7 @@ double SimdNormalErrorFunction::getError( const FloatP dist = dot(pos_world - target, normal_world); const auto weight = drjit::load(&constraints_->weights[constraintOffsetIndex]); - error += weight * drjit::sqr(dist); + error += weight * drjit::square(dist); } } @@ -200,7 +200,7 @@ double SimdNormalErrorFunction::getGradient( const auto weight = drjit::load(&constraints_->weights[constraintOffsetIndex]); const FloatP wgt = weight * (2.0f * kPlaneWeight); - error += weight * drjit::sqr(dist); + error += weight * drjit::square(dist); // loop over all joints the constraint is attached to and calculate gradient size_t jointIndex = jointId; @@ -337,7 +337,7 @@ double SimdNormalErrorFunction::getJacobian( const auto weight = drjit::load(&constraints_->weights[constraintOffsetIndex]); const FloatP wgt = drjit::sqrt(weight * kPlaneWeight * this->weight_); - jointError += weight * drjit::sqr(dist); + jointError += weight * drjit::square(dist); drjit::store(residual.segment(jacobianOffsetCur, kSimdPacketSize).data(), dist * wgt); diff --git a/momentum/character_solver/simd_plane_error_function.cpp b/momentum/character_solver/simd_plane_error_function.cpp index 3c728ea7..e4fe77c0 100644 --- a/momentum/character_solver/simd_plane_error_function.cpp +++ b/momentum/character_solver/simd_plane_error_function.cpp @@ -146,7 +146,7 @@ double SimdPlaneErrorFunction::getError( // Calculate error as squared distance: err = constraintWeight * dist * dist const FloatP constraintWeight = drjit::load(&constraints_->weights[constraintOffsetIndex]); - error += constraintWeight * drjit::sqr(dist); + error += constraintWeight * drjit::square(dist); } } @@ -201,7 +201,7 @@ double SimdPlaneErrorFunction::getGradient( // Calculate error as squared distance: err = constraintWeight * dist * dist const FloatP constraintWeight = drjit::load(&constraints_->weights[constraintOffsetIndex]); - jointError += constraintWeight * drjit::sqr(dist); + jointError += constraintWeight * drjit::square(dist); // Pre-calculate values for the gradient: wgt = 2.0 * kPlaneWeight * constraintWeight * // dist @@ -353,7 +353,7 @@ double SimdPlaneErrorFunction::getJacobian( // Calculate error as squared distance: err = constraintWeight * dist * dist const FloatP constraintWeight = drjit::load(&constraints_->weights[constraintOffsetIndex]); - jointError += constraintWeight * drjit::sqr(dist); + jointError += constraintWeight * drjit::square(dist); // Calculate square-root of weight: wgt = sqrt(kPlaneWeight * weight * constraintWeight) const FloatP wgt = drjit::sqrt(kPlaneWeight * weight_ * constraintWeight);