お世話になっております。
サブステップ間にVehicleと衝突した対象のPhysicalMaterialを取得する方法について、
void FChaosVehicleManagerAsyncCallback::OnContactModification_Internal(Chaos::FCollisionContactModifier& Modifier) { const FChaosVehicleManagerAsyncInput* Input = GetConsumerInput_Internal(); const TArray<TUniquePtr<FChaosVehicleAsyncInput>>& InputVehiclesBatch = Input->VehicleInputs; //なんらかの方法で操作対象を取得する for( auto& Vehicle : InputVehiclesBatch) { Chaos::FSingleParticlePhysicsProxy* PhysicsProxy = Vehicle->Proxy; Chaos::FGeometryParticleHandle* Handle = reinterpret_cast<Chaos::FGeometryParticleHandle*>(PhysicsProxy->GetHandle_LowLevel()); Chaos::FContactPairModifierParticleRange Range = Modifier.GetContacts(Handle); //対象のParticleProxyに関連したコンタクトペアリストを取得 for (Chaos::FContactPairModifier PairModifier : Range ) { int32 OtherIndex = PairModifier.GetParticlePair()[0] != Handle ? 0 : 1; if(Chaos::FGeometryParticleHandle* OtherHandle = PairModifier.GetParticlePair()[OtherIndex]) { if(IPhysicsProxyBase* Proxy = OtherHandle->PhysicsProxy()) { if(const Chaos::FPhysicsSolver* PhysicsSolver = Proxy->GetSolver<Chaos::FPhysicsSolver>()) { if(const FPhysScene* PhysScene = static_cast<FPhysScene*>(PhysicsSolver->PhysSceneHack)) { if(UPrimitiveComponent* ContactComp = PhysScene->GetOwningComponent<UPrimitiveComponent>(Proxy)) { if(FBodyInstance* BodyInstance = ContactComp->GetBodyInstance()) { //衝突対象のPhysicalMaterialを取得 UPhysicalMaterial* PhysicalMaterial = BodyInstance->GetSimplePhysicalMaterial(); } } } } } } } } }
<br/>
こちらの方法で対応できることを確認しております。
ただ、下記URLにある通り、UObjectへのアクセスは安全ではないという記載があるため、
別途対応方法について検討しているのですが、何か別の方法でPhysicalMaterialを取得する方法はありますでしょうか?
[Content removed]
<br/>