MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / doTwoSectorsIntersect

Function doTwoSectorsIntersect

game/state/rules/battle/battlemap.cpp:383–399  ·  view source on GitHub ↗

Checks whether two cubes intersect s1 = size of sector 1, x1, y1, z1 = coordinate of sector 1 s2 = size of sector 2, x2, y2, z2 = coordinate of sector 2

Source from the content-addressed store, hash-verified

381// s1 = size of sector 1, x1, y1, z1 = coordinate of sector 1
382// s2 = size of sector 2, x2, y2, z2 = coordinate of sector 2
383bool doTwoSectorsIntersect(int x1, int y1, int z1, Vec3<int> s1, int x2, int y2, int z2,
384 Vec3<int> s2)
385{
386 return
387 // 1's right > 2's left
388 x1 + s1.x > x2
389 // 2's right > 1's left
390 && x2 + s2.x > x1
391 // 1's top > 2's bottom
392 && z1 + s1.z > z2
393 // 2's top > 1's bottom
394 && z2 + s2.z > z1
395 // 1's front > 2's back
396 && y1 + s1.y > y2
397 // 2's front > 1's back
398 && y2 + s2.y > y1;
399}
400
401bool doesCellIntersectSomething(std::vector<sp<BattleMapSector>> &sec_map,
402 const Vec3<int> &map_size, int x1, int y1, int z1)

Callers 3

placeSectorFunction · 0.85
initNewMapMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected