]> Dogcows Code - chaz/yoink/blobdiff - src/moof/mesh.cc
remove some unused stlplus modules
[chaz/yoink] / src / moof / mesh.cc
index e380adfd19d6eb2ea9e9bc2bc9799eb0c2bf8362..32550f7fcfb3361aff55ea7e2748c0c2c62531df 100644 (file)
@@ -1,13 +1,11 @@
 
-/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+/*]  Copyright (c) 2009-2011, Charles McGarvey  [*****************************
 **]  All rights reserved.
 *
-* vi:ts=4 sw=4 tw=75
-*
 * Distributable under the terms and conditions of the 2-clause BSD license;
 * see the file COPYING for a complete text of the license.
 *
-**************************************************************************/
+*****************************************************************************/
 
 #include <cstring>
 #include <fstream>
@@ -18,8 +16,6 @@
 #include <boost/algorithm/string/trim.hpp>
 #include <zlib.h>
 
-#include <stlplus/strings/string_utilities.hpp>
-
 #include "debug.hh"
 #include "log.hh"
 #include "mesh.hh"
@@ -27,9 +23,8 @@
 
 // TODO: this file needs to be cleaned up
 
-
-#define AC3D_FORMAT_VERSION            (0x0b)
-#define ZLIB_BUF_SIZE                  (262114)
+#define AC3D_FORMAT_VERSION    0x0b
+#define ZLIB_BUF_SIZE          262114
 
 
 namespace moof {
@@ -37,22 +32,17 @@ namespace moof {
 
 MOOF_REGISTER_RESOURCE(mesh, ac, models);
 
-
 static std::string read_string(std::istream& stream)
 {
        std::string     str;
        char            atom;
 
-       do      // skip to the next non-space character
-       {
-               stream.get(atom);
-       }
+       do stream.get(atom);
        while (stream && std::isspace(atom));
 
        if (atom == '"')
        {
-               do
-               {
+               do {
                        stream.get(atom);
                        if (atom == '"') break;
                        str += atom;
@@ -61,8 +51,7 @@ static std::string read_string(std::istream& stream)
        }
        else
        {
-               do
-               {
+               do {
                        stream.get(atom);
                        if (std::isspace(atom)) break;
                        str += atom;
@@ -73,7 +62,7 @@ static std::string read_string(std::istream& stream)
        return str;
 }
 
-inline int read_hex(std::istream& stream)
+static int read_hex(std::istream& stream)
 {
        int hex;
        std::ios::fmtflags flags = stream.flags();
@@ -83,21 +72,21 @@ inline int read_hex(std::istream& stream)
        return hex;
 }
 
-inline vector2 read_pair(std::istream& stream)
+static vector2 read_pair(std::istream& stream)
 {
        vector2 triplet;
        stream >> triplet[0] >> triplet[1];
        return triplet;
 }
 
-inline vector3 read_triplet(std::istream& stream)
+static vector3 read_triplet(std::istream& stream)
 {
        vector3 triplet;
        stream >> triplet[0] >> triplet[1] >> triplet[2];
        return triplet;
 }
 
-inline vector4 read_color(std::istream& stream)
+static vector4 read_color(std::istream& stream)
 {
        vector4 color;
        stream >> color[0] >> color[1] >> color[2];
@@ -105,12 +94,10 @@ inline vector4 read_color(std::istream& stream)
        return color;
 }
 
-
 void mesh::import(std::istream& stream)
 {
-       std::string             atom;
-
-       object_ptr              obj;
+       std::string     atom;
+       object_ptr      obj;
        std::stack<int> kids;
 
        // read and verify the AC3D header
@@ -379,12 +366,10 @@ void mesh::import(std::istream& stream)
        //face.triangles.push_back(vert);
 //}
 
-
-
 mesh::mesh(const std::string& path)
 {
        std::ifstream file(path.c_str(), std::ifstream::in |
-                                                                        std::ifstream::binary);
+                       std::ifstream::binary);
        if (!file) throw std::runtime_error("cannot find mesh file");
 
        // if we can read the header, the file isn't compressed
@@ -394,7 +379,6 @@ mesh::mesh(const std::string& path)
        {
                log_info("text mesh detected");
                file.seekg(std::ios::beg);
-
                import(file);
        }
        else
@@ -415,31 +399,30 @@ mesh::mesh(const std::string& path)
                zstream.next_in = Z_NULL;
                
                int result = inflateInit2(&zstream, 32+MAX_WBITS);
-               if (result != Z_OK) throw std::runtime_error("zlib init error");
+               if (result != Z_OK)
+                       throw std::runtime_error("zlib init error");
 
-               do
-               {
+               do {
                        file.read(in, sizeof(in));
                        zstream.next_in = (Bytef*)in;
                        zstream.avail_in = file.gcount();
 
                        if (zstream.avail_in == 0) break;
 
-                       do
-                       {
+                       do {
                                zstream.next_out = (Bytef*)out;
                                zstream.avail_out = sizeof(out);
 
                                result = inflate(&zstream, Z_NO_FLUSH);
                                switch (result)
                                {
-                                       case Z_NEED_DICT:
-                                       case Z_DATA_ERROR:
-                                       case Z_MEM_ERROR:
-                                               inflateEnd(&zstream);
-                                               throw std::runtime_error("zlib inflate error");
-                                       case Z_STREAM_ERROR:
-                                               throw std::runtime_error("zlib stream error");
+                               case Z_NEED_DICT:
+                               case Z_DATA_ERROR:
+                               case Z_MEM_ERROR:
+                                       inflateEnd(&zstream);
+                                       throw std::runtime_error("zlib inflate error");
+                               case Z_STREAM_ERROR:
+                                       throw std::runtime_error("zlib stream error");
                                }
 
                                int inflated = sizeof(out) - zstream.avail_out;
@@ -450,12 +433,10 @@ mesh::mesh(const std::string& path)
                while(result != Z_STREAM_END);
 
                inflateEnd(&zstream);
-
                import(stream);
        }
 }
 
-
 void mesh::draw(scalar alpha) const
 {
        glEnableClientState(GL_VERTEX_ARRAY);
@@ -469,7 +450,6 @@ void mesh::draw(scalar alpha) const
        // TODO: disable vertex array?
 }
 
-
 void mesh::set_material(int index) const
 {
        set_material(materials_[index]);
@@ -485,7 +465,6 @@ void mesh::set_material(const material& material) const
        glMaterial(GL_FRONT, GL_SHININESS, material.shininess);
 }
 
-
 void mesh::object::draw(scalar alpha, bool recurse) const
 {
        glVertexPointer(verts);
@@ -516,13 +495,10 @@ void mesh::object::draw(scalar alpha, bool recurse) const
        {
                std::vector<object_ptr>::const_iterator jt;
                for (jt = kids.begin(); jt != kids.end(); ++jt)
-               {
                        (*jt)->draw(alpha);
-               }
        }
 }
 
-
 //class mesh_resource_loader
 //{
 //public:
This page took 0.026557 seconds and 4 git commands to generate.