Project

General

Profile

Feature #2474

OpenMW-CS: Optimize cell reference listing

Added by scrawl . over 2 years ago. Updated 10 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Editor
Target version:
Start date:
03/30/2015
% Done:

0%

Severity:
Normal

Description

There is some room for optimization in the reference listing code used for cell rendering, in particular this piece of code. https://github.com/OpenMW/openmw/blob/f6509fe53eeffd1fc3834616b68989b09300087c/apps/opencs/view/render/cell.cpp#L42 loops over all references in the game world and compares their cell names with the wanted cell.

I found that for just Morrowind.esm, this takes ~0.5 sec per cell, which seems a bit excessive compared to the time needed for actually rendering the objects.

For better performance the cell reference model should group references by the cell they are in, just like in OpenMW.

History

#1 Updated by Marc Zinnschlag over 2 years ago

We need the flat model in many situations (search, reference tables handling references from multiple cells, moving references between cells).

0.5 seconds does not sound so bad for a single cell, but it might be an issue when adding multiple cells at once. Depends on how it compares to other parts of the cell adding process (e.g. loading resources).

If performance is an issue, we could add a multimap to the reference collection which keeps track of which reference sits in which cell.

Maybe there are other ways to improve performance. The function you link goes through the Qt model. If we bypass that and use the reference collection directly that will save us one layer of indirection. No idea how much performance we could gain by that, but it is worth trying before any more complex methods are attempted.

#2 Updated by Marc Zinnschlag over 2 years ago

Maybe there are other ways to improve performance. The function you link goes through the Qt model. If we bypass that and use the reference collection directly that will save us one layer of indirection. No idea how much performance we could gain by that, but it is worth trying before any more complex methods are attempted.

Commit: https://github.com/OpenMW/openmw/commit/a9a8b5ad475bfbd80e0f5a390f849083d8507168

Improved performance from 417 ms to 269 ms on a random cell.

#3 Updated by scrawl . over 2 years ago

That's a good start.

Depends on how it compares to other parts of the cell adding process (e.g. loading resources).

Well, if the cell has been loaded already at some point in the past there are no resources to load. This isn't working well in the Ogre branch, because there was no way to make NIF's a resource. In the OSG branch the loading of previously loaded cells should be instant.

#4 Updated by Jeffrey Haines 11 months ago

  • Subject changed from Editor: optimize cell reference listing to OpenMW-CS: Optimize cell reference listing
  • Target version set to openmw-future

Unify all editor ticket subjects to start with "OpenMW-CS:"

#5 Updated by Alexei Dobrohotov 10 months ago

  • Target version changed from openmw-future to openmw-cs-1.0

Also available in: Atom PDF