Skip to content

Commit

Permalink
Merge pull request #2447 from gazebosim/merge_6_7_20240617
Browse files Browse the repository at this point in the history
Merge 6 -> 7
  • Loading branch information
iche033 authored Jun 26, 2024
2 parents 49ab5c6 + dc83c33 commit e71c719
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/gz/sim/components/Gravity.hh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ namespace components
/// \brief Store the gravity acceleration.
using Gravity = Component<math::Vector3d, class GravityTag>;
GZ_SIM_REGISTER_COMPONENT("gz_sim_components.Gravity", Gravity)

/// \brief Store the gravity acceleration.
using GravityEnabled = Component<bool, class GravityEnabledTag>;
GZ_SIM_REGISTER_COMPONENT(
"gz_sim_components.GravityEnabled", GravityEnabled)
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/SdfEntityCreator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ Entity SdfEntityCreator::CreateEntities(const sdf::Link *_link)
linkEntity, components::WindMode(_link->EnableWind()));
}

if (!_link->EnableGravity())
{
// If disable gravity, create a GravityEnabled component to the entity
this->dataPtr->ecm->CreateComponent(
linkEntity, components::GravityEnabled(false));
}

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

// get link gravity
const components::GravityEnabled *gravityEnabled =
_ecm.Component<components::GravityEnabled>(_entity);
if (nullptr != gravityEnabled)
{
// gravityEnabled set in SdfEntityCreator::CreateEntities()
link.SetEnableGravity(gravityEnabled->Data());
}

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

0 comments on commit e71c719

Please sign in to comment.