mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-09 20:32:43 +01:00
Remove defunct grid code
This commit is contained in:
parent
cd0a11d899
commit
280f83ecc7
@ -244,32 +244,6 @@ public:
|
||||
*/
|
||||
GameObject *getBlipTarget(const BlipData &blip) const;
|
||||
|
||||
/**
|
||||
* Stores objects within a grid cell, and their maximum
|
||||
* bounding radius
|
||||
*/
|
||||
struct GridCell
|
||||
{
|
||||
/**
|
||||
* Static instances within this grid cell
|
||||
*/
|
||||
std::set<GameObject*> instances;
|
||||
float boundingRadius = 0.f;
|
||||
};
|
||||
std::array<GridCell, WORLD_GRID_CELLS> worldGrid;
|
||||
|
||||
/**
|
||||
* returns true if the given object should be stored
|
||||
* within the grid
|
||||
*/
|
||||
bool shouldBeOnGrid(GameObject* object);
|
||||
void addToGrid(GameObject* object);
|
||||
|
||||
/**
|
||||
* Returns the grid coordinates for a world coordinates
|
||||
*/
|
||||
glm::ivec2 worldToGrid(const glm::vec2& world);
|
||||
|
||||
/**
|
||||
* Map of Model Names to Instances
|
||||
*/
|
||||
|
@ -209,11 +209,6 @@ InstanceObject *GameWorld::createInstance(const uint16_t id, const glm::vec3& po
|
||||
instancePool.insert(instance);
|
||||
allObjects.push_back(instance);
|
||||
|
||||
if( shouldBeOnGrid(instance) )
|
||||
{
|
||||
addToGrid( instance );
|
||||
}
|
||||
|
||||
modelInstances.insert({
|
||||
oi->modelName,
|
||||
instance
|
||||
@ -578,14 +573,6 @@ GameObject*GameWorld::getBlipTarget(const BlipData& blip) const
|
||||
|
||||
void GameWorld::destroyObject(GameObject* object)
|
||||
{
|
||||
auto coord = worldToGrid(glm::vec2(object->getPosition()));
|
||||
if( coord.x < 0 || coord.y < 0 || coord.x >= WORLD_GRID_WIDTH || coord.y >= WORLD_GRID_WIDTH )
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto index = (coord.x * WORLD_GRID_WIDTH) + coord.y;
|
||||
worldGrid[index].instances.erase(object);
|
||||
|
||||
auto& pool = getTypeObjectPool(object);
|
||||
pool.remove(object);
|
||||
|
||||
@ -613,42 +600,6 @@ void GameWorld::destroyQueuedObjects()
|
||||
}
|
||||
}
|
||||
|
||||
bool GameWorld::shouldBeOnGrid(GameObject* object)
|
||||
{
|
||||
if( object->type() != GameObject::Instance )
|
||||
{
|
||||
// Only static instances currently.
|
||||
return false;
|
||||
}
|
||||
auto instance = static_cast<InstanceObject*>(object);
|
||||
return instance->body == nullptr || instance->body->body->isStaticObject();
|
||||
}
|
||||
|
||||
void GameWorld::addToGrid(GameObject* object)
|
||||
{
|
||||
auto coord = worldToGrid(glm::vec2(object->getPosition()));
|
||||
if( coord.x < 0 || coord.y < 0 || coord.x >= WORLD_GRID_WIDTH || coord.y >= WORLD_GRID_WIDTH )
|
||||
{
|
||||
return;
|
||||
}
|
||||
auto index = (coord.x * WORLD_GRID_WIDTH) + coord.y;
|
||||
worldGrid[index].instances.insert(object);
|
||||
if( object->model->resource )
|
||||
{
|
||||
float cellhalf = WORLD_CELL_SIZE/2.f;
|
||||
auto world = glm::vec3(glm::vec2(coord) * glm::vec2(WORLD_CELL_SIZE) - glm::vec2(WORLD_GRID_SIZE/2.f) + glm::vec2(cellhalf), 0.f);
|
||||
auto offset = world - object->getPosition();
|
||||
float maxRadius = glm::length(offset) + object->model->resource->getBoundingRadius();
|
||||
worldGrid[index].boundingRadius = std::max(worldGrid[index].boundingRadius, maxRadius);
|
||||
}
|
||||
}
|
||||
|
||||
glm::ivec2 GameWorld::worldToGrid(const glm::vec2& world)
|
||||
{
|
||||
static const float lowerCoord = -(WORLD_GRID_SIZE)/2.f;
|
||||
return glm::ivec2((world - glm::vec2(lowerCoord)) / glm::vec2(WORLD_CELL_SIZE));
|
||||
}
|
||||
|
||||
VisualFX* GameWorld::createEffect(VisualFX::EffectType type)
|
||||
{
|
||||
auto effect = new VisualFX( type );
|
||||
|
Loading…
Reference in New Issue
Block a user