EdgeCollisionConstraint.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using Unity.Burst;
  5. using Unity.Collections;
  6. using Unity.Jobs;
  7. using Unity.Mathematics;
  8. namespace MagicaCloth
  9. {
  10. /// <summary>
  11. /// エッジコリジョン拘束
  12. /// </summary>
  13. public class EdgeCollisionConstraint : PhysicsManagerConstraint
  14. {
  15. /// <summary>
  16. /// 拘束データ
  17. /// todo:共有化可能
  18. /// </summary>
  19. [System.Serializable]
  20. public struct EdgeCollisionData
  21. {
  22. /// <summary>
  23. /// エッジ形成パーティクルインデックス
  24. /// </summary>
  25. public ushort vindex0;
  26. public ushort vindex1;
  27. /// <summary>
  28. /// 書き込みバッファインデックス
  29. /// </summary>
  30. public int writeIndex0;
  31. public int writeIndex1;
  32. /// <summary>
  33. /// データが有効か判定する
  34. /// </summary>
  35. /// <returns></returns>
  36. public bool IsValid()
  37. {
  38. return vindex0 > 0 && vindex1 > 0;
  39. }
  40. }
  41. FixedChunkNativeArray<EdgeCollisionData> dataList;
  42. /// <summary>
  43. /// データごとのグループインデックス
  44. /// </summary>
  45. FixedChunkNativeArray<short> groupIndexList;
  46. /// <summary>
  47. /// 内部パーティクルインデックスごとの書き込みバッファ参照
  48. /// </summary>
  49. FixedChunkNativeArray<ReferenceDataIndex> refDataList;
  50. /// <summary>
  51. /// 頂点計算結果書き込みバッファ
  52. /// </summary>
  53. FixedChunkNativeArray<float3> writeBuffer;
  54. /// <summary>
  55. /// グループごとの拘束データ
  56. /// </summary>
  57. public struct GroupData
  58. {
  59. public int teamId;
  60. public int active;
  61. public float edgeRadius;
  62. /// <summary>
  63. /// データチャンク
  64. /// </summary>
  65. public ChunkData dataChunk;
  66. /// <summary>
  67. /// グループデータチャンク
  68. /// </summary>
  69. public ChunkData groupIndexChunk;
  70. /// <summary>
  71. /// 内部インデックス用チャンク
  72. /// </summary>
  73. public ChunkData refDataChunk;
  74. /// <summary>
  75. /// 頂点計算結果書き込み用チャンク
  76. /// </summary>
  77. public ChunkData writeDataChunk;
  78. }
  79. FixedNativeList<GroupData> groupList;
  80. //=========================================================================================
  81. public override void Create()
  82. {
  83. dataList = new FixedChunkNativeArray<EdgeCollisionData>();
  84. groupIndexList = new FixedChunkNativeArray<short>();
  85. refDataList = new FixedChunkNativeArray<ReferenceDataIndex>();
  86. writeBuffer = new FixedChunkNativeArray<float3>();
  87. groupList = new FixedNativeList<GroupData>();
  88. }
  89. public override void Release()
  90. {
  91. dataList.Dispose();
  92. groupIndexList.Dispose();
  93. refDataList.Dispose();
  94. writeBuffer.Dispose();
  95. groupList.Dispose();
  96. }
  97. //=========================================================================================
  98. public int AddGroup(int teamId, bool active, float edgeRadius, EdgeCollisionData[] dataArray, ReferenceDataIndex[] refDataArray, int writeBufferCount)
  99. {
  100. if (dataArray == null || dataArray.Length == 0 || refDataArray == null || refDataArray.Length == 0 || writeBufferCount == 0)
  101. return -1;
  102. var teamData = MagicaPhysicsManager.Instance.Team.teamDataList[teamId];
  103. // グループデータ作成
  104. var gdata = new GroupData();
  105. gdata.teamId = teamId;
  106. gdata.active = active ? 1 : 0;
  107. gdata.edgeRadius = edgeRadius;
  108. //gdata.stiffness.Setup(stiffness);
  109. gdata.dataChunk = dataList.AddChunk(dataArray.Length);
  110. gdata.groupIndexChunk = groupIndexList.AddChunk(dataArray.Length);
  111. gdata.refDataChunk = refDataList.AddChunk(refDataArray.Length);
  112. gdata.writeDataChunk = writeBuffer.AddChunk(writeBufferCount);
  113. // チャンクデータコピー
  114. dataList.ToJobArray().CopyFromFast(gdata.dataChunk.startIndex, dataArray);
  115. refDataList.ToJobArray().CopyFromFast(gdata.refDataChunk.startIndex, refDataArray);
  116. int group = groupList.Add(gdata);
  117. // データごとのグループインデックス
  118. groupIndexList.Fill(gdata.groupIndexChunk, (short)group);
  119. return group;
  120. }
  121. public override void RemoveTeam(int teamId)
  122. {
  123. var teamData = MagicaPhysicsManager.Instance.Team.teamDataList[teamId];
  124. int group = teamData.edgeCollisionGroupIndex;
  125. if (group < 0)
  126. return;
  127. var cdata = groupList[group];
  128. // チャンクデータ削除
  129. dataList.RemoveChunk(cdata.dataChunk);
  130. refDataList.RemoveChunk(cdata.refDataChunk);
  131. writeBuffer.RemoveChunk(cdata.writeDataChunk);
  132. groupIndexList.RemoveChunk(cdata.groupIndexChunk);
  133. // データ削除
  134. groupList.Remove(group);
  135. }
  136. public void ChangeParam(int teamId, bool active, float edgeRadius)
  137. {
  138. var teamData = MagicaPhysicsManager.Instance.Team.teamDataList[teamId];
  139. int group = teamData.edgeCollisionGroupIndex;
  140. if (group < 0)
  141. return;
  142. var gdata = groupList[group];
  143. gdata.active = active ? 1 : 0;
  144. gdata.edgeRadius = edgeRadius;
  145. //gdata.stiffness.Setup(stiffness);
  146. groupList[group] = gdata;
  147. }
  148. //public int ActiveCount
  149. //{
  150. // get
  151. // {
  152. // int cnt = 0;
  153. // for (int i = 0; i < groupList.Length; i++)
  154. // if (groupList[i].active == 1)
  155. // cnt++;
  156. // return cnt;
  157. // }
  158. //}
  159. //=========================================================================================
  160. /// <summary>
  161. /// 拘束の解決
  162. /// </summary>
  163. /// <param name="dtime"></param>
  164. /// <param name="jobHandle"></param>
  165. /// <returns></returns>
  166. public override JobHandle SolverConstraint(int runCount, float dtime, float updatePower, int iteration, JobHandle jobHandle)
  167. {
  168. if (groupList.Count == 0)
  169. return jobHandle;
  170. // ステップ1:コリジョンの計算
  171. var job = new EdgeCollisionCalcJob()
  172. {
  173. updatePower = updatePower,
  174. runCount = runCount,
  175. groupDataList = groupList.ToJobArray(),
  176. dataList = dataList.ToJobArray(),
  177. groupIndexList = groupIndexList.ToJobArray(),
  178. //colliderMap = Manager.Team.colliderMap.Map,
  179. colliderList = Manager.Team.colliderList.ToJobArray(),
  180. teamDataList = Manager.Team.teamDataList.ToJobArray(),
  181. flagList = Manager.Particle.flagList.ToJobArray(),
  182. radiusList = Manager.Particle.radiusList.ToJobArray(),
  183. posList = Manager.Particle.posList.ToJobArray(),
  184. rotList = Manager.Particle.rotList.ToJobArray(),
  185. nextPosList = Manager.Particle.InNextPosList.ToJobArray(),
  186. nextRotList = Manager.Particle.InNextRotList.ToJobArray(),
  187. localPosList = Manager.Particle.localPosList.ToJobArray(),
  188. //oldPosList = Manager.Particle.oldPosList.ToJobArray(),
  189. transformIndexList = Manager.Particle.transformIndexList.ToJobArray(),
  190. boneSclList = Manager.Bone.boneSclList.ToJobArray(),
  191. writeBuffer = writeBuffer.ToJobArray(),
  192. };
  193. jobHandle = job.Schedule(dataList.Length, 64, jobHandle);
  194. // ステップ2:コリジョン結果の集計
  195. var job2 = new EdgeCollisionSumJob()
  196. {
  197. runCount = runCount,
  198. groupDataList = groupList.ToJobArray(),
  199. refDataList = refDataList.ToJobArray(),
  200. writeBuffer = writeBuffer.ToJobArray(),
  201. teamDataList = Manager.Team.teamDataList.ToJobArray(),
  202. teamIdList = Manager.Particle.teamIdList.ToJobArray(),
  203. flagList = Manager.Particle.flagList.ToJobArray(),
  204. inoutNextPosList = Manager.Particle.InNextPosList.ToJobArray(),
  205. frictionList = Manager.Particle.frictionList.ToJobArray(),
  206. };
  207. jobHandle = job2.Schedule(Manager.Particle.Length, 64, jobHandle);
  208. return jobHandle;
  209. }
  210. [BurstCompile]
  211. struct EdgeCollisionCalcJob : IJobParallelFor
  212. {
  213. public float updatePower;
  214. public int runCount;
  215. [Unity.Collections.ReadOnly]
  216. public NativeArray<GroupData> groupDataList;
  217. [Unity.Collections.ReadOnly]
  218. public NativeArray<EdgeCollisionData> dataList;
  219. [Unity.Collections.ReadOnly]
  220. public NativeArray<short> groupIndexList;
  221. //[Unity.Collections.ReadOnly]
  222. //public NativeMultiHashMap<int, int> colliderMap;
  223. [Unity.Collections.ReadOnly]
  224. public NativeArray<int> colliderList;
  225. [Unity.Collections.ReadOnly]
  226. public NativeArray<PhysicsManagerTeamData.TeamData> teamDataList;
  227. [Unity.Collections.ReadOnly]
  228. public NativeArray<PhysicsManagerParticleData.ParticleFlag> flagList;
  229. [Unity.Collections.ReadOnly]
  230. public NativeArray<float3> radiusList;
  231. [Unity.Collections.ReadOnly]
  232. public NativeArray<float3> posList;
  233. [Unity.Collections.ReadOnly]
  234. public NativeArray<quaternion> rotList;
  235. [Unity.Collections.ReadOnly]
  236. public NativeArray<float3> nextPosList;
  237. [Unity.Collections.ReadOnly]
  238. public NativeArray<quaternion> nextRotList;
  239. [Unity.Collections.ReadOnly]
  240. public NativeArray<float3> localPosList;
  241. //[Unity.Collections.ReadOnly]
  242. //public NativeArray<float3> oldPosList;
  243. [Unity.Collections.ReadOnly]
  244. public NativeArray<int> transformIndexList;
  245. [Unity.Collections.ReadOnly]
  246. public NativeArray<float3> boneSclList;
  247. [Unity.Collections.WriteOnly]
  248. [NativeDisableParallelForRestriction]
  249. public NativeArray<float3> writeBuffer;
  250. // エッジデータごと
  251. public void Execute(int index)
  252. {
  253. var data = dataList[index];
  254. if (data.IsValid() == false)
  255. return;
  256. int gindex = groupIndexList[index];
  257. var gdata = groupDataList[gindex];
  258. if (gdata.teamId == 0 || gdata.active == 0)
  259. return;
  260. var tdata = teamDataList[gdata.teamId];
  261. if (tdata.IsActive() == false)
  262. return;
  263. // 更新確認
  264. if (tdata.IsUpdate(runCount) == false)
  265. return;
  266. int pstart = tdata.particleChunk.startIndex;
  267. float3 corr0 = 0;
  268. float3 corr1 = 0;
  269. int pindex0 = data.vindex0 + pstart;
  270. int pindex1 = data.vindex1 + pstart;
  271. float3 nextpos0 = nextPosList[pindex0];
  272. float3 nextpos1 = nextPosList[pindex1];
  273. //float3 oldpos0 = oldPosList[pindex0];
  274. //float3 oldpos1 = oldPosList[pindex1];
  275. // エッジの太さ
  276. float radius = gdata.edgeRadius;
  277. // 計算結果の移動値をcorrに格納
  278. // チームごとに判定[グローバル(0)]->[自身のチーム(team)]
  279. int colliderTeam = 0;
  280. bool hitresult = false;
  281. for (int i = 0; i < 2; i++)
  282. {
  283. // チーム内のコライダーをループ
  284. var c = teamDataList[colliderTeam].colliderChunk;
  285. int dataIndex = c.startIndex;
  286. for (int j = 0; j < c.useLength; j++, dataIndex++)
  287. {
  288. int cindex = colliderList[dataIndex];
  289. var cflag = flagList[cindex];
  290. if (cflag.IsValid() == false)
  291. continue;
  292. bool hit = false;
  293. if (cflag.IsFlag(PhysicsManagerParticleData.Flag_Plane))
  294. {
  295. // 平面コライダー判定
  296. //hit = PlaneColliderDetection(ref nextpos, radius, cindex);
  297. }
  298. else if (cflag.IsFlag(PhysicsManagerParticleData.Flag_CapsuleX))
  299. {
  300. // カプセルコライダー判定
  301. hit = CapsuleColliderDetection(nextpos0, nextpos1, ref corr0, ref corr1, radius, cindex, new float3(1, 0, 0));
  302. //hit = CapsuleColliderDetection(nextpos0, nextpos1, oldpos0, oldpos1, ref corr0, ref corr1, radius, cindex, new float3(1, 0, 0));
  303. }
  304. else if (cflag.IsFlag(PhysicsManagerParticleData.Flag_CapsuleY))
  305. {
  306. // カプセルコライダー判定
  307. hit = CapsuleColliderDetection(nextpos0, nextpos1, ref corr0, ref corr1, radius, cindex, new float3(0, 1, 0));
  308. //hit = CapsuleColliderDetection(nextpos0, nextpos1, oldpos0, oldpos1, ref corr0, ref corr1, radius, cindex, new float3(0, 1, 0));
  309. }
  310. else if (cflag.IsFlag(PhysicsManagerParticleData.Flag_CapsuleZ))
  311. {
  312. // カプセルコライダー判定
  313. hit = CapsuleColliderDetection(nextpos0, nextpos1, ref corr0, ref corr1, radius, cindex, new float3(0, 0, 1));
  314. //hit = CapsuleColliderDetection(nextpos0, nextpos1, oldpos0, oldpos1, ref corr0, ref corr1, radius, cindex, new float3(0, 0, 1));
  315. }
  316. else if (cflag.IsFlag(PhysicsManagerParticleData.Flag_Box))
  317. {
  318. // ボックスコライダー判定
  319. // ★まだ未実装
  320. }
  321. else
  322. {
  323. // 球コライダー判定
  324. hit = SphereColliderDetection(nextpos0, nextpos1, ref corr0, ref corr1, radius, cindex);
  325. //hit = SphereColliderDetection(nextpos0, nextpos1, oldpos0, oldpos1, ref corr0, ref corr1, radius, cindex);
  326. }
  327. hitresult = hit ? true : hitresult;
  328. //if (hit)
  329. //{
  330. // // 衝突あり!
  331. // // 摩擦設定
  332. // //frictionList[index] = math.max(frictionList[index], teamData.friction);
  333. //}
  334. }
  335. // 自身のチームに切り替え
  336. colliderTeam = gdata.teamId;
  337. }
  338. // 摩擦係数?
  339. // 作業バッファへ格納
  340. int wstart = gdata.writeDataChunk.startIndex;
  341. int windex0 = data.writeIndex0 + wstart;
  342. int windex1 = data.writeIndex1 + wstart;
  343. writeBuffer[windex0] = corr0;
  344. writeBuffer[windex1] = corr1;
  345. }
  346. /// <summary>
  347. /// 球衝突判定
  348. /// </summary>
  349. /// <param name="nextpos0">エッジの始点</param>
  350. /// <param name="nextpos1">エッジの終点</param>
  351. /// <param name="corr0"></param>
  352. /// <param name="corr1"></param>
  353. /// <param name="radius"></param>
  354. /// <param name="cindex"></param>
  355. /// <returns></returns>
  356. bool SphereColliderDetection(float3 nextpos0, float3 nextpos1, ref float3 corr0, ref float3 corr1, float radius, int cindex)
  357. //bool SphereColliderDetection(float3 nextpos0, float3 nextpos1, float3 oldpos0, float3 oldpos1, ref float3 corr0, ref float3 corr1, float radius, int cindex)
  358. {
  359. var cpos = nextPosList[cindex];
  360. var coldpos = posList[cindex];
  361. var cradius = radiusList[cindex];
  362. // スケール
  363. var tindex = transformIndexList[cindex];
  364. var cscl = boneSclList[tindex];
  365. cradius *= cscl.x; // X軸のみを見る
  366. // コライダー球とエッジの最接近点を求める
  367. float3 d = MathUtility.ClosestPtPointSegment(coldpos, nextpos0, nextpos1);
  368. //float3 d = MathUtility.ClosestPtPointSegment(coldpos, oldpos0, oldpos1);
  369. float3 n = math.normalize(d - coldpos);
  370. float3 c = cpos + n * (cradius.x + radius);
  371. // c = 平面位置
  372. // n = 平面方向
  373. // 平面衝突判定と押し出し
  374. float3 outpos0, outpos1;
  375. bool ret0 = MathUtility.IntersectPointPlane(c, n, nextpos0, out outpos0);
  376. bool ret1 = MathUtility.IntersectPointPlane(c, n, nextpos1, out outpos1);
  377. if (ret0)
  378. corr0 += outpos0 - nextpos0;
  379. if (ret1)
  380. corr1 += outpos1 - nextpos1;
  381. return ret0 || ret1;
  382. }
  383. /// <summary>
  384. /// カプセル衝突判定
  385. /// </summary>
  386. /// <param name="nextpos0">エッジの始点</param>
  387. /// <param name="nextpos1">エッジの終点</param>
  388. /// <param name="corr0"></param>
  389. /// <param name="corr1"></param>
  390. /// <param name="radius"></param>
  391. /// <param name="cindex"></param>
  392. /// <param name="dir"></param>
  393. /// <returns></returns>
  394. bool CapsuleColliderDetection(float3 nextpos0, float3 nextpos1, ref float3 corr0, ref float3 corr1, float radius, int cindex, float3 dir)
  395. //bool CapsuleColliderDetection(float3 nextpos0, float3 nextpos1, float3 oldpos0, float3 oldpos1, ref float3 corr0, ref float3 corr1, float radius, int cindex, float3 dir)
  396. {
  397. var cpos = nextPosList[cindex];
  398. var crot = nextRotList[cindex];
  399. var coldpos = posList[cindex];
  400. var coldrot = rotList[cindex];
  401. // x = 長さ(片側)
  402. // y = 始点半径
  403. // z = 終点半径
  404. //var lpos = localPosList[cindex];
  405. var cradius = radiusList[cindex];
  406. // スケール
  407. var tindex = transformIndexList[cindex];
  408. var cscl = boneSclList[tindex];
  409. float scl = math.dot(cscl, dir); // dirの軸のスケールを使用する
  410. cradius *= scl;
  411. // 移動前のコライダーに対するエッジの最近接点を求める
  412. float3 oldl = math.mul(coldrot, dir * cradius.x);
  413. float3 soldpos = coldpos - oldl;
  414. float3 eoldpos = coldpos + oldl;
  415. float3 c1, c2;
  416. float s, t;
  417. MathUtility.ClosestPtSegmentSegment(soldpos, eoldpos, nextpos0, nextpos1, out s, out t, out c1, out c2);
  418. //MathUtility.ClosestPtSegmentSegment(soldpos, eoldpos, oldpos0, oldpos1, out s, out t, out c1, out c2);
  419. float3 v = c2 - c1;
  420. // 現在のカプセル始点と終点
  421. float3 l = math.mul(crot, dir * cradius.x);
  422. float3 spos = cpos - l;
  423. float3 epos = cpos + l;
  424. float sr = cradius.y;
  425. float er = cradius.z;
  426. // 移動後のコライダーのベクトルに変換する
  427. var iq = math.inverse(coldrot);
  428. float3 lv = math.mul(iq, v);
  429. v = math.mul(crot, lv);
  430. // コライダーの半径
  431. float r = math.lerp(sr, er, s);
  432. // 平面方程式
  433. float3 n = math.normalize(v);
  434. float3 q = math.lerp(spos, epos, s);
  435. float3 c = q + n * (r + radius);
  436. // c = 平面位置
  437. // n = 平面方向
  438. // 平面衝突判定と押し出し
  439. float3 outpos0, outpos1;
  440. bool ret0 = MathUtility.IntersectPointPlane(c, n, nextpos0, out outpos0);
  441. bool ret1 = MathUtility.IntersectPointPlane(c, n, nextpos1, out outpos1);
  442. if (ret0)
  443. corr0 += outpos0 - nextpos0;
  444. if (ret1)
  445. corr1 += outpos1 - nextpos1;
  446. return ret0 || ret1;
  447. }
  448. }
  449. [BurstCompile]
  450. struct EdgeCollisionSumJob : IJobParallelFor
  451. {
  452. public int runCount;
  453. [Unity.Collections.ReadOnly]
  454. public NativeArray<GroupData> groupDataList;
  455. [Unity.Collections.ReadOnly]
  456. public NativeArray<ReferenceDataIndex> refDataList;
  457. [Unity.Collections.ReadOnly]
  458. public NativeArray<float3> writeBuffer;
  459. // チーム
  460. [Unity.Collections.ReadOnly]
  461. public NativeArray<PhysicsManagerTeamData.TeamData> teamDataList;
  462. [Unity.Collections.ReadOnly]
  463. public NativeArray<int> teamIdList;
  464. [Unity.Collections.ReadOnly]
  465. public NativeArray<PhysicsManagerParticleData.ParticleFlag> flagList;
  466. public NativeArray<float3> inoutNextPosList;
  467. public NativeArray<float> frictionList;
  468. // パーティクルごと
  469. public void Execute(int pindex)
  470. {
  471. var flag = flagList[pindex];
  472. if (flag.IsValid() == false || flag.IsFixed())
  473. return;
  474. // チーム
  475. var team = teamDataList[teamIdList[pindex]];
  476. if (team.IsActive() == false)
  477. return;
  478. if (team.edgeCollisionGroupIndex < 0)
  479. return;
  480. // 更新確認
  481. if (team.IsUpdate(runCount) == false)
  482. return;
  483. // グループデータ
  484. var gdata = groupDataList[team.edgeCollisionGroupIndex];
  485. if (gdata.active == 0)
  486. return;
  487. // 集計
  488. int start = team.particleChunk.startIndex;
  489. int index = pindex - start;
  490. var refdata = refDataList[gdata.refDataChunk.startIndex + index];
  491. if (refdata.count > 0)
  492. {
  493. float3 corr = 0;
  494. var bindex = gdata.writeDataChunk.startIndex + refdata.startIndex;
  495. for (int i = 0; i < refdata.count; i++)
  496. {
  497. corr += writeBuffer[bindex];
  498. bindex++;
  499. }
  500. corr /= refdata.count;
  501. // 加算
  502. inoutNextPosList[pindex] = inoutNextPosList[pindex] + corr;
  503. // 摩擦
  504. //if (math.lengthsq(corr) > 0.00001f)
  505. //if (math.lengthsq(corr) > 0.0f)
  506. {
  507. // 摩擦設定
  508. //frictionList[pindex] = math.max(frictionList[pindex], team.friction);
  509. }
  510. }
  511. }
  512. }
  513. }
  514. }