Skip to content

Commit

Permalink
Compiles with taichi_mpm and clang++-7
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanming-hu committed Mar 18, 2019
1 parent 304829b commit 8b67ecf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 13 additions & 13 deletions include/taichi/dynamics/rigid_body.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ struct RigidBody {
TC_STATIC_ELSE {
// "Rotate" the inertia_tensor
Matrix rotation_matrix = rotation.get_rotation_matrix();
id(ret) = rotation_matrix * inertia * transposed(rotation_matrix);
ret = rotation_matrix * inertia * transposed(rotation_matrix);
};
TC_STATIC_END_IF
return ret;
Expand All @@ -137,8 +137,8 @@ struct RigidBody {
TC_STATIC_ELSE {
// "Rotate" the inertia_tensor
Matrix rotation_matrix = rotation.get_rotation_matrix();
ret = id(rotation_matrix) * id(this->get_inv_inertia()) *
id(transposed(rotation_matrix));
ret = rotation_matrix * this->get_inv_inertia() *
transposed(rotation_matrix);
};
TC_STATIC_END_IF
return ret;
Expand Down Expand Up @@ -180,7 +180,7 @@ struct RigidBody {
if (rot_func) {
TC_STATIC_IF(dim == 3) {
auto rot_quat = [&](real t) {
Vector r = id(radians(this->rot_func(t)));
Vector r = radians(this->rot_func(t));
Eigen::AngleAxis<real> angleAxisX(r[0],
Eigen::Matrix<real, 3, 1>::UnitX());
Eigen::AngleAxis<real> angleAxisY(r[1],
Expand All @@ -201,10 +201,10 @@ struct RigidBody {
"Rotation not differentiable at time {}. (Magnitude {} at d = "
"{})",
t, len_rot, d);
angular_velocity.value = id(Vector(0));
angular_velocity.value = Vector(0);
} else {
for (int i = 0; i < dim; i++) {
id(angular_velocity).value[i] =
angular_velocity.value[i] =
angle_axis.angle() * angle_axis.axis()(i);
}
}
Expand All @@ -220,9 +220,9 @@ struct RigidBody {
"Rotation not differentiable at time {}. (Magnitude {} at d = "
"{})",
t, len_rot, d);
id(angular_velocity.value) = 0;
angular_velocity.value = 0;
} else {
angular_velocity.value = id(rot);
angular_velocity.value = rot;
}
}
TC_STATIC_END_IF
Expand Down Expand Up @@ -286,7 +286,7 @@ struct RigidBody {
direction = normalized(direction);
TC_STATIC_IF(dim == 3) {
angular_velocity.value =
dot(id(angular_velocity.value), id(direction)) * direction;
dot(angular_velocity.value, direction) * direction;
}
TC_STATIC_END_IF
}
Expand All @@ -296,12 +296,12 @@ struct RigidBody {
real ret;
TC_STATIC_IF(dim == 2) {
ret =
this->get_inv_mass() + length2(cross(id(r), id(n))) * this->get_inv_inertia();
this->get_inv_mass() + length2(cross(r, n)) * this->get_inv_inertia();
}
TC_STATIC_ELSE {
ret = inv_mass;
InertiaType inversed_inertia = this->get_transformed_inversed_inertia();
auto rn = cross_product_matrix(id(r));
auto rn = cross_product_matrix(r);
inversed_inertia = transposed(rn) * inversed_inertia * rn;
ret += dot(n, inversed_inertia * n);
}
Expand Down Expand Up @@ -350,10 +350,10 @@ struct RigidBody {
#ifdef _WIN64
#ifdef _MSVC_LANG
this->inv_inertia =
inversed(id(inertia).cast<float64>()).cast<real>();
inversed(inertia.cast<float64>()).cast<real>();
#else
this->inv_inertia =
inversed(id(inertia).template cast<float64>()).template cast<real>();
inversed(inertia.template cast<float64>()).template cast<real>();
#endif
#else
this->inv_inertia =
Expand Down
6 changes: 3 additions & 3 deletions include/taichi/math/angular.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class AngularVelocity {
ret = Vector(-input.y, input.x) * value;
}
TC_STATIC_ELSE {
ret = taichi::cross(id(value), id(input));
ret = taichi::cross(value, input);
}
TC_STATIC_END_IF;
return ret;
Expand Down Expand Up @@ -124,10 +124,10 @@ class Rotation {

void apply_angular_velocity(const AngVel &vel, real dt) {
TC_STATIC_IF(dim == 2) {
value += id(dt * vel.value);
value += dt * vel.value;
}
TC_STATIC_ELSE {
Vector3 axis(id(vel).value[0], id(vel).value[1], id(vel).value[2]);
Vector3 axis(vel.value[0], vel.value[1], vel.value[2]);
real angle = length(axis);
if (angle < 1e-10_f) {
return;
Expand Down

0 comments on commit 8b67ecf

Please sign in to comment.