Skip to content

Commit

Permalink
fix setting emitter properties
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <ichen@osrfoundation.org>
  • Loading branch information
iche033 committed Feb 17, 2021
1 parent 471f0d1 commit f8a971d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 2 additions & 7 deletions src/rendering/RenderUtil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,16 +320,11 @@ void RenderUtil::UpdateECM(const UpdateInfo &/*_info*/,
if (poseComp)
poseComp->Data() = msgs::Convert(_emitterCmd->Data().pose());
}
_ecm.RemoveComponent<components::ParticleEmitterCmd>(_entity);

return true;
});

for (auto &emitterCmd : this->dataPtr->newParticleEmittersCmds)
{
if (!_ecm.RemoveComponent<components::ParticleEmitterCmd>(
std::get<0>(emitterCmd)))
ignwarn << "Unable to remove ParticleEmitterCmd component" << std::endl;
}

// Update thermal cameras
_ecm.Each<components::ThermalCamera>(
[&](const Entity &_entity,
Expand Down
11 changes: 6 additions & 5 deletions src/rendering/SceneManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,8 +1087,13 @@ rendering::ParticleEmitterPtr SceneManager::UpdateParticleEmitter(Entity _id,
// Velocity range.
emitter->SetVelocityRange(_emitter.min_velocity(), _emitter.max_velocity());

// Color range image.
if (!_emitter.color_range_image().empty())
{
emitter->SetColorRangeImage(_emitter.color_range_image());
}
// Color range.
if (_emitter.has_color_start() && _emitter.has_color_end())
else if (_emitter.has_color_start() && _emitter.has_color_end())
{
emitter->SetColorRange(
ignition::msgs::Convert(_emitter.color_start()),
Expand All @@ -1098,10 +1103,6 @@ rendering::ParticleEmitterPtr SceneManager::UpdateParticleEmitter(Entity _id,
// Scale rate.
emitter->SetScaleRate(_emitter.scale_rate());

// Color range image.
if (!_emitter.color_range_image().empty())
emitter->SetColorRangeImage(_emitter.color_range_image());

// pose
if (_emitter.has_pose())
emitter->SetLocalPose(msgs::Convert(_emitter.pose()));
Expand Down
4 changes: 4 additions & 0 deletions src/systems/particle_emitter/ParticleEmitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ void ParticleEmitter::PreUpdate(const ignition::gazebo::UpdateInfo &_info,
else
{
emitterComp->Data() = this->dataPtr->userCmd;

_ecm.SetChanged(this->dataPtr->emitterEntity,
components::ParticleEmitterCmd::typeId,
ComponentState::OneTimeChange);
}

igndbg << "New ParticleEmitterCmd component created" << std::endl;
Expand Down

0 comments on commit f8a971d

Please sign in to comment.