From 01b98a40b9c6d8ace96538342ccdd6ac46fbbbe7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 22 Oct 2011 10:42:01 +0000 Subject: Initial support for the Material::Origin surface flag --- src/model/mapfile.cc | 7 +++++++ src/model/mapfile.h | 5 ++++- src/model/material.h | 26 ++++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) (limited to 'src/model') diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index b0f5bea..2cbee2b 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -169,6 +169,7 @@ MapFile::~MapFile() void MapFile::clear_materials() { + // delete primitives for each material for (Materials::iterator mit = map_materials.begin(); mit != map_materials.end(); mit++) { // delete list of primitives delete(*mit).second; @@ -176,6 +177,12 @@ void MapFile::clear_materials() map_materials.clear(); map_collisiontriangles.clear(); + + // delete origin vertices + for (std::vector::iterator ovit = class_origin_vertices.begin(); ovit != class_origin_vertices.end(); ovit++) { + delete (*ovit); + } + class_origin_vertices.clear(); } bool MapFile::open(std::string const & mapname) diff --git a/src/model/mapfile.h b/src/model/mapfile.h index 011c01d..551943e 100644 --- a/src/model/mapfile.h +++ b/src/model/mapfile.h @@ -174,7 +174,6 @@ private: /// list of planes for the current brush std::vector planes; - std::string classname_current; std::string key_current; std::string value_current; @@ -203,6 +202,10 @@ private: float class_distance; bool class_engine; + + /// list of vertices with the origin material within the current map class + std::vector class_origin_vertices; + Materials map_materials; TriangleList map_collisiontriangles; diff --git a/src/model/material.h b/src/model/material.h index 9b54dcc..885831c 100644 --- a/src/model/material.h +++ b/src/model/material.h @@ -24,7 +24,7 @@ public: typedef void(* LoaderFuncPtr)(Material *); /// surface flags - enum SurfaceFlags { None = 0, Primary = 1, Secondary = 2, Tertiary = 3, Bright = 4, Engine = 8, Environment = 16, Texture = 32, Ignore = 64, Clip = 128}; + enum SurfaceFlags { None = 0, Primary = 1, Secondary = 2, Tertiary = 3, Bright = 4, Engine = 8, Environment = 16, Texture = 32, Ignore = 64, Clip = 128, Origin = 256}; /// type definition for the material registry typedef std::map Registry; @@ -64,10 +64,32 @@ public: return material_size; } + /** + * @brief returns true if the material has the requested flag set + * */ + inline bool flag_is_set(const SurfaceFlags surfaceflag) const { + return ((material_flags & surfaceflag) == surfaceflag); + } + + /** + * @brief returns true if the material has the Ignore flag set + * @see flags() + * */ + inline bool ignore_is_set() const { + return (flag_is_set(Ignore)); + } + + /** + * @brief returns true if the material has the Origin flag set + * @see flags() + * */ + inline bool origin_is_set() const { + return (flag_is_set(Origin)); + } + /* ---- mutators ------------------------------------------- */ void set_color(const math::Color &color); - /** * @brief set the material texture name */ -- cgit v1.2.3