From 8e9c3de276293dc8e9982d88250e312854859d6f Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 2 Jul 2009 08:59:55 +0000 Subject: [PATCH] Merged revisions 2349:2403 from 1.5 branch. Added defines for version handling, added method to check for drivers. Fix bugs in Joystick handler, filename handler, and byteswap. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2439 dfc29bdd-3216-0410-991c-e03cc46cb475 --- include/EDriverTypes.h | 6 +-- include/ISceneCollisionManager.h | 7 +-- include/IrrCompileConfig.h | 10 ++++- include/IrrlichtDevice.h | 51 ++++++++++++++++++++-- source/Irrlicht/CFileSystem.cpp | 6 ++- source/Irrlicht/CGUISpinBox.cpp | 4 ++ source/Irrlicht/CGUISpriteBank.cpp | 4 ++ source/Irrlicht/CImage.cpp | 3 ++ source/Irrlicht/COBJMeshFileLoader.cpp | 4 ++ source/Irrlicht/CParticleScaleAffector.cpp | 3 ++ source/Irrlicht/CSceneCollisionManager.cpp | 15 +++---- source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm | 8 ++-- source/Irrlicht/Makefile | 4 +- source/Irrlicht/os.cpp | 39 +++++++---------- 14 files changed, 115 insertions(+), 49 deletions(-) diff --git a/include/EDriverTypes.h b/include/EDriverTypes.h index b59b6b27..06bd67f5 100644 --- a/include/EDriverTypes.h +++ b/include/EDriverTypes.h @@ -19,9 +19,9 @@ namespace video EDT_NULL, //! The Irrlicht Engine Software renderer. - /** Runs on all platforms, with every hardware. It should only be used for - 2d graphics, but it can also perform some primitive 3d - functions. These 3d drawing functions are quite fast, but + /** Runs on all platforms, with every hardware. It should only + be used for 2d graphics, but it can also perform some primitive + 3d functions. These 3d drawing functions are quite fast, but very inaccurate, and don't even support clipping in 3D mode. */ EDT_SOFTWARE, diff --git a/include/ISceneCollisionManager.h b/include/ISceneCollisionManager.h index 531a91f0..a0324ae8 100644 --- a/include/ISceneCollisionManager.h +++ b/include/ISceneCollisionManager.h @@ -25,9 +25,6 @@ namespace scene { public: - //! Destructor - virtual ~ISceneCollisionManager() {} - //! Finds the collision point of a line and lots of triangles, if there is one. /** \param ray: Line with witch collisions are tested. \param selector: TriangleSelector containing the triangles. It @@ -112,6 +109,8 @@ namespace scene \param idBitMask: Only scene nodes with an id with bits set like in this mask will be tested. If the BitMask is 0, this feature is disabled. + Please note that the default node id of -1 will match with + every bitmask != 0 \param bNoDebugObjects: Doesn't take debug objects into account when true. These are scene nodes with IsDebugObject() = true. \param root If different from 0, the search is limited to the children of this node. @@ -147,6 +146,8 @@ namespace scene bits contained in this mask will be tested. However, if this parameter is 0, then all nodes are checked. feature is disabled. + Please note that the default node id of -1 will match with + every bitmask != 0 \param bNoDebugObjects: Doesn't take debug objects into account when true. These are scene nodes with IsDebugObject() = true. \return Scene node nearest to the camera, which collides with diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index 74fe443e..44e65e11 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -6,7 +6,13 @@ #define __IRR_COMPILE_CONFIG_H_INCLUDED__ //! Irrlicht SDK Version -#define IRRLICHT_SDK_VERSION "1.6 SVN" +#define IRRLICHT_VERSION_MAJOR 1 +#define IRRLICHT_VERSION_MINOR 6 +#define IRRLICHT_VERSION_REVISION 0 +// This flag will be defined only in SVN, the official release code will have +// it undefined +#define IRRLICHT_VERSION_SVN +#define IRRLICHT_SDK_VERSION "1.6-SVN" #include // TODO: Although included elsewhere this is required at least for mingw @@ -112,7 +118,7 @@ headers, e.g. Summer 2004. This is a Microsoft issue, not an Irrlicht one. #endif //! Define _IRR_COMPILE_WITH_OPENGL_ to compile the Irrlicht engine with OpenGL. -/** If you do not wish the engine to be compiled with OpengGL, comment this +/** If you do not wish the engine to be compiled with OpenGL, comment this define out. */ #define _IRR_COMPILE_WITH_OPENGL_ diff --git a/include/IrrlichtDevice.h b/include/IrrlichtDevice.h index 64b96a2f..7ee84411 100644 --- a/include/IrrlichtDevice.h +++ b/include/IrrlichtDevice.h @@ -33,9 +33,10 @@ namespace irr } // end namespace scene //! The Irrlicht device. You can create it with createDevice() or createDeviceEx(). - /** This is the most important class of the Irrlicht Engine. You can access everything - in the engine if you have a pointer to an instance of this class. - There should be only one instance of this class at any time. + /** This is the most important class of the Irrlicht Engine. You can + access everything in the engine if you have a pointer to an instance of + this class. There should be only one instance of this class at any + time. */ class IrrlichtDevice : public virtual IReferenceCounted { @@ -229,6 +230,50 @@ namespace irr virtual bool getGammaRamp(f32 &red, f32 &green, f32 &blue, f32 &brightness, f32 &contrast) =0; + + //! Allows to check which drivers are supported by the engine. + /** Even if true is returned the driver needs not be available + for an actual configuration requested upon device creation. */ + static bool isDriverSupported(video::E_DRIVER_TYPE driver) + { + switch (driver) + { + case video::EDT_NULL: + return true; + case video::EDT_SOFTWARE: +#ifdef _IRR_COMPILE_WITH_SOFTWARE_ + return true; +#else + return false; +#endif + case video::EDT_BURNINGSVIDEO: +#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ + return true; +#else + return false; +#endif + case video::EDT_DIRECT3D8: +#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_ + return true; +#else + return false; +#endif + case video::EDT_DIRECT3D9: +#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_ + return true; +#else + return false; +#endif + case video::EDT_OPENGL: +#ifdef _IRR_COMPILE_WITH_OPENGL_ + return true; +#else + return false; +#endif + default: + return false; + } + } }; } // end namespace irr diff --git a/source/Irrlicht/CFileSystem.cpp b/source/Irrlicht/CFileSystem.cpp index b55ceb74..76ae359e 100644 --- a/source/Irrlicht/CFileSystem.cpp +++ b/source/Irrlicht/CFileSystem.cpp @@ -398,10 +398,14 @@ core::string CFileSystem::getFileBasename(const core::string& filename s32 lastSlash = filename.findLast('/'); const s32 lastBackSlash = filename.findLast('\\'); lastSlash = core::max_(lastSlash, lastBackSlash); + + // get number of chars after last dot s32 end = 0; if (!keepExtension) { - end = filename.findLast('.'); + // take care to search only after last slash to check only for + // dots in the filename + end = filename.findLast('.', lastSlash); if (end == -1) end=0; else diff --git a/source/Irrlicht/CGUISpinBox.cpp b/source/Irrlicht/CGUISpinBox.cpp index 75475d65..e0dddbf7 100644 --- a/source/Irrlicht/CGUISpinBox.cpp +++ b/source/Irrlicht/CGUISpinBox.cpp @@ -26,6 +26,10 @@ CGUISpinBox::CGUISpinBox(const wchar_t* text, bool border,IGUIEnvironment* envir RangeMin(-FLT_MAX), RangeMax(FLT_MAX), FormatString(L"%f"), DecimalPlaces(-1) { + #ifdef _DEBUG + setDebugName("CGUISpinBox"); + #endif + s32 ButtonWidth = 16; IGUISpriteBank *sb = 0; if (environment && environment->getSkin()) diff --git a/source/Irrlicht/CGUISpriteBank.cpp b/source/Irrlicht/CGUISpriteBank.cpp index 6c8f13f7..3831d809 100644 --- a/source/Irrlicht/CGUISpriteBank.cpp +++ b/source/Irrlicht/CGUISpriteBank.cpp @@ -17,6 +17,10 @@ namespace gui CGUISpriteBank::CGUISpriteBank(IGUIEnvironment* env) : Environment(env), Driver(0) { + #ifdef _DEBUG + setDebugName("CGUISpriteBank"); + #endif + if (Environment) { Driver = Environment->getVideoDriver(); diff --git a/source/Irrlicht/CImage.cpp b/source/Irrlicht/CImage.cpp index 52331eb7..6fc2994e 100644 --- a/source/Irrlicht/CImage.cpp +++ b/source/Irrlicht/CImage.cpp @@ -1038,6 +1038,9 @@ namespace video CImage::CImage(ECOLOR_FORMAT format, const core::dimension2d& size) :Data(0), Size(size), Format(format), DeleteMemory(true) { + #ifdef _DEBUG + setDebugName("CImage"); + #endif initData(); } diff --git a/source/Irrlicht/COBJMeshFileLoader.cpp b/source/Irrlicht/COBJMeshFileLoader.cpp index b1c7eb71..01b8e64d 100644 --- a/source/Irrlicht/COBJMeshFileLoader.cpp +++ b/source/Irrlicht/COBJMeshFileLoader.cpp @@ -32,6 +32,10 @@ static const u32 WORD_BUFFER_LENGTH = 512; COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) : SceneManager(smgr), FileSystem(fs) { + #ifdef _DEBUG + setDebugName("COBJMeshFileLoader"); + #endif + if (FileSystem) FileSystem->grab(); } diff --git a/source/Irrlicht/CParticleScaleAffector.cpp b/source/Irrlicht/CParticleScaleAffector.cpp index 6b051e44..b3c2715d 100644 --- a/source/Irrlicht/CParticleScaleAffector.cpp +++ b/source/Irrlicht/CParticleScaleAffector.cpp @@ -8,6 +8,9 @@ namespace irr CParticleScaleAffector::CParticleScaleAffector(const core::dimension2df& scaleTo) : ScaleTo(scaleTo) { + #ifdef _DEBUG + setDebugName("CParticleScaleAffector"); + #endif } diff --git a/source/Irrlicht/CSceneCollisionManager.cpp b/source/Irrlicht/CSceneCollisionManager.cpp index fabfd7d1..3860242b 100644 --- a/source/Irrlicht/CSceneCollisionManager.cpp +++ b/source/Irrlicht/CSceneCollisionManager.cpp @@ -70,9 +70,9 @@ ISceneNode* CSceneCollisionManager::getSceneNodeFromRayBB(const core::line3d& children = root->getChildren(); const core::vector3df rayVector = ray.getVector().normalize(); @@ -782,7 +782,7 @@ core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, return pos + vel; // original destination point - core::vector3df destinationPoint = pos + vel; + const core::vector3df destinationPoint = pos + vel; core::vector3df newBasePoint = pos; // only update if we are not already very close @@ -800,9 +800,8 @@ core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, // calculate sliding plane - core::vector3df slidePlaneOrigin = colData.intersectionPoint; - core::vector3df slidePlaneNormal = newBasePoint - colData.intersectionPoint; - slidePlaneNormal.normalize(); + const core::vector3df slidePlaneOrigin = colData.intersectionPoint; + const core::vector3df slidePlaneNormal = (newBasePoint - colData.intersectionPoint).normalize(); core::plane3d slidingPlane(slidePlaneOrigin, slidePlaneNormal); core::vector3df newDestinationPoint = @@ -811,7 +810,7 @@ core::vector3df CSceneCollisionManager::collideWithWorld(s32 recursionDepth, // generate slide vector - core::vector3df newVelocityVector = newDestinationPoint - + const core::vector3df newVelocityVector = newDestinationPoint - colData.intersectionPoint; if (newVelocityVector.getLength() < veryCloseDistance) diff --git a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm index a6214201..495e144f 100644 --- a/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm +++ b/source/Irrlicht/MacOSX/CIrrDeviceMacOSX.mm @@ -1342,10 +1342,10 @@ void CIrrDeviceMacOSX::pollJoysticks() result = (*(ActiveJoysticks[joystick].interface))->getElementValue(ActiveJoysticks[joystick].interface, ActiveJoysticks[joystick].axisComp[n].cookie, &hidEvent); if (kIOReturnSuccess == result) { - f32 min = -32768.0f; - f32 max = 32768.0f; - f32 deviceScale = max - min; - f32 readScale = (f32)ActiveJoysticks[joystick].axisComp[n].maxRead - (f32)ActiveJoysticks[joystick].axisComp[n].minRead; + const f32 min = -32768.0f; + const f32 max = 32767.0f; + const f32 deviceScale = max - min; + const f32 readScale = (f32)ActiveJoysticks[joystick].axisComp[n].maxRead - (f32)ActiveJoysticks[joystick].axisComp[n].minRead; if (hidEvent.value < ActiveJoysticks[joystick].axisComp[n].minRead) ActiveJoysticks[joystick].axisComp[n].minRead = hidEvent.value; diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 60b727bd..7a6057d1 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -1,5 +1,5 @@ -VERSION = 1.5 -# Irrlicht Engine 1.5 +VERSION = 1.6.0-SVN +# Irrlicht Engine 1.6.0-SVN # Makefile for Linux # # To use, just run: diff --git a/source/Irrlicht/os.cpp b/source/Irrlicht/os.cpp index f8845017..a41eee1b 100644 --- a/source/Irrlicht/os.cpp +++ b/source/Irrlicht/os.cpp @@ -11,30 +11,23 @@ #include #define bswap_16(X) SDL_Swap16(X) #define bswap_32(X) SDL_Swap32(X) -#elif defined(_IRR_WINDOWS_API_) - #if (defined(_MSC_VER) && (_MSC_VER > 1298)) - #include - #define bswap_16(X) _byteswap_ushort(X) - #define bswap_32(X) _byteswap_ulong(X) - #else - #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) - #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) - #endif +#elif defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && (_MSC_VER > 1298) + #include + #define bswap_16(X) _byteswap_ushort(X) + #define bswap_32(X) _byteswap_ulong(X) +#elif defined(_IRR_OSX_PLATFORM_) + #include + #define bswap_16(X) OSReadSwapInt16(&X,0) + #define bswap_32(X) OSReadSwapInt32(&X,0) +#elif defined(__FreeBSD__) + #include + #define bswap_16(X) bswap16(X) + #define bswap_32(X) bswap32(X) +#elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) && !defined(_IRR_WINDOWS_API_) + #include #else - #if defined(_IRR_OSX_PLATFORM_) - #include - #define bswap_16(X) OSReadSwapInt16(&X,0) - #define bswap_32(X) OSReadSwapInt32(&X,0) - #elif defined(__FreeBSD__) - #include - #define bswap_16(X) bswap16(X) - #define bswap_32(X) bswap32(X) - #elif !defined(_IRR_SOLARIS_PLATFORM_) && !defined(__PPC__) - #include - #else - #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&=0xFF00) >> 8)) - #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) - #endif + #define bswap_16(X) ((((X)&0xFF) << 8) | (((X)&0xFF00) >> 8)) + #define bswap_32(X) ( (((X)&0x000000FF)<<24) | (((X)&0xFF000000) >> 24) | (((X)&0x0000FF00) << 8) | (((X) &0x00FF0000) >> 8)) #endif namespace irr