2008-05-05 12:36:31 +00:00
|
|
|
// Copyright (C) 2002-2007 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine" and the "irrXML" project.
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h and irrXML.h
|
2008-08-13 23:46:46 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
// Original description: (Schrompf)
|
2008-05-05 12:36:31 +00:00
|
|
|
// Adapted to the ASSIMP library because the builtin atof indeed takes AGES to parse a
|
|
|
|
// float inside a large string. Before parsing, it does a strlen on the given point.
|
2008-08-13 23:46:46 +00:00
|
|
|
// Changes:
|
2011-03-23 14:26:19 +00:00
|
|
|
// 22nd October 08 (Aramis_acg): Added temporary cast to double, added strtoul10_64
|
2008-08-13 23:46:46 +00:00
|
|
|
// to ensure long numbers are handled correctly
|
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
#ifndef __FAST_A_TO_F_H_INCLUDED__
|
|
|
|
#define __FAST_A_TO_F_H_INCLUDED__
|
|
|
|
|
|
|
|
#include <math.h>
|
2013-08-07 12:29:17 +00:00
|
|
|
#include <limits.h>
|
2008-05-05 12:36:31 +00:00
|
|
|
|
|
|
|
namespace Assimp
|
|
|
|
{
|
|
|
|
|
|
|
|
const float fast_atof_table[16] = { // we write [16] here instead of [] to work around a swig bug
|
|
|
|
0.f,
|
|
|
|
0.1f,
|
|
|
|
0.01f,
|
|
|
|
0.001f,
|
|
|
|
0.0001f,
|
|
|
|
0.00001f,
|
|
|
|
0.000001f,
|
|
|
|
0.0000001f,
|
|
|
|
0.00000001f,
|
|
|
|
0.000000001f,
|
|
|
|
0.0000000001f,
|
|
|
|
0.00000000001f,
|
|
|
|
0.000000000001f,
|
|
|
|
0.0000000000001f,
|
|
|
|
0.00000000000001f,
|
|
|
|
0.000000000000001f
|
|
|
|
};
|
|
|
|
|
2008-08-13 23:46:46 +00:00
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2009-04-15 14:16:11 +00:00
|
|
|
// Convert a string in decimal format to a number
|
2008-08-13 23:46:46 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline unsigned int strtoul10( const char* in, const char** out=0)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
unsigned int value = 0;
|
|
|
|
|
2009-10-10 11:59:00 +00:00
|
|
|
bool running = true;
|
|
|
|
while ( running )
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
if ( *in < '0' || *in > '9' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
value = ( value * 10 ) + ( *in - '0' );
|
|
|
|
++in;
|
|
|
|
}
|
2008-10-13 16:45:48 +00:00
|
|
|
if (out)*out = in;
|
2008-05-05 12:36:31 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2009-04-15 14:16:11 +00:00
|
|
|
// Convert a string in octal format to a number
|
2008-10-13 16:45:48 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline unsigned int strtoul8( const char* in, const char** out=0)
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
|
|
|
unsigned int value = 0;
|
|
|
|
|
2009-10-10 11:59:00 +00:00
|
|
|
bool running = true;
|
|
|
|
while ( running )
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
|
|
|
if ( *in < '0' || *in > '7' )
|
|
|
|
break;
|
|
|
|
|
|
|
|
value = ( value << 3 ) + ( *in - '0' );
|
|
|
|
++in;
|
|
|
|
}
|
|
|
|
if (out)*out = in;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
2009-04-15 14:16:11 +00:00
|
|
|
// Convert a string in hex format to a number
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline unsigned int strtoul16( const char* in, const char** out=0)
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
|
|
|
unsigned int value = 0;
|
|
|
|
|
2009-10-10 11:59:00 +00:00
|
|
|
bool running = true;
|
|
|
|
while ( running )
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
|
|
|
if ( *in >= '0' && *in <= '9' )
|
|
|
|
{
|
|
|
|
value = ( value << 4u ) + ( *in - '0' );
|
|
|
|
}
|
|
|
|
else if (*in >= 'A' && *in <= 'F')
|
|
|
|
{
|
|
|
|
value = ( value << 4u ) + ( *in - 'A' ) + 10;
|
|
|
|
}
|
|
|
|
else if (*in >= 'a' && *in <= 'f')
|
|
|
|
{
|
|
|
|
value = ( value << 4u ) + ( *in - 'a' ) + 10;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
++in;
|
|
|
|
}
|
|
|
|
if (out)*out = in;
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2009-02-11 20:56:05 +00:00
|
|
|
// Convert just one hex digit
|
2011-04-22 21:29:18 +00:00
|
|
|
// Return value is UINT_MAX if the input character is not a hex digit.
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2008-10-13 16:45:48 +00:00
|
|
|
inline unsigned int HexDigitToDecimal(char in)
|
|
|
|
{
|
2011-04-22 21:29:18 +00:00
|
|
|
unsigned int out = UINT_MAX;
|
2008-10-13 16:45:48 +00:00
|
|
|
if (in >= '0' && in <= '9')
|
|
|
|
out = in - '0';
|
|
|
|
|
|
|
|
else if (in >= 'a' && in <= 'f')
|
|
|
|
out = 10u + in - 'a';
|
|
|
|
|
|
|
|
else if (in >= 'A' && in <= 'F')
|
|
|
|
out = 10u + in - 'A';
|
|
|
|
|
2011-04-22 21:29:18 +00:00
|
|
|
// return value is UINT_MAX if the input is not a hex digit
|
2008-10-13 16:45:48 +00:00
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2009-02-11 20:56:05 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-04-22 21:29:18 +00:00
|
|
|
// Convert a hex-encoded octet (2 characters, i.e. df or 1a).
|
2009-02-11 20:56:05 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
|
|
|
inline uint8_t HexOctetToDecimal(const char* in)
|
|
|
|
{
|
|
|
|
return ((uint8_t)HexDigitToDecimal(in[0])<<4)+(uint8_t)HexDigitToDecimal(in[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-05 13:21:01 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
// signed variant of strtoul10
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline int strtol10( const char* in, const char** out=0)
|
2008-09-05 13:21:01 +00:00
|
|
|
{
|
2009-05-03 21:49:34 +00:00
|
|
|
bool inv = (*in=='-');
|
|
|
|
if (inv || *in=='+')
|
|
|
|
++in;
|
|
|
|
|
2011-03-23 14:26:19 +00:00
|
|
|
int value = strtoul10(in,out);
|
2009-05-03 21:49:34 +00:00
|
|
|
if (inv) {
|
|
|
|
value = -value;
|
|
|
|
}
|
2008-09-05 13:21:01 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2008-10-13 16:45:48 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2008-10-22 20:06:16 +00:00
|
|
|
// Parse a C++-like integer literal - hex and oct prefixes.
|
2008-10-13 16:45:48 +00:00
|
|
|
// 0xNNNN - hex
|
|
|
|
// 0NNN - oct
|
|
|
|
// NNN - dec
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline unsigned int strtoul_cppstyle( const char* in, const char** out=0)
|
2008-10-13 16:45:48 +00:00
|
|
|
{
|
|
|
|
if ('0' == in[0])
|
|
|
|
{
|
2011-03-23 14:26:19 +00:00
|
|
|
return 'x' == in[1] ? strtoul16(in+2,out) : strtoul8(in+1,out);
|
2008-10-13 16:45:48 +00:00
|
|
|
}
|
2011-03-23 14:26:19 +00:00
|
|
|
return strtoul10(in, out);
|
2008-10-13 16:45:48 +00:00
|
|
|
}
|
2008-08-06 23:01:38 +00:00
|
|
|
|
2008-08-13 23:46:46 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2009-04-15 14:16:11 +00:00
|
|
|
// Special version of the function, providing higher accuracy and safety
|
|
|
|
// It is mainly used by fast_atof to prevent ugly and unwanted integer overflows.
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2011-03-23 14:26:19 +00:00
|
|
|
inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int* max_inout=0)
|
2008-08-06 23:01:38 +00:00
|
|
|
{
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
unsigned int cur = 0;
|
2008-08-06 23:01:38 +00:00
|
|
|
uint64_t value = 0;
|
|
|
|
|
2009-10-10 11:59:00 +00:00
|
|
|
bool running = true;
|
|
|
|
while ( running )
|
2008-08-06 23:01:38 +00:00
|
|
|
{
|
|
|
|
if ( *in < '0' || *in > '9' )
|
|
|
|
break;
|
|
|
|
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
const uint64_t new_value = ( value * 10 ) + ( *in - '0' );
|
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
if (new_value < value) /* numeric overflow, we rely on you */
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
return value;
|
|
|
|
|
|
|
|
value = new_value;
|
|
|
|
|
2008-08-06 23:01:38 +00:00
|
|
|
++in;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
++cur;
|
|
|
|
|
|
|
|
if (max_inout && *max_inout == cur) {
|
|
|
|
|
|
|
|
if (out) { /* skip to end */
|
2009-04-15 14:16:11 +00:00
|
|
|
while (*in >= '0' && *in <= '9')
|
|
|
|
++in;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
*out = in;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2008-08-06 23:01:38 +00:00
|
|
|
}
|
|
|
|
if (out)
|
|
|
|
*out = in;
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
if (max_inout)
|
|
|
|
*max_inout = cur;
|
|
|
|
|
2008-08-06 23:01:38 +00:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
// Number of relevant decimals for floating-point parsing.
|
2012-01-31 16:28:19 +00:00
|
|
|
#define AI_FAST_ATOF_RELAVANT_DECIMALS 15
|
2008-08-13 23:46:46 +00:00
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------
|
2008-05-05 12:36:31 +00:00
|
|
|
//! Provides a fast function for converting a string into a float,
|
|
|
|
//! about 6 times faster than atof in win32.
|
|
|
|
// If you find any bugs, please send them to me, niko (at) irrlicht3d.org.
|
2008-10-22 20:06:16 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2012-01-31 16:18:32 +00:00
|
|
|
template <typename Real>
|
|
|
|
inline const char* fast_atoreal_move( const char* c, Real& out)
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
2012-01-31 16:18:32 +00:00
|
|
|
Real f;
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
bool inv = (*c=='-');
|
2012-01-31 16:18:32 +00:00
|
|
|
if (inv || *c=='+') {
|
2008-05-05 12:36:31 +00:00
|
|
|
++c;
|
2012-01-31 16:18:32 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2012-01-31 16:18:32 +00:00
|
|
|
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
2012-03-20 16:29:57 +00:00
|
|
|
if (*c == '.' || (c[0] == ',' && c[1] >= '0' && c[1] <= '9')) // allow for commas, too
|
2008-05-05 12:36:31 +00:00
|
|
|
{
|
|
|
|
++c;
|
|
|
|
|
2012-01-31 16:18:32 +00:00
|
|
|
// NOTE: The original implementation is highly inaccurate here. The precision of a single
|
2009-04-15 14:16:11 +00:00
|
|
|
// IEEE 754 float is not high enough, everything behind the 6th digit tends to be more
|
|
|
|
// inaccurate than it would need to be. Casting to double seems to solve the problem.
|
2008-08-06 23:01:38 +00:00
|
|
|
// strtol_64 is used to prevent integer overflow.
|
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
// Another fix: this tends to become 0 for long numbers if we don't limit the maximum
|
|
|
|
// number of digits to be read. AI_FAST_ATOF_RELAVANT_DECIMALS can be a value between
|
|
|
|
// 1 and 15.
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
unsigned int diff = AI_FAST_ATOF_RELAVANT_DECIMALS;
|
2012-01-31 16:18:32 +00:00
|
|
|
double pl = static_cast<double>( strtoul10_64 ( c, &c, &diff ));
|
General
- Added format auto-detection to most loaders
- Simplified BaseImporter::CanRead() with some utility methods
- improved fast_atof -> no overruns anymore. Fuck you, irrlicht.
- added assimp_cmd tool to allow command line model processing. Mainly adebugging tool for internal purposes, but others might find it useful, too.
- vc8/vc9: revision number is now written to DLL version header
- mkutil: some batch scripts to simplify tagging & building of release versions
- some API cleanup
- fixing some doxygen markup (+now explicit use of @file <filename>)
- Icon for assimp_view and assimp_cmd
3DS
- Normal vectors are not anymore inverted in some cases
- Improved pivot handling
- Improved handling of x-flipped meshes
Collada
- fixed a minor bug (visual_scene element)
LWS
- WIP implementation. No animations yet, some bugs and crashes.
- Animation system remains disabled, WIP code
- many test files for LWS, but most of them test the anim support, which is, read above, currently disabled.
STL
- fixing a log warning which appears for every model
- added binary&ascii test spider, exported from truespace
MD3
- Cleaning up output tags for automatically joined player models.
IRR
- Fixing coordinate system issues.
- Instance handling improved.
- Some of the reported crashes not yet fixed.
PretransformVertices
- Numerous performance improvements.
- Added config option to preserve the hierarchy during the step.
RemoveRedundantMaterials
- Added config option to specify a list of materials which are kept in every case.
UNREAL
- Added support for the old unreal data format (*.a,*.d,*.uc)
- tested only with exports from Milkshape
- more Unreal stuff to come soon
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@356 67173fc5-114c-0410-ac8e-9d2fd5bffc1f
2009-03-05 22:32:13 +00:00
|
|
|
|
|
|
|
pl *= fast_atof_table[diff];
|
2012-01-31 16:18:32 +00:00
|
|
|
f += static_cast<Real>( pl );
|
2009-04-15 14:16:11 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
// A major 'E' must be allowed. Necessary for proper reading of some DXF files.
|
|
|
|
// Thanks to Zhao Lei to point out that this if() must be outside the if (*c == '.' ..)
|
2012-01-31 16:18:32 +00:00
|
|
|
if (*c == 'e' || *c == 'E') {
|
|
|
|
|
2009-04-15 14:16:11 +00:00
|
|
|
++c;
|
2012-02-02 22:53:26 +00:00
|
|
|
const bool einv = (*c=='-');
|
2012-01-31 16:18:32 +00:00
|
|
|
if (einv || *c=='+') {
|
2008-05-05 12:36:31 +00:00
|
|
|
++c;
|
2012-01-31 16:18:32 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
|
2012-01-31 16:18:32 +00:00
|
|
|
// The reason float constants are used here is that we've seen cases where compilers
|
|
|
|
// would perform such casts on compile-time constants at runtime, which would be
|
|
|
|
// bad considering how frequently fast_atoreal_move<float> is called in Assimp.
|
|
|
|
Real exp = static_cast<Real>( strtoul10_64(c, &c) );
|
|
|
|
if (einv) {
|
2012-02-02 22:53:26 +00:00
|
|
|
exp = -exp;
|
2012-01-31 16:18:32 +00:00
|
|
|
}
|
|
|
|
f *= pow(static_cast<Real>(10.0f), exp);
|
2008-05-05 12:36:31 +00:00
|
|
|
}
|
|
|
|
|
2012-01-31 16:18:32 +00:00
|
|
|
if (inv) {
|
2012-02-02 22:53:26 +00:00
|
|
|
f = -f;
|
2012-01-31 16:18:32 +00:00
|
|
|
}
|
2008-05-05 12:36:31 +00:00
|
|
|
out = f;
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2008-08-13 23:46:46 +00:00
|
|
|
// ------------------------------------------------------------------------------------
|
2009-04-15 14:16:11 +00:00
|
|
|
// The same but more human.
|
2008-05-05 12:36:31 +00:00
|
|
|
inline float fast_atof(const char* c)
|
|
|
|
{
|
|
|
|
float ret;
|
2012-01-31 16:18:32 +00:00
|
|
|
fast_atoreal_move<float>(c, ret);
|
2008-05-05 12:36:31 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-02 04:17:05 +00:00
|
|
|
|
|
|
|
inline float fast_atof( const char* c, const char** cout)
|
|
|
|
{
|
|
|
|
float ret;
|
2012-01-31 16:18:32 +00:00
|
|
|
*cout = fast_atoreal_move<float>(c, ret);
|
2010-04-02 04:17:05 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline float fast_atof( const char** inout)
|
|
|
|
{
|
|
|
|
float ret;
|
2012-01-31 16:18:32 +00:00
|
|
|
*inout = fast_atoreal_move<float>(*inout, ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline double fast_atod(const char* c)
|
|
|
|
{
|
|
|
|
double ret;
|
|
|
|
fast_atoreal_move<double>(c, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
inline double fast_atod( const char* c, const char** cout)
|
|
|
|
{
|
|
|
|
double ret;
|
|
|
|
*cout = fast_atoreal_move<double>(c, ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline double fast_atod( const char** inout)
|
|
|
|
{
|
|
|
|
double ret;
|
|
|
|
*inout = fast_atoreal_move<double>(*inout, ret);
|
2010-04-02 04:17:05 +00:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-05-05 12:36:31 +00:00
|
|
|
} // end of namespace Assimp
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|