Skip to content

Commit

Permalink
drjit::sqr -> drjit::square
Browse files Browse the repository at this point in the history
  • Loading branch information
jeongseok-meta committed Jan 7, 2025
1 parent 87ee4b0 commit cd43d05
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions momentum/character_solver/simd_collision_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ double SimdCollisionErrorFunctionT<T>::getError(
const Packet<T> 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));
}
}

Expand Down Expand Up @@ -331,7 +331,7 @@ double SimdCollisionErrorFunctionT<T>::getGradient(
const Packet<T> 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) {
Expand Down Expand Up @@ -519,7 +519,7 @@ double SimdCollisionErrorFunctionT<T>::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
Expand Down
6 changes: 3 additions & 3 deletions momentum/character_solver/simd_normal_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ double SimdNormalErrorFunction::getError(
const FloatP dist = dot(pos_world - target, normal_world);

const auto weight = drjit::load<FloatP>(&constraints_->weights[constraintOffsetIndex]);
error += weight * drjit::sqr(dist);
error += weight * drjit::square(dist);
}
}

Expand Down Expand Up @@ -200,7 +200,7 @@ double SimdNormalErrorFunction::getGradient(
const auto weight = drjit::load<FloatP>(&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;
Expand Down Expand Up @@ -337,7 +337,7 @@ double SimdNormalErrorFunction::getJacobian(
const auto weight = drjit::load<FloatP>(&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);

Expand Down
6 changes: 3 additions & 3 deletions momentum/character_solver/simd_plane_error_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ double SimdPlaneErrorFunction::getError(
// Calculate error as squared distance: err = constraintWeight * dist * dist
const FloatP constraintWeight =
drjit::load<FloatP>(&constraints_->weights[constraintOffsetIndex]);
error += constraintWeight * drjit::sqr(dist);
error += constraintWeight * drjit::square(dist);
}
}

Expand Down Expand Up @@ -201,7 +201,7 @@ double SimdPlaneErrorFunction::getGradient(
// Calculate error as squared distance: err = constraintWeight * dist * dist
const FloatP constraintWeight =
drjit::load<FloatP>(&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
Expand Down Expand Up @@ -353,7 +353,7 @@ double SimdPlaneErrorFunction::getJacobian(
// Calculate error as squared distance: err = constraintWeight * dist * dist
const FloatP constraintWeight =
drjit::load<FloatP>(&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);
Expand Down

0 comments on commit cd43d05

Please sign in to comment.