|
Revision 11274, 2.6 kB
(checked in by paulmartz, 3 years ago)
|
|
2.8 branch: Hm, mysteriously, the ply plugin seems to be missing changes that were previously merged. This commit brings them up to date with svn trunk as of r11237.
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | #ifndef MESH_TYPEDEFS_H |
|---|
| 13 | #define MESH_TYPEDEFS_H |
|---|
| 14 | |
|---|
| 15 | # if defined(_MSC_VER) |
|---|
| 16 | # include <Winsock2.h> |
|---|
| 17 | # include <Windows.h> |
|---|
| 18 | # endif |
|---|
| 19 | |
|---|
| 20 | # include <osg/Notify> |
|---|
| 21 | |
|---|
| 22 | #ifdef NDEBUG |
|---|
| 23 | # define MESHASSERT( x ) |
|---|
| 24 | #else |
|---|
| 25 | # define MESHASSERT(x) { if( !(x) ) \ |
|---|
| 26 | osg::notify(osg::WARN) << "Ply Loader ##### Assert: " << #x << " #####" << std::endl; } |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | # define MESHERROR osg::notify(osg::WARN) |
|---|
| 30 | # define MESHWARN osg::notify(osg::WARN) |
|---|
| 31 | # define MESHINFO osg::notify(osg::INFO) |
|---|
| 32 | |
|---|
| 33 | #if defined(_MSC_VER) |
|---|
| 34 | typedef int socklen_t; |
|---|
| 35 | |
|---|
| 36 | typedef UINT64 uint64_t; |
|---|
| 37 | typedef INT64 int64_t; |
|---|
| 38 | typedef UINT32 uint32_t; |
|---|
| 39 | typedef INT32 int32_t; |
|---|
| 40 | typedef UINT16 uint16_t; |
|---|
| 41 | typedef UINT8 uint8_t; |
|---|
| 42 | # ifndef HAVE_SSIZE_T |
|---|
| 43 | typedef SSIZE_T ssize_t; |
|---|
| 44 | # endif |
|---|
| 45 | |
|---|
| 46 | #endif // defined(_MSC_VER) |
|---|
| 47 | |
|---|
| 48 | #include <exception> |
|---|
| 49 | #include <iostream> |
|---|
| 50 | #include <string> |
|---|
| 51 | |
|---|
| 52 | namespace ply |
|---|
| 53 | { |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | typedef size_t Index; |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | struct MeshException : public std::exception |
|---|
| 63 | { |
|---|
| 64 | explicit MeshException( const std::string& msg ) : _message( msg ) {} |
|---|
| 65 | virtual ~MeshException() throw() {} |
|---|
| 66 | virtual const char* what() const throw() { return _message.c_str(); } |
|---|
| 67 | private: |
|---|
| 68 | std::string _message; |
|---|
| 69 | }; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | struct NullOStream : std::ostream |
|---|
| 73 | { |
|---|
| 74 | struct NullStreamBuf : std::streambuf |
|---|
| 75 | { |
|---|
| 76 | int overflow( int c ) { return traits_type::not_eof( c ); } |
|---|
| 77 | } _nullBuf; |
|---|
| 78 | |
|---|
| 79 | NullOStream() : std::ios( &_nullBuf ), std::ostream( &_nullBuf ) {} |
|---|
| 80 | }; |
|---|
| 81 | |
|---|
| 82 | |
|---|
| 83 | template< class T, size_t d > |
|---|
| 84 | struct ArrayWrapper |
|---|
| 85 | { |
|---|
| 86 | T& operator[]( const size_t i ) |
|---|
| 87 | { |
|---|
| 88 | MESHASSERT( i < d ); |
|---|
| 89 | return data[i]; |
|---|
| 90 | } |
|---|
| 91 | |
|---|
| 92 | const T& operator[]( const size_t i ) const |
|---|
| 93 | { |
|---|
| 94 | MESHASSERT( i < d ); |
|---|
| 95 | return data[i]; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | private: |
|---|
| 99 | T data[d]; |
|---|
| 100 | }; |
|---|
| 101 | |
|---|
| 102 | |
|---|
| 103 | |
|---|
| 104 | const unsigned short FILE_VERSION ( 0x0114 ); |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | |
|---|
| 108 | enum Axis |
|---|
| 109 | { |
|---|
| 110 | AXIS_X, |
|---|
| 111 | AXIS_Y, |
|---|
| 112 | AXIS_Z |
|---|
| 113 | }; |
|---|
| 114 | |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | #endif // MESH_TYPEDEFS_H |
|---|