Recent Changes - Search:

Main.SideBar (edit)

PmWiki

GroundTypes

Problems

Problems with current ground types/ground theme:

  • All ground types (textures) are always loaded, even when they're not used by current map. With the 7 ground types we have atm, this is not very bad, but in the future we might have tens of ground types and that means quite a big memory overhead already, plus loading times will increase.
    AB: There is an error in this argument. You assume that every new groundtype is also included in the groundtheme, which would be stupid nonsense. Only a few (<10) groundtypes should be used per theme.
    RL: I don't think it's nonsense. You might want to use few different types of grass, few different types of desert, etc. Plus there might be many more different ground types in the future (e.g. concrete, soil, etc). I thought groundthemes should be for totally different grounds (e.g. earth, mars, moon, etc).
  • Map's texmap is stored for all ground types, even if certain ground type isn't used by the map. This makes map files unnecessary big.
    AB: However it also makes accessing the data very fast, as we can use a simple array access
  • Lots of different method in BosonGroundTheme to access data (e.g. textures, animationdelay) of a single ground type.
    AB: Note that the current design is built upon assumptions that are partially obsolete now. For example when it was implemented we required (IIRC) to have random access to different groundtypes. This is not the case anymore: storing all groundtypes in a simple linked list would be sufficient (and more powerful, as adding new types is more easy - it's essentially similar to what you propose here)

Solution

Introduce public BosonGroundType class:

  class BosonGroundType
  {
  public:
    int id;
    BoTextureArray* textures;
    QString texturefile;
    int animationDelay;
    QString name;
    // Maybe change to BoVector3Float?
    QRgb color;
    QPixmap* icon;
    QString iconfile;
  };

This class would be visible to other classes and could be used to get certain info/data of a ground type, such as it's textures or icon.
ATM such data is accessible through BosonGroundTheme which has different methods to get texture, icon, etc.
By grouping all relevant data into single class and making it publicly accessible, I think it'd be easier to get all necessary data about a ground type, especially as additional data (e.g. bumpmaps) might be added in the future.

AB: sounds good so far, I agree.

Loading

ATM we have "Boson Ground" group in index.ground, which includes the number of textures (ground types) in the file. Each texture has group "Texture_n", where n is number from 0 to texturecount-1.
This might be a bit uncomfortable when adding new ground types, because you need to check which number you can use and also remember to increase textureCount in the main group.

AB: I don't see your point here. All you need to do is to increase texturecount and add the texture to the end. Where is the problem? (btw: this is the standard way of saving linked lists to kconfig files)

So I'm proposing to make it group-based instead: all ground types would be in groups "Ground-name" where name would be a string which would identify the ground type. So we'd also use strings instead of integers as ids. At loading time, we can easily assign numeric id to every ground type (e.g. in the order of loading) to speed up in-game queries.

AB: I don't see the gain from this. Why do we need to add so much complexity? After all no user/designer should ever look at index.ground, but rather use a tool that generates it. The index.ground file is for loading only. With your proposal you need to iterate all groups in the file, which can be very error prone in kconfig files, as old groups are not necessarily deleted. E.g. you can have texture count=10 but have Texture_0 .. Texture_100 groups. Everything above Texture_19 would be simply ignored when loading.
RL: Yeah, ground type editor would make this pointless indeed... Ok, then I won't make this change.

Maps

Maps would store a texmap for every used ground type.
Texmap files would be in form map/texmap-name (atm: map/texmap) where name would be string id of the ground type.
When loading map, we could easily check which ground types are used by the map and load only the necessary ones.

AB: seems good, would make index.ground files obsolete, no?
RL: No, index.ground would still be used to load description of each (used) ground type. It's just that texmap of each ground type would be stored in a different file.
Edit - History - Print - Recent Changes - Search
Page last modified on May 14, 2005, at 16:05