Prevent visualization of SDF iterations from writing outside the maximum allocated vector. Fixes #1539.

PiperOrigin-RevId: 632071103
Change-Id: Idf91ede1661e717ad338f601a5482ab171d7f625
This commit is contained in:
Alessio Quaglino
2024-05-09 01:41:25 -07:00
committed by Copybara-Service
parent d6bc8c7781
commit 1d181786a2
2 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ SdfVisualizer::SdfVisualizer() {
}
void SdfVisualizer::AddPoint(const mjtNum point[3]) {
if (!npoints_.empty()) {
if (!npoints_.empty() && npoints_.back() < points_.size()/3) {
points_[3*npoints_.back()+0] = point[0];
points_[3*npoints_.back()+1] = point[1];
points_[3*npoints_.back()+2] = point[2];