public virtual unsafe void OnContact(PhyContactPairHeader *pairHeader, PhyContactPair *pairs, UInt32 nbPairs) { unsafe { CPhyEntity entity1 = null, entity2 = null; var pair = (*pairHeader); var entity1Handle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.actors0); if (entity1Handle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(entity1Handle); entity1 = weakRef.Target as CPhyEntity; } var entity2Handle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.actors0); if (entity2Handle != IntPtr.Zero) { var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(entity2Handle); entity2 = weakRef.Target as CPhyEntity; } if (entity1.EntityType == PhyEntityType.PET_Actor) { } if (entity1.EntityType == PhyEntityType.PET_Controller) { } if (entity2.EntityType == PhyEntityType.PET_Controller) { } } }
private static unsafe void _OnContact(IntPtr self, PhyContactPairHeader *pairHeader, PhyContactPair *pairs, UInt32 nbPairs) { var handle = System.Runtime.InteropServices.GCHandle.FromIntPtr(self); var cb = handle.Target as PhySimulationEventCallback; if (cb == null) { return; } cb.OnContact(pairHeader, pairs, nbPairs); }