Skip to content

Commit 577efcc

Browse files
committed
Merge branch 'master' of https://github.com/sofa-framework/sofa
2 parents 61a20f0 + 4853dd7 commit 577efcc

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

Sofa/Component/Visual/src/sofa/component/visual/TrailRenderer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,15 @@ void registerTrailRenderer(sofa::core::ObjectFactory* factory)
3030
{
3131
factory->registerObjects(core::ObjectRegistrationData("Render a trail behind particles.")
3232
.add<TrailRenderer<defaulttype::Vec3Types>>()
33+
.add<TrailRenderer<defaulttype::Vec2Types>>()
34+
.add<TrailRenderer<defaulttype::Vec1Types>>()
3335
.add<TrailRenderer<defaulttype::Rigid3Types>>()
3436
);
3537
}
3638

3739
template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec3Types>;
40+
template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec2Types>;
41+
template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec1Types>;
3842
template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Rigid3Types>;
3943

4044
}

Sofa/Component/Visual/src/sofa/component/visual/TrailRenderer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ class TrailRenderer : public core::visual::VisualModel
6464

6565
#if !defined(SOFA_COMPONENT_VISUAL_TRAILRENDERER_CPP)
6666
extern template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec3Types>;
67+
extern template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec2Types>;
68+
extern template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Vec1Types>;
6769
extern template class SOFA_COMPONENT_VISUAL_API TrailRenderer<defaulttype::Rigid3Types>;
6870
#endif
6971

Sofa/Component/Visual/src/sofa/component/visual/TrailRenderer.inl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ void TrailRenderer<DataTypes>::storeParticlePositions()
7272
sofa::Size i {};
7373
for (const auto& pos : position)
7474
{
75-
m_trail[i++].push_back(DataTypes::getCPos(pos));
75+
sofa::type::Vec3 pvec3;
76+
DataTypes::get(pvec3[0], pvec3[1], pvec3[2], pos);
77+
m_trail[i++].push_back(pvec3);
7678
}
7779

7880
removeFirstElements();

Sofa/Component/Visual/src/sofa/component/visual/VisualPointCloud.inl

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,30 @@ void VisualPointCloud<DataTypes>::computeBBox(const core::ExecParams* exec_param
6363

6464
type::Vec3 pvec3;
6565
type::BoundingBox bbox;
66-
for (const auto& p : position)
66+
67+
const auto drawMode = d_drawMode.getValue();
68+
69+
if (drawMode == DrawMode("Sphere"))
70+
{
71+
const auto sphereRadius = sofa::helper::getWriteAccessor(d_sphereRadius);
72+
73+
for (std::size_t i = 0; i < std::min(sphereRadius.size(), positionSize); ++i)
74+
{
75+
DataTypes::get(pvec3[0], pvec3[1], pvec3[2], position[i]);
76+
77+
const auto sphereRadius_i = sphereRadius[i];
78+
const auto sphereRadiusVec3 = sofa::type::Vec3(sphereRadius_i, sphereRadius_i, sphereRadius_i);
79+
bbox.include(pvec3 + sphereRadiusVec3);
80+
bbox.include(pvec3 - sphereRadiusVec3);
81+
}
82+
}
83+
else
6784
{
68-
DataTypes::get(pvec3[0], pvec3[1], pvec3[2], p);
69-
bbox.include(pvec3);
85+
for (const auto& p : position)
86+
{
87+
DataTypes::get(pvec3[0], pvec3[1], pvec3[2], p);
88+
bbox.include(pvec3);
89+
}
7090
}
7191

7292
this->f_bbox.setValue(bbox);

0 commit comments

Comments
 (0)