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);
 }
        public void AddToWorldForPathFinding()
        {
            if (_bodyType != BodyType.Static)
            {
                return;
            }

            ParallelCollider3D[] colliders = GetComponentsInChildren <ParallelCollider3D>();
            PBody3D body = Parallel3D.AddBody(
                (int)bodyType,
                pTransform.position,
                pTransform.rotation,
                linearDamping,
                angularDamping,
                gravityScale,
                fixedRotationX,
                fixedRotationY,
                fixedRotationZ,
                this);

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

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

                Parallel3D.AddFixture(body, shape, (Fix64)1);
            }
        }
Beispiel #3
0
        public static void UpdateMesh(PShape3D shape, PFixture3D fixture, Fix64Vec3 scale)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateMesh(shape.IntPointer, fixture.IntPointer, scale);
        }
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 UpdateSphere(PShape3D shape, PFixture3D fixture, Fix64 radius, Fix64Vec3 center)
        {
            if (!initialized)
            {
                Initialize();
            }

            NativeParallel3D.UpdateSphere(shape.IntPointer, fixture.IntPointer, radius, center);
        }
Beispiel #6
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 #7
0
        //3D fixture
        public static PFixture3D AddFixture(PBody3D body, PShape3D shape, Fix64 density)
        {
            if (!initialized)
            {
                Initialize();
            }

            IntPtr m_NativeObject = NativeParallel3D.AddFixtureToBody(body.IntPointer, shape.IntPointer, density);

            return(new PFixture3D(m_NativeObject));
        }
        //============================== 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);
                }
            }
        }