Skip to content

Commit 527dad7

Browse files
committed
correct previous commit
1 parent 226f4b6 commit 527dad7

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/SofaShells/forcefield/TriangularShellForceField.inl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,8 @@ void TriangularShellForceField<DataTypes>::draw(const core::visual::VisualParams
12811281
// Draw arrows from using shell triangle info (tinfo.R) in the center of the triangle
12821282

12831283
int nbTriangles=_topology->getNbTriangles();
1284+
auto triangles = _topology->getTriangles();
1285+
const VecCoord& positions =this->mstate->read(sofa::core::ConstVecCoordId::position())->getValue();
12841286
type::vector<TriangleInformation>& triangleInf = *(triangleInfo.beginEdit());
12851287
const Real radius = d_arrow_radius.getValue();
12861288
for (unsigned int i=0; i< nbTriangles; i++)
@@ -1290,9 +1292,14 @@ void TriangularShellForceField<DataTypes>::draw(const core::visual::VisualParams
12901292
Vec3 vy = tinfo.R * Vec3(0, 1, 0);
12911293
Vec3 vz = tinfo.R * Vec3(0, 0, 1);
12921294

1295+
auto triangle = _topology->getTriangle(i);
1296+
// get triangle i indices
1297+
auto a = triangle[0];
1298+
auto b = triangle[1];
1299+
auto c = triangle[2];
1300+
12931301
// compute the center of the triangle
1294-
Vec3 center = (tinfo.deformedPositions[0] + tinfo.deformedPositions[1] +
1295-
tinfo.deformedPositions[2])/3;
1302+
Vec3 center = (positions[a].getCenter() + positions[b].getCenter() + positions[c].getCenter())/3;
12961303
vparams->drawTool()->drawArrow(center, center + vx, radius, type::RGBAColor(1.0, 0.0, 0.0, 1.0));
12971304
vparams->drawTool()->drawArrow(center, center + vy, radius, type::RGBAColor(0.0, 1.0, 0.0, 1.0));
12981305
vparams->drawTool()->drawArrow(center, center + vz, radius, type::RGBAColor(0.0, 0.0, 1.0, 1.0));

0 commit comments

Comments
 (0)