internal void RemoveObject(PSortableObject ox, PSortableObject oy) { int indexX = -1; int indexY = -1; for (int i = 0; i < numObject; i++) { if (objsX[i] != ox) continue; indexX = i; break; } if (indexX != -1 && indexX != numObject - 1) System.Array.Copy((objsX),indexX + 1,(objsX),indexX,numObject - indexX - 1); for (int i_0 = 0; i_0 < numObject; i_0++) { if (objsY[i_0] != oy) continue; indexY = i_0; break; } if (indexY != -1 && indexY != numObject - 1) System.Array.Copy((objsY),indexY + 1,(objsY),indexY,numObject - indexY - 1); numObject--; }
internal void AddObject(PSortableObject ox, PSortableObject oy) { if (numObject + 1 >= objsX.Length) { objsX = (PSortableObject[]) CollectionUtils.CopyOf(objsX, objsX.Length * 2); objsY = (PSortableObject[]) CollectionUtils.CopyOf(objsY, objsY.Length * 2); } objsX[numObject] = ox; objsY[numObject] = oy; numObject++; }
public void Set(PSweepAndPrune sap, PShape s, AABB aabb) { set = true; this.sap = sap; parent = s; this.aabb = aabb; beginX = new PSortableObject(s, this, aabb.minX, true); beginY = new PSortableObject(s, this, aabb.minY, true); endX = new PSortableObject(s, this, aabb.maxX, false); endY = new PSortableObject(s, this, aabb.maxY, false); sap.AddObject(beginX, beginY); sap.AddObject(endX, endY); }
internal void AddObject(PSortableObject ox, PSortableObject oy) { if (numObject + 1 >= objsX.Length) { objsX = (PSortableObject[])CollectionUtils.CopyOf(objsX, objsX.Length * 2); objsY = (PSortableObject[])CollectionUtils.CopyOf(objsY, objsY.Length * 2); } objsX[numObject] = ox; objsY[numObject] = oy; numObject++; }
internal void RemoveObject(PSortableObject ox, PSortableObject oy) { int indexX = -1; int indexY = -1; for (int i = 0; i < numObject; i++) { if (objsX[i] != ox) { continue; } indexX = i; break; } if (indexX != -1 && indexX != numObject - 1) { System.Array.Copy((objsX), indexX + 1, (objsX), indexX, numObject - indexX - 1); } for (int i_0 = 0; i_0 < numObject; i_0++) { if (objsY[i_0] != oy) { continue; } indexY = i_0; break; } if (indexY != -1 && indexY != numObject - 1) { System.Array.Copy((objsY), indexY + 1, (objsY), indexY, numObject - indexY - 1); } numObject--; }
private void Collide(long st) { PSortableObject[] obj = sap.Sort(); if (sap.checkX) { for (int i = 0; i < sap.numObject; i++) { if (obj[i].begin) { PSortableObject end = obj[i].aabb.endX; PShape s1 = obj[i].parent; int j = i; do { j++; if (obj[j].begin) { PShape s2 = obj[j].parent; if ((!s1._parent.fix || !s2._parent.fix) && s1._parent != s2._parent && s1._aabb.IsHit(s2._aabb)) { CollisionShape(s1, s2, cc); } } } while (obj[j] != end && j < sap.numObject); } } } else { for (int i_0 = 0; i_0 < sap.numObject; i_0++) { if (obj[i_0].begin) { PSortableObject end_1 = obj[i_0].aabb.endY; PShape s1_2 = obj[i_0].parent; int j_3 = i_0; do { j_3++; if (obj[j_3].begin) { PShape s2_4 = obj[j_3].parent; if ((!s1_2._parent.fix || !s2_4._parent.fix) && s1_2._parent != s2_4._parent && s1_2._aabb.IsHit(s2_4._aabb)) { CollisionShape(s1_2, s2_4, cc); } } } while (obj[j_3] != end_1 && j_3 < sap.numObject); } } } long en = (System.DateTime.Now.Ticks * 100); collisionDetectionTime = en - st; for (int i_5 = 0; i_5 < numSolvers; i_5++) { if (solvers[i_5].rem) { RemoveSolver(i_5); i_5--; } } }