Skip to content

Commit

Permalink
Fix name clash with std::byte (#764)
Browse files Browse the repository at this point in the history
  • Loading branch information
pattacini authored Sep 2, 2021
1 parent 4176887 commit 4078e16
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
26 changes: 13 additions & 13 deletions src/simulators/iCubSimulation/odesdl/MS3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,10 @@ bool Model::loadModelData( const char *filename )
if ( pHeader->m_version < 3 )
return false; // "Unhandled file version. Only Milkshape3D Version 1.3 and 1.4 is supported." );

int nVertices = *( word* )pPtr;
int nVertices = *( ms3d::word* )pPtr;
m_numVertices = nVertices;
m_pVertices = new Vertex[nVertices];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );

int i;
for ( i = 0; i < nVertices; i++ )
Expand All @@ -130,10 +130,10 @@ bool Model::loadModelData( const char *filename )
pPtr += sizeof( MS3DVertex );
}

int nTriangles = *( word* )pPtr;
int nTriangles = *( ms3d::word* )pPtr;
m_numTriangles = nTriangles;
m_pTriangles = new Triangle[nTriangles];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );

for ( i = 0; i < nTriangles; i++ )
{
Expand All @@ -149,22 +149,22 @@ bool Model::loadModelData( const char *filename )



int nGroups = *( word* )pPtr;
int nGroups = *( ms3d::word* )pPtr;
m_numMeshes = nGroups;
m_pMeshes = new Mesh[nGroups];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );
for ( i = 0; i < nGroups; i++ )
{
pPtr += sizeof( byte ); // flags
pPtr += sizeof( ms3d::byte ); // flags
pPtr += 32; // name

word nTriangles = *( word* )pPtr;
pPtr += sizeof( word );
ms3d::word nTriangles = *( ms3d::word* )pPtr;
pPtr += sizeof( ms3d::word );
int *pTriangleIndices = new int[nTriangles];
for ( int j = 0; j < nTriangles; j++ )
{
pTriangleIndices[j] = *( word* )pPtr;
pPtr += sizeof( word );
pTriangleIndices[j] = *( ms3d::word* )pPtr;
pPtr += sizeof( ms3d::word );
}

char materialIndex = *( char* )pPtr;
Expand All @@ -175,10 +175,10 @@ bool Model::loadModelData( const char *filename )
m_pMeshes[i].m_pTriangleIndices = pTriangleIndices;
}

int nMaterials = *( word* )pPtr;
int nMaterials = *( ms3d::word* )pPtr;
m_numMaterials = nMaterials;
m_pMaterials = new Material[nMaterials];
pPtr += sizeof( word );
pPtr += sizeof( ms3d::word );
for ( i = 0; i < nMaterials; i++ )
{
MS3DMaterial *pMaterial = ( MS3DMaterial* )pPtr;
Expand Down
20 changes: 11 additions & 9 deletions src/simulators/iCubSimulation/odesdl/MS3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,10 @@
# error you must byte-align these structures with the appropriate compiler directives
#endif

typedef unsigned char byte;
typedef unsigned short word;
namespace ms3d {
typedef unsigned char byte;
typedef unsigned short word;
}

struct MS3DHeader // File Header
{
Expand All @@ -81,20 +83,20 @@ struct MS3DHeader // File Header

struct MS3DVertex // Vertex info
{
byte m_flags;
ms3d::byte m_flags;
float m_vertex[3];
char m_boneID;
byte m_refCount;
ms3d::byte m_refCount;
} PACK_STRUCT;

struct MS3DTriangle // Triangle info
{
word m_flags;
word m_vertexIndices[3];
ms3d::word m_flags;
ms3d::word m_vertexIndices[3];
float m_vertexNormals[3][3];
float m_s[3], m_t[3];
byte m_smoothingGroup;
byte m_groupIndex;
ms3d::byte m_smoothingGroup;
ms3d::byte m_groupIndex;
} PACK_STRUCT;

struct MS3DMaterial // Material info
Expand All @@ -108,7 +110,7 @@ struct MS3DMaterial // Material info
float m_emissive[4];
float m_shininess; // 0.0f - 128.0f
float m_transparency; // 0.0f - 1.0f
byte m_mode; // 0, 1, 2 (unused now)
ms3d::byte m_mode; // 0, 1, 2 (unused now)
char m_texture[128];
char m_alphamap[128];
} PACK_STRUCT;
Expand Down
3 changes: 3 additions & 0 deletions src/tools/skinManagerGui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ add_executable(skinManagerGui WIN32 ${skinManagerGui_SRCS}
${skinManagerGui_HDRS}
${skinManagerGui_QRC_GEN_SRCS}
${skinManagerGui_UI_GEN_SRCS})
if(WIN32)
target_compile_definitions(skinManagerGui PUBLIC _HAS_STD_BYTE=0)
endif()
target_link_libraries(skinManagerGui YARP::YARP_OS
YARP::YARP_init
YARP::YARP_sig
Expand Down

0 comments on commit 4078e16

Please sign in to comment.