public void SetNativeArray() { //OYM: 创建各种实例 pointReadList = new NativeArray <PointRead>(m_pointReadList.ToArray(), Allocator.Persistent); pointReadWriteList = new NativeArray <PointReadWrite>(m_pointReadWriteList.ToArray(), Allocator.Persistent); constraintReadList = new NativeArray <ConstraintRead> [m_constraintList.Count]; List <ConstraintRead> constraintReadList1Target = new List <ConstraintRead>(); for (int i = 0; i < m_constraintList.Count; i++) { constraintReadList1Target.AddRange(m_constraintList[i]); constraintReadList[i] = new NativeArray <ConstraintRead>(m_constraintList[i], Allocator.Persistent); } constraintReadList1 = new NativeArray <ConstraintRead>(constraintReadList1Target.ToArray(), Allocator.Persistent); colliderGet = new ADBRunTimeJobsTable.ColliderGetTransform(); pointGet = new ADBRunTimeJobsTable.PointGetTransform(); pointUpdate = new ADBRunTimeJobsTable.PointUpdate(); colliderUpdate = new ADBRunTimeJobsTable.ColliderUpdate(); constraintUpdates = new ADBRunTimeJobsTable.ConstraintUpdate[m_constraintList.Count]; constraintUpdates1 = new ADBRunTimeJobsTable.ConstraintUpdate(); pointToTransform = new ADBRunTimeJobsTable.JobPointToTransform(); //OYM: 获取指针与赋值 colliderGet.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderGet.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); colliderUpdate.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderUpdate.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointGet.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointGet.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointUpdate.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointUpdate.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointUpdate.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); pointUpdate.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointUpdate.colliderCount = collidersReadList.Length; for (int i = 0; i < constraintUpdates.Length; i++) { constraintUpdates[i].pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); constraintUpdates[i].pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); constraintUpdates[i].pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintUpdates[i].pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintUpdates[i].pConstraintsRead = (ConstraintRead *)constraintReadList[i].GetUnsafePtr(); constraintUpdates[i].colliderCount = collidersReadList.Length; } constraintUpdates1.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); constraintUpdates1.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); constraintUpdates1.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintUpdates1.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintUpdates1.pConstraintsRead = (ConstraintRead *)constraintReadList1.GetUnsafePtr(); constraintUpdates1.colliderCount = collidersReadList.Length; pointToTransform.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointToTransform.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); }
public void SetNativeArray() { pointReadList = new NativeArray <PointRead>(m_pointReadList.ToArray(), Allocator.Persistent); pointReadWriteList = new NativeArray <PointReadWrite>(m_pointReadWriteList.ToArray(), Allocator.Persistent); constraintReadList = new NativeArray <ConstraintRead> [m_constraintList.Count]; for (int i = 0; i < m_constraintList.Count; i++) { constraintReadList[i] = new NativeArray <ConstraintRead>(m_constraintList[i], Allocator.Persistent); } colliderGet = new ADBRunTimeJobsTable.ColliderGetTransform(); pointGet = new ADBRunTimeJobsTable.PointGetTransform(); pointUpdate = new ADBRunTimeJobsTable.PointUpdate(); colliderUpdate = new ADBRunTimeJobsTable.ColliderUpdate(); constraintUpdates = new ADBRunTimeJobsTable.JobConstraintUpdate[m_constraintList.Count]; pointCollision = new ADBRunTimeJobsTable.JobCollisionPoint(); pointToTransform = new ADBRunTimeJobsTable.JobPointToTransform2(); colliderGet.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderGet.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); colliderUpdate.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderUpdate.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointGet.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointGet.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointUpdate.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointUpdate.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); for (int i = 0; i < constraintUpdates.Length; i++) { constraintUpdates[i].pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); constraintUpdates[i].pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); constraintUpdates[i].pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintUpdates[i].pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintUpdates[i].pConstraintsRead = (ConstraintRead *)constraintReadList[i].GetUnsafePtr(); } pointCollision.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); pointCollision.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointCollision.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointCollision.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointToTransform.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointToTransform.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); }
public void SetNativeArray() { //OYM: 创建各种实例 pointReadList = new NativeArray <PointRead>(m_pointReadList.ToArray(), Allocator.Persistent); pointReadWriteList = new NativeArray <PointReadWrite>(m_pointReadWriteList.ToArray(), Allocator.Persistent); constraintReadList = new NativeArray <ConstraintRead> [m_constraintList.Count]; List <ConstraintRead> constraintReadList1Target = new List <ConstraintRead>(); ConstraintReadByPointIndex = new NativeMultiHashMap <int, ConstraintRead>(8, Allocator.Persistent); for (int i = 0; i < m_constraintList.Count; i++) { constraintReadList1Target.AddRange(m_constraintList[i]); constraintReadList[i] = new NativeArray <ConstraintRead>(m_constraintList[i], Allocator.Persistent); for (int j = 0; j < m_constraintList[i].Length; j++) { ConstraintRead temp = m_constraintList[i][j]; ConstraintReadByPointIndex.Add(m_constraintList[i][j].indexA, temp); //OYM: 考虑到只会读取indexB,及相对的点,这里要交换一下顺序,避免读取到自己 int exchange = temp.indexA; temp.indexA = temp.indexB; temp.indexB = exchange; ConstraintReadByPointIndex.Add(m_constraintList[i][j].indexB, temp); } } constraintReadList1 = new NativeArray <ConstraintRead>(constraintReadList1Target.ToArray(), Allocator.Persistent); colliderGet = new ADBRunTimeJobsTable.ColliderGetTransform(); pointGet = new ADBRunTimeJobsTable.PointGetTransform(); pointUpdate = new ADBRunTimeJobsTable.PointUpdate(); colliderUpdate = new ADBRunTimeJobsTable.ColliderUpdate(); constraintUpdates = new ADBRunTimeJobsTable.ConstraintUpdate[m_constraintList.Count]; constraintUpdates1 = new ADBRunTimeJobsTable.ConstraintUpdate(); constraintForceUpdateByPoint = new ADBRunTimeJobsTable.ConstraintForceUpdateByPoint(); pointToTransform = new ADBRunTimeJobsTable.JobPointToTransform(); //OYM: 获取指针与赋值 colliderGet.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderGet.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); colliderUpdate.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); colliderUpdate.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointGet.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointGet.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointUpdate.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointUpdate.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); pointUpdate.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); pointUpdate.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); pointUpdate.colliderCount = collidersReadList.Length; for (int i = 0; i < constraintUpdates.Length; i++) { constraintUpdates[i].pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); constraintUpdates[i].pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); constraintUpdates[i].pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintUpdates[i].pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintUpdates[i].pConstraintsRead = (ConstraintRead *)constraintReadList[i].GetUnsafePtr(); constraintUpdates[i].colliderCount = collidersReadList.Length; } constraintUpdates1.pReadColliders = (ColliderRead *)collidersReadList.GetUnsafePtr(); constraintUpdates1.pReadWriteColliders = (ColliderReadWrite *)collidersReadWriteList.GetUnsafePtr(); constraintUpdates1.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintUpdates1.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintUpdates1.pConstraintsRead = (ConstraintRead *)constraintReadList1.GetUnsafePtr(); constraintUpdates1.colliderCount = collidersReadList.Length; constraintForceUpdateByPoint.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); constraintForceUpdateByPoint.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); constraintForceUpdateByPoint.constraintsRead = ConstraintReadByPointIndex; pointToTransform.pReadPoints = (PointRead *)pointReadList.GetUnsafePtr(); pointToTransform.pReadWritePoints = (PointReadWrite *)pointReadWriteList.GetUnsafePtr(); }