Skip to content

Commit

Permalink
Fix particle emitter color range image path warning (#2560)
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
iche033 and ahcorde authored Sep 4, 2024
1 parent fec31aa commit 8b74a43
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "gz/sim/Events.hh"
#include "gz/sim/SdfEntityCreator.hh"
#include "gz/sim/Util.hh"

#include "gz/sim/components/Actor.hh"
#include "gz/sim/components/AirPressureSensor.hh"
Expand Down Expand Up @@ -67,7 +68,7 @@
#include "gz/sim/components/NavSat.hh"
#include "gz/sim/components/ParentEntity.hh"
#include "gz/sim/components/ParentLinkName.hh"
#include <gz/sim/components/ParticleEmitter.hh>
#include "gz/sim/components/ParticleEmitter.hh"
#include "gz/sim/components/Performer.hh"
#include "gz/sim/components/Physics.hh"
#include "gz/sim/components/PhysicsEnginePlugin.hh"
Expand Down Expand Up @@ -1004,9 +1005,27 @@ Entity SdfEntityCreator::CreateEntities(const sdf::ParticleEmitter *_emitter)
// Entity
Entity emitterEntity = this->dataPtr->ecm->CreateEntity();

auto particleEmitterMsg = convert<msgs::ParticleEmitter>(*_emitter);

// Update image path
// Ideally this is done by gz/sim/src/SceneManager.cc when creating
// the particle emitter. However the component stores a msg instead of
// an sdf so the sdf FilePath information is lost and rendering is not
// able to construct the full path of the image.
// \todo(iche033) Consider changing the ParticleEmitter component to
// store an sdf::ParticleEmitter object instead of msgs::ParticleEmitter.
std::string imagePath = _emitter->ColorRangeImage();
if (!imagePath.empty())
{
std::string path = common::findFile(asFullPath(imagePath,
_emitter->Element()->FilePath()));
path = path.empty() ? imagePath : path;
particleEmitterMsg.mutable_color_range_image()->set_data(path);
}

// Components
this->dataPtr->ecm->CreateComponent(emitterEntity,
components::ParticleEmitter(convert<msgs::ParticleEmitter>(*_emitter)));
components::ParticleEmitter(particleEmitterMsg));
this->dataPtr->ecm->CreateComponent(emitterEntity,
components::Pose(ResolveSdfPose(_emitter->SemanticPose())));
this->dataPtr->ecm->CreateComponent(emitterEntity,
Expand Down

0 comments on commit 8b74a43

Please sign in to comment.