コード例 #1
0
        /// <summary>
        /// Create a new instance of the <see cref="World"/> class.
        /// </summary>
        /// <param name="collision">The collisionSystem which is used to detect
        /// collisions. See for example: <see cref="CollisionSystemSAP"/>
        /// or <see cref="CollisionSystemBrute"/>.
        /// </param>
        public World(CollisionSystem collision)
        {
            if (collision == null)
            {
                throw new ArgumentNullException("The CollisionSystem can't be null.", "collision");
            }

            arbiterCallback   = new Action <object>(ArbiterCallback);
            integrateCallback = new Action <object>(IntegrateCallback);

            // Create the readonly wrappers
            this.RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies);
            this.Constraints = new ReadOnlyHashset <Constraint>(constraints);
            this.SoftBodies  = new ReadOnlyHashset <SoftBody>(softbodies);

            this.CollisionSystem = collision;

            collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected);

            this.CollisionSystem.CollisionDetected += collisionDetectionHandler;

            this.arbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }
コード例 #2
0
ファイル: World.cs プロジェクト: fxredeemer/jitterphysics
        public World(CollisionSystem collision)
        {
            CollisionSystem = collision ?? throw new ArgumentNullException("The CollisionSystem can't be null.", nameof(collision));

            arbiterCallback   = new Action <object>(ArbiterCallback);
            integrateCallback = new Action <object>(IntegrateCallback);

            RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies);
            Constraints = new ReadOnlyHashset <Constraint>(constraints);
            SoftBodies  = new ReadOnlyHashset <SoftBody>(softbodies);

            collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected);

            CollisionSystem.CollisionDetected += collisionDetectionHandler;

            ArbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }
コード例 #3
0
ファイル: World.cs プロジェクト: BenjaminMoore/JPhysics
        public World(CollisionSystem collision)
        {
            if (collision == null) throw new ArgumentNullException("collision", "The CollisionSystem can't be null.");

            arbiterCallback = ArbiterCallback;
            integrateCallback = IntegrateCallback;

            RigidBodies = new ReadOnlyHashset<RigidBody>(rigidBodies);
            Constraints = new ReadOnlyHashset<Constraint>(constraints);
            SoftBodies = new ReadOnlyHashset<SoftBody>(softbodies);

            CollisionSystem = collision;

            collisionDetectionHandler = CollisionDetected;

            CollisionSystem.CollisionDetected += collisionDetectionHandler;

            arbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }
コード例 #4
0
        public World(CollisionSystem collision)
        {
            if (collision == null) throw new ArgumentNullException("collision", "The CollisionSystem can't be null.");

            arbiterCallback = ArbiterCallback;
            integrateCallback = IntegrateCallback;

            RigidBodies = new ReadOnlyHashset<RigidBody>(rigidBodies);
            Constraints = new ReadOnlyHashset<Constraint>(constraints);
            SoftBodies = new ReadOnlyHashset<SoftBody>(softbodies);

            CollisionSystem = collision;

            collisionDetectionHandler = CollisionDetected;

            CollisionSystem.CollisionDetected += collisionDetectionHandler;

            arbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }
コード例 #5
0
ファイル: World.cs プロジェクト: LaserYGD/Zeldo-CSharp
        /// <summary>
        /// Create a new instance of the <see cref="World"/> class.
        /// </summary>
        /// <param name="collision">The collisionSystem which is used to detect
        /// collisions. See for example: <see cref="CollisionSystemSAP"/>
        /// or <see cref="CollisionSystemBrute"/>.
        /// </param>
        public World(CollisionSystem system)
        {
            Debug.Assert(system != null, "Collision system can't be null.");

            Arbiter.World = this;

            arbiterCallback   = ArbiterCallback;
            integrateCallback = IntegrateCallback;

            // Create the readonly wrappers
            this.RigidBodies = new ReadOnlyHashset <RigidBody>(rigidBodies);
            this.Constraints = new ReadOnlyHashset <Constraint>(constraints);
            this.SoftBodies  = new ReadOnlyHashset <SoftBody>(softbodies);

            this.CollisionSystem = system;

            collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected);

            this.CollisionSystem.CollisionDetected += collisionDetectionHandler;

            this.arbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }
コード例 #6
0
ファイル: World.cs プロジェクト: fxredeemer/jitterphysics
        public void Clear()
        {
            foreach (var body in rigidBodies)
            {
                CollisionSystem.RemoveEntity(body);

                if (body.island != null)
                {
                    body.island.ClearLists();
                    body.island = null;
                }

                body.connections.Clear();
                body.arbiters.Clear();
                body.constraints.Clear();

                Events.RaiseRemovedRigidBody(body);
            }

            foreach (var body in softbodies)
            {
                CollisionSystem.RemoveEntity(body);
            }

            rigidBodies.Clear();

            foreach (var constraint in constraints)
            {
                Events.RaiseRemovedConstraint(constraint);
            }
            constraints.Clear();
            softbodies.Clear();
            islands.RemoveAll();
            ArbiterMap.Clear();
            ResetResourcePools();
        }
コード例 #7
0
ファイル: World.cs プロジェクト: ajmd17/apexengine-sharp
        /// <summary>
        /// Create a new instance of the <see cref="World"/> class.
        /// </summary>
        /// <param name="collision">The collisionSystem which is used to detect
        /// collisions. See for example: <see cref="CollisionSystemSAP"/>
        /// or <see cref="CollisionSystemBrute"/>.
        /// </param>
        public World(CollisionSystem collision)
        {
            if (collision == null)
                throw new ArgumentNullException("The CollisionSystem can't be null.", "collision");

            arbiterCallback = new Action<object>(ArbiterCallback);
            integrateCallback = new Action<object>(IntegrateCallback);

            // Create the readonly wrappers
            this.RigidBodies = new ReadOnlyHashset<RigidBody>(rigidBodies);
            this.Constraints = new ReadOnlyHashset<Constraint>(constraints);
            this.SoftBodies = new ReadOnlyHashset<SoftBody>(softbodies);

            this.CollisionSystem = collision;

            collisionDetectionHandler = new CollisionDetectedHandler(CollisionDetected);

            this.CollisionSystem.CollisionDetected += collisionDetectionHandler;

            this.arbiterMap = new ArbiterMap();

            AllowDeactivation = true;
        }