Beispiel #1
0
 public void ReceiveFixture(PFixture3D fixture)
 {
     _fixture = fixture;
     _shape   = Parallel3D.GetShapeOfFixture(fixture);
     Parallel3D.SetLayer(fixture, gameObject.layer, false);
     Parallel3D.SetFixtureProperties(fixture, isTrigger, _friction, _bounciness);
 }
Beispiel #2
0
        public static void UpdateMesh(PShape3D shape, PFixture3D fixture, Fix64Vec3 scale)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateMesh(shape.IntPointer, fixture.IntPointer, scale);
        }
Beispiel #3
0
        public static void UpdateSphere(PShape3D shape, PFixture3D fixture, Fix64 radius, Fix64Vec3 center)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateSphere(shape.IntPointer, fixture.IntPointer, radius, center);
        }
Beispiel #4
0
        public static void UpdateCapsule(PShape3D shape, PFixture3D fixture, Fix64Vec3 v1, Fix64Vec3 v2, Fix64 radius, Fix64Vec3 center, Fix64Quat rotation)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateCapsule(shape.IntPointer, fixture.IntPointer, v1, v2, radius, center, rotation);
        }
Beispiel #5
0
        public static void UpdateCube(PShape3D shape, PFixture3D fixture, Fix64 x, Fix64 y, Fix64 z, Fix64Vec3 center, Fix64Quat rotation)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateCube(shape.IntPointer, fixture.IntPointer, x, y, z, center, rotation);
        }
Beispiel #6
0
        public static void SetFixtureProperties(PFixture3D fixture, bool isTrigger, Fix64 friction, Fix64 bounciness)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.SetFixtureProperties(fixture.IntPointer, isTrigger, friction, bounciness);
        }
Beispiel #7
0
        public static PShape3D GetShapeOfFixture(PFixture3D fixture)
        {
            if (!initialized)
            {
                Initialize();
            }

            return(new PShape3D(fixture.IntPointer));
        }
Beispiel #8
0
        public static void SetLayer(PFixture3D fixture, int layer, bool refilter)
        {
            if (!initialized)
            {
                Initialize();
            }

            int mask = masksByLayer[layer];
            //shift layer
            int shiftedLayer = 1 << layer;

            NativeParallel3D.SetLayer(fixture.IntPointer, shiftedLayer, mask, refilter);
        }
        //============================== Unity Events ==============================
        void Awake()
        {
            ParallelPhysicsController3D pSettings = FindObjectOfType <ParallelPhysicsController3D>();

            if (pSettings == null)
            {
                return;
            }

            pSettings.InitIfNecessary();

            parallelFixedUpdates = GetComponents <IParallelFixedUpdate>();
            parallelCollisions   = GetComponents <IParallelCollision3D>();
            parallelTriggers     = GetComponents <IParallelTrigger3D>();

            pTransform.ImportFromUnity();

            colliders = GetComponentsInChildren <ParallelCollider3D>();

            _body3D = Parallel3D.AddBody(
                (int)bodyType,
                pTransform.position,
                pTransform.rotation,
                linearDamping,
                angularDamping,
                gravityScale,
                fixedRotationX,
                fixedRotationY,
                fixedRotationZ,
                this);

            _bodyID = _body3D.BodyID;

            foreach (ParallelCollider3D collider in colliders)
            {
                PShape3D shape = collider.CreateShape(gameObject);

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

                PFixture3D fixture = Parallel3D.AddFixture(_body3D, shape, (Fix64)1);

                collider.ReceiveFixture(fixture);
            }

            if (_overideMassData)
            {
                //Parallel3D.UpdateMassData(_body3D, _mass, _centerOfMass);
                if (_centerOfMass != null)
                {
                    Fix64Vec3 com = _centerOfMass;
                    //Debug.Log(com);
                    Parallel3D.UpdateMassData(_body3D, _mass, com);
                }
                else
                {
                    Parallel3D.UpdateMass(_body3D, _mass);
                }
            }
        }