From 291fb2ffac4ac612a0436c8801bacdf14c561dfd Mon Sep 17 00:00:00 2001 From: cutealien Date: Tue, 23 Apr 2019 20:17:39 +0000 Subject: [PATCH] Merging r5788 through r5805 from trunk to ogl-es branch git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5806 dfc29bdd-3216-0410-991c-e03cc46cb475 --- changes.txt | 9 ++- examples/11.PerPixelLighting/main.cpp | 16 ++--- examples/12.TerrainRendering/main.cpp | 14 ++--- examples/13.RenderToTexture/main.cpp | 55 +++++++++------- include/EReadFileType.h | 34 ++++++++++ include/IColladaMeshWriter.h | 9 +-- include/IMemoryReadFile.h | 31 ++++++++++ include/IReadFile.h | 7 +++ include/IrrCompileConfig.h | 48 ++++++++++++++ include/S3DVertex.h | 2 + include/SColor.h | 2 +- include/SViewFrustum.h | 4 +- include/dimension2d.h | 2 +- include/irrString.h | 26 ++++++++ source/Irrlicht/CAnimatedMeshSceneNode.cpp | 8 +++ source/Irrlicht/CBillboardSceneNode.cpp | 3 + source/Irrlicht/CColladaFileLoader.cpp | 62 ++++++++++++++++++- source/Irrlicht/CColladaFileLoader.h | 16 +++++ source/Irrlicht/CColladaMeshWriter.cpp | 39 ++++++++++-- source/Irrlicht/CColladaMeshWriter.h | 15 ++++- source/Irrlicht/CCubeSceneNode.cpp | 11 ++++ source/Irrlicht/CLimitReadFile.h | 6 ++ source/Irrlicht/CMemoryFile.h | 16 ++++- source/Irrlicht/CMeshSceneNode.cpp | 8 +++ source/Irrlicht/CNullDriver.cpp | 5 +- source/Irrlicht/COctreeSceneNode.cpp | 12 ++++ source/Irrlicht/COpenGLSLMaterialRenderer.cpp | 12 ++-- source/Irrlicht/CQuake3ShaderSceneNode.cpp | 8 +++ source/Irrlicht/CReadFile.h | 6 ++ source/Irrlicht/CSceneManager.cpp | 48 ++++++++++++++ source/Irrlicht/CShadowVolumeSceneNode.cpp | 6 ++ source/Irrlicht/CSkyDomeSceneNode.cpp | 4 ++ source/Irrlicht/CSphereSceneNode.cpp | 11 ++++ source/Irrlicht/CTerrainSceneNode.cpp | 6 +- source/Irrlicht/CTerrainTriangleSelector.cpp | 6 ++ source/Irrlicht/CWaterSurfaceSceneNode.cpp | 3 + source/Irrlicht/Irrlicht-gcc.cbp | 2 + tests/irrString.cpp | 25 ++++++++ tests/tests-last-passed-at.txt | 2 +- 39 files changed, 532 insertions(+), 67 deletions(-) create mode 100644 include/EReadFileType.h create mode 100644 include/IMemoryReadFile.h diff --git a/changes.txt b/changes.txt index c0297142..6b7f3795 100644 --- a/changes.txt +++ b/changes.txt @@ -9,6 +9,10 @@ Changes in ogl-es (not yet released - will be merged with trunk at some point) -------------------------- Changes in 1.9 (not yet released) +- Add IMemoryReadFile interface which allows direct access to memory block used as file. +- Add IReadFile::getType() interface to all users to find out what kind of class implements that interface. +- .dae/Collada reader/writer now handle whitespace in texture-filenames with escape characters (handle them as xs:anyURI). +- Add function string::insert. - EditBox now still allows overwriting characters when the text-length is at max. - Bugfix: CMatrix4::transformPlane was calculating the wrong plane-normal before. - SViewFrustum::recalculateBoundingBox no longer includes camera position in the bounding-box. Only using frustum corners now. Thx @DevSH for bugreport & patch. @@ -17,7 +21,7 @@ Changes in 1.9 (not yet released) - Bugfix: CCameraSceneNode resets the IsOrthogonal flag to false now when it recalculates a projection matrix. - SViewFrustum::setFrom and SViewFrustum constructor now use a parameter to allow to set the correct near clipping plane when the projection matrix doesn't use a target depth range of 0 to z, but for example -z to z. So OGL projections matrices can now also use it. - Remove code to read boundingbox element in Collada reader as it's not in Collada specification. -- .dae/Collade reader now converts from Collada's right-handed to Irrlicht's left handed coordinate system (switching z to -z) +- .dae/Collada reader now converts from Collada's right-handed to Irrlicht's left handed coordinate system (switching z to -z) - Add irr::string::eraseTrailingFloatZeros to kick out trailing 0's for strings generated from floats. - .dae/Collada writer now converts from Irrlicht's left-handed to Collada's right-handed coordinate system (switching z to -z) - Switch Collada writer to utf8 xml's. @@ -235,6 +239,9 @@ should now be fps independentn -------------------------- Changes in 1.8.5 + - Fix SViewFrustum::clipLine. Was before clipping at wrong points (inverse places along lines). + - Fix compilation on OSX and prevent capturing mouse cursor when Window is not on top (Patch #319) + Thanks at Artem Shoobovych for bugreport and patch (https://sourceforge.net/p/irrlicht/patches/319/) - Fix serialization of OverrideTextColorEnabled flag in CGUITab. Thanks @ chronologicaldot for reporting (http://irrlicht.sourceforge.net/forum/viewtopic.php?f=7&t=52344&p=303891#p303891) - CFileSystem::getAbsolutePath no longer wrongly converts an empty filename to "/" on unix platforms. This fixes the bug that CFileSystem::createAndOpenFile("") returned a (strange behaving) non-null file pointer. diff --git a/examples/11.PerPixelLighting/main.cpp b/examples/11.PerPixelLighting/main.cpp index a4d8c5b0..c2e03af2 100644 --- a/examples/11.PerPixelLighting/main.cpp +++ b/examples/11.PerPixelLighting/main.cpp @@ -237,8 +237,8 @@ int main() if (roomMesh) { - // The Room mesh doesn't have proper Texture Mapping on the - // floor, so we can recreate them on runtime + // The room mesh doesn't have proper texture mapping on the + // floor, so we can recreate the mapping on runtime. smgr->getMeshManipulator()->makePlanarTextureMapping( roomMesh->getMesh(0), 0.003f); @@ -263,11 +263,7 @@ int main() if (normalMap) driver->makeNormalMapTexture(normalMap, 9.0f); -/* - // The Normal Map and the displacement map/height map in the alpha channel - video::ITexture* normalMap = - driver->getTexture(mediaPath + "rockwall_NRM.tga"); -*/ + /* But just setting color and normal map is not everything. The material we want to use needs some additional information per @@ -317,7 +313,7 @@ int main() scene::IAnimatedMesh* earthMesh = smgr->getMesh(mediaPath + "earth.x"); if (earthMesh) { - //perform various task with the mesh manipulator + //perform various tasks with the mesh manipulator scene::IMeshManipulator *manipulator = smgr->getMeshManipulator(); // create mesh copy with tangent information from original earth.x mesh @@ -389,9 +385,9 @@ int main() /* Now the same again, with the second light. The difference is that we add a particle system to it too. And because the light moves, the - particles of the particlesystem will follow. If you want to know more + particles of the particle system will follow. If you want to know more about how particle systems are created in Irrlicht, take a look at the - specialFx example. Maybe you will have noticed that we only add 2 + SpecialFX example. Maybe you will have noticed that we only add 2 lights, this has a simple reason: The low end version of this material was written in ps1.1 and vs1.1, which doesn't allow more lights. You could add a third light to the scene, but it won't be used to shade the diff --git a/examples/12.TerrainRendering/main.cpp b/examples/12.TerrainRendering/main.cpp index 5686bf32..7c38598e 100644 --- a/examples/12.TerrainRendering/main.cpp +++ b/examples/12.TerrainRendering/main.cpp @@ -10,9 +10,7 @@ simple solution for building larger area on small heightmaps -> terrain smoothing. In the beginning there is nothing special. We include the needed header files -and create an event listener to listen if the user presses a key: The 'W' key -switches to wireframe mode, the 'P' key to pointcloud mode, and the 'D' key -toggles between solid and detail mapped material. +and create an event listener to listen if the user presses certain keys. */ #include #include "driverChoice.h" @@ -48,7 +46,7 @@ public: !Terrain->getMaterial(0).Wireframe); Terrain->setMaterialFlag(video::EMF_POINTCLOUD, false); return true; - case irr::KEY_KEY_P: // switch wire frame mode + case irr::KEY_KEY_P: // switch point cloud mode Terrain->setMaterialFlag(video::EMF_POINTCLOUD, !Terrain->getMaterial(0).PointCloud); Terrain->setMaterialFlag(video::EMF_WIREFRAME, false); @@ -128,7 +126,7 @@ int main() //set other font env->getSkin()->setFont(env->getFont(mediaPath + "fontlucida.png")); - // add some help text + // add some help text (let's ignore 'P' and 'X' which are more about debugging) env->addStaticText( L"Press 'W' to change wireframe mode\nPress 'D' to toggle detail map\nPress 'S' to toggle skybox/skydome", core::rect(10,421,250,475), true, true, 0, -1, true); @@ -147,13 +145,13 @@ int main() /* Here comes the terrain renderer scene node: We add it just like any other scene node to the scene using - ISceneManager::addTerrainSceneNode(). The only parameter we use is a + ISceneManager::addTerrainSceneNode(). The first parameter is a file name to the heightmap we use. A heightmap is simply a gray scale texture. The terrain renderer loads it and creates the 3D terrain from it. - To make the terrain look more big, we change the scale factor of - it to (40, 4.4, 40). Because we don't have any dynamic lights in the + To make the terrain look bigger, we change it's scale factor to + (40, 4.4, 40). Because we don't have any dynamic lights in the scene, we switch off the lighting, and we set the file terrain-texture.jpg as texture for the terrain and detailmap3.jpg as second texture, called detail map. At last, we set the scale values for diff --git a/examples/13.RenderToTexture/main.cpp b/examples/13.RenderToTexture/main.cpp index f0145ff3..99a18eac 100644 --- a/examples/13.RenderToTexture/main.cpp +++ b/examples/13.RenderToTexture/main.cpp @@ -1,11 +1,13 @@ /** Example 013 Render To Texture This tutorial shows how to render to a texture using Irrlicht. Render to -texture is a feature with which it is possible to create nice special effects. +texture is a feature where everything which would usually be rendered to +the screen is instead written to a (special) texture. This can be used to +create nice special effects. In addition, this tutorial shows how to enable specular highlights. In the beginning, everything as usual. Include the needed headers, ask the user -for the rendering driver, create the Irrlicht Device: +for the rendering driver, create the Irrlicht device: */ #include @@ -84,27 +86,36 @@ int main() */ // create test cube - scene::ISceneNode* test = smgr->addCubeSceneNode(60); + scene::ISceneNode* cube = smgr->addCubeSceneNode(60); // let the cube rotate and set some light settings scene::ISceneNodeAnimator* anim = smgr->createRotationAnimator( core::vector3df(0.3f, 0.3f,0)); - test->setPosition(core::vector3df(-100,0,-100)); - test->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting - test->addAnimator(anim); + cube->setPosition(core::vector3df(-100,0,-100)); + cube->setMaterialFlag(video::EMF_LIGHTING, false); // disable dynamic lighting + cube->addAnimator(anim); anim->drop(); // set window caption device->setWindowCaption(L"Irrlicht Engine - Render to Texture and Specular Highlights example"); /* - To test out the render to texture feature, we need a render target - texture. These are not like standard textures, but need to be created - first. To create one, we call IVideoDriver::addRenderTargetTexture() - and specify the size of the texture. Please don't use sizes bigger than - the frame buffer for this, because the render target shares the zbuffer - with the frame buffer. + To test out the render to texture feature, we need to define our + new rendertarget. The rendertarget will need one texture to receive + the result you would otherwise see on screen and one texture + which is used as depth-buffer. + + (Note: If you worked with older Irrlicht versions (before 1.9) you might be + used to only create a rendertarget texture and no explicit rendertarget. While + that's still possible, it's no longer recommended.) + + The rendertarget textures are not like standard textures, but need to be created + first. To create them, we call IVideoDriver::addRenderTargetTexture() + and specify the size of the texture and the type. + For depth-maps you can use types ECF_D16, ECF_D32 or ECF_D24S8. When ECF_D24S8 + you can also use a stencil-buffer. + Because we want to render the scene not from the user camera into the texture, we add another fixed camera to the scene. But before we do all this, we check if the current running driver is able to render to @@ -113,19 +124,18 @@ int main() // create render target video::IRenderTarget* renderTarget = 0; - video::ITexture* renderTargetTex = 0; scene::ICameraSceneNode* fixedCam = 0; - if (driver->queryFeature(video::EVDF_RENDER_TO_TARGET)) { - renderTargetTex = driver->addRenderTargetTexture(core::dimension2d(256, 256), "RTT1", video::ECF_A8R8G8B8); - video::ITexture* renderTargetDepth = driver->addRenderTargetTexture(core::dimension2d(256, 256), "DepthStencil", video::ECF_D16); + const core::dimension2d rtDim(256, 256); // always use same size for render target texture and it's depth-buffer + video::ITexture* renderTargetTex = driver->addRenderTargetTexture(rtDim, "RTT1", video::ECF_A8R8G8B8); + video::ITexture* renderTargetDepth = driver->addRenderTargetTexture(rtDim, "DepthStencil", video::ECF_D16); renderTarget = driver->addRenderTarget(); renderTarget->setTexture(renderTargetTex, renderTargetDepth); - test->setMaterialTexture(0, renderTargetTex); // set material of cube to render target + cube->setMaterialTexture(0, renderTargetTex); // set material of cube to render target // add fixed camera fixedCam = smgr->addCameraSceneNode(0, core::vector3df(10,10,-80), @@ -174,22 +184,21 @@ int main() { // draw scene into render target - // set render target texture + // set render target driver->setRenderTargetEx(renderTarget, video::ECBF_COLOR | video::ECBF_DEPTH, video::SColor(0,0,0,255)); // make cube invisible and set fixed camera as active camera - test->setVisible(false); + cube->setVisible(false); smgr->setActiveCamera(fixedCam); // draw whole scene into render buffer smgr->drawAll(); - // set back old render target - // The buffer might have been distorted, so clear it - driver->setRenderTargetEx(0, 0, video::SColor(0)); + // set back old render target (the screen) + driver->setRenderTargetEx(0, 0); // make the cube visible and set the user controlled camera as active one - test->setVisible(true); + cube->setVisible(true); smgr->setActiveCamera(fpsCamera); } diff --git a/include/EReadFileType.h b/include/EReadFileType.h new file mode 100644 index 00000000..3ea49c1d --- /dev/null +++ b/include/EReadFileType.h @@ -0,0 +1,34 @@ +// Copyright (C) Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __E_READ_FILE_TYPES_H_INCLUDED__ +#define __E_READ_FILE_TYPES_H_INCLUDED__ + +#include "irrTypes.h" + +namespace irr +{ +namespace io +{ + + //! An enumeration for different class types implementing IReadFile + enum EREAD_FILE_TYPE + { + //! CReadFile + ERFT_READ_FILE = MAKE_IRR_ID('r','e','a','d'), + + //! CMemoryReadFile + ERFT_MEMORY_READ_FILE = MAKE_IRR_ID('r','m','e','m'), + + //! CLimitReadFile + ERFT_LIMIT_READ_FILE = MAKE_IRR_ID('r','l','i','m'), + + //! Unknown type + EFIT_UNKNOWN = MAKE_IRR_ID('u','n','k','n'), + }; +} // end namespace io +} // end namespace irr + + +#endif diff --git a/include/IColladaMeshWriter.h b/include/IColladaMeshWriter.h index cbd4030e..a8c6dd24 100644 --- a/include/IColladaMeshWriter.h +++ b/include/IColladaMeshWriter.h @@ -154,6 +154,7 @@ namespace scene //! Callback interface to use custom names on collada writing. /** You can either modify names and id's written to collada or you can use this interface to just find out which names are used on writing. + Names are often used later as xs:anyURI, so avoid whitespace, '#' and '%' in the names. */ class IColladaMeshWriterNames : public virtual IReferenceCounted { @@ -165,7 +166,7 @@ namespace scene /** Note that names really must be unique here per mesh-pointer, so mostly it's a good idea to return the nameForMesh from IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow - the xs::NCName standard to be valid, you can run them through + the xs:NCName standard to be valid, you can run them through IColladaMeshWriter::toNCName to ensure that. \param mesh Pointer to the mesh which needs a name \param instance When E_COLLADA_GEOMETRY_WRITING is not ECGI_PER_MESH then @@ -177,7 +178,7 @@ namespace scene /** Note that names really must be unique here per node-pointer, so mostly it's a good idea to return the nameForNode from IColladaMeshWriter::getDefaultNameGenerator(). Also names must follow - the xs::NCName standard to be valid, you can run them through + the xs:NCName standard to be valid, you can run them through IColladaMeshWriter::toNCName to ensure that. */ virtual irr::core::stringc nameForNode(const scene::ISceneNode* node) = 0; @@ -190,7 +191,7 @@ namespace scene instances per node are identical between different nodes you can reduce the number of exported materials using that knowledge by using identical names for such shared materials. - Names must follow the xs::NCName standard to be valid, you can run them + Names must follow the xs:NCName standard to be valid, you can run them through IColladaMeshWriter::toNCName to ensure that. */ virtual irr::core::stringc nameForMaterial(const video::SMaterial & material, int materialId, const scene::IMesh* mesh, const scene::ISceneNode* node) = 0; @@ -382,7 +383,7 @@ namespace scene return DefaultNameGenerator; } - //! Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix. + //! Restrict the characters of oldString a set of allowed characters in xs:NCName and add the prefix. /** A tool function to help when using a custom name generator to generative valid names for collada names and id's. */ virtual irr::core::stringc toNCName(const irr::core::stringc& oldString, const irr::core::stringc& prefix=irr::core::stringc("_NC_")) const = 0; diff --git a/include/IMemoryReadFile.h b/include/IMemoryReadFile.h new file mode 100644 index 00000000..435cfa53 --- /dev/null +++ b/include/IMemoryReadFile.h @@ -0,0 +1,31 @@ +// Copyright Michael Zeilfelder +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __I_MEMORY_READ_FILE_H_INCLUDED__ +#define __I_MEMORY_READ_FILE_H_INCLUDED__ + +#include "IReadFile.h" + +namespace irr +{ +namespace io +{ + + //! Interface providing read access to a memory read file. + class IMemoryReadFile : public IReadFile + { + public: + //! Get direct access to internal buffer of memory block used as file. + /** It's usually better to use the IReadFile functions to access + the file content. But as that buffer exist over the full life-time + of a CMemoryReadFile, it's sometimes nice to avoid the additional + data-copy which read() needs. + */ + virtual const void *getBuffer() const = 0; + }; +} // end namespace io +} // end namespace irr + +#endif + diff --git a/include/IReadFile.h b/include/IReadFile.h index 47deb7e4..f3de9ebb 100644 --- a/include/IReadFile.h +++ b/include/IReadFile.h @@ -7,6 +7,7 @@ #include "IReferenceCounted.h" #include "coreutil.h" +#include "EReadFileType.h" namespace irr { @@ -42,6 +43,12 @@ namespace io //! Get name of file. /** \return File name as zero terminated character string. */ virtual const io::path& getFileName() const = 0; + + //! Get the type of the class implementing this interface + virtual EREAD_FILE_TYPE getType() const + { + return EFIT_UNKNOWN; + } }; //! Internal function, please do not use. diff --git a/include/IrrCompileConfig.h b/include/IrrCompileConfig.h index 9257875c..4906aacc 100644 --- a/include/IrrCompileConfig.h +++ b/include/IrrCompileConfig.h @@ -439,6 +439,54 @@ tool . */ //! Uncomment the following line if you want to ignore the deprecated warnings //#define IGNORE_DEPRECATED_WARNING +//! Define _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ to support ShadowVolumes +#define _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ +#undef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_OCTREE_SCENENODE_ to support OctreeSceneNodes +#define _IRR_COMPILE_WITH_OCTREE_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_OCTREE_SCENENODE_ +#undef _IRR_COMPILE_WITH_OCTREE_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ to support TerrainSceneNodes +#define _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_TERRAIN_SCENENODE_ +#undef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ to support BillboardSceneNodes +#define _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ +#undef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ to support WaterSurfaceSceneNodes +#define _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ +#undef _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ to support SkydomeSceneNodes +#define _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_SKYDOME_SCENENODE_ +#undef _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_CUBE_SCENENODE_ to support CubeSceneNodes +#define _IRR_COMPILE_WITH_CUBE_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_CUBE_SCENENODE_ +#undef _IRR_COMPILE_WITH_CUBE_SCENENODE_ +#endif + +//! Define _IRR_COMPILE_WITH_SPHERE_SCENENODE_ to support CubeSceneNodes +#define _IRR_COMPILE_WITH_SPHERE_SCENENODE_ +#ifdef NO_IRR_COMPILE_WITH_SPHERE_SCENENODE_ +#undef _IRR_COMPILE_WITH_SPHERE_SCENENODE_ +#endif + //! Define _IRR_COMPILE_WITH_IRR_SCENE_LOADER_ if you want to be able to load /** .irr scenes using ISceneManager::loadScene */ #define _IRR_COMPILE_WITH_IRR_SCENE_LOADER_ diff --git a/include/S3DVertex.h b/include/S3DVertex.h index 0950a4d4..41563d5e 100644 --- a/include/S3DVertex.h +++ b/include/S3DVertex.h @@ -92,6 +92,7 @@ struct S3DVertex return EVT_STANDARD; } + //\param d d=0 returns other, d=1 returns this, values between interpolate. S3DVertex getInterpolated(const S3DVertex& other, f32 d) { d = core::clamp(d, 0.0f, 1.0f); @@ -170,6 +171,7 @@ struct S3DVertex2TCoords : public S3DVertex return EVT_2TCOORDS; } + //\param d d=0 returns other, d=1 returns this, values between interpolate. S3DVertex2TCoords getInterpolated(const S3DVertex2TCoords& other, f32 d) { d = core::clamp(d, 0.0f, 1.0f); diff --git a/include/SColor.h b/include/SColor.h index 7fccb381..f7790557 100644 --- a/include/SColor.h +++ b/include/SColor.h @@ -448,7 +448,7 @@ namespace video //! Interpolates the color with a f32 value to another color /** \param other: Other color - \param d: value between 0.0f and 1.0f + \param d: value between 0.0f and 1.0f. d=0 returns other, d=1 returns this, values between interpolate. \return Interpolated color. */ SColor getInterpolated(const SColor &other, f32 d) const { diff --git a/include/SViewFrustum.h b/include/SViewFrustum.h index b1d53e39..1b522976 100644 --- a/include/SViewFrustum.h +++ b/include/SViewFrustum.h @@ -402,13 +402,13 @@ namespace scene if (planes[i].classifyPointRelation(line.start) == core::ISREL3D_FRONT) { line.start = line.start.getInterpolated(line.end, - planes[i].getKnownIntersectionWithLine(line.start, line.end)); + 1.f-planes[i].getKnownIntersectionWithLine(line.start, line.end)); wasClipped = true; } if (planes[i].classifyPointRelation(line.end) == core::ISREL3D_FRONT) { line.end = line.start.getInterpolated(line.end, - planes[i].getKnownIntersectionWithLine(line.start, line.end)); + 1.f-planes[i].getKnownIntersectionWithLine(line.start, line.end)); wasClipped = true; } } diff --git a/include/dimension2d.h b/include/dimension2d.h index 13addb4b..4f0a87a1 100644 --- a/include/dimension2d.h +++ b/include/dimension2d.h @@ -191,7 +191,7 @@ namespace core //! Get the interpolated dimension /** \param other Other dimension to interpolate with. - \param d Value between 0.0f and 1.0f. + \param d Value between 0.0f and 1.0f. d=0 returns other, d=1 returns this, values between interpolate. \return Interpolated dimension. */ dimension2d getInterpolated(const dimension2d& other, f32 d) const { diff --git a/include/irrString.h b/include/irrString.h index 2643c975..47c9cff2 100644 --- a/include/irrString.h +++ b/include/irrString.h @@ -730,6 +730,32 @@ public: return *this; } + //! Insert a certain amount of characters into the string before the given index + //\param pos Insert the characters before this index + //\param s String to insert. Must be at least of size n + //\param n Number of characters from string s to use. + string& insert(u32 pos, const char* s, u32 n) + { + if ( pos < used ) + { + reserve(used+n); + + // move stuff behind insert point + const u32 end = used+n-1; + for (u32 i=0; igetVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -567,6 +572,9 @@ IShadowVolumeSceneNode* CAnimatedMeshSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } //! Returns a pointer to a child node, which has the same transformation as diff --git a/source/Irrlicht/CBillboardSceneNode.cpp b/source/Irrlicht/CBillboardSceneNode.cpp index 02658d0f..9eddb985 100644 --- a/source/Irrlicht/CBillboardSceneNode.cpp +++ b/source/Irrlicht/CBillboardSceneNode.cpp @@ -2,6 +2,8 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ #include "CBillboardSceneNode.h" #include "IVideoDriver.h" #include "ISceneManager.h" @@ -316,3 +318,4 @@ ISceneNode* CBillboardSceneNode::clone(ISceneNode* newParent, ISceneManager* new } // end namespace scene } // end namespace irr +#endif // _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ diff --git a/source/Irrlicht/CColladaFileLoader.cpp b/source/Irrlicht/CColladaFileLoader.cpp index 1e1f5247..62b5216f 100644 --- a/source/Irrlicht/CColladaFileLoader.cpp +++ b/source/Irrlicht/CColladaFileLoader.cpp @@ -332,6 +332,22 @@ CColladaFileLoader::CColladaFileLoader(scene::ISceneManager* smgr, setDebugName("CColladaFileLoader"); #endif + // Escape characters, see https://www.w3schools.com/tags/ref_urlencode.asp + // TODO: There should be more, but usually people just escape the space character anyway. + // And I'm not sure if our xml files are utf-8 or windows-1252, so let's avoid the ambiguous ones. + EscapeCharsAnyURI.push_back(EscapeCharacterURL(' ', "%20")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('"', "%22")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('#', "%23")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('$', "%24")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('%', "%25")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('&', "%26")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('\'', "%27")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('(', "%28")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL(')', "%29")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('/', "%2F")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('\\', "%5C")); + + TextureLoader = new CMeshTextureLoader( FileSystem, SceneManager->getVideoDriver() ); } @@ -1209,6 +1225,7 @@ void CColladaFileLoader::readImage(io::IXMLReaderUTF8* reader) reader->read(); image.Source = reader->getNodeData(); image.Source.trim(); + unescape(image.Source); image.SourceIsFilename=true; } else @@ -2742,8 +2759,8 @@ void CColladaFileLoader::clearData() //! changes the XML URI into an internal id void CColladaFileLoader::uriToId(core::stringc& str) { - // currently, we only remove the # from the begin if there - // because we simply don't support referencing other files. + // Currently, we only remove the # from the beginning + // as we don't support referencing other files. if (!str.size()) return; @@ -2942,6 +2959,47 @@ core::matrix4 CColladaFileLoader::flipZAxis(const core::matrix4& m) return matrix; } +void CColladaFileLoader::unescape(irr::core::stringc& uri) +{ + u32 len = uri.size(); + for (u32 i=0; i > MeshesToBind; bool CreateInstances; + + struct EscapeCharacterURL + { + EscapeCharacterURL(irr::c8 c, const irr::c8* e) + : Character(c) + { + Escape = e; + } + + irr::c8 Character; // unescaped (like ' ') + irr::core::stringc Escape; // escaped (like '%20') + }; + irr::core::array EscapeCharsAnyURI; }; diff --git a/source/Irrlicht/CColladaMeshWriter.cpp b/source/Irrlicht/CColladaMeshWriter.cpp index eb5c6a54..52653a04 100644 --- a/source/Irrlicht/CColladaMeshWriter.cpp +++ b/source/Irrlicht/CColladaMeshWriter.cpp @@ -178,7 +178,7 @@ irr::core::stringc CColladaMeshWriterNames::nameForMesh(const scene::IMesh* mesh irr::core::stringc CColladaMeshWriterNames::nameForNode(const scene::ISceneNode* node) { irr::core::stringc name; - // Prefix, because xs::ID can't start with a number, also nicer name + // Prefix, because xs:ID can't start with a number, also nicer name if ( node && node->getType() == ESNT_LIGHT ) name = "light"; else @@ -235,6 +235,17 @@ CColladaMeshWriter::CColladaMeshWriter( ISceneManager * smgr, video::IVideoDrive if ( smgr ) setAmbientLight( smgr->getAmbientLight() ); + // Escape some characters + // Slightly fuzzy definition for xs:anyURI. + // In theory not even spaces would need to be escaped, + // but it's strongly encouraged to do so and many Apps rely on it. + // If there are any apps out there which need more escapes we can add them. + // See https://www.w3schools.com/tags/ref_urlencode.asp for a list. + // NOTE: Never replace by empty characters (so not the place to delete chars!) + EscapeCharsAnyURI.push_back(EscapeCharacterURL(' ', "%20")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('#', "%23")); + EscapeCharsAnyURI.push_back(EscapeCharacterURL('%', "%25")); + CColladaMeshWriterProperties * p = new CColladaMeshWriterProperties(); setDefaultProperties(p); setProperties(p); @@ -1214,7 +1225,7 @@ bool CColladaMeshWriter::isXmlNameChar(c8 c) const */ } -// Restrict the characters to a set of allowed characters in xs::NCName. +// Restrict the characters to a set of allowed characters in xs:NCName. irr::core::stringc CColladaMeshWriter::toNCName(const irr::core::stringc& oldString, const irr::core::stringc& prefix) const { irr::core::stringc result(prefix); // help to ensure id starts with a valid char and reduce chance of name-conflicts @@ -1249,7 +1260,7 @@ const irr::core::stringc* CColladaMeshWriter::findGeometryNameForNode(ISceneNode return &colladaMesh.findGeometryNameForNode(node); } -// Restrict the characters to a set of allowed characters in xs::NCName. +// Restrict the characters to a set of allowed characters in xs:anyURI irr::core::stringc CColladaMeshWriter::pathToURI(const irr::io::path& path) const { irr::core::stringc result; @@ -1269,7 +1280,25 @@ irr::core::stringc CColladaMeshWriter::pathToURI(const irr::io::path& path) cons } result.append(path); - // TODO: make correct URI (without whitespaces) + // Make correct URI (without whitespace) + u32 len = result.size(); + for (u32 i=0; iinternal_texturename Writer->writeElement("init_from", false); irr::io::path p(FileSystem->getRelativeFilename(layer.Texture->getName().getPath(), Directory)); - Writer->writeText(toNCName(irr::core::stringc(p)).c_str()); + Writer->writeText(toNCName(irr::core::stringc(p)).c_str()); // same ID for internal name as in writeLibraryImages Writer->writeClosingTag("init_from"); Writer->writeLineBreak(); diff --git a/source/Irrlicht/CColladaMeshWriter.h b/source/Irrlicht/CColladaMeshWriter.h index 1761e53d..6c07d49c 100644 --- a/source/Irrlicht/CColladaMeshWriter.h +++ b/source/Irrlicht/CColladaMeshWriter.h @@ -93,7 +93,7 @@ public: //! writes a mesh virtual bool writeMesh(io::IWriteFile* file, scene::IMesh* mesh, s32 flags=EMWF_NONE) _IRR_OVERRIDE_; - // Restrict the characters of oldString a set of allowed characters in xs::NCName and add the prefix. + // Restrict the characters of oldString a set of allowed characters in xs:NCName and add the prefix. virtual irr::core::stringc toNCName(const irr::core::stringc& oldString, const irr::core::stringc& prefix=irr::core::stringc("_NC_")) const _IRR_OVERRIDE_; //! After export you can find out which name had been used for writing the geometry for this node. @@ -260,6 +260,19 @@ protected: irr::core::array< MaterialName > MaterialNameCache; irr::core::stringc WriteBuffer; // use for writing short strings to avoid regular memory allocations + + struct EscapeCharacterURL + { + EscapeCharacterURL(irr::c8 c, const irr::c8* e) + : Character(c) + { + Escape = e; + } + + irr::c8 Character; // unescaped (like ' ') + irr::core::stringc Escape; // escaped (like '%20') + }; + irr::core::array EscapeCharsAnyURI; }; diff --git a/source/Irrlicht/CCubeSceneNode.cpp b/source/Irrlicht/CCubeSceneNode.cpp index e3eaecc8..0e00da95 100644 --- a/source/Irrlicht/CCubeSceneNode.cpp +++ b/source/Irrlicht/CCubeSceneNode.cpp @@ -2,13 +2,19 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_CUBE_SCENENODE #include "CCubeSceneNode.h" #include "IVideoDriver.h" #include "ISceneManager.h" #include "S3DVertex.h" #include "SMeshBuffer.h" #include "os.h" +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "CShadowVolumeSceneNode.h" +#else +#include "IShadowVolumeSceneNode.h" +#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ namespace irr { @@ -147,6 +153,7 @@ bool CCubeSceneNode::removeChild(ISceneNode* child) IShadowVolumeSceneNode* CCubeSceneNode::addShadowVolumeSceneNode( const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) { +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -158,6 +165,9 @@ IShadowVolumeSceneNode* CCubeSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } @@ -233,3 +243,4 @@ ISceneNode* CCubeSceneNode::clone(ISceneNode* newParent, ISceneManager* newManag } // end namespace scene } // end namespace irr +#endif // _IRR_COMPILE_WITH_CUBE_SCENENODE diff --git a/source/Irrlicht/CLimitReadFile.h b/source/Irrlicht/CLimitReadFile.h index 041c8883..d95511fe 100644 --- a/source/Irrlicht/CLimitReadFile.h +++ b/source/Irrlicht/CLimitReadFile.h @@ -46,6 +46,12 @@ namespace io //! returns name of file virtual const io::path& getFileName() const _IRR_OVERRIDE_; + //! Get the type of the class implementing this interface + virtual EREAD_FILE_TYPE getType() const _IRR_OVERRIDE_ + { + return ERFT_LIMIT_READ_FILE; + } + private: io::path Filename; diff --git a/source/Irrlicht/CMemoryFile.h b/source/Irrlicht/CMemoryFile.h index 71f95057..b86c175e 100644 --- a/source/Irrlicht/CMemoryFile.h +++ b/source/Irrlicht/CMemoryFile.h @@ -5,7 +5,7 @@ #ifndef __C_MEMORY_READ_FILE_H_INCLUDED__ #define __C_MEMORY_READ_FILE_H_INCLUDED__ -#include "IReadFile.h" +#include "IMemoryReadFile.h" #include "IWriteFile.h" #include "irrString.h" @@ -18,7 +18,7 @@ namespace io /*! Class for reading from memory. */ - class CMemoryReadFile : public IReadFile + class CMemoryReadFile : public IMemoryReadFile { public: @@ -43,6 +43,18 @@ namespace io //! returns name of file virtual const io::path& getFileName() const _IRR_OVERRIDE_; + //! Get the type of the class implementing this interface + virtual EREAD_FILE_TYPE getType() const _IRR_OVERRIDE_ + { + return ERFT_MEMORY_READ_FILE; + } + + //! Get direct access to internal buffer + virtual const void *getBuffer() const _IRR_OVERRIDE_ + { + return Buffer; + } + private: const void *Buffer; diff --git a/source/Irrlicht/CMeshSceneNode.cpp b/source/Irrlicht/CMeshSceneNode.cpp index b2bb4b1f..def77d43 100644 --- a/source/Irrlicht/CMeshSceneNode.cpp +++ b/source/Irrlicht/CMeshSceneNode.cpp @@ -11,7 +11,11 @@ #include "IAnimatedMesh.h" #include "IMaterialRenderer.h" #include "IFileSystem.h" +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "CShadowVolumeSceneNode.h" +#else +#include "IShadowVolumeSceneNode.h" +#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ namespace irr { @@ -297,6 +301,7 @@ void CMeshSceneNode::setMesh(IMesh* mesh) IShadowVolumeSceneNode* CMeshSceneNode::addShadowVolumeSceneNode( const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) { +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -308,6 +313,9 @@ IShadowVolumeSceneNode* CMeshSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } diff --git a/source/Irrlicht/CNullDriver.cpp b/source/Irrlicht/CNullDriver.cpp index 61b19f1e..3b2fcde3 100644 --- a/source/Irrlicht/CNullDriver.cpp +++ b/source/Irrlicht/CNullDriver.cpp @@ -1714,7 +1714,10 @@ IImage* CNullDriver::createImage(ITexture* texture, const core::position2d& { if ((pos==core::position2di(0,0)) && (size == texture->getSize())) { - IImage* image = new CImage(texture->getColorFormat(), size, texture->lock(ETLM_READ_ONLY), false, false); + void * data = texture->lock(ETLM_READ_ONLY); + if ( !data) + return 0; + IImage* image = new CImage(texture->getColorFormat(), size, data, false, false); texture->unlock(); return image; } diff --git a/source/Irrlicht/COctreeSceneNode.cpp b/source/Irrlicht/COctreeSceneNode.cpp index ad6bb2ee..79a1a1e2 100644 --- a/source/Irrlicht/COctreeSceneNode.cpp +++ b/source/Irrlicht/COctreeSceneNode.cpp @@ -2,6 +2,9 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_OCTREE_SCENENODE_ + #include "COctreeSceneNode.h" #include "Octree.h" #include "ISceneManager.h" @@ -11,7 +14,11 @@ #include "IAnimatedMesh.h" #include "IMaterialRenderer.h" #include "os.h" +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "CShadowVolumeSceneNode.h" +#else +#include "IShadowVolumeSceneNode.h" +#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "EProfileIDs.h" #include "IProfiler.h" @@ -339,6 +346,7 @@ EOCTREE_POLYGON_CHECKS COctreeSceneNode::getPolygonChecks() const IShadowVolumeSceneNode* COctreeSceneNode::addShadowVolumeSceneNode( const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) { +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -350,6 +358,9 @@ IShadowVolumeSceneNode* COctreeSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } @@ -671,3 +682,4 @@ bool COctreeSceneNode::isReadOnlyMaterials() const } // end namespace scene } // end namespace irr +#endif // _IRR_COMPILE_WITH_OCTREE_SCENENODE_ diff --git a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp index 8d0e616b..5b2cabab 100644 --- a/source/Irrlicht/COpenGLSLMaterialRenderer.cpp +++ b/source/Irrlicht/COpenGLSLMaterialRenderer.cpp @@ -339,7 +339,9 @@ bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shad if (status != GL_TRUE) { - os::Printer::log("GLSL shader failed to compile", ELL_ERROR); + core::stringc typeInfo("shaderType: "); + typeInfo += core::stringc((unsigned long)shaderType); + os::Printer::log("GLSL (> 2.x) shader failed to compile", typeInfo.c_str(), ELL_ERROR); // check error message and log it GLint maxLength=0; GLint length; @@ -375,7 +377,9 @@ bool COpenGLSLMaterialRenderer::createShader(GLenum shaderType, const char* shad if (!status) { - os::Printer::log("GLSL shader failed to compile", ELL_ERROR); + core::stringc typeInfo("shaderType: "); + typeInfo += core::stringc((unsigned long)shaderType); + os::Printer::log("GLSL shader failed to compile", typeInfo.c_str(), ELL_ERROR); // check error message and log it GLint maxLength=0; GLsizei length; @@ -414,7 +418,7 @@ bool COpenGLSLMaterialRenderer::linkProgram() if (!status) { - os::Printer::log("GLSL shader program failed to link", ELL_ERROR); + os::Printer::log("GLSL (> 2.x) shader program failed to link", ELL_ERROR); // check error message and log it GLint maxLength=0; GLsizei length; @@ -452,7 +456,7 @@ bool COpenGLSLMaterialRenderer::linkProgram() if (maxlen == 0) { - os::Printer::log("GLSL: failed to retrieve uniform information", ELL_ERROR); + os::Printer::log("GLSL (> 2.x): failed to retrieve uniform information", ELL_ERROR); return false; } diff --git a/source/Irrlicht/CQuake3ShaderSceneNode.cpp b/source/Irrlicht/CQuake3ShaderSceneNode.cpp index 7a0fb830..9df0f61e 100644 --- a/source/Irrlicht/CQuake3ShaderSceneNode.cpp +++ b/source/Irrlicht/CQuake3ShaderSceneNode.cpp @@ -14,7 +14,11 @@ #include "IMeshManipulator.h" #include "SMesh.h" #include "IMaterialRenderer.h" +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "CShadowVolumeSceneNode.h" +#else +#include "IShadowVolumeSceneNode.h" +#endif namespace irr { @@ -516,6 +520,7 @@ bool CQuake3ShaderSceneNode::removeChild(ISceneNode* child) IShadowVolumeSceneNode* CQuake3ShaderSceneNode::addShadowVolumeSceneNode( const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) { +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -527,6 +532,9 @@ IShadowVolumeSceneNode* CQuake3ShaderSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } diff --git a/source/Irrlicht/CReadFile.h b/source/Irrlicht/CReadFile.h index 090e30a2..d0a3cac3 100644 --- a/source/Irrlicht/CReadFile.h +++ b/source/Irrlicht/CReadFile.h @@ -47,6 +47,12 @@ namespace io //! returns name of file virtual const io::path& getFileName() const _IRR_OVERRIDE_; + //! Get the type of the class implementing this interface + virtual EREAD_FILE_TYPE getType() const _IRR_OVERRIDE_ + { + return ERFT_READ_FILE; + } + //! create read file on disk. static IReadFile* createReadFile(const io::path& fileName); diff --git a/source/Irrlicht/CSceneManager.cpp b/source/Irrlicht/CSceneManager.cpp index f564091d..c3c7e2ee 100644 --- a/source/Irrlicht/CSceneManager.cpp +++ b/source/Irrlicht/CSceneManager.cpp @@ -138,24 +138,38 @@ #include "CB3DMeshWriter.h" #endif +#ifdef _IRR_COMPILE_WITH_CUBE_SCENENODE #include "CCubeSceneNode.h" +#endif // _IRR_COMPILE_WITH_CUBE_SCENENODE +#ifdef _IRR_COMPILE_WITH_SPHERE_SCENENODE_ #include "CSphereSceneNode.h" +#endif #include "CAnimatedMeshSceneNode.h" +#ifdef _IRR_COMPILE_WITH_OCTREE_SCENENODE_ #include "COctreeSceneNode.h" +#endif // #ifdef _IRR_COMPILE_WITH_OCTREE_SCENENODE_ #include "CCameraSceneNode.h" #include "CLightSceneNode.h" +#ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ #include "CBillboardSceneNode.h" +#endif // _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ #include "CMeshSceneNode.h" #include "CSkyBoxSceneNode.h" +#ifdef _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ #include "CSkyDomeSceneNode.h" +#endif // _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ #ifdef _IRR_COMPILE_WITH_PARTICLES_ #include "CParticleSystemSceneNode.h" #endif // _IRR_COMPILE_WITH_PARTICLES_ #include "CDummyTransformationSceneNode.h" +#ifdef _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ #include "CWaterSurfaceSceneNode.h" +#endif // _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ #include "CTerrainSceneNode.h" +#endif // _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ #include "CEmptySceneNode.h" #include "CTextSceneNode.h" #include "CQuake3ShaderSceneNode.h" @@ -168,7 +182,9 @@ #include "COctreeTriangleSelector.h" #include "CTriangleBBSelector.h" #include "CMetaTriangleSelector.h" +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ #include "CTerrainTriangleSelector.h" +#endif // _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ #include "CSceneNodeAnimatorRotation.h" #include "CSceneNodeAnimatorFlyCircle.h" @@ -588,6 +604,7 @@ IMeshSceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, s32 id, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) { +#ifdef _IRR_COMPILE_WITH_CUBE_SCENENODE if (!parent) parent = this; @@ -595,6 +612,9 @@ IMeshSceneNode* CSceneManager::addCubeSceneNode(f32 size, ISceneNode* parent, node->drop(); return node; +#else + return 0; +#endif } @@ -603,6 +623,7 @@ IMeshSceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, ISceneNode* parent, s32 id, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) { +#ifdef _IRR_COMPILE_WITH_SPHERE_SCENENODE_ if (!parent) parent = this; @@ -610,6 +631,9 @@ IMeshSceneNode* CSceneManager::addSphereSceneNode(f32 radius, s32 polyCount, node->drop(); return node; +#else + return 0; +#endif // _IRR_COMPILE_WITH_SPHERE_SCENENODE_ } @@ -637,6 +661,7 @@ ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, ISceneNode* parent, s32 id, const core::vector3df& position, const core::vector3df& rotation, const core::vector3df& scale) { +#ifdef _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ if (!parent) parent = this; @@ -646,6 +671,9 @@ ISceneNode* CSceneManager::addWaterSurfaceSceneNode(IMesh* mesh, f32 waveHeight, node->drop(); return node; +#else + return 0; +#endif } @@ -689,6 +717,7 @@ IOctreeSceneNode* CSceneManager::addOctreeSceneNode(IAnimatedMesh* mesh, ISceneN IOctreeSceneNode* CSceneManager::addOctreeSceneNode(IMesh* mesh, ISceneNode* parent, s32 id, s32 minimalPolysPerNode, bool alsoAddIfMeshPointerZero) { +#ifdef _IRR_COMPILE_WITH_OCTREE_SCENENODE_ if (!alsoAddIfMeshPointerZero && !mesh) return 0; @@ -704,6 +733,9 @@ IOctreeSceneNode* CSceneManager::addOctreeSceneNode(IMesh* mesh, ISceneNode* par } return node; +#else + return 0; +#endif } @@ -801,6 +833,7 @@ IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent, video::SColor colorTop, video::SColor colorBottom ) { +#ifdef _IRR_COMPILE_WITH_BILLBOARD_SCENENODE_ if (!parent) parent = this; @@ -809,6 +842,9 @@ IBillboardSceneNode* CSceneManager::addBillboardSceneNode(ISceneNode* parent, node->drop(); return node; +#else + return 0; +#endif } @@ -835,6 +871,7 @@ ISceneNode* CSceneManager::addSkyDomeSceneNode(video::ITexture* texture, u32 horiRes, u32 vertRes, f32 texturePercentage,f32 spherePercentage, f32 radius, ISceneNode* parent, s32 id) { +#ifdef _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ if (!parent) parent = this; @@ -843,6 +880,9 @@ ISceneNode* CSceneManager::addSkyDomeSceneNode(video::ITexture* texture, node->drop(); return node; +#else + return 0; +#endif } @@ -909,6 +949,7 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode( s32 smoothFactor, bool addAlsoIfHeightmapEmpty) { +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ if (!parent) parent = this; @@ -933,6 +974,9 @@ ITerrainSceneNode* CSceneManager::addTerrainSceneNode( node->drop(); return node; +#else + return 0; +#endif // _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ } @@ -1920,7 +1964,11 @@ IMetaTriangleSelector* CSceneManager::createMetaTriangleSelector() ITriangleSelector* CSceneManager::createTerrainTriangleSelector( ITerrainSceneNode* node, s32 LOD) { +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ return new CTerrainTriangleSelector(node, LOD); +#else + return 0; +#endif } diff --git a/source/Irrlicht/CShadowVolumeSceneNode.cpp b/source/Irrlicht/CShadowVolumeSceneNode.cpp index 55c802a1..2f2a2971 100644 --- a/source/Irrlicht/CShadowVolumeSceneNode.cpp +++ b/source/Irrlicht/CShadowVolumeSceneNode.cpp @@ -2,6 +2,10 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ + #include "CShadowVolumeSceneNode.h" #include "ISceneManager.h" #include "IMesh.h" @@ -417,3 +421,5 @@ void CShadowVolumeSceneNode::calculateAdjacency() } // end namespace scene } // end namespace irr + +#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ diff --git a/source/Irrlicht/CSkyDomeSceneNode.cpp b/source/Irrlicht/CSkyDomeSceneNode.cpp index 2e0499da..410a0952 100644 --- a/source/Irrlicht/CSkyDomeSceneNode.cpp +++ b/source/Irrlicht/CSkyDomeSceneNode.cpp @@ -3,6 +3,8 @@ // For conditions of distribution and use, see copyright notice in irrlicht.h // Code for this scene node has been contributed by Anders la Cour-Harbo (alc) +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ #include "CSkyDomeSceneNode.h" #include "IVideoDriver.h" #include "ISceneManager.h" @@ -262,3 +264,5 @@ ISceneNode* CSkyDomeSceneNode::clone(ISceneNode* newParent, ISceneManager* newMa } // namespace scene } // namespace irr + +#endif // _IRR_COMPILE_WITH_SKYDOME_SCENENODE_ diff --git a/source/Irrlicht/CSphereSceneNode.cpp b/source/Irrlicht/CSphereSceneNode.cpp index 4193507c..7dbe814d 100644 --- a/source/Irrlicht/CSphereSceneNode.cpp +++ b/source/Irrlicht/CSphereSceneNode.cpp @@ -2,12 +2,18 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_SPHERE_SCENENODE_ #include "CSphereSceneNode.h" #include "IVideoDriver.h" #include "ISceneManager.h" #include "S3DVertex.h" #include "os.h" +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ #include "CShadowVolumeSceneNode.h" +#else +#include "IShadowVolumeSceneNode.h" +#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ namespace irr { @@ -83,6 +89,7 @@ bool CSphereSceneNode::removeChild(ISceneNode* child) IShadowVolumeSceneNode* CSphereSceneNode::addShadowVolumeSceneNode( const IMesh* shadowMesh, s32 id, bool zfailmethod, f32 infinity) { +#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_ if (!SceneManager->getVideoDriver()->queryFeature(video::EVDF_STENCIL_BUFFER)) return 0; @@ -94,6 +101,9 @@ IShadowVolumeSceneNode* CSphereSceneNode::addShadowVolumeSceneNode( Shadow = new CShadowVolumeSceneNode(shadowMesh, this, SceneManager, id, zfailmethod, infinity); return Shadow; +#else + return 0; +#endif } @@ -197,3 +207,4 @@ ISceneNode* CSphereSceneNode::clone(ISceneNode* newParent, ISceneManager* newMan } // end namespace scene } // end namespace irr +#endif // _IRR_COMPILE_WITH_SPHERE_SCENENODE_ diff --git a/source/Irrlicht/CTerrainSceneNode.cpp b/source/Irrlicht/CTerrainSceneNode.cpp index 91a060e2..395a45da 100644 --- a/source/Irrlicht/CTerrainSceneNode.cpp +++ b/source/Irrlicht/CTerrainSceneNode.cpp @@ -7,6 +7,10 @@ // distributed under this licence. I only modified some parts. A lot of thanks // go to him. +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ + #include "CTerrainSceneNode.h" #include "CTerrainTriangleSelector.h" #include "IVideoDriver.h" @@ -1511,4 +1515,4 @@ namespace scene } // end namespace scene } // end namespace irr - +#endif // _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ diff --git a/source/Irrlicht/CTerrainTriangleSelector.cpp b/source/Irrlicht/CTerrainTriangleSelector.cpp index 459a62a3..db544d40 100644 --- a/source/Irrlicht/CTerrainTriangleSelector.cpp +++ b/source/Irrlicht/CTerrainTriangleSelector.cpp @@ -2,6 +2,10 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" + +#ifdef _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ + #include "CTerrainTriangleSelector.h" #include "CTerrainSceneNode.h" #include "os.h" @@ -263,3 +267,5 @@ const ITriangleSelector* CTerrainTriangleSelector::getSelector(u32 index) const } // end namespace scene } // end namespace irr + +#endif // _IRR_COMPILE_WITH_TERRAIN_SCENENODE_ diff --git a/source/Irrlicht/CWaterSurfaceSceneNode.cpp b/source/Irrlicht/CWaterSurfaceSceneNode.cpp index 12d20c28..0aee1012 100644 --- a/source/Irrlicht/CWaterSurfaceSceneNode.cpp +++ b/source/Irrlicht/CWaterSurfaceSceneNode.cpp @@ -2,6 +2,8 @@ // This file is part of the "Irrlicht Engine". // For conditions of distribution and use, see copyright notice in irrlicht.h +#include "IrrCompileConfig.h" +#ifdef _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ #include "CWaterSurfaceSceneNode.h" #include "ISceneManager.h" #include "IMeshManipulator.h" @@ -135,3 +137,4 @@ f32 CWaterSurfaceSceneNode::addWave(const core::vector3df &source, f32 time) con } // end namespace scene } // end namespace irr +#endif // _IRR_COMPILE_WITH_WATER_SURFACE_SCENENODE_ diff --git a/source/Irrlicht/Irrlicht-gcc.cbp b/source/Irrlicht/Irrlicht-gcc.cbp index 7c26aee2..3e8d0ad0 100644 --- a/source/Irrlicht/Irrlicht-gcc.cbp +++ b/source/Irrlicht/Irrlicht-gcc.cbp @@ -424,6 +424,7 @@ + @@ -486,6 +487,7 @@ + diff --git a/tests/irrString.cpp b/tests/irrString.cpp index f2ce776c..ad35e89d 100644 --- a/tests/irrString.cpp +++ b/tests/irrString.cpp @@ -180,6 +180,29 @@ bool testAppendStringc() return true; } +bool testInsert() +{ + core::stringc str; + + str.insert(0, "something", 4); + if (str != "some") + return false; + + str.insert(4, "thing", 5); + if (str != "something") + return false; + + str.insert(0, "is ", 3); + if (str != "is something") + return false; + + str.insert(3, "there ", 6); + if (str != "is there something") + return false; + + return true; +} + bool testLowerUpper() { irr::core::array stringsOrig, targetLower, targetUpper; @@ -356,6 +379,8 @@ bool testIrrString(void) } allExpected &= testAppendStringc(); + allExpected &= testInsert(); + logTestString("Test io::path\n"); { // Only test that this type exists, it's one from above diff --git a/tests/tests-last-passed-at.txt b/tests/tests-last-passed-at.txt index 6f354ef6..8f8b58a1 100644 --- a/tests/tests-last-passed-at.txt +++ b/tests/tests-last-passed-at.txt @@ -1,4 +1,4 @@ Tests finished. 1 test of 1 passed. Compiled as DEBUG -Test suite pass at GMT Fri Feb 22 17:53:28 2019 +Test suite pass at GMT Fri Mar 15 13:00:55 2019