MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / getHitPoint

Method getHitPoint

Source/Platformer/UnitAction.cpp:380–405  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

378}
379
380Vec2 Attack::getHitPoint(Body* self, Body* target, const pd::Shape& selfShape) {
381 Vec2 hitPoint{};
382 float distance = -1;
383 auto selfB = self->getPrBody();
384 auto targetB = target->getPrBody();
385 if (target->getPhysicsWorld() && target->getPhysicsWorld()->getPrWorld()) {
386 auto& world = *target->getPhysicsWorld()->getPrWorld();
387 const auto transformA = pd::GetTransformation(world, selfB);
388 for (pr::ShapeID f : pd::GetShapes(world, targetB)) {
389 if (!pd::IsSensor(world, f)) {
390 const auto proxyA = pd::GetChild(selfShape, 0);
391 const auto shapeB = pd::GetShape(world, f);
392 const auto proxyB = pd::GetChild(shapeB, 0);
393 const auto transformB = pd::GetTransformation(world, targetB);
394 pd::DistanceOutput output = Distance(proxyA, transformA, proxyB, transformB);
395 const auto witnessPoints = pd::GetWitnessPoints(output.simplex);
396 const auto outputDistance = pr::GetMagnitude(std::get<0>(witnessPoints) - std::get<1>(witnessPoints));
397 if (distance == -1 || distance > outputDistance) {
398 distance = outputDistance;
399 hitPoint = PhysicsWorld::Val(std::get<1>(witnessPoints));
400 }
401 }
402 }
403 }
404 return hitPoint;
405}
406
407// MeleeAttack
408

Callers

nothing calls this directly

Calls 14

GetShapesFunction · 0.85
GetShapeFunction · 0.85
DistanceFunction · 0.85
GetWitnessPointsFunction · 0.85
GetMagnitudeFunction · 0.85
get<0>Function · 0.85
get<1>Function · 0.85
ValFunction · 0.85
getPrBodyMethod · 0.80
getPrWorldMethod · 0.80
GetTransformationFunction · 0.50
IsSensorFunction · 0.50

Tested by

no test coverage detected