CreateProxies() 개인적인 메소드

private CreateProxies ( BroadPhase broadPhase, Transform &xf ) : void
broadPhase BroadPhase
xf Transform
리턴 void
예제 #1
0
        ///<summary>
        /// Warning: This method is locked during callbacks.
        /// </summary>>
        /// <exception cref="System.InvalidOperationException">Thrown when the world is Locked/Stepping.</exception>
        public void Add(Fixture fixture)
        {
            if (World != null && World.IsLocked)
            {
                throw new WorldLockedException("Cannot add fixtures to a body when the World is locked.");
            }
            if (fixture == null)
            {
                throw new ArgumentNullException("fixture");
            }
            if (fixture.Body != null)
            {
                if (fixture.Body == this)
                {
                    throw new ArgumentException("You are adding the same fixture more than once.", "fixture");
                }
                else
                {
                    throw new ArgumentException("fixture belongs to another body.", "fixture");
                }
            }

            fixture.Body = this;
            this.FixtureList.Add(fixture);
#if DEBUG
            if (fixture.Shape.ShapeType == ShapeType.Polygon)
            {
                ((PolygonShape)fixture.Shape).Vertices.AttachedToBody = true;
            }
#endif

            // Adjust mass properties if needed.
            if (fixture.Shape._density > 0.0f)
            {
                ResetMassData();
            }

            if (World != null)
            {
                if (Enabled)
                {
                    IBroadPhase broadPhase = World.ContactManager.BroadPhase;
                    fixture.CreateProxies(broadPhase, ref _xf);
                }

                // Let the world know we have a new fixture. This will cause new contacts
                // to be created at the beginning of the next time step.
                World._worldHasNewFixture = true;

                if (World.FixtureAdded != null)
                {
                    World.FixtureAdded(World, this, fixture);
                }
            }
        }
예제 #2
0
파일: Body.cs 프로젝트: jwmcglynn/float
        /// <summary>
        /// Creates a fixture and attach it to this body.
        /// If the density is non-zero, this function automatically updates the mass of the body.
        /// Contacts are not created until the next time step.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="density">The density.</param>
        /// <returns></returns>
        public Fixture CreateFixture(Shape shape, float density)
        {
            Debug.Assert(World.IsLocked == false);
            if (World.IsLocked)
            {
                return(null);
            }

            Fixture fixture = new Fixture(this, shape, density);

            if ((Flags & BodyFlags.Active) == BodyFlags.Active)
            {
                BroadPhase broadPhase = World.ContactManager.BroadPhase;
                fixture.CreateProxies(broadPhase, ref Xf);
            }

            FixtureList.Add(fixture);
            fixture.Body = this;

            // Adjust mass properties if needed.
            if (fixture.Density > 0.0f)
            {
                ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            World.Flags |= WorldFlags.NewFixture;

            if (World.FixtureAdded != null)
            {
                World.FixtureAdded(fixture);
            }

            return(fixture);
        }
예제 #3
0
파일: Body.cs 프로젝트: scastle/Solitude
        /// <summary>
        /// Creates a fixture and attach it to this body.
        /// If the density is non-zero, this function automatically updates the mass of the body.
        /// Contacts are not created until the next time step.
        /// Warning: This function is locked during callbacks.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="density">The density.</param>
        /// <returns></returns>
        public Fixture CreateFixture(Shape shape, float density)
        {
            Debug.Assert(World.IsLocked == false);
            if (World.IsLocked)
            {
                return null;
            }

            Fixture fixture = new Fixture(this, shape, density);

            if ((Flags & BodyFlags.Active) == BodyFlags.Active)
            {
                BroadPhase broadPhase = World.ContactManager.BroadPhase;
                fixture.CreateProxies(broadPhase, ref Xf);
            }

            FixtureList.Add(fixture);
            fixture.Body = this;

            // Adjust mass properties if needed.
            if (fixture.Density > 0.0f)
            {
                ResetMassData();
            }

            // Let the world know we have a new fixture. This will cause new contacts
            // to be created at the beginning of the next time step.
            World.Flags |= WorldFlags.NewFixture;

            if (World.FixtureAdded != null)
            {
                World.FixtureAdded(fixture);
            }

            return fixture;
        }