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

Function HandleItemSphereCollision

TombEngine/Game/collision/sphere.cpp:16–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14namespace TEN::Collision::Sphere
15{
16 bool HandleItemSphereCollision(ItemInfo& item0, ItemInfo& item1)
17 {
18 auto spheres0 = item0.GetSpheres();
19 auto spheres1 = item1.GetSpheres();
20
21 item1.TouchBits.ClearAll();
22
23 if (spheres0.empty())
24 {
25 item0.TouchBits.ClearAll();
26 return false;
27 }
28
29 // Run through item 0 spheres.
30 bool isCollided = false;
31 for (int i = 0; i < spheres0.size(); i++)
32 {
33 // Get sphere 0.
34 const auto& sphere0 = spheres0[i];
35 if (sphere0.Radius <= 0.0f)
36 continue;
37
38 // Run through item 1 spheres.
39 for (int j = 0; j < spheres1.size(); j++)
40 {
41 // Get sphere 1.
42 const auto& sphere1 = spheres1[j];
43 if (sphere1.Radius <= 0.0f)
44 continue;
45
46 // Test sphere collision.
47 if (!sphere0.Intersects(sphere1))
48 continue;
49
50 // Set touch bits.
51 item0.TouchBits.Set(i);
52 item1.TouchBits.Set(j);
53
54 isCollided = true;
55 break;
56 }
57 }
58
59 return isCollided;
60 }
61}

Callers 15

SkidooManCollisionFunction · 0.85
GetVehicleMountTypeFunction · 0.85
CollideFirePendulumFunction · 0.85
CollideTurningBladeFunction · 0.85
CollideTrainFunction · 0.85
UPVPlayerCollisionFunction · 0.85
CollideThorHammerFunction · 0.85
DoorCollisionFunction · 0.85
SteelDoorCollisionFunction · 0.85
PoleCollisionFunction · 0.85
CollideMovingLaserFunction · 0.85
RollingBallCollisionFunction · 0.85

Calls 6

ClearAllMethod · 0.80
IntersectsMethod · 0.80
GetSpheresMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected