示例#1
0
 public void ReceiveFixture(PFixture2D fixture)
 {
     _fixture = fixture;
     _shape   = Parallel2D.GetShapeOfFixture(fixture);
     Parallel2D.SetLayer(fixture, gameObject.layer, false);
     Parallel2D.SetFixtureProperties(fixture, isTrigger, _friction, _bounciness);
 }
示例#2
0
        public static void UpdateCapsule(PShape2D shape, PFixture2D fixture, Fix64Vec2 v1, Fix64Vec2 v2, Fix64 radius, Fix64Vec2 center, Fix64 angle)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel2D.UpdateCapsule(shape.IntPointer, fixture.IntPointer, v1, v2, radius, center, angle);
        }
示例#3
0
        public static void UpdateBox(PShape2D shape, PFixture2D fixture, Fix64 width, Fix64 height, Fix64Vec2 center, Fix64 angle)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel2D.UpdateBox(shape.IntPointer, fixture.IntPointer, width, height, center, angle);
        }
示例#4
0
        public static void UpdateCircle(PShape2D shape, PFixture2D fixture, Fix64 radius, Fix64Vec2 center)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel2D.UpdateCircle(shape.IntPointer, fixture.IntPointer, radius, center);
        }
示例#5
0
        //2D fixture
        public static PFixture2D AddFixture(PBody2D body2D, PShape2D shape2D, Fix64 density)
        {
            if (!initialized)
            {
                Initialize();
            }

            IntPtr m_NativeObject = NativeParallel2D.AddFixtureToBody(body2D.IntPointer, shape2D.IntPointer, density);

            return(new PFixture2D(m_NativeObject));
        }
示例#6
0
        public static void UpdatePolygon(PShape2D shape, PFixture2D fixture, Fix64Vec2[] verts, int count, Fix64Vec2 center, Fix64 angle)
        {
            if (!initialized)
            {
                Initialize();
            }

            ParallelVec2List parallelVec2List = new ParallelVec2List();

            parallelVec2List.count  = count;
            parallelVec2List.points = verts;
            NativeParallel2D.UpdatePolygon(shape.IntPointer, fixture.IntPointer, ref parallelVec2List, center, angle);
        }
示例#7
0
        //============================== Unity Events ==============================
        void Awake()
        {
            ParallelPhysicsController2D pSettings = FindObjectOfType <ParallelPhysicsController2D>();

            if (pSettings == null)
            {
                return;
            }

            pSettings.InitIfNecessary();

            parallelFixedUpdates = GetComponents <IParallelFixedUpdate>();
            parallelCollisions   = GetComponents <IParallelCollision2D>();
            parallelTriggers     = GetComponents <IParallelTrigger2D>();

            pTransform.ImportFromUnity();

            colliders = GetComponentsInChildren <ParallelCollider2D>();

            _body2D = Parallel2D.AddBody(
                (int)bodyType,
                (Fix64Vec2)pTransform.position,
                pTransform.rotation.GetZAngle(),
                linearDampling,
                angularDamping,
                fixedRotation,
                gravityScale,
                this);

            _bodyID = _body2D.BodyID;

            foreach (ParallelCollider2D collider in colliders)
            {
                collider.SetRootGameObject(gameObject);
                PShape2D shape = collider.CreateShape(gameObject);

                if (shape == null)
                {
                    Debug.LogError("Failed to create collider shape");
                    continue;
                }

                PFixture2D fixture2D = Parallel2D.AddFixture(_body2D, shape, (Fix64)1);

                collider.ReceiveFixture(fixture2D);
            }
        }