From 3adacbdeb7f20ae43307575163eac9d4c0875813 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Wed, 9 Jun 2004 16:28:51 +0000 Subject: [PATCH] Changed the *(itr++) instances with *(itr), *(itr+1) with a seperate itr+=n etc. This has been done to avoid VC6.0 optimization ordering problems. --- src/osgPlugins/lwo/iffparser.h | 9 +-- src/osgPlugins/lwo/lwo2read.h | 116 ++++++++++++++++++--------------- 2 files changed, 67 insertions(+), 58 deletions(-) diff --git a/src/osgPlugins/lwo/iffparser.h b/src/osgPlugins/lwo/iffparser.h index 8e587d2e7..659c91dbd 100644 --- a/src/osgPlugins/lwo/iffparser.h +++ b/src/osgPlugins/lwo/iffparser.h @@ -92,10 +92,11 @@ namespace iff { std::string tag; for (int i=0; i<4; ++i) tag += *(it++); - unsigned int len = ((static_cast(*(it++)) & 0xFF) << 24) | - ((static_cast(*(it++)) & 0xFF) << 16) | - ((static_cast(*(it++)) & 0xFF) << 8) | - (static_cast(*(it++)) & 0xFF); + unsigned int len = ((static_cast(*(it)) & 0xFF) << 24) | + ((static_cast(*(it+1)) & 0xFF) << 16) | + ((static_cast(*(it+2)) & 0xFF) << 8) | + (static_cast(*(it+3)) & 0xFF); + it += 4; os_ << "DEBUG INFO: iffparser: reading chunk " << tag << ", length = " << len << ", context = " << context << "\n"; Chunk *chk = parse_chunk_data(tag, context, it, it+len); if (!chk) os_ << "DEBUG INFO: iffparser: \tprevious chunk not handled\n"; diff --git a/src/osgPlugins/lwo/lwo2read.h b/src/osgPlugins/lwo/lwo2read.h index 2f9e76f0c..5c4a5bf35 100644 --- a/src/osgPlugins/lwo/lwo2read.h +++ b/src/osgPlugins/lwo/lwo2read.h @@ -1,9 +1,9 @@ /**************************************************************************** - Functions for reading basic data types from LWO2 files + Functions for reading basic data types from LWO2 files - Copyright (C) 2002 by Marco Jez + Copyright (C) 2002 by Marco Jez ****************************************************************************/ @@ -18,128 +18,136 @@ namespace lwo2 template I1 read_I1(Iter &it) { - return static_cast(*(it++)); + return static_cast(*(it++)); } template I2 read_I2(Iter &it) { - return ((static_cast(*(it++)) & 0xFF) << 8) | - (static_cast(*(it++)) & 0xFF); + I2 i2(((static_cast(*(it)) & 0xFF) << 8) | + (static_cast(*(it+1)) & 0xFF)); + it += 2; + return i2; } template I4 read_I4(Iter &it) { - return ((static_cast(*(it++)) & 0xFF) << 24) | - ((static_cast(*(it++)) & 0xFF) << 16) | - ((static_cast(*(it++)) & 0xFF) << 8) | - (static_cast(*(it++)) & 0xFF); + I4 i4(((static_cast(*(it)) & 0xFF) << 24) | + ((static_cast(*(it+1)) & 0xFF) << 16) | + ((static_cast(*(it+2)) & 0xFF) << 8) | + (static_cast(*(it+3)) & 0xFF)); + it += 4; + return i4; } template U1 read_U1(Iter &it) { - return static_cast(*(it++)); + return static_cast(*(it++)); } template U2 read_U2(Iter &it) { - return ((static_cast(*(it++)) & 0xFF) << 8) | - (static_cast(*(it++)) & 0xFF); + U2 u2(((static_cast(*(it)) & 0xFF) << 8) | + (static_cast(*(it+1)) & 0xFF)); + it += 2; + return u2; } template U4 read_U4(Iter &it) { - return ((static_cast(*(it++)) & 0xFF) << 24) | - ((static_cast(*(it++)) & 0xFF) << 16) | - ((static_cast(*(it++)) & 0xFF) << 8) | - (static_cast(*(it++)) & 0xFF); + U4 u4(((static_cast(*(it)) & 0xFF) << 24) | + ((static_cast(*(it+1)) & 0xFF) << 16) | + ((static_cast(*(it+2)) & 0xFF) << 8) | + (static_cast(*(it+3)) & 0xFF)); + it += 4; + return u4; } template F4 read_F4(Iter &it) { - U4 u4 = read_U4(it); - return *reinterpret_cast(&u4); + U4 u4 = read_U4(it); + return *reinterpret_cast(&u4); } template ID4 read_ID4(Iter &it) { - ID4 value; - for (int i=0; i<4; ++i) value.id[i] = *(it++); - return value; + ID4 value; + for (int i=0; i<4; ++i) value.id[i] = *(it++); + return value; } template S0 read_S0(Iter &it) { - S0 value; - while (*it) { - value += *(it++); - } - ++it; - if (value.length() % 2 == 0) ++it; - return value; + S0 value; + while (*it) { + value += *(it++); + } + ++it; + if (value.length() % 2 == 0) ++it; + return value; } template VX read_VX(Iter &it) { - VX vx; - if ((*it & 0xFF) == 0xFF) { - vx.index = read_U4(it) & 0x00FFFFFF; - } else { - vx.index = static_cast(read_U2(it)); - } - return vx; + VX vx; + if ((*it & 0xFF) == 0xFF) { + vx.index = read_U4(it) & 0x00FFFFFF; + } else { + vx.index = static_cast(read_U2(it)); + } + return vx; } template COL12 read_COL12(Iter &it) { - COL12 value; - value.red = read_F4(it); - value.green = read_F4(it); - value.blue = read_F4(it); - return value; + COL12 value; + value.red = read_F4(it); + value.green = read_F4(it); + value.blue = read_F4(it); + return value; } template VEC12 read_VEC12(Iter &it) { - VEC12 value; - value.X = read_F4(it); - value.Y = read_F4(it); - value.Z = read_F4(it); - return value; + VEC12 value; + value.X = read_F4(it); + value.Y = read_F4(it); + value.Z = read_F4(it); + return value; } template FP4 read_FP4(Iter &it) { - FP4 value; - value.fraction = read_F4(it); - return value; + FP4 value; + value.fraction = read_F4(it); + return value; } template ANG4 read_ANG4(Iter &it) { - ANG4 value; - value.radians = read_F4(it); - return value; + ANG4 value; + value.radians = read_F4(it); + return value; } template FNAM0 read_FNAM0(Iter &it) { - FNAM0 value; - value.name = read_S0(it); - return value; + FNAM0 value; + value.name = read_S0(it); + return value; } }