From aaaae14884eefe5571b5c5d6ce1606085e0b9376 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 20 Jul 2008 13:50:24 +0000 Subject: handle vertexarray overflows more gracefull --- src/model/vertexarray.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/model/vertexarray.cc') diff --git a/src/model/vertexarray.cc b/src/model/vertexarray.cc index b0da6ab..27124fa 100644 --- a/src/model/vertexarray.cc +++ b/src/model/vertexarray.cc @@ -44,11 +44,12 @@ VertexArray::~VertexArray() void VertexArray::clear() { vertex_index = 0; + vertex_overflow = false; memset(vertex_vertex, 0, sizeof(vertex_vertex)); memset(vertex_color, 0, sizeof(vertex_color)); memset(vertex_normal, 0, sizeof(vertex_normal)); - memset(vertex_texture, 0, sizeof(vertex_normal)); + memset(vertex_texture, 0, sizeof(vertex_texture)); add_sphere(); } @@ -128,10 +129,11 @@ void VertexArray::add_sphere() delete[] costable; } -void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color) { +size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color) { if (vertex_index + 3 >= vertex_size) { con_warn << "VertexArray overflow!" << std::endl; - return; + vertex_overflow = true; + return 0; } for (int i = 0; i < 3; i ++) { @@ -144,12 +146,15 @@ void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, m vertex_color[vertex_index+2] = color.b; vertex_index += 3; + + return 1; } -void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, math::Vector3f const &tex) { +size_t VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, math::Color const &color, math::Vector3f const &tex) { if (vertex_index + 3 >= vertex_size) { con_warn << "VertexArray overflow!" << std::endl; - return; + vertex_overflow = true; + return 0; } for (int i = 0; i < 3; i ++) { @@ -163,6 +168,7 @@ void VertexArray::add_vertex(math::Vector3f const &v, math::Vector3f const &n, m vertex_color[vertex_index+2] = color.b; vertex_index += 3; + return 1; } } -- cgit v1.2.3