added draw() in array mode

This commit is contained in:
h4570
2020-12-26 13:31:43 +01:00
parent 91772a905c
commit 7f9f86d7c3
3 changed files with 13 additions and 2 deletions
+7 -2
View File
@@ -60,8 +60,13 @@ void Floors::onUpdate()
player->update(engine->pad, camera, *floorManager, *enemy);
engine->renderer->draw(player->mesh);
engine->renderer->draw(enemy->getMeshes(), enemy->getMeshesCount());
for (u16 i = 0; i < FLOORS_COUNT; i++)
engine->renderer->draw(floorManager->floors[i].mesh, lightManager.bulbs, lightManager.bulbsCount);
// You can draw array of meshes in draw() function also. It can be A LOT faster than for looping!
// Why? When given mesh is small, is not animated and is not backface culled, vertex data are send once!
engine->renderer->draw(floorManager->getMeshes(), FLOORS_COUNT, lightManager.bulbs, lightManager.bulbsCount);
// draw() in array mode, sometimes will force you to do synchronization between EE <-> VU1 <-> GS via:
// renderer->clearAndWaitForRender(); or renderer->waitForRender();
ui->render(engine->renderer); // 2D rendering ist LAST step, because layers gonna play there.
}
@@ -22,6 +22,7 @@
*/
FloorManager::FloorManager(int t_floorAmount, TextureRepository *t_texRepo)
{
meshes = new Mesh *[t_floorAmount];
texRepo = t_texRepo;
floorAmount = t_floorAmount;
spirals = new Point[t_floorAmount];
@@ -85,12 +86,15 @@ void FloorManager::initFloors()
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
floors[0].mesh.shouldBeFrustumCulled = true;
floors[0].mesh.shouldBeLighted = true;
meshes[0] = &floors[0].mesh;
texRepo->addByMesh("meshes/floor/", floors[0].mesh, BMP);
for (u16 i = 1; i < floorAmount; i++)
{
floors[i].mesh.shouldBeFrustumCulled = true;
floors[i].init(floors[0].mesh, spirals[i], i);
texRepo->getByMesh(floors[0].mesh.getId(), floors[0].mesh.getMaterial(0).getId())
->addLink(floors[i].mesh.getId(), floors[i].mesh.getMaterial(0).getId());
meshes[i] = &floors[i].mesh;
}
PRINT_LOG("Floors initialized!");
}
@@ -31,8 +31,10 @@ public:
u16 floorAmount;
void update(Player &t_player);
void onAudioTick();
Mesh **getMeshes() { return meshes; }
private:
Mesh **meshes;
TextureRepository *texRepo;
u8 audioOffset, audioMode;
u32 audioTick;