multiple loops in Actors::update

Everything about development and the OpenMW source code.
Post Reply
User avatar
cc9cii
Posts: 523
Joined: 28 Mar 2013, 04:01

multiple loops in Actors::update

Post by cc9cii »

The subject is probably not explaining the issue/question properly. Maybe I don't quite understand how the code works, but it seems that the list of actors in a scene (across multiple cells) are being iterated unnecessarily. I'm guessing if there are n actors we check them n^2 times. Here is the bit of code with two print statements + a counter, standing next to our friendly tax collector:
Spoiler: Show
That generates in a couple of seconds:
Spoiler: Show
Aren't each of the actors already updated (and hence Actors::update() is called) so maybe there is no need to iterate through all of them again?
Hallfaer
Posts: 10
Joined: 15 May 2014, 17:10

Re: multiple loops in Actors::update

Post by Hallfaer »

I suspected this kind of stuff happening, and I explicitly mention that when trying to fix the summon death (In reply to: viewtopic.php?f=6&t=2223#p25055) we should avoid that kind of multiple-iteration. I'm think the current summons and bound weapons update code is free of this issue.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: multiple loops in Actors::update

Post by Zini »

The innermost loop makes an actor interact with all the guards in range. That is separate issue from updating.
User avatar
cc9cii
Posts: 523
Joined: 28 Mar 2013, 04:01

Re: multiple loops in Actors::update

Post by cc9cii »

I'm wondering whether we need to do the guard interactions so often (and the way I understand, multiple times)
Post Reply