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); } } } } } } }
public CPhyActor CreateActor(EPhyActorType type, ref PhyTransform pose) { CPhyActor.NativePointer ptr; unsafe { fixed(PhyTransform *p = &pose) { ptr = SDK_PhyContext_CreateActor(CoreObject, type, p); } } var ret = new CPhyActor(ptr, type); return(ret); }
public bool AddToActor(CPhyActor actor, ref PhyTransform transform) { if (actor == mActor) { return(true); } if (mActor != null) { mActor.Shapes.Remove(this); } mActor = actor; if (mActor != null) { //TODO.. Vector3 center = mActor.HostActor.GetAABBCenter(); Vector3 pos = mActor.HostActor.Placement.Location; CenterOffset = center - pos; mActor.Shapes.Add(this); } if (actor == null) { if (ShapeDesc != null) { ShapeDesc.onChangePlacement -= onChangePlacement; ShapeDesc.onChangeShapeSize -= onChangeShapeSize; } } unsafe { fixed(PhyTransform *p = &transform) { if (mActor != null) { return(SDK_PhyShape_AddToActor(CoreObject, actor.CoreObject, p)); } else { return(SDK_PhyShape_AddToActor(CoreObject, CPhyActor.GetEmptyNativePointer(), p)); } } } }