From d4119ba6640fa96eb0587b46c4a64c2e818818a8 Mon Sep 17 00:00:00 2001 From: JosiahWI Date: Tue, 9 Nov 2021 13:47:54 -0600 Subject: [PATCH] Remove unused functions renderLine16_Blend(), renderLine16_Decal(), renderLine32_Blend(), renderLine32_Decal() clipLine() frand() drawRectangle() and drawLine() remove unused private fields --- include/IRandomizer.h | 3 - source/Irrlicht/CB3DMeshFileLoader.cpp | 2 +- source/Irrlicht/CB3DMeshFileLoader.h | 1 - source/Irrlicht/CBlit.h | 397 ------------------------- source/Irrlicht/CIrrDeviceStub.cpp | 5 - source/Irrlicht/COBJMeshFileLoader.cpp | 2 - source/Irrlicht/COpenGLDriver.cpp | 11 +- source/Irrlicht/COpenGLDriver.h | 2 - source/Irrlicht/CXMeshFileLoader.cpp | 3 +- source/Irrlicht/CXMeshFileLoader.h | 3 - source/Irrlicht/os.cpp | 6 - source/Irrlicht/os.h | 3 - 12 files changed, 4 insertions(+), 434 deletions(-) diff --git a/include/IRandomizer.h b/include/IRandomizer.h index a0c0730..e821190 100644 --- a/include/IRandomizer.h +++ b/include/IRandomizer.h @@ -21,9 +21,6 @@ public: //! generates a pseudo random number in the range 0..randMax() virtual s32 rand() const =0; - //! generates a pseudo random number in the range 0..1 - virtual f32 frand() const =0; - //! get maxmimum number generated by rand() virtual s32 randMax() const =0; }; diff --git a/source/Irrlicht/CB3DMeshFileLoader.cpp b/source/Irrlicht/CB3DMeshFileLoader.cpp index ec20bf8..41498ea 100644 --- a/source/Irrlicht/CB3DMeshFileLoader.cpp +++ b/source/Irrlicht/CB3DMeshFileLoader.cpp @@ -26,7 +26,7 @@ namespace scene //! Constructor CB3DMeshFileLoader::CB3DMeshFileLoader(scene::ISceneManager* smgr) -: SceneManager(smgr), AnimatedMesh(0), B3DFile(0), NormalsInFile(false), +: AnimatedMesh(0), B3DFile(0), NormalsInFile(false), HasVertexColors(false), ShowWarning(true) { #ifdef _DEBUG diff --git a/source/Irrlicht/CB3DMeshFileLoader.h b/source/Irrlicht/CB3DMeshFileLoader.h index 6a3c4c7..12784c4 100644 --- a/source/Irrlicht/CB3DMeshFileLoader.h +++ b/source/Irrlicht/CB3DMeshFileLoader.h @@ -68,7 +68,6 @@ private: core::array BaseVertices; - ISceneManager* SceneManager; CSkinnedMesh* AnimatedMesh; io::IReadFile* B3DFile; diff --git a/source/Irrlicht/CBlit.h b/source/Irrlicht/CBlit.h index c2fcf77..7a9455a 100644 --- a/source/Irrlicht/CBlit.h +++ b/source/Irrlicht/CBlit.h @@ -85,96 +85,6 @@ inline u32 GetClipCode( const AbsRectangle &r, const core::position2d &p ) return code; } - -/*! - Cohen Sutherland clipping - @return: 1 if valid -*/ - -static int ClipLine(const AbsRectangle &clipping, - core::position2d &p0, - core::position2d &p1, - const core::position2d& p0_in, - const core::position2d& p1_in) -{ - u32 code0; - u32 code1; - u32 code; - - p0 = p0_in; - p1 = p1_in; - - code0 = GetClipCode( clipping, p0 ); - code1 = GetClipCode( clipping, p1 ); - - // trivial accepted - while ( code0 | code1 ) - { - s32 x=0; - s32 y=0; - - // trivial reject - if ( code0 & code1 ) - return 0; - - if ( code0 ) - { - // clip first point - code = code0; - } - else - { - // clip last point - code = code1; - } - - if ( (code & CLIPCODE_BOTTOM) == CLIPCODE_BOTTOM ) - { - // clip bottom viewport - y = clipping.y1; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_TOP) == CLIPCODE_TOP ) - { - // clip to viewport - y = clipping.y0; - x = p0.X + ( p1.X - p0.X ) * ( y - p0.Y ) / ( p1.Y - p0.Y ); - } - else - if ( (code & CLIPCODE_RIGHT) == CLIPCODE_RIGHT ) - { - // clip right viewport - x = clipping.x1; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - else - if ( (code & CLIPCODE_LEFT) == CLIPCODE_LEFT ) - { - // clip left viewport - x = clipping.x0; - y = p0.Y + ( p1.Y - p0.Y ) * ( x - p0.X ) / ( p1.X - p0.X ); - } - - if ( code == code0 ) - { - // modify first point - p0.X = x; - p0.Y = y; - code0 = GetClipCode( clipping, p0 ); - } - else - { - // modify second point - p1.X = x; - p1.Y = y; - code1 = GetClipCode( clipping, p1 ); - } - } - - return 1; -} - /* */ inline void GetClip(AbsRectangle &clipping, video::IImage * t) @@ -226,263 +136,6 @@ inline u32 PixelLerp32(const u32 source, const u32 value) } -/* -*/ -static void RenderLine32_Decal(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - do - { - *dst = argb; - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } while (run>=0); -} - - -/* -*/ -static void RenderLine32_Blend(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb, u32 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 4; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u32 *dst; - dst = (u32*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 4 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - const u32 packA = packAlpha ( alpha ); - do - { - *dst = packA | PixelBlend32( *dst, argb, alpha ); - - dst = (u32*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u32*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } while (run>=0); -} - -/* -*/ -static void RenderLine16_Decal(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u32 argb ) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - do - { - *dst = (u16)argb; - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } while (run>=0); -} - -/* -*/ -static void RenderLine16_Blend(video::IImage *t, - const core::position2d &p0, - const core::position2d &p1, - u16 argb, - u16 alpha) -{ - s32 dx = p1.X - p0.X; - s32 dy = p1.Y - p0.Y; - - s32 c; - s32 m; - s32 d = 0; - s32 run; - - s32 xInc = 2; - s32 yInc = (s32) t->getPitch(); - - if ( dx < 0 ) - { - xInc = -xInc; - dx = -dx; - } - - if ( dy < 0 ) - { - yInc = -yInc; - dy = -dy; - } - - u16 *dst; - dst = (u16*) ( (u8*) t->getData() + ( p0.Y * t->getPitch() ) + ( p0.X * 2 ) ); - - if ( dy > dx ) - { - s32 tmp; - tmp = dx; - dx = dy; - dy = tmp; - tmp = xInc; - xInc = yInc; - yInc = tmp; - } - - c = dx << 1; - m = dy << 1; - - run = dx; - const u16 packA = alpha ? 0x8000 : 0; - do - { - *dst = packA | PixelBlend16( *dst, argb, alpha ); - - dst = (u16*) ( (u8*) dst + xInc ); // x += xInc - d += m; - if ( d > dx ) - { - dst = (u16*) ( (u8*) dst + yInc ); // y += yInc - d -= c; - } - run -= 1; - } while (run>=0); -} - - /*! */ static void executeBlit_TextureCopy_x_to_x( const SBlitJob * job ) @@ -1471,56 +1124,6 @@ static s32 StretchBlit(eBlitter operation, } #endif -// Methods for Software drivers -//! draws a rectangle -static void drawRectangle(video::IImage* img, const core::rect& rect, const video::SColor &color) -{ - Blit(color.getAlpha() == 0xFF ? BLITTER_COLOR : BLITTER_COLOR_ALPHA, - img, 0, &rect.UpperLeftCorner, 0, &rect, color.color); -} - - -//! draws a line from to with color -static void drawLine(video::IImage* img, const core::position2d& from, - const core::position2d& to, const video::SColor &color) -{ - AbsRectangle clip; - GetClip(clip, img); - - core::position2d p[2]; - if (ClipLine( clip, p[0], p[1], from, to)) - { - u32 alpha = extractAlpha(color.color); - - switch(img->getColorFormat()) - { - case video::ECF_A1R5G5B5: - if (alpha == 256) - { - RenderLine16_Decal(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color)); - } - else - { - RenderLine16_Blend(img, p[0], p[1], video::A8R8G8B8toA1R5G5B5(color.color), alpha >> 3); - } - break; - case video::ECF_A8R8G8B8: - if (alpha == 256) - { - RenderLine32_Decal(img, p[0], p[1], color.color); - } - else - { - RenderLine32_Blend(img, p[0], p[1], color.color, alpha); - } - break; - default: - break; - } - } -} - - } #endif diff --git a/source/Irrlicht/CIrrDeviceStub.cpp b/source/Irrlicht/CIrrDeviceStub.cpp index 31e21ab..800d372 100644 --- a/source/Irrlicht/CIrrDeviceStub.cpp +++ b/source/Irrlicht/CIrrDeviceStub.cpp @@ -308,11 +308,6 @@ namespace return os::Randomizer::rand(); } - virtual f32 frand() const _IRR_OVERRIDE_ - { - return os::Randomizer::frand(); - } - virtual s32 randMax() const _IRR_OVERRIDE_ { return os::Randomizer::randMax(); diff --git a/source/Irrlicht/COBJMeshFileLoader.cpp b/source/Irrlicht/COBJMeshFileLoader.cpp index 19b9f56..5997e39 100644 --- a/source/Irrlicht/COBJMeshFileLoader.cpp +++ b/source/Irrlicht/COBJMeshFileLoader.cpp @@ -26,8 +26,6 @@ namespace scene #define _IRR_DEBUG_OBJ_LOADER_ #endif -static const u32 WORD_BUFFER_LENGTH = 512; - //! Constructor COBJMeshFileLoader::COBJMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) : SceneManager(smgr), FileSystem(fs) diff --git a/source/Irrlicht/COpenGLDriver.cpp b/source/Irrlicht/COpenGLDriver.cpp index 5315232..68351ef 100644 --- a/source/Irrlicht/COpenGLDriver.cpp +++ b/source/Irrlicht/COpenGLDriver.cpp @@ -38,14 +38,7 @@ const u16 COpenGLDriver::Quad2DIndices[4] = { 0, 1, 2, 3 }; COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFileSystem* io, IContextManager* contextManager) : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE), Params(params), - ContextManager(contextManager), -#if defined(_IRR_COMPILE_WITH_WINDOWS_DEVICE_) - DeviceType(EIDT_WIN32) -#elif defined(_IRR_COMPILE_WITH_X11_DEVICE_) - DeviceType(EIDT_X11) -#else - DeviceType(EIDT_OSX) -#endif + ContextManager(contextManager) { #ifdef _DEBUG setDebugName("COpenGLDriver"); @@ -58,7 +51,7 @@ COpenGLDriver::COpenGLDriver(const SIrrlichtCreationParameters& params, io::IFil : CNullDriver(io, params.WindowSize), COpenGLExtensionHandler(), CacheHandler(0), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), AntiAlias(params.AntiAlias), ColorFormat(ECF_R8G8B8), FixedPipelineState(EOFPS_ENABLE), - Params(params), SDLDevice(device), ContextManager(0), DeviceType(EIDT_SDL) + Params(params), SDLDevice(device), ContextManager(0) { #ifdef _DEBUG setDebugName("COpenGLDriver"); diff --git a/source/Irrlicht/COpenGLDriver.h b/source/Irrlicht/COpenGLDriver.h index f3d89fd..8b2616e 100644 --- a/source/Irrlicht/COpenGLDriver.h +++ b/source/Irrlicht/COpenGLDriver.h @@ -522,8 +522,6 @@ namespace video #endif IContextManager* ContextManager; - - E_DEVICE_TYPE DeviceType; }; } // end namespace video diff --git a/source/Irrlicht/CXMeshFileLoader.cpp b/source/Irrlicht/CXMeshFileLoader.cpp index 27c4e36..343895f 100644 --- a/source/Irrlicht/CXMeshFileLoader.cpp +++ b/source/Irrlicht/CXMeshFileLoader.cpp @@ -28,8 +28,7 @@ namespace scene //! Constructor CXMeshFileLoader::CXMeshFileLoader(scene::ISceneManager* smgr, io::IFileSystem* fs) -: SceneManager(smgr), FileSystem(fs), AnimatedMesh(0), - Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0), +: AnimatedMesh(0), Buffer(0), P(0), End(0), BinaryNumCount(0), Line(0), CurFrame(0), MajorVersion(0), MinorVersion(0), BinaryFormat(false), FloatSize(0) { #ifdef _DEBUG diff --git a/source/Irrlicht/CXMeshFileLoader.h b/source/Irrlicht/CXMeshFileLoader.h index a517f55..8021e8f 100644 --- a/source/Irrlicht/CXMeshFileLoader.h +++ b/source/Irrlicht/CXMeshFileLoader.h @@ -159,9 +159,6 @@ private: bool readRGB(video::SColor& color); bool readRGBA(video::SColor& color); - ISceneManager* SceneManager; - io::IFileSystem* FileSystem; - CSkinnedMesh* AnimatedMesh; c8* Buffer; diff --git a/source/Irrlicht/os.cpp b/source/Irrlicht/os.cpp index a410a91..b736eaf 100644 --- a/source/Irrlicht/os.cpp +++ b/source/Irrlicht/os.cpp @@ -338,12 +338,6 @@ namespace os return seed-1; // -1 because we want it to start at 0 } - //! generates a pseudo random number - f32 Randomizer::frand() - { - return rand()*(1.f/rMax); - } - s32 Randomizer::randMax() { return rMax; diff --git a/source/Irrlicht/os.h b/source/Irrlicht/os.h index 379abb8..7512757 100644 --- a/source/Irrlicht/os.h +++ b/source/Irrlicht/os.h @@ -58,9 +58,6 @@ namespace os //! generates a pseudo random number in the range 0..randMax() static s32 rand(); - //! generates a pseudo random number in the range 0..1 - static f32 frand(); - //! get maximum number generated by rand() static s32 randMax();