Skip to content

Commit

Permalink
Merge from ign-gazebo6
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Jun 17, 2024
2 parents 49ab5c6 + 45239e9 commit d9bc3bd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,14 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Link *_link)
linkEntity, components::WindMode(_link->EnableWind()));
}

if (!_link->EnableGravity())
{
// If disable gravity, create a gravity component to the entity
// This gravity will have value 0,0,0
this->dataPtr->ecm->CreateComponent(
linkEntity, components::Gravity());
}

// Visuals
for (uint64_t visualIndex = 0; visualIndex < _link->VisualCount();
++visualIndex)
Expand Down
18 changes: 18 additions & 0 deletions src/systems/physics/Physics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,24 @@ void PhysicsPrivate::CreateLinkEntities(const EntityComponentManager &_ecm,
link.SetInertial(inertial->Data());
}

// get link gravity
const components::Gravity *gravity =
_ecm.Component<components::Gravity>(_entity);
if (nullptr != gravity)
{
// Entity has a gravity component that is all zeros when
// <gravity> is set to false
// See SdfEntityCreator::CreateEntities()
if (gravity->Data() == math::Vector3d::Zero)
{
link.SetEnableGravity(false);
}
else
{
link.SetEnableGravity(true);
}
}

auto constructLinkFeature =
this->entityModelMap.EntityCast<ConstructSdfLinkFeatureList>(
_parent->Data());
Expand Down

0 comments on commit d9bc3bd

Please sign in to comment.