slight entity rework (todo: memory corruption >.<)

This commit is contained in:
Asuro
2025-05-31 01:39:34 +02:00
parent 383c6f975b
commit 196d119338
16 changed files with 773 additions and 392 deletions

View File

@@ -29,7 +29,12 @@ namespace Game
{
void EntityRenderData::Render(const Model* models, const Material* materials, const Texture* textures)
{
if (DebugBreakOnRender) bx::debugBreak();
if (DebugBreakOnRender)
{
bx::debugBreak();
DebugBreakOnRender = false;
}
if (models == nullptr || materials == nullptr || textures == nullptr) return;
if (!Gen::IsValid(ModelH) || MaterialHandle >= EMaterial::EntryCount) return;
if (!Visible) return;
@@ -201,7 +206,9 @@ namespace Game
}
PuzzleUI.Setup();
TabletHandle = UIQuads.New();
ReloadLevelEntities();
UpdatePlayerInputMode();
}
@@ -272,18 +279,6 @@ namespace Game
UpdatePlayerInputMode();
}
// UI Tablet
if (IsValid(TabletHandle))
{
auto& tablet = UIQuads.Get(TabletHandle);
tablet.EData.LoadFromSaved(player.Config.TabletBackgroundRenderData);
UpdateMatrix(player.PlayerCamTransform);
tablet.EData.Transform.Rotation = player.PlayerCamTransform.Rotation;
Rotate(tablet.EData.Transform, {0.5f * bx::kPi, 0.0f, 0.0f});
tablet.EData.Transform.Position =
player.PlayerCamTransform.Position + AxisForward(player.PlayerCamTransform.M) * 1.0f;
}
// Cubes
for (uint16_t i = 0; i < Cubes.Count; ++i)
{
@@ -342,6 +337,7 @@ namespace Game
{
UIQuads.Render(models, materials, textures);
}
LevelEntities.Render(models, materials, textures);
}
void Cube::Setup()
@@ -440,4 +436,16 @@ namespace Game
}
}
}
void Level::ReloadLevelEntities()
{
LevelEntities.Count = 0;
for (int32_t i = 0; i < BX_COUNTOF(BackgroundEntityHandles); ++i)
{
BackgroundEntityHandles[i] = LevelEntities.New();
auto& levelBgEntity = LevelEntities.Get(BackgroundEntityHandles[i]);
levelBgEntity.EData.LoadFromSaved(GetInstance().Player.Config.BackgroundLevelRenderData[i]);
}
}
} // namespace Game