MCPcopy Create free account
hub / github.com/axmolengine/axmol / slice

Method slice

tests/cpp-tests/Source/PhysicsTest/PhysicsTest.cpp:1189–1209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1187}
1188
1189bool PhysicsDemoSlice::slice(PhysicsWorld& /*world*/, const PhysicsRayCastInfo& info, void* /*data*/)
1190{
1191 if (info.shape->getBody()->getTag() != _sliceTag)
1192 {
1193 return true;
1194 }
1195
1196 if (!info.shape->containsPoint(info.start) && !info.shape->containsPoint(info.end))
1197 {
1198 Vec2 normal = info.end - info.start;
1199 normal = normal.getPerp().getNormalized();
1200 float dist = info.start.dot(normal);
1201
1202 clipPoly(dynamic_cast<PhysicsShapePolygon*>(info.shape), normal, dist);
1203 clipPoly(dynamic_cast<PhysicsShapePolygon*>(info.shape), -normal, -dist);
1204
1205 info.shape->getBody()->removeFromWorld();
1206 }
1207
1208 return true;
1209}
1210
1211void PhysicsDemoSlice::clipPoly(PhysicsShapePolygon* shape, Vec2 normal, float distance)
1212{

Callers 1

lazyInitMethod · 0.80

Calls 6

getTagMethod · 0.80
removeFromWorldMethod · 0.80
getBodyMethod · 0.45
containsPointMethod · 0.45
getNormalizedMethod · 0.45
dotMethod · 0.45

Tested by

no test coverage detected