| 181 | } |
| 182 | |
| 183 | static void HandleDiagonalShift(ItemInfo& item, CollisionInfo& coll, const Vector3i& pos, CardinalDirection quadrant, bool isRightShift) |
| 184 | { |
| 185 | // Calculate angles. |
| 186 | int sign = isRightShift ? 1 : -1; |
| 187 | short perpSplitAngle = (ANGLE(90.0f) * quadrant) + (ANGLE(45.0f) * sign); |
| 188 | short deltaAngle = abs(Geometry::GetShortestAngle(coll.Setup.ForwardAngle, perpSplitAngle)); |
| 189 | |
| 190 | // HACK: Force slight push left to avoid getting stuck. |
| 191 | float alpha = 1.0f - ((float)deltaAngle / (float)ANGLE(90.0f)); |
| 192 | if (alpha >= 0.5f) |
| 193 | item.Pose.Translate(perpSplitAngle, item.Animation.Velocity.z * alpha); |
| 194 | |
| 195 | // Set shift. |
| 196 | coll.Shift.Position.x += coll.Setup.PrevPosition.x - pos.x; |
| 197 | coll.Shift.Position.z += coll.Setup.PrevPosition.z - pos.z; |
| 198 | }; |
| 199 | |
| 200 | void GetCollisionInfo(CollisionInfo* coll, ItemInfo* item, const Vector3i& offset, bool resetRoom) |
| 201 | { |
no test coverage detected