private void RotateVec(Fix64 rot) { for (int i = 0; i < vertexInit.Length; i++) { vertex[i] = Fix64Vector2.Rotate(vertexInit[i], -rot); } Forward = Fix64Vector2.Rotate(initForward, -rot); }
internal void CalcCollisionDir(MGFObject mgfObject) { if (IsTrigger == true) { CollisionDir = Forward; return; } Fix64Vector2[] vertexO = mgfObject.GetVertex(); Fix64Vector2 v1 = Fix64Vector2.Rotate(vertexO[0], -(Fix64)90); Fix64Vector2 v2 = Fix64Vector2.Rotate(vertexO[1], -(Fix64)90); Fix64Vector2 v3 = -v1; Fix64Vector2 v4 = -v2; Fix64Vector2 dir = GetPos() - mgfObject.GetPos(); Fix64 d1 = Fix64Vector2.Dot(v1, dir); Fix64 d2 = Fix64Vector2.Dot(v2, dir); Fix64 d3 = Fix64Vector2.Dot(v3, dir); Fix64 d4 = Fix64Vector2.Dot(v4, dir); Fix64Vector2 collisionDirVertical = vertexO[0] - vertexO[1]; Fix64Vector2 collisionDirHorizontal = vertexO[1] - vertexO[2]; if (d1 >= Fix64.Zero && d4 >= Fix64.Zero) { if (Fix64Vector2.Dot(collisionDirHorizontal, Forward) > Fix64.Zero) { CollisionDir = Forward; } else { if (Fix64Vector2.Dot(collisionDirVertical, Forward) > Fix64.Zero) { CollisionDir = collisionDirVertical; } else { CollisionDir = -collisionDirVertical; } } } else if (d1 >= Fix64.Zero && d2 >= Fix64.Zero) { if (Fix64Vector2.Dot(collisionDirVertical, Forward) < Fix64.Zero) { CollisionDir = Forward; } else { if (Fix64Vector2.Dot(collisionDirHorizontal, Forward) > Fix64.Zero) { CollisionDir = collisionDirHorizontal; } else { CollisionDir = -collisionDirHorizontal; } } } else if (d2 >= Fix64.Zero && d3 >= Fix64.Zero) { if (Fix64Vector2.Dot(collisionDirHorizontal, Forward) < Fix64.Zero) { CollisionDir = Forward; } else { if (Fix64Vector2.Dot(collisionDirVertical, Forward) > Fix64.Zero) { CollisionDir = collisionDirVertical; } else { CollisionDir = -collisionDirVertical; } } } else if (d3 >= Fix64.Zero && d4 >= Fix64.Zero) { if (Fix64Vector2.Dot(collisionDirVertical, Forward) > Fix64.Zero) { CollisionDir = Forward; } else { if (Fix64Vector2.Dot(collisionDirHorizontal, Forward) > Fix64.Zero) { CollisionDir = collisionDirHorizontal; } else { CollisionDir = -collisionDirHorizontal; } } } }