| 498 | //--------------------------------------------------------------------------- |
| 499 | |
| 500 | static void renderDrawMapView(const DVector2& cpos, const DVector2& cangvect, const DVector2& xydim) |
| 501 | { |
| 502 | TArray<FVector4> vertices; |
| 503 | TArray<DCoreActor*> floorsprites; |
| 504 | |
| 505 | for (int i = (int)sector.Size() - 1; i >= 0; i--) |
| 506 | { |
| 507 | auto sect = §or[i]; |
| 508 | if (!gFullMap && !show2dsector[i]) continue; |
| 509 | |
| 510 | //Collect floor sprites to draw |
| 511 | TSectIterator<DCoreActor> it(sect); |
| 512 | while (auto act = it.Next()) |
| 513 | { |
| 514 | if (act->spr.cstat & CSTAT_SPRITE_INVISIBLE) |
| 515 | continue; |
| 516 | |
| 517 | if (act->spr.cstat & CSTAT_SPRITE_ALIGNMENT_FLOOR) // floor and slope sprites |
| 518 | { |
| 519 | if ((act->spr.cstat & (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_YFLIP)) == (CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_YFLIP)) |
| 520 | continue; // upside down |
| 521 | floorsprites.Push(act); |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | if (sect->floorstat & CSTAT_SECTOR_SKY) continue; |
| 526 | |
| 527 | auto flortex = sect->floortexture; |
| 528 | if (!flortex.isValid()) continue; |
| 529 | |
| 530 | auto translation = TRANSLATION(Translation_Remap + curbasepal, sector[i].floorpal); |
| 531 | PalEntry light = shadeToLight(sector[i].floorshade); |
| 532 | |
| 533 | for (auto section : sectionsPerSector[i]) |
| 534 | { |
| 535 | TArray<int>* indices; |
| 536 | auto mesh = sectionGeometry.get(§ions[section], 0, { 0.f, 0.f }, &indices); |
| 537 | vertices.Resize(mesh->vertices.Size()); |
| 538 | for (unsigned j = 0; j < mesh->vertices.Size(); j++) |
| 539 | { |
| 540 | auto v = OutAutomapVector(DVector2(mesh->vertices[j].X - cpos.X, -mesh->vertices[j].Y - cpos.Y), cangvect, gZoom, xydim); |
| 541 | vertices[j] = { float(v.X), float(v.Y), mesh->texcoords[j].X, mesh->texcoords[j].Y }; |
| 542 | } |
| 543 | |
| 544 | twod->AddPoly(TexMan.GetGameTexture(flortex, true), vertices.Data(), vertices.Size(), (unsigned*)indices->Data(), indices->Size(), translation, light, |
| 545 | LegacyRenderStyles[STYLE_Translucent], &viewport3d); |
| 546 | } |
| 547 | } |
| 548 | qsort(floorsprites.Data(), floorsprites.Size(), sizeof(DCoreActor*), [](const void* a, const void* b) |
| 549 | { |
| 550 | auto A = *(DCoreActor**)a; |
| 551 | auto B = *(DCoreActor**)b; |
| 552 | if (A->spr.pos.Z < B->spr.pos.Z) return 1; |
| 553 | if (A->spr.pos.Z > B->spr.pos.Z) return -1; |
| 554 | return A->time - B->time; // ensures stable sort. |
| 555 | }); |
| 556 | |
| 557 | vertices.Resize(4); |
no test coverage detected