Example #1
0
        internal static PhysicalEntity TryGet(IntPtr IPhysicalEntityHandle)
        {
#if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (IPhysicalEntityHandle == IntPtr.Zero)
            {
                throw new NullPointerException();
            }
#endif

            var physicalEntity = physicalEntities.FirstOrDefault(x => x.Handle == IPhysicalEntityHandle);
            if (physicalEntity == null)
            {
                switch (PhysicsInterop.GetPhysicalEntityType(IPhysicalEntityHandle))
                {
                case PhysicalizationType.Static:
                case PhysicalizationType.Rigid:
                case PhysicalizationType.WheeledVehicle:
                case PhysicalizationType.Articulated:
                case PhysicalizationType.Soft:
                case PhysicalizationType.Rope:
                    physicalEntity = new PhysicalEntity(IPhysicalEntityHandle);
                    break;

                case PhysicalizationType.Living:
                    physicalEntity = new PhysicalEntityLiving(IPhysicalEntityHandle);
                    break;

                case PhysicalizationType.Particle:
                    physicalEntity = new PhysicalEntityParticle(IPhysicalEntityHandle);
                    break;

                case PhysicalizationType.Area:
                    physicalEntity = new PhysicalEntityArea(IPhysicalEntityHandle);
                    break;
                }

                if (physicalEntity != null)
                {
                    physicalEntities.Add(physicalEntity);
                }
            }

            return(physicalEntity);
        }
Example #2
0
        internal static PhysicalEntity TryGet(IntPtr IPhysicalEntityHandle)
        {
            #if !(RELEASE && RELEASE_DISABLE_CHECKS)
            if (IPhysicalEntityHandle == IntPtr.Zero)
                throw new NullPointerException();
            #endif

            var physicalEntity = physicalEntities.FirstOrDefault(x => x.Handle == IPhysicalEntityHandle);
            if (physicalEntity == null)
            {
                switch (PhysicsInterop.GetPhysicalEntityType(IPhysicalEntityHandle))
                {
                    case PhysicalizationType.Static:
                    case PhysicalizationType.Rigid:
                    case PhysicalizationType.WheeledVehicle:
                    case PhysicalizationType.Articulated:
                    case PhysicalizationType.Soft:
                    case PhysicalizationType.Rope:
                        physicalEntity = new PhysicalEntity(IPhysicalEntityHandle);
                        break;
                    case PhysicalizationType.Living:
                        physicalEntity = new PhysicalEntityLiving(IPhysicalEntityHandle);
                        break;
                    case PhysicalizationType.Particle:
                        physicalEntity = new PhysicalEntityParticle(IPhysicalEntityHandle);
                        break;
                    case PhysicalizationType.Area:
                        physicalEntity = new PhysicalEntityArea(IPhysicalEntityHandle);
                        break;
                }

                if (physicalEntity != null)
                    physicalEntities.Add(physicalEntity);
            }

            return physicalEntity;
        }