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

Function FindPlinth

TombEngine/Game/pickup/pickup.cpp:1029–1070  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1027}
1028
1029const GameBoundingBox* FindPlinth(ItemInfo* item)
1030{
1031 auto coll = GetLosCollision(item->Pose.Position.ToVector3(), item->RoomNumber, Vector3::UnitY, CLICK(1), true, false, true);
1032
1033 if (!coll.Statics.empty())
1034 {
1035 for (auto& staticLosEntry : coll.Statics)
1036 {
1037 auto& staticObj = *staticLosEntry.Static;
1038
1039 if (!(staticObj.Flags & StaticMeshFlags::SM_VISIBLE))
1040 continue;
1041
1042 const auto& bounds = GetClosestKeyframe(*item).BoundingBox;
1043 auto& bBox = GetBoundsAccurate(staticObj, false);
1044
1045 if (bounds.X1 <= bBox.X2 && bounds.X2 >= bBox.X1 &&
1046 bounds.Z1 <= bBox.Z2 && bounds.Z2 >= bBox.Z1 &&
1047 (bBox.X1 || bBox.X2))
1048 {
1049 return &bBox;
1050 }
1051 }
1052 }
1053
1054 if (!coll.Items.empty())
1055 {
1056 for (auto& itemLosEntry : coll.Items)
1057 {
1058 auto& currentItem = *itemLosEntry.Item;
1059 auto& object = Objects[currentItem.ObjectNumber];
1060
1061 if (!object.isPickup && (currentItem.ObjectNumber != ID_HIGH_OBJECT1 || currentItem.ItemFlags[0] == 5))
1062 return &GetClosestKeyframe(g_Level.Items[currentItem.Index]).BoundingBox;
1063 }
1064 }
1065
1066 constexpr int MIN_BOUND = CLICK(0.5f);
1067 static auto defautBounds = GameBoundingBox(-MIN_BOUND, MIN_BOUND, 0, MIN_BOUND, -MIN_BOUND, MIN_BOUND);
1068
1069 return &defautBounds;
1070}
1071
1072void InitializePickup(short itemNumber)
1073{

Callers 1

PickupCollisionFunction · 0.85

Calls 4

GetLosCollisionFunction · 0.85
GameBoundingBoxClass · 0.70
ToVector3Method · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected