Geometry collection particle’s world location?

I’ve built a custom Geometry Collection that needs to get the absolute world location of each of the particles. But so far, I’ve only got the relative translation of the particle. So in the following code, before the geometry collection has broken apart from the original rest collection, all the particle translations are [0, 0, 0]:

void ACustomGCActor::Tick(float DeltaSeconds)
{
    Super::Tick(DeltaSeconds);

    for (int32 i = 0; i < GeometryCollectionComponent->GetDynamicCollection()->GetNumTransforms(); ++i)
    {
        // This is the translation relative to the original resting location 
        UE::Math::TVector<float> T = GeometryCollectionComponent->GetDynamicCollection()->GetTransform(i).GetTranslation();
    }
}

I think I am on the right track with Particle->GetP() or Particle->GetX(). Also I’ve noticed that the particle at index 0 has some special behavior.

The answer is basically Particle->GetX() after getting a particle from the geometry collection physics proxy, but a major gotcha is that particles only update their location when they break off.

This code comment from GeometryCollectionEngine -> GeometryCollectionComponent.cpp:2135 sheds some light on this:

Clusters always fracture with one off pieces being removed.
This means we only need to record the one offs that broke and we get the connected components for free.
If the first child is disabled it means the properties apply to the parent (i.e. the cluster).
If the first child is enabled it means it’s a one off and the cluster IS the first child

Ergo, we must check if each particle is disabled, and if it is, use its parent location.

void ACustomGCActor::Tick(float DeltaTime)
{
  Super::Tick(DeltaTime);

  const FGeometryCollectionPhysicsProxy* PhysicsProxy = GeometryCollectionComponent->GetPhysicsProxy();
  for (int32 i = FirstRealParticleIndex; i < GeometryCollectionComponent->GetDynamicCollection()->GetNumTransforms(); ++i)
  {
    if (Chaos::FPBDRigidClusteredParticleHandle* Particle = PhysicsProxy->GetParticle_Internal(i))
    {
      const Chaos::TVector<double, 3> Location =
        Particle->Disabled()
        ? GeometryCollectionComponent->GetPhysicsProxy()->GetParticleByIndex_External(
          GeometryCollectionComponent->GetParentArrayRest()[i + FirstRealParticleIndex])->GetX()
        : Particle->GetX();
    }
  }
}

See also: how to compute FirstRealParticleIndex how to tell real particles from clusters (and ignore the cluster union particles)

Don’t forget to add "GeometryCollectionEngine" to the dependency module names in the <Project>.Build.cs file.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật