Browse Source

BlenderTesselator: Fix OffsetOf() macro

acgessler 11 years ago
parent
commit
d080f92241
1 changed files with 5 additions and 2 deletions
  1. 5 2
      code/BlenderTessellator.cpp

+ 5 - 2
code/BlenderTessellator.cpp

@@ -374,10 +374,13 @@ void BlenderTessellatorP2T::ReferencePoints( std::vector< Blender::PointP2T >& p
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
 // Yes this is filthy... but we have no choice
 // Yes this is filthy... but we have no choice
-#define OffsetOf( Class, Member ) ( reinterpret_cast< unsigned int >( &( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) ) ) )
+#define OffsetOf( Class, Member ) ( static_cast< unsigned int >( \
+	reinterpret_cast<uint8_t*>(&( reinterpret_cast< Class* >( NULL )->*( &Class::Member ) )) - \
+	static_cast<uint8_t*>(NULL) ) )
+
 inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const
 inline PointP2T& BlenderTessellatorP2T::GetActualPointStructure( p2t::Point& point ) const
 {
 {
-	int pointOffset = OffsetOf( PointP2T, point2D );
+	unsigned int pointOffset = OffsetOf( PointP2T, point2D );
 	PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset );
 	PointP2T& pointStruct = *reinterpret_cast< PointP2T* >( reinterpret_cast< char* >( &point ) - pointOffset );
 	if ( pointStruct.magic != BLEND_TESS_MAGIC )
 	if ( pointStruct.magic != BLEND_TESS_MAGIC )
 	{
 	{