Navigation Menu

Skip to content

Commit

Permalink
Refactor: Moved editable map elements into Map
Browse files Browse the repository at this point in the history
Upon instantiation a Map is initially configured in editable mode.
The map edit API calls Map::endEditing() to signal that editing has
completed. At which point the new map elements are transferred from
the editable element lists, a BSP is built (todo: defer this) and
the map is switched to non-editable mode.

Todo: Cleanup.
  • Loading branch information
danij-deng committed Jun 9, 2013
1 parent 5013d25 commit b0d6b78
Show file tree
Hide file tree
Showing 3 changed files with 741 additions and 677 deletions.
40 changes: 40 additions & 0 deletions doomsday/client/include/world/map.h
Expand Up @@ -87,6 +87,9 @@ class Map
DENG2_ERROR(MissingLightGridError);
#endif

/// Base error for runtime map editing errors. @ingroup errors
DENG2_ERROR(EditError);

typedef QList<Vertex *> Vertexes;
typedef QList<Sector *> Sectors;
typedef QList<Line *> Lines;
Expand Down Expand Up @@ -149,6 +152,19 @@ class Map

int _ambientLightLevel; // Ambient lightlevel for the current map.

struct EditableElements
{
Map::Vertexes vertexes;
Map::Lines lines;
Map::Sectors sectors;
Map::Polyobjs polyobjs;

/// Map entities and element properties (things, line specials, etc...).
EntityDatabase *entityDatabase;

EditableElements() : entityDatabase(0) {}
} editable;

public:
Map();
~Map();
Expand Down Expand Up @@ -761,6 +777,30 @@ class Map

#endif // __CLIENT__

public:
/*
* Runtime map editiing:
*/

/// @return @c true= a new BSP was built successfully for the map.
bool endEditing();

Vertex *createVertex(Vector2d const &origin,
int archiveIndex = MapElement::NoIndex);

Line *createLine(Vertex &v1, Vertex &v2, int flags = 0,
Sector *frontSector = 0, Sector *backSector = 0,
int archiveIndex = MapElement::NoIndex);

Sector *createSector(float lightLevel, Vector3f const &lightColor,
int archiveIndex = MapElement::NoIndex);

Polyobj *createPolyobj(Vector2d const &origin);

void clearEditableElements();

void pruneEditableVertexes();

private:
DENG2_PRIVATE(d)
};
Expand Down

0 comments on commit b0d6b78

Please sign in to comment.