Skip to content

Commit

Permalink
Fix particle emitter image path
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Aug 30, 2024
1 parent a20bf25 commit 2448a79
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 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,26 @@ 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 istead of msgs::ParticleEmitter
std::string imagePath = _emitter->ColorRangeImage();
if (!imagePath.empty())
{
imagePath = common::findFile(asFullPath(imagePath,
_emitter->Element()->FilePath()));
particleEmitterMsg.mutable_color_range_image()->set_data(imagePath);
}

// 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 2448a79

Please sign in to comment.