Skip to content

Commit

Permalink
[SofaConstraint] Fix BilateralInteractionConstraint's draw() (#2530)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredroy authored Dec 9, 2021
1 parent ba9b76b commit 2405dd2
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -522,10 +522,15 @@ void BilateralInteractionConstraint<DataTypes>::draw(const core::visual::VisualP
std::vector< sofa::type::Vector3 > vertices;

unsigned minp = std::min(m1.getValue().size(),m2.getValue().size());
auto positionsM1 = sofa::helper::getReadAccessor(*this->mstate1->read(ConstVecCoordId::position()));
auto positionsM2 = sofa::helper::getReadAccessor(*this->mstate2->read(ConstVecCoordId::position()));
auto indicesM1 = sofa::helper::getReadAccessor(m1);
auto indicesM2 = sofa::helper::getReadAccessor(m2);

for (unsigned i=0; i<minp; i++)
{
vertices.push_back(DataTypes::getCPos(this->mstate1->read(ConstVecCoordId::position())->getValue()[m1.getValue()[i]]));
vertices.push_back(DataTypes::getCPos(this->mstate2->read(ConstVecCoordId::position())->getValue()[m1.getValue()[i]]));
vertices.push_back(DataTypes::getCPos(positionsM1[indicesM1[i]]));
vertices.push_back(DataTypes::getCPos(positionsM2[indicesM2[i]]));
}

vparams->drawTool()->drawPoints(vertices, 10, (activated) ? colorActive : colorNotActive);
Expand Down

0 comments on commit 2405dd2

Please sign in to comment.