iw4x-client/src/Components/Modules/AssetInterfaces/IclipMap_t.hpp

81 lines
2.1 KiB
C++
Raw Normal View History

2017-01-20 08:36:52 -05:00
#pragma once
namespace Assets
{
class IclipMap_t : public Components::AssetHandler::IAsset
{
public:
2016-12-28 15:35:30 -05:00
virtual Game::XAssetType getType() override { return Game::XAssetType::ASSET_TYPE_CLIPMAP_PVS; };
virtual void save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void mark(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
virtual void load(Game::XAssetHeader* header, std::string name, Components::ZoneBuilder::Zone* builder) override;
private:
class SModelQuadtree
{
public:
2017-03-20 07:40:06 -04:00
SModelQuadtree(Game::cStaticModel_t* /*modelList*/, int numModels)
{
numValues = 0;
for (int i = 0; i < numModels; ++i)
{
}
}
void insert(Game::cStaticModel_t* item)
{
if (numValues < 4) // add here
{
values[numValues++] = item;
}
else // add to child
{
if (numValues == 4) // split
{
numValues++;
for (int i = 0; i < 4; ++i)
{
if (item->origin[0] > x && values[i]->origin[1] > y)
children[0]->insert(values[i]);
if (item->origin[0] < x && values[i]->origin[1] > y)
children[1]->insert(values[i]);
if (item->origin[0] < x && values[i]->origin[1] < y)
children[2]->insert(values[i]);
if (item->origin[0] > x && values[i]->origin[1] < y)
children[3]->insert(values[i]);
values[i] = nullptr;
}
for (int i = 0; i < 4; ++i)
{
children[i]->halfX = halfX / 2;
children[i]->halfY = halfY / 2;
children[i]->halfZ = halfZ / 2;
}
}
if (item->origin[0] > x && item->origin[1] > y)
children[0]->insert(item);
if (item->origin[0] < x && item->origin[1] > y)
children[1]->insert(item);
if (item->origin[0] < x && item->origin[1] < y)
children[2]->insert(item);
if (item->origin[0] > x && item->origin[1] < y)
children[3]->insert(item);
}
}
private:
SModelQuadtree* children[4];
Game::cStaticModel_t* values[4];
int numValues;
float x, y, z;
float halfX, halfY, halfZ;
};
};
}