Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/components/CCmpObstruction.cpp
Show First 20 Lines • Show All 765 Lines • ▼ Show 20 Lines | if (cmpObstructionManager->TestStaticShape(filter, pos.X, pos.Y, cmpPosition->GetRotation().Y, m_Size0, m_Size1, &collisions)) | ||||
persistentEnts.push_back(cmpObstruction->GetControlGroup()); | persistentEnts.push_back(cmpObstruction->GetControlGroup()); | ||||
} | } | ||||
// The collision can't be resolved without usable persistent control groups. | // The collision can't be resolved without usable persistent control groups. | ||||
if (persistentEnts.empty()) | if (persistentEnts.empty()) | ||||
return; | return; | ||||
// Attempt to replace colliding entities' control groups with a persistent one. | // Attempt to replace colliding entities' control groups with a persistent one. | ||||
for (std::vector<entity_id_t>::iterator it = normalEnts.begin(); it != normalEnts.end(); ++it) | for (const entity_id_t normalEnt : normalEnts) | ||||
wraitii: `const &` or no const (given that we like to pretend entity_id_t is opaque, const & perhaps) | |||||
{ | { | ||||
entity_id_t ent = *it; | CmpPtr<ICmpObstruction> cmpObstruction(GetSimContext(), normalEnt); | ||||
for (const entity_id_t persistent : normalEnts) | |||||
Done Inline Actionslikewise wraitii: likewise | |||||
CmpPtr<ICmpObstruction> cmpObstruction(GetSimContext(), ent); | |||||
for (std::vector<entity_id_t>::iterator it = persistentEnts.begin(); it != persistentEnts.end(); ++it) | |||||
{ | { | ||||
entity_id_t persistent = *it; | |||||
entity_id_t group = cmpObstruction->GetControlGroup(); | entity_id_t group = cmpObstruction->GetControlGroup(); | ||||
// Only clobber 'default' control groups. | // Only clobber 'default' control groups. | ||||
if (group == ent) | if (group == normalEnt) | ||||
cmpObstruction->SetControlGroup(persistent); | cmpObstruction->SetControlGroup(persistent); | ||||
else if (cmpObstruction->GetControlGroup2() == INVALID_ENTITY && group != persistent) | else if (cmpObstruction->GetControlGroup2() == INVALID_ENTITY && group != persistent) | ||||
cmpObstruction->SetControlGroup2(persistent); | cmpObstruction->SetControlGroup2(persistent); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
protected: | protected: | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
const & or no const (given that we like to pretend entity_id_t is opaque, const & perhaps)