Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/helpers/Selection.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
struct DefaultComponentFilter | struct DefaultComponentFilter | ||||
{ | { | ||||
bool operator()(IComponent* UNUSED(cmp)) | bool operator()(IComponent* UNUSED(cmp)) | ||||
{ | { | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
template<typename Filter = DefaultComponentFilter> | template<typename Filter = DefaultComponentFilter> | ||||
std::vector<entity_id_t> GetEntitiesWithComponentInRect(CSimulation2& simulation, int cid, const CCamera& camera, int sx0, int sy0, int sx1, int sy1) | std::vector<entity_id_t> GetEntitiesWithComponentInRect(CSimulation2& simulation, int cid, const CCamera& camera, int sx0, int sy0, int sx1, int sy1) | ||||
Stan: Is this used at all? | |||||
Done Inline ActionsGetEntitiesWithComponentInRect is called on line 120 of simulation2/scripting/JSInterface_Simulation.cpp. Mercury: GetEntitiesWithComponentInRect is called on line 120 of… | |||||
{ | { | ||||
PROFILE2("GetEntitiesWithObstructionInRect"); | PROFILE2("GetEntitiesWithObstructionInRect"); | ||||
// Make sure sx0 <= sx1, and sy0 <= sy1 | // Make sure sx0 <= sx1, and sy0 <= sy1 | ||||
if (sx0 > sx1) | if (sx0 > sx1) | ||||
std::swap(sx0, sx1); | std::swap(sx0, sx1); | ||||
if (sy0 > sy1) | if (sy0 > sy1) | ||||
std::swap(sy0, sy1); | std::swap(sy0, sy1); | ||||
std::vector<entity_id_t> hitEnts; | std::vector<entity_id_t> hitEnts; | ||||
Done Inline ActionsCan we resize it? Stan: Can we resize it? | |||||
Done Inline ActionsThat's a good idea, but seems out of scope of this patch? Mercury: That's a good idea, but seems out of scope of this patch? | |||||
Done Inline ActionsProbably. Since you were improving performance it seemed like a good candidate. Stan: Probably. Since you were improving performance it seemed like a good candidate. | |||||
Filter filter; | Filter filter; | ||||
const CSimulation2::InterfaceListUnordered& entities = simulation.GetEntitiesWithInterfaceUnordered(cid); | SComponentDataGenerator* entities = simulation.GetEntitiesWithInterfaceUnordered(cid); | ||||
Done Inline ActionsWhat's the use of this, since it's a method that always returns true? Stan: What's the use of this, since it's a method that always returns true? | |||||
Done Inline ActionsWhich method? Mercury: Which method? | |||||
Done Inline ActionsFilter is by default default filter which does nothing. Stan: Filter is by default default filter which does nothing. | |||||
for (const std::pair<const entity_id_t, IComponent*>& item : entities) | while(IComponent* cmp = entities->Next()) | ||||
{ | { | ||||
if (!filter(item.second)) | if (!filter(cmp)) | ||||
continue; | continue; | ||||
if (CheckEntityInRect(item.second->GetEntityHandle(), camera, sx0, sy0, sx1, sy1, false)) | if (CheckEntityInRect(cmp->GetEntityHandle(), camera, sx0, sy0, sx1, sy1, false)) | ||||
hitEnts.push_back(item.first); | hitEnts.push_back(cmp->GetEntityId()); | ||||
} | } | ||||
return hitEnts; | return hitEnts; | ||||
} | } | ||||
/** | /** | ||||
* Finds all entities with the given entity template name, belonging to the given player. | * Finds all entities with the given entity template name, belonging to the given player. | ||||
* | * | ||||
Show All 23 Lines |
Wildfire Games · Phabricator
Is this used at all?