[IGfxWorld] My terrible attempt at sorting gfxsurfaces
This commit is contained in:
parent
9e2fab7f54
commit
c02eede3f4
@ -18,6 +18,8 @@ namespace Assets
|
|||||||
asset->smodelInsts = reader->readArray<Game::GfxStaticModelInst>(asset->smodelCount);
|
asset->smodelInsts = reader->readArray<Game::GfxStaticModelInst>(asset->smodelCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<Game::GfxSurface*> surfs;
|
||||||
|
|
||||||
if (asset->surfaces)
|
if (asset->surfaces)
|
||||||
{
|
{
|
||||||
asset->surfaces = reader->readArray<Game::GfxSurface>(world->surfaceCount);
|
asset->surfaces = reader->readArray<Game::GfxSurface>(world->surfaceCount);
|
||||||
@ -25,6 +27,7 @@ namespace Assets
|
|||||||
for (unsigned int i = 0; i < world->surfaceCount; ++i)
|
for (unsigned int i = 0; i < world->surfaceCount; ++i)
|
||||||
{
|
{
|
||||||
Game::GfxSurface* surface = &asset->surfaces[i];
|
Game::GfxSurface* surface = &asset->surfaces[i];
|
||||||
|
surfs.push_back(&asset->surfaces[i]);
|
||||||
|
|
||||||
if (surface->material)
|
if (surface->material)
|
||||||
{
|
{
|
||||||
@ -33,6 +36,23 @@ namespace Assets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::sort(surfs.begin(), surfs.end(), [](Game::GfxSurface* a, Game::GfxSurface* b)
|
||||||
|
{
|
||||||
|
if (a->material->name == nullptr && b->material->name == nullptr) return false;
|
||||||
|
if (a->material->name == nullptr && b->material->name != nullptr) return true;
|
||||||
|
if (a->material->name != nullptr && b->material->name == nullptr) return false;
|
||||||
|
return strcmp(a->material->name, b->material->name) == 0;
|
||||||
|
});
|
||||||
|
|
||||||
|
Game::GfxSurface* tmpBuffer = builder->getAllocator()->allocateArray<Game::GfxSurface>(world->surfaceCount);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < world->surfaceCount; ++i)
|
||||||
|
{
|
||||||
|
std::memcpy(&tmpBuffer[i], surfs[i], sizeof(Game::GfxSurface));
|
||||||
|
}
|
||||||
|
|
||||||
|
asset->surfaces = tmpBuffer;
|
||||||
|
|
||||||
if (asset->surfacesBounds)
|
if (asset->surfacesBounds)
|
||||||
{
|
{
|
||||||
asset->surfacesBounds = reader->readArray<Game::GfxSurfaceBounds>(world->surfaceCount);
|
asset->surfacesBounds = reader->readArray<Game::GfxSurfaceBounds>(world->surfaceCount);
|
||||||
|
@ -545,7 +545,17 @@ namespace Game
|
|||||||
|
|
||||||
struct GfxDrawSurfFields
|
struct GfxDrawSurfFields
|
||||||
{
|
{
|
||||||
__int64 _bf0;
|
unsigned __int64 objectId : 16;
|
||||||
|
unsigned __int64 reflectionProbeIndex : 8;
|
||||||
|
unsigned __int64 hasGfxEntIndex : 1;
|
||||||
|
unsigned __int64 customIndex : 5;
|
||||||
|
unsigned __int64 materialSortedIndex : 12;
|
||||||
|
unsigned __int64 prepass : 2;
|
||||||
|
unsigned __int64 useHeroLighting : 1;
|
||||||
|
unsigned __int64 sceneLightIndex : 8;
|
||||||
|
unsigned __int64 surfType : 4;
|
||||||
|
unsigned __int64 primarySortKey : 6;
|
||||||
|
unsigned __int64 unused : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
union GfxDrawSurf
|
union GfxDrawSurf
|
||||||
@ -559,6 +569,7 @@ namespace Game
|
|||||||
unsigned int loadBits[2];
|
unsigned int loadBits[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#pragma pack(push, 4)
|
#pragma pack(push, 4)
|
||||||
struct Material
|
struct Material
|
||||||
{
|
{
|
||||||
@ -3052,6 +3063,8 @@ namespace Game
|
|||||||
float scale;
|
float scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct GfxStaticModelDrawInst
|
struct GfxStaticModelDrawInst
|
||||||
{
|
{
|
||||||
GfxPackedPlacement placement;
|
GfxPackedPlacement placement;
|
||||||
|
Loading…
Reference in New Issue
Block a user