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

Function TestBoundsCollideStatic

TombEngine/Game/collision/collide_item.cpp:587–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585}
586
587bool TestBoundsCollideStatic(ItemInfo* item, const StaticMesh& mesh, int radius)
588{
589 const auto& bounds = GetBoundsAccurate(mesh, false);
590
591 if (!(bounds.Z2 != 0 || bounds.Z1 != 0 || bounds.X1 != 0 || bounds.X2 != 0 || bounds.Y1 != 0 || bounds.Y2 != 0))
592 return false;
593
594 const auto& itemBounds = GetClosestKeyframe(*item).BoundingBox;
595 if (mesh.Pose.Position.y + bounds.Y2 <= item->Pose.Position.y + itemBounds.Y1)
596 return false;
597
598 if (mesh.Pose.Position.y + bounds.Y1 >= item->Pose.Position.y + itemBounds.Y2)
599 return false;
600
601 float sinY = phd_sin(mesh.Pose.Orientation.y);
602 float cosY = phd_cos(mesh.Pose.Orientation.y);
603
604 int x = item->Pose.Position.x - mesh.Pose.Position.x;
605 int z = item->Pose.Position.z - mesh.Pose.Position.z;
606 int dx = (x * cosY) - (z * sinY);
607 int dz = (z * cosY) + (x * sinY);
608
609 if (dx <= (radius + bounds.X2) &&
610 dx >= (bounds.X1 - radius) &&
611 dz <= (radius + bounds.Z2) &&
612 dz >= (bounds.Z1 - radius))
613 {
614 return true;
615 }
616 else
617 {
618 return false;
619 }
620}
621
622bool ItemPushItem(ItemInfo* item0, ItemInfo* item1, CollisionInfo* coll, bool enableSpasm, char bigPushFlags)
623{

Callers 1

DoObjectCollisionFunction · 0.85

Calls 2

phd_sinFunction · 0.85
phd_cosFunction · 0.85

Tested by

no test coverage detected