From 94adc32d8ea57e084b1dcbef0ba54a0465de259c Mon Sep 17 00:00:00 2001 From: Steve Peters Date: Fri, 28 Oct 2022 11:51:04 -0700 Subject: [PATCH] Fix for opende heightfield and console spam (#3271) * opende heightfield: fix memory access bug Port fix from bitbucket: odedevs/ode@63caf226abf3be2225972955bec828f65887886f Original message: oleh_derevenko#1921: Fixed: A bug with heightfield data assigned to a wrong field in dGeomHeightfieldSetHeightfieldData (bug report #88 by Luc). * Visual::CreateDynamicLine check connection Only call ConnectPreRender if a Visual doesn't already have a ConnectionPtr, since reassigning it may generate console errors like: [Event.cc:61] Warning: Deleting a connection right after creation. Make sure to save the ConnectionPtr from a Connect call. In particular, the OriginVisual calls CreateDynamicLine three times in succession, which may be a source of these console messages. Signed-off-by: Steve Peters --- deps/opende/src/heightfield.cpp | 2 +- gazebo/rendering/Visual.cc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/deps/opende/src/heightfield.cpp b/deps/opende/src/heightfield.cpp index f18382bb3b..8048763fe0 100644 --- a/deps/opende/src/heightfield.cpp +++ b/deps/opende/src/heightfield.cpp @@ -880,7 +880,7 @@ dGeomID dCreateHeightfield( dSpaceID space, dHeightfieldDataID data, int bPlacea void dGeomHeightfieldSetHeightfieldData( dGeomID g, dHeightfieldDataID d ) { dxHeightfield* geom = (dxHeightfield*) g; - geom->data = d; + geom->m_p_data = d; } diff --git a/gazebo/rendering/Visual.cc b/gazebo/rendering/Visual.cc index ee8512becd..e35f00a1c2 100644 --- a/gazebo/rendering/Visual.cc +++ b/gazebo/rendering/Visual.cc @@ -2180,8 +2180,11 @@ void Visual::SetRibbonTrail(bool _value, ////////////////////////////////////////////////// DynamicLines *Visual::CreateDynamicLine(RenderOpType _type) { - this->dataPtr->preRenderConnection = event::Events::ConnectPreRender( - boost::bind(&Visual::Update, this)); + if (!this->dataPtr->preRenderConnection) + { + this->dataPtr->preRenderConnection = event::Events::ConnectPreRender( + boost::bind(&Visual::Update, this)); + } DynamicLines *line = new DynamicLines(_type); this->dataPtr->lines.push_back(line);