MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / HandleDiagonalShift

Function HandleDiagonalShift

TombEngine/Game/collision/collide_room.cpp:183–198  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183static 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
200void GetCollisionInfo(CollisionInfo* coll, ItemInfo* item, const Vector3i& offset, bool resetRoom)
201{

Callers 1

GetCollisionInfoFunction · 0.85

Calls 3

ANGLEFunction · 0.85
GetShortestAngleFunction · 0.85
TranslateMethod · 0.45

Tested by

no test coverage detected