Mass

About
Screenshots
Download
Developement
Links

SourceForge.net Logo

(***) means this might be changed soon.

Engine Overview

TODO
  • about the height of the mass, heightfield blur
  • picture of a screenshot fited into cells
  • perhaps something about mass interfaces

Ownership and similar things

Masses

CreateMass() mallocs the space and returns it.
FreeMass() frees the memory.
PlaceMassNearby() does not transfer ownership.
AddMassToField() transfers ownership to field.c; refcounting starts.
RemoveMassFromField() tells field.c that the mass is dead. It will be freed as soon as all other references are gone.

m->interfaces

A MassInterface is a linked list which holds pointer to other masses that are nearby. Uses:
  • cache for the reaction for border pixels in touch with other masses, mi->borderreaction (***)
  • quickly check what other masses are touched: infection, wakeOnPlayer, lightning
  • keep track about how long a mass has already been nearby
It always contains useable values (***); it is the primary use of refcounting.

Field Cells

This is a cache to find masses inside a region without having to go through all masses. Those details are only relevant in field.c, after AddMassToField().
The field is divided into rectangular cells, each cell is a list of masses being in there. There are special cells, one for unclassified and oversized masses and one for zombies (masses that have been removed but are still referenced). This optimization was needed because GetMassesInRect() is called for every mass every round to find out about neighbour masses.

by martinxyz

Mirrors: sourceforge, old.homeip.net