Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix steam audio mesh loader #64

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Loaders/GoldSrcFileBuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace MetaAudio
}

FILESYSTEM_ANY_SEEK(mFile, static_cast<int>(offset), seekType);
auto curPosition = g_pFileSystem->Tell(mFile);
auto curPosition = FILESYSTEM_ANY_TELL(mFile);

setg(nullptr, nullptr, nullptr);
return curPosition;
Expand Down
23 changes: 20 additions & 3 deletions src/Loaders/SteamAudioMapMeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include "Utilities/VectorUtils.hpp"
#include "Loaders/SteamAudioMapMeshLoader.hpp"

extern int g_iEngineType;

namespace MetaAudio
{
constexpr const float EPSILON = 0.000001f;
Expand Down Expand Up @@ -67,13 +69,26 @@ namespace MetaAudio

for (int i = 0; i < mapModel->nummodelsurfaces; ++i)
{
auto surface = mapModel->surfaces[mapModel->firstmodelsurface + i];
glpoly_t* poly = surface.polys;
glpoly_t* firstPoly = nullptr;
if (g_iEngineType == ENGINE_GOLDSRC_HL25)
{
msurface_hl25_t* surfaces = reinterpret_cast<msurface_hl25_t*>(mapModel->surfaces);
msurface_hl25_t* surface = &surfaces[mapModel->firstmodelsurface + i];
firstPoly = surface->polys;
}
else
{
msurface_t* surface = &mapModel->surfaces[mapModel->firstmodelsurface + i];
firstPoly = surface->polys;
}
std::vector<alure::Vector3> surfaceVerts;
glpoly_t* poly = firstPoly;
while (poly)
{
if (poly->numverts <= 0)
{
continue;
}

for (int j = 0; j < poly->numverts; ++j)
{
Expand All @@ -83,8 +98,10 @@ namespace MetaAudio
poly = poly->next;

// escape rings
if (poly == surface.polys)
if (poly == firstPoly)
{
break;
}
}

// triangulation
Expand Down
Loading