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

Method renderCollisionDebug

source/game/StarWorldClient.cpp:2349–2382  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2347}
2348
2349void WorldClient::renderCollisionDebug() {
2350 RectI clientWindow = m_clientState.window();
2351 if (clientWindow.isEmpty())
2352 return;
2353
2354 auto logPoly = [](PolyF poly, Vec2F position, float r, float g, float b) {
2355 poly.translate(position);
2356 SpatialLogger::logPoly("world", poly, {floatToByte(r, true), floatToByte(g, true), floatToByte(b, true), 255});
2357 };
2358
2359 forEachCollisionBlock(clientWindow, [&](auto const& block) {
2360 logPoly(block.poly, Vec2F{}, 1.0f, 0.0f, 0.0f);
2361 });
2362
2363 for (auto const& object : query<TileEntity>(RectF(clientWindow))) {
2364 for (auto const& space : object->spaces())
2365 logPoly(PolyF(RectF(Vec2F(space), Vec2F(space) + Vec2F(1, 1))), Vec2F(object->tilePosition()), 0., 1., 0.);
2366 }
2367
2368 for (auto const& physics : query<PhysicsEntity>(RectF(clientWindow))) {
2369 for (auto const& forceRegion : physics->forceRegions()) {
2370 if (auto dfr = forceRegion.ptr<DirectionalForceRegion>())
2371 logPoly(dfr->region, {}, 1.0f, 1.0f, 0.0f);
2372 else if (auto rfr = forceRegion.ptr<RadialForceRegion>())
2373 logPoly(PolyF(rfr->boundBox()), {}, 0.0f, 1.0f, 1.0f);
2374 }
2375
2376 for (size_t i = 0; i < physics->movingCollisionCount(); ++i) {
2377 if (auto pmc = physics->movingCollision(i)) {
2378 logPoly(pmc->collision, pmc->position, 1.0f, 1.0f, 1.0f);
2379 }
2380 }
2381 }
2382}
2383
2384void WorldClient::informTilePrediction(Vec2I const& pos, TileModification const& modification) {
2385 auto now = Time::monotonicMilliseconds();

Callers

nothing calls this directly

Calls 10

floatToByteFunction · 0.85
windowMethod · 0.45
isEmptyMethod · 0.45
translateMethod · 0.45
spacesMethod · 0.45
tilePositionMethod · 0.45
forceRegionsMethod · 0.45
boundBoxMethod · 0.45
movingCollisionCountMethod · 0.45
movingCollisionMethod · 0.45

Tested by

no test coverage detected