コード例 #1
0
ファイル: CPhyCallBacks.cs プロジェクト: huangdonghai/titan3d
 public virtual unsafe void OnTrigger(PhyTriggerPair *pairs, UInt32 count)
 {
     unsafe
     {
         CPhyEntity triggerEntity = null, otherEntity = null;
         for (int i = 0; i < count; ++i)
         {
             var pair        = pairs[i];
             var otherHandle = CPhyEntity.SDK_PhyEntity_GetCSharpHandle(pair.otherActor);
             if (otherHandle != IntPtr.Zero)
             {
                 var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(otherHandle);
                 otherEntity = weakRef.Target as CPhyEntity;
             }
             var triggerHandle = CPhyActor.SDK_PhyEntity_GetCSharpHandle(pair.triggerActor);
             if (triggerHandle != IntPtr.Zero)
             {
                 var weakRef = System.Runtime.InteropServices.GCHandle.FromIntPtr(triggerHandle);
                 triggerEntity = weakRef.Target as CPhyEntity;
             }
             if (otherEntity != null)
             {
                 //if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND)
                 //    triggerPhyActor.HostComponent?.OnTriggerIn();
             }
             if (triggerEntity != null && otherEntity != null)
             {
                 var triggerActor = triggerEntity as CPhyActor;
                 if (triggerActor != null)
                 {
                     if (otherEntity.EntityType == PhyEntityType.PET_Actor)
                     {
                         var otherActor = otherEntity as CPhyActor;
                         if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND)
                         {
                             triggerActor.HostComponent?.OnTriggerIn(otherActor);
                         }
                         if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_LOST) == PhyPairFlag.eNOTIFY_TOUCH_LOST)
                         {
                             triggerActor.HostComponent?.OnTriggerOut(otherActor);
                         }
                     }
                     if (otherEntity.EntityType == PhyEntityType.PET_Controller)
                     {
                         var otherController = otherEntity as CPhyController;
                         if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_FOUND) == PhyPairFlag.eNOTIFY_TOUCH_FOUND)
                         {
                             triggerActor.HostComponent?.OnTriggerIn(otherController);
                         }
                         if ((pair.status & PhyPairFlag.eNOTIFY_TOUCH_LOST) == PhyPairFlag.eNOTIFY_TOUCH_LOST)
                         {
                             triggerActor.HostComponent?.OnTriggerOut(otherController);
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: CPhyCallBacks.cs プロジェクト: huangdonghai/titan3d
        private static unsafe void _OnTrigger(IntPtr self, PhyTriggerPair *pairs, UInt32 count)
        {
            var handle = System.Runtime.InteropServices.GCHandle.FromIntPtr(self);
            var cb     = handle.Target as PhySimulationEventCallback;

            if (cb == null)
            {
                return;
            }
            cb.OnTrigger(pairs, count);
        }