MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / polyCollision

Method polyCollision

source/game/interfaces/StarWorld.cpp:132–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130}
131
132bool World::polyCollision(PolyF const& poly, CollisionSet const& collisionSet) const {
133 auto geometry = this->geometry();
134 Vec2F polyCenter = poly.center();
135 PolyF translatedPoly;
136 bool collided = false;
137
138 forEachCollisionBlock(RectI::integral(poly.boundBox()).padded(1), [&](CollisionBlock const& block) {
139 if (collided || !isColliding(block.kind, collisionSet))
140 return;
141
142 Vec2F center = block.poly.center();
143 Vec2F newCenter = geometry.nearestTo(polyCenter, center);
144 translatedPoly = block.poly;
145 translatedPoly.translate(newCenter - center);
146 if (poly.intersects(translatedPoly))
147 collided = true;
148 });
149
150 return collided;
151}
152
153}

Callers 3

tickMasterMethod · 0.45
validateEdgeMethod · 0.45
isFreeSpaceMethod · 0.45

Calls 8

isCollidingFunction · 0.85
paddedMethod · 0.80
geometryMethod · 0.45
centerMethod · 0.45
boundBoxMethod · 0.45
nearestToMethod · 0.45
translateMethod · 0.45
intersectsMethod · 0.45

Tested by

no test coverage detected