diff options
Diffstat (limited to 'src/model')
-rw-r--r-- | src/model/asefile.cc | 5 | ||||
-rw-r--r-- | src/model/fragment.cc | 2 | ||||
-rw-r--r-- | src/model/fragment.h | 29 | ||||
-rw-r--r-- | src/model/mapfile.cc | 2 | ||||
-rw-r--r-- | src/model/vertexarray.cc | 3 | ||||
-rw-r--r-- | src/model/vertexarray.h | 11 |
6 files changed, 32 insertions, 20 deletions
diff --git a/src/model/asefile.cc b/src/model/asefile.cc index f02c450..0275603 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -686,8 +686,9 @@ Model *ASEFile::load(const std::string &name) model->model_maxbbox.assign (asefile.ase_maxbbox * SCALE); model->set_radius(math::max(model->model_minbbox.length(), model->model_maxbbox.length())); - for (FragmentGroup::iterator fit = asefile.fragmentgroup()->begin(); fit != asefile.fragmentgroup()->end(); fit++) { - Fragment *fragment = (*fit); + for (FragmentGroup::Fragments::const_iterator fit = asefile.fragmentgroup()->fragments().begin(); fit != asefile.fragmentgroup()->fragments().end(); fit++) { + + const Fragment *fragment = (*fit); model->model_tris_count += fragment->structural_size() + fragment->detail_size(); } model->add_group(asefile.fragmentgroup()); diff --git a/src/model/fragment.cc b/src/model/fragment.cc index 9071b00..30e89e0 100644 --- a/src/model/fragment.cc +++ b/src/model/fragment.cc @@ -74,7 +74,7 @@ FragmentGroup::~FragmentGroup() void FragmentGroup::clear() { - for (iterator it = group_fragments.begin(); it != group_fragments.end(); it++) { + for (Fragments::iterator it = group_fragments.begin(); it != group_fragments.end(); it++) { delete(*it); } group_fragments.clear(); diff --git a/src/model/fragment.h b/src/model/fragment.h index 6d65f7a..9da30b0 100644 --- a/src/model/fragment.h +++ b/src/model/fragment.h @@ -81,11 +81,14 @@ class FragmentGroup public: enum Type {None = 0, Rotate = 1, Door = 2 }; - typedef std::list<Fragment *>::iterator iterator; + /// type definition for a list of model fragments + typedef std::list<Fragment *> Fragments; FragmentGroup(); ~FragmentGroup(); + + /* ---- inspectors ----------------------------------------- */ inline const Type type() const { return group_type; @@ -111,7 +114,16 @@ public: return group_transform; } + inline const size_t size() const { + return group_fragments.size(); + } + inline const Fragments & fragments() const { + return group_fragments; + } + + /* ---- mutators ------------------------------------------- */ + inline void set_type(const Type type) { group_type = type; } @@ -136,18 +148,6 @@ public: group_transform = transform; } - inline iterator begin() { - return group_fragments.begin(); - } - - inline iterator end() { - return group_fragments.end(); - } - - inline const size_t size() const { - return group_fragments.size(); - } - inline void add_fragment(Fragment *fragment) { group_fragments.push_back(fragment); } @@ -155,9 +155,6 @@ public: void clear(); private: - /// type definition for a list of model fragments - typedef std::list<Fragment *> Fragments; - Fragments group_fragments; math::Vector3f group_location; math::Axis group_axis; diff --git a/src/model/mapfile.cc b/src/model/mapfile.cc index 6bac44e..e3fda6c 100644 --- a/src/model/mapfile.cc +++ b/src/model/mapfile.cc @@ -1451,7 +1451,7 @@ Model * MapFile::load(std::string const &name) groupdst->set_axis(groupsrc->axis() * tag_submodel->axis()); // copy fragments, this only copies the original fragment's pointer into the vertex array - for (FragmentGroup::iterator fit = groupsrc->begin(); fit != groupsrc->end(); fit++) { + for (FragmentGroup::Fragments::const_iterator fit = groupsrc->fragments().begin(); fit != groupsrc->fragments().end(); fit++) { Fragment *fragmentdst = new Fragment(*(*fit)); groupdst->add_fragment(fragmentdst); } diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc index a559892..d06b976 100644 --- a/src/model/vertexarray.cc +++ b/src/model/vertexarray.cc @@ -40,6 +40,7 @@ VertexArray::~VertexArray() void VertexArray::clear() { + vertex_dirty = true; vertex_index = 0; vertex_overflow = false; @@ -127,6 +128,8 @@ size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, } vertex_index += 8; + + vertex_dirty = true; return 1; } diff --git a/src/model/vertexarray.h b/src/model/vertexarray.h index 2e43f2a..9a71811 100644 --- a/src/model/vertexarray.h +++ b/src/model/vertexarray.h @@ -38,6 +38,11 @@ public: return vertex_overflow; } + /// return true if the vertex data has changed and needs to uploaded to video memory + inline bool dirty() const { + return vertex_dirty; + } + /// pointer to model vertices, sequential in GL_T2F_N3F_V3F format inline const float *ptr() const { return vertex_data; @@ -52,6 +57,10 @@ public: inline size_t index() const { return vertex_index; } + + inline void set_dirty(const bool dirty = true) { + vertex_dirty = dirty; + } static inline VertexArray *instance() { return vertex_instance; @@ -69,6 +78,8 @@ private: static VertexArray *vertex_instance; bool vertex_overflow; + + bool vertex_dirty; }; } |