From 897a3fa6a6158e5f9a71d1c3053e07162bae3182 Mon Sep 17 00:00:00 2001 From: hybrid Date: Sun, 30 Mar 2008 23:19:12 +0000 Subject: [PATCH] Merged from branch 1.4 revisions 1290:1305. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1306 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 2 ++ include/ISceneManager.h | 17 +++++++++-- include/irrTypes.h | 33 +++++++++++++++++++-- source/Irrlicht/CBillboardSceneNode.cpp | 2 +- source/Irrlicht/CD3D8Driver.h | 2 +- source/Irrlicht/CIrrDeviceWin32.cpp | 7 +++-- source/Irrlicht/COpenGLDriver.cpp | 4 +-- source/Irrlicht/CReadFile.cpp | 2 +- source/Irrlicht/CSceneManager.cpp | 38 +++++++++++++++++++++++++ source/Irrlicht/CSceneManager.h | 3 ++ 10 files changed, 98 insertions(+), 12 deletions(-) diff --git a/changes.txt b/changes.txt index 734943d1..3027c145 100644 --- a/changes.txt +++ b/changes.txt @@ -49,6 +49,8 @@ Changes in version 1.5 (... 2008) ------------------------------------------- Changes in version 1.4.1 (??? 2008) + - Fixed bug in CBillboardSceneNode::setColor, reported by rogerborg + - Fixed clipping of menu, toolbar and combo box GUI elements, reported by greenya - setNotClipped now applies all the way up to the root of the GUI environment, rather than just to the next parent diff --git a/include/ISceneManager.h b/include/ISceneManager.h index bb38329a..9f951e89 100644 --- a/include/ISceneManager.h +++ b/include/ISceneManager.h @@ -290,6 +290,17 @@ namespace scene **/ virtual IAnimatedMesh* getMesh(const c8* filename) = 0; + //! Returns pointer to an animateable mesh. Loads the file if not loaded already. + /** + * Works just as getMesh(const char* filename) + * If you want to remove a loaded mesh from the cache again, use removeMesh(). + * \param file: File handle of the mesh to load. + * \return Returns NULL if failed and the pointer to the mesh if + * successful. + * This pointer should not be dropped. See IReferenceCounted::drop() for more information. + **/ + virtual IAnimatedMesh* getMesh(io::IReadFile* file) = 0; + //! Returns an interface to the mesh cache which is shared beween all existing scene managers. /** With this interface, it is possible to manually add new loaded meshes (if ISceneManager::getMesh() is not sufficient), to remove them and to iterate @@ -891,9 +902,9 @@ namespace scene ISceneNode::OnRegisterSceneNode() call. \param node: Node to register for drawing. Usually scene nodes would set 'this' as parameter here because they want to be drawn. - \param pass: Specifies when the mode wants to be drawn in relation to the other nodes. + \param pass: Specifies when the node wants to be drawn in relation to the other nodes. For example, if the node is a shadow, it usually wants to be drawn after all other nodes - and will use ESNRP_SHADOW for this. See E_SCENE_NODE_RENDER_PASS for details. + and will use ESNRP_SHADOW for this. See scene::E_SCENE_NODE_RENDER_PASS for details. \return scene will be rendered ( passed culling ) */ virtual u32 registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0; @@ -973,7 +984,7 @@ namespace scene how big the radius should be, you could use the following code to determine it: \code - const core::aabbox& box = yourSceneNode->getBoundingBox(); + const core::aabbox3d& box = yourSceneNode->getBoundingBox(); core::vector3df radius = box.MaxEdge - box.getCenter(); \endcode \param gravityPerSecond: Sets the gravity of the environment. A good example value would be diff --git a/include/irrTypes.h b/include/irrTypes.h index e6c9fc21..15deb92a 100644 --- a/include/irrTypes.h +++ b/include/irrTypes.h @@ -12,11 +12,19 @@ namespace irr //! 8 bit unsigned variable. /** This is a typedef for unsigned char, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef unsigned __int8 u8; +#else typedef unsigned char u8; +#endif //! 8 bit signed variable. /** This is a typedef for signed char, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef __int8 s8; +#else typedef signed char s8; +#endif //! 8 bit character variable. /** This is a typedef for char, it ensures portability of the engine. */ @@ -26,21 +34,37 @@ typedef char c8; //! 16 bit unsigned variable. /** This is a typedef for unsigned short, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef unsigned __int16 u16; +#else typedef unsigned short u16; +#endif //! 16 bit signed variable. /** This is a typedef for signed short, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef __int16 s16; +#else typedef signed short s16; +#endif //! 32 bit unsigned variable. /** This is a typedef for unsigned int, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef unsigned __int32 u32; +#else typedef unsigned int u32; +#endif //! 32 bit signed variable. /** This is a typedef for signed int, it ensures portability of the engine. */ +#ifdef _MSC_VER +typedef __int32 s32; +#else typedef signed int s32; +#endif @@ -98,7 +122,12 @@ typedef unsigned short wchar_t; //! define a break macro for debugging. #if defined(_DEBUG) #if defined(_IRR_WINDOWS_API_) && defined(_MSC_VER) && !defined (_WIN32_WCE) -#define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} + #if defined(_WIN64) // using portable common solution for x64 configuration + #include + #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_CrtDbgBreak();} + #else + #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) if (_CONDITION_) {_asm int 3} + #endif #else #include "assert.h" #define _IRR_DEBUG_BREAK_IF( _CONDITION_ ) assert( !(_CONDITION_) ); @@ -108,7 +137,7 @@ typedef unsigned short wchar_t; #endif //! Defines a small statement to work around a microsoft compiler bug. -/** The microsft compiler 7.0 - 7.1 has a bug: +/** The microsoft compiler 7.0 - 7.1 has a bug: When you call unmanaged code that returns a bool type value of false from managed code, the return value may appear as true. See http://support.microsoft.com/default.aspx?kbid=823071 for details. diff --git a/source/Irrlicht/CBillboardSceneNode.cpp b/source/Irrlicht/CBillboardSceneNode.cpp index eafc53e9..3ce71c81 100644 --- a/source/Irrlicht/CBillboardSceneNode.cpp +++ b/source/Irrlicht/CBillboardSceneNode.cpp @@ -191,7 +191,7 @@ void CBillboardSceneNode::deserializeAttributes(io::IAttributes* in, io::SAttrib void CBillboardSceneNode::setColor(const video::SColor & overallColor) { for(u32 vertex = 0; vertex < 4; ++vertex) - vertices[0].Color = overallColor; + vertices[vertex].Color = overallColor; } diff --git a/source/Irrlicht/CD3D8Driver.h b/source/Irrlicht/CD3D8Driver.h index 15764d6f..c714b25b 100644 --- a/source/Irrlicht/CD3D8Driver.h +++ b/source/Irrlicht/CD3D8Driver.h @@ -43,7 +43,7 @@ namespace video virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color); //! applications must call this method after performing any rendering. returns false if failed. - virtual bool endScene( s32 windowId, core::rect* sourceRect=0 ); + virtual bool endScene(s32 windowId=0, core::rect* sourceRect=0); //! queries the features of the driver, returns true if feature is available virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const; diff --git a/source/Irrlicht/CIrrDeviceWin32.cpp b/source/Irrlicht/CIrrDeviceWin32.cpp index 2ffa0bdc..00757d70 100644 --- a/source/Irrlicht/CIrrDeviceWin32.cpp +++ b/source/Irrlicht/CIrrDeviceWin32.cpp @@ -237,7 +237,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) WORD KeyAsc=0; GetKeyboardState(allKeys); - ToAscii(wParam,lParam,allKeys,&KeyAsc,0); + ToAscii((UINT)wParam,(UINT)lParam,allKeys,&KeyAsc,0); event.KeyInput.Shift = ((allKeys[VK_SHIFT] & 0x80)!=0); event.KeyInput.Control = ((allKeys[VK_CONTROL] & 0x80)!=0); @@ -610,7 +610,7 @@ void CIrrDeviceWin32::present(video::IImage* image, s32 windowId, core::rect(windowId); HDC dc = GetDC(hwnd); @@ -779,10 +779,13 @@ void CIrrDeviceWin32::getWindowsVersion(core::stringc& out) case VER_PLATFORM_WIN32_NT: if (osvi.dwMajorVersion <= 4) out.append("Microsoft Windows NT "); + else if (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0) out.append("Microsoft Windows 2000 "); + else if ( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 1 ) out.append("Microsoft Windows XP "); + else if ( osvi.dwMajorVersion == 6 && osvi.dwMinorVersion == 0 ) out.append("Microsoft Windows Vista "); diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index e18b9bf3..8ba82e90 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -396,7 +396,7 @@ void COpenGLDriver::createMaterialRenderers() //! presents the rendered scene on the screen, returns false if failed bool COpenGLDriver::endScene( s32 windowId, core::rect* sourceRect ) { - CNullDriver::endScene( windowId ); + CNullDriver::endScene(); glFlush(); @@ -2257,7 +2257,7 @@ void COpenGLDriver::setFog(SColor c, bool linearFog, f32 start, { CNullDriver::setFog(c, linearFog, start, end, density, pixelFog, rangeFog); - glFogi(GL_FOG_MODE, linearFog ? GL_LINEAR : GL_EXP); + glFogf(GL_FOG_MODE, linearFog ? GL_LINEAR : GL_EXP); #ifdef GL_EXT_fog_coord if (FeatureAvailable[IRR_EXT_fog_coord]) glFogi(GL_FOG_COORDINATE_SOURCE, GL_FRAGMENT_DEPTH); diff --git a/source/Irrlicht/CReadFile.cpp b/source/Irrlicht/CReadFile.cpp index 42452d4a..fbc7f03e 100644 --- a/source/Irrlicht/CReadFile.cpp +++ b/source/Irrlicht/CReadFile.cpp @@ -37,7 +37,7 @@ s32 CReadFile::read(void* buffer, u32 sizeToRead) if (!isOpen()) return 0; - return fread(buffer, 1, sizeToRead, File); + return (s32)fread(buffer, 1, sizeToRead, File); } diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index 8137aee3..5cfae40e 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -345,6 +345,44 @@ IAnimatedMesh* CSceneManager::getMesh(const c8* filename) } +//! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. +IAnimatedMesh* CSceneManager::getMesh(io::IReadFile* file) +{ + if (!file) + return 0; + + core::stringc name = file->getFileName(); + IAnimatedMesh* msh = MeshCache->getMeshByFilename(file->getFileName()); + if (msh) + return msh; + + name.make_lower(); + s32 count = MeshLoaderList.size(); + for (s32 i=count-1; i>=0; --i) + { + if (MeshLoaderList[i]->isALoadableFileExtension(name.c_str())) + { + // reset file to avoid side effects of previous calls to createMesh + file->seek(0); + msh = MeshLoaderList[i]->createMesh(file); + if (msh) + { + MeshCache->addMesh(file->getFileName(), msh); + msh->drop(); + break; + } + } + } + + if (!msh) + os::Printer::log("Could not load mesh, file format seems to be unsupported", file->getFileName(), ELL_ERROR); + else + os::Printer::log("Loaded mesh", file->getFileName(), ELL_INFORMATION); + + return msh; +} + + //! returns the video driver video::IVideoDriver* CSceneManager::getVideoDriver() { diff --git a/source/Irrlicht/CSceneManager.h b/source/Irrlicht/CSceneManager.h index 33210c14..9898c4eb 100644 --- a/source/Irrlicht/CSceneManager.h +++ b/source/Irrlicht/CSceneManager.h @@ -42,6 +42,9 @@ namespace scene //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. virtual IAnimatedMesh* getMesh(const c8* filename); + //! gets an animateable mesh. loads it if needed. returned pointer must not be dropped. + virtual IAnimatedMesh* getMesh(io::IReadFile* file); + //! Returns an interface to the mesh cache which is shared beween all existing scene managers. virtual IMeshCache* getMeshCache();