Skip to content

Commit 575f94f

Browse files
recreate the view each for each loop in ground move system.
1 parent 03bad97 commit 575f94f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

rts/Sim/MoveTypes/Systems/GroundMoveSystem.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ using namespace MoveTypes;
1818
void GroundMoveSystem::Init() {}
1919

2020
void GroundMoveSystem::Update() {
21-
auto view = Sim::registry.view<GroundMoveType>();
22-
23-
size_t count = view.storage<GroundMoveType>().size();
24-
assert( count == view.size() );
2521
{
2622
SCOPED_TIMER("Sim::Unit::MoveType::1::UpdatePreCollisionsMT");
23+
auto view = Sim::registry.view<GroundMoveType>();
2724
for_mt(0, view.size(), [&view](const int i){
2825
auto entity = view.storage<GroundMoveType>()[i];
2926
auto unitId = view.get<GroundMoveType>(entity);
@@ -41,6 +38,7 @@ void GroundMoveSystem::Update() {
4138
}
4239
{
4340
SCOPED_TIMER("Sim::Unit::MoveType::2::UpdatePreCollisionsST");
41+
auto view = Sim::registry.view<GroundMoveType>();
4442
view.each([](GroundMoveType& unitId){
4543
CUnit* unit = unitHandler.GetUnit(unitId.value);
4644
AMoveType* moveType = unit->moveType;
@@ -50,7 +48,9 @@ void GroundMoveSystem::Update() {
5048
}
5149
{
5250
SCOPED_TIMER("Sim::Unit::MoveType::3::CollisionDetectionMT");
53-
for_mt(0, count, [&view](const int i){
51+
auto view = Sim::registry.view<GroundMoveType>();
52+
//size_t count = view.storage<GroundMoveType>().size();
53+
for_mt(0, view.size(), [&view](const int i){
5454
auto entity = view.storage<GroundMoveType>()[i];
5555
assert( Sim::registry.valid(entity) );
5656
assert( Sim::registry.all_of<GroundMoveType>(entity) );
@@ -66,6 +66,7 @@ void GroundMoveSystem::Update() {
6666
}
6767
{
6868
SCOPED_TIMER("Sim::Unit::MoveType::4::ProcessCollisionEvents");
69+
auto view = Sim::registry.view<GroundMoveType>();
6970
view.each([](GroundMoveType& unitId){
7071
CUnit* unit = unitHandler.GetUnit(unitId.value);
7172
AMoveType* moveType = unit->moveType;
@@ -74,6 +75,7 @@ void GroundMoveSystem::Update() {
7475
}
7576
{
7677
SCOPED_TIMER("Sim::Unit::MoveType::5::UpdateST");
78+
auto view = Sim::registry.view<GroundMoveType>();
7779
view.each([](GroundMoveType& unitId){
7880
CUnit* unit = unitHandler.GetUnit(unitId.value);
7981
AMoveType* moveType = unit->moveType;

0 commit comments

Comments
 (0)