diff --git a/gazebo/physics/Model.cc b/gazebo/physics/Model.cc index a561344d02..a8a30c24fb 100644 --- a/gazebo/physics/Model.cc +++ b/gazebo/physics/Model.cc @@ -1390,17 +1390,17 @@ void Model::SetState(const ModelState &_state) void Model::SetScale(const ignition::math::Vector3d &_scale, const bool _publish) { - if (this->scale == _scale) - return; - - this->scale = _scale; - - Base_V::iterator iter; - for (iter = this->children.begin(); iter != this->children.end(); ++iter) + if (this->scale != _scale) { - if (*iter && (*iter)->HasType(LINK)) + this->scale = _scale; + + Base_V::iterator iter; + for (iter = this->children.begin(); iter != this->children.end(); ++iter) { - boost::static_pointer_cast(*iter)->SetScale(_scale); + if (*iter && (*iter)->HasType(LINK)) + { + boost::static_pointer_cast(*iter)->SetScale(_scale); + } } } diff --git a/test/integration/model.cc b/test/integration/model.cc index 0d51370f62..331b1b4d55 100644 --- a/test/integration/model.cc +++ b/test/integration/model.cc @@ -152,6 +152,23 @@ TEST_F(ModelTest, SetScale) receivedVisualMsg.geometry().sphere().radius()); g_modelMsgs.clear(); + + // Call SetScale again with same value and expect another message + model->SetScale(scale, true); + + // publish msg + sleep = 0; + receivedMsgs = false; + while (!receivedMsgs && sleep++ < 100) + { + world->Step(1); + common::Time::MSleep(100); + { + std::lock_guard lock(g_mutex); + receivedMsgs = !g_modelMsgs.empty(); + } + } + EXPECT_FALSE(g_modelMsgs.empty()); }