Exemplo n.º 1
0
        // ----------------------------------------------------

        #region // Public Methods

        public void Initialize()
        {
            this._blittableFieldsPtr =
                (BlittableFields *)UnsafeUtilityHelper.Malloc <BlittableFields>(Allocator.Persistent);
            this.CopyBlittableFields();

            if (this.m_center != null)
            {
                this._centerMatrixPtr = (float4x4 *)UnsafeUtilityHelper.Malloc <float4x4>(Allocator.Persistent);
                this.UpdateCenterMatrix();
            }

            if (this.ColliderGroups != null && this.ColliderGroups.Length > 0)
            {
                this._colliderGroupInstanceIDs = new NativeArray <int>(this.ColliderGroups.Length, Allocator.Persistent);
                for (var i = 0; i < this._colliderGroupInstanceIDs.Length; i++)
                {
                    this._colliderGroupInstanceIDs[i] = this.ColliderGroups[i].GetInstanceID();
                }
            }

            foreach (var go in RootBones)
            {
                if (go == null)
                {
                    continue;
                }

                this.CreateNode(go);
            }
        }
Exemplo n.º 2
0
 public Node(
     Transform trs,
     BlittableFields *blittableFieldsPtr,
     EntityManager entityManager,
     Entity centerEntity,
     Node parent = null)
 {
     this.Transform           = trs;
     this._blittableFieldsPtr = blittableFieldsPtr;
     this._entityManager      = entityManager;
     this._centerEntity       = centerEntity;
     this._parent             = parent;
 }
Exemplo n.º 3
0
        // ----------------------------------------------------

        #region // Public Methods

        public void Initialize(EntityManager entityManager)
        {
            Assert.IsFalse(this.RootBones == null || this.RootBones.Count <= 0);
            this._entityManager = entityManager;

            // コライダーの初期化
            if (this.ColliderGroups != null && this.ColliderGroups.Length > 0)
            {
                foreach (var collider in this.ColliderGroups)
                {
                    collider.Initialize(this._entityManager);
                }

                this._colliderGroupInstanceIDs = new NativeArray <int>(this.ColliderGroups.Length, Allocator.Persistent);
                for (var i = 0; i < this._colliderGroupInstanceIDs.Length; i++)
                {
                    this._colliderGroupInstanceIDs[i] = this.ColliderGroups[i].GetInstanceID();
                }
            }

            this._centerEntity = Entity.Null;
            if (this.m_center != null)
            {
                var centerEntity = GetOrAddComponent <GameObjectEntity>(this.m_center.gameObject);
                this._centerEntity = centerEntity.Entity;
                this._entityManager.AddComponentData(
                    this._centerEntity, new Center()
                {
                    Value = this.m_center.localToWorldMatrix
                });
            }

            // 各種パラメータ用のメモリ確保 + 初期化
            {
                this._blittableFieldsPtr =
                    (BlittableFields *)UnsafeUtilityHelper.Malloc <BlittableFields>(Allocator.Persistent);
                this.CopyBlittableFields();
            }

            this.Nodes = new List <Node>();
            foreach (var go in RootBones)
            {
                if (go == null)
                {
                    continue;
                }

                this.CreateNode(go);
            }
        }
Exemplo n.º 4
0
 public Node(
     Transform nodeTrs,
     BlittableFields *blittableFieldsPtr,
     float4x4 *centerMatrixPtr,
     float3 initTail,
     float length,
     quaternion localRotation,
     float3 boneAxis)
 {
     this.Transform          = nodeTrs;
     this.BlittableFieldsPtr = blittableFieldsPtr;
     this.CenterMatrixPtr    = centerMatrixPtr;
     this.InitTail           = initTail;
     this.Length             = length;
     this.LocalRotation      = localRotation;
     this.BoneAxis           = boneAxis;
 }
Exemplo n.º 5
0
        public void Dispose()
        {
            if (this._blittableFieldsPtr != null)
            {
                UnsafeUtility.Free(this._blittableFieldsPtr, Allocator.Persistent);
                this._blittableFieldsPtr = null;
            }

            if (this._centerMatrixPtr != null)
            {
                UnsafeUtility.Free(this._centerMatrixPtr, Allocator.Persistent);
                this._centerMatrixPtr = null;
            }

            if (this._colliderGroupInstanceIDs.IsCreated)
            {
                this._colliderGroupInstanceIDs.Dispose();
            }

            Nodes?.Clear();
        }
Exemplo n.º 6
0
        public void Dispose()
        {
            if (this.ColliderGroups != null && this.ColliderGroups.Length > 0)
            {
                foreach (var collider in this.ColliderGroups)
                {
                    collider.Dispose();
                }

                if (this._colliderGroupInstanceIDs.IsCreated)
                {
                    this._colliderGroupInstanceIDs.Dispose();
                }
            }

            if (this._blittableFieldsPtr != null)
            {
                UnsafeUtility.Free(this._blittableFieldsPtr, Allocator.Persistent);
                this._blittableFieldsPtr = null;
            }

            this.Nodes?.Clear();
            this.Nodes = null;
        }