PositionBasedDynamics
PositionBasedDynamics copied to clipboard
a bug in function bool PBD::DirectPositionBasedSolverForStiffRods::solve(...) in PositionBasedElasticRods.cpp
I think the constraints do not work in the right way when there are more than one static segment because in the
bool PBD::DirectPositionBasedSolverForStiffRods::solve(int , std::list <Node*> * , std::list <Node*> * , std::vector<Vector6r> & , std::vector<Vector6r> & , std::vector<Vector3r> & , std::vector<Quaternionr> & )
of PositionBasedElasticRods.cpp
// compute position and orientation updates
for (nodeIter = forward[intervalIndex].begin(); nodeIter != forward[intervalIndex].end(); nodeIter++)
{
Node *node = *nodeIter;
if (!node->isconstraint)
{
RodSegment *segment = (RodSegment *)node->object;
if (!segment->isDynamic())
{
break;
}
const Vector6r & soln(node->soln);
Vector3r deltaXSoln = Vector3r(-soln[0], -soln[1], -soln[2]);
corr_x[node->index] = deltaXSoln;
Eigen::Matrix<Real, 4, 3> G;
computeMatrixG(segment->Rotation(), G);
Quaternionr deltaQSoln;
deltaQSoln.coeffs() = G * Vector3r(-soln[3], -soln[4], -soln[5]);
corr_q[node->index] = deltaQSoln;
}
}
Here I guess when a segment is not dynamic, the loop needs continue instead of break. Therefore, when there is no non-dynamic segment, the update is fine. And when there is one non-dynamic-segment, the update is also okay because the non-dynamic segment is the root which is at the end of the forward vector. However, when there is more than one static segment, the segments between the first and the last segments will not satisfy under rods constraints(bending, twisting, etc.) anymore because they are not updated then.