Merging r6519 through r6561 from trunk to ogl-es branch

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@6562 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien
2023-10-16 21:17:56 +00:00
parent e9c494503d
commit 849336343d
169 changed files with 465 additions and 511 deletions

View File

@ -8,7 +8,7 @@
#include "C3DSMeshFileLoader.h"
#include "CMeshTextureLoader.h"
#include "os.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
#include "SAnimatedMesh.h"
#include "IReadFile.h"
#include "IVideoDriver.h"

View File

@ -10,7 +10,7 @@
#include "CColorConverter.h"
#include "CImage.h"
#include "coreutil.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"

View File

@ -6,7 +6,6 @@
#ifdef _IRR_COMPILE_WITH_MD2_LOADER_
#include "CAnimatedMeshMD2.h"
#include "SColor.h"
#include "irrMath.h"
namespace irr

View File

@ -8,8 +8,6 @@
#include "IAnimatedMeshMD2.h"
#include "IMesh.h"
#include "CMeshBuffer.h"
#include "IReadFile.h"
#include "S3DVertex.h"
#include "irrArray.h"
#include "irrString.h"

View File

@ -8,11 +8,8 @@
#include "IAnimatedMeshMD3.h"
#include "IReadFile.h"
#include "IFileSystem.h"
#include "irrArray.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "IQ3Shader.h"
#include "CMeshBuffer.h"
namespace irr
{

View File

@ -5,8 +5,8 @@
#include "CAnimatedMeshSceneNode.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "S3DVertex.h"
#include "os.h"
#include "IFileSystem.h"
#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_
#include "CShadowVolumeSceneNode.h"
#else
@ -14,9 +14,7 @@
#endif // _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_
#include "IAnimatedMeshMD3.h"
#include "CSkinnedMesh.h"
#include "IDummyTransformationSceneNode.h"
#include "IBoneSceneNode.h"
#include "IMaterialRenderer.h"
#include "IMesh.h"
#include "IMeshCache.h"
#include "IAnimatedMesh.h"

View File

@ -2,7 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CAttributes.h"
#include "fast_atof.h"
#include "ITexture.h"
#include "IVideoDriver.h"

View File

@ -13,7 +13,7 @@
#include "CMeshTextureLoader.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "IAttributes.h"
#include "os.h"
#ifdef _DEBUG
@ -255,7 +255,7 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
os::Printer::log(logStr.c_str(), ELL_DEBUG);
#endif
s32 brushID;
s32 brushID=-1;
B3DFile->read(&brushID, sizeof(brushID));
#ifdef __BIG_ENDIAN__
brushID = os::Byteswap::byteswap(brushID);
@ -283,11 +283,15 @@ bool CB3DMeshFileLoader::readChunkMESH(CSkinnedMesh::SJoint *inJoint)
{
scene::SSkinMeshBuffer *meshBuffer = AnimatedMesh->addMeshBuffer();
if (brushID!=-1)
if ( brushID >= 0 && (u32)brushID < Materials.size() )
{
loadTextures(Materials[brushID]);
meshBuffer->Material=Materials[brushID].Material;
}
else if (brushID != -1) // -1 is OK
{
os::Printer::log("Illegal brush ID found", B3DFile->getFileName(), ELL_WARNING);
}
if(readChunkTRIS(meshBuffer,AnimatedMesh->getMeshBuffers().size()-1, VerticesStart)==false)
return false;
@ -364,7 +368,8 @@ bool CB3DMeshFileLoader::readChunkVRTS(CSkinnedMesh::SJoint *inJoint)
tex_coord_set_size = os::Byteswap::byteswap(tex_coord_set_size);
#endif
if (tex_coord_sets >= max_tex_coords || tex_coord_set_size >= 4) // Something is wrong
if (tex_coord_sets < 0 || tex_coord_set_size < 0 ||
tex_coord_sets >= max_tex_coords || tex_coord_set_size >= 4) // Something is wrong
{
os::Printer::log("tex_coord_sets or tex_coord_set_size too big", B3DFile->getFileName(), ELL_ERROR);
return false;
@ -460,7 +465,7 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m
bool showVertexWarning=false;
s32 triangle_brush_id; // Note: Irrlicht can't have different brushes for each triangle (using a workaround)
s32 triangle_brush_id=-1; // Note: Irrlicht can't have different brushes for each triangle (using a workaround)
B3DFile->read(&triangle_brush_id, sizeof(triangle_brush_id));
#ifdef __BIG_ENDIAN__
triangle_brush_id = os::Byteswap::byteswap(triangle_brush_id);
@ -468,14 +473,20 @@ bool CB3DMeshFileLoader::readChunkTRIS(scene::SSkinMeshBuffer *meshBuffer, u32 m
SB3dMaterial *B3dMaterial;
if (triangle_brush_id != -1)
if (triangle_brush_id >= 0 && (u32)triangle_brush_id < Materials.size())
{
loadTextures(Materials[triangle_brush_id]);
B3dMaterial = &Materials[triangle_brush_id];
meshBuffer->Material = B3dMaterial->Material;
}
else
{
B3dMaterial = 0;
if (triangle_brush_id < -1) // -1 is OK
{
os::Printer::log("Illegal material index for triangle brush found", B3DFile->getFileName(), ELL_WARNING);
}
}
const s32 memoryNeeded = B3dStack.getLast().length / sizeof(s32);
meshBuffer->Indices.reallocate(memoryNeeded + meshBuffer->Indices.size() + 1);
@ -594,7 +605,11 @@ bool CB3DMeshFileLoader::readChunkBONE(CSkinnedMesh::SJoint *inJoint)
#endif
globalVertexID += VerticesStart;
if (AnimatedVertices_VertexID[globalVertexID]==-1)
if (globalVertexID >= AnimatedVertices_VertexID.size())
{
os::Printer::log("Illegal vertex index found", B3DFile->getFileName(), ELL_WARNING);
}
else if (AnimatedVertices_VertexID[globalVertexID]==-1)
{
os::Printer::log("B3dMeshLoader: Weight has bad vertex id (no link to meshbuffer index found)");
}
@ -1081,10 +1096,9 @@ void CB3DMeshFileLoader::loadTextures(SB3dMaterial& material) const
void CB3DMeshFileLoader::readString(core::stringc& newstring)
{
newstring="";
while (B3DFile->getPos() <= B3DFile->getSize())
c8 character=0;
while (B3DFile->read(&character, sizeof(character)) > 0) // until eof
{
c8 character;
B3DFile->read(&character, sizeof(character));
if (character==0)
return;
newstring.append(character);

View File

@ -2,13 +2,12 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
// TODO: replace printf's by logging messages
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_B3D_WRITER_
#include "CB3DMeshWriter.h"
#include "SB3DStructs.h"
#include "os.h"
#include "ISkinnedMesh.h"
#include "IMeshBuffer.h"

View File

@ -9,11 +9,8 @@
#include "IMeshWriter.h"
#include "IWriteFile.h"
#include "SB3DStructs.h"
#include "ISkinnedMesh.h"
namespace irr
{
namespace scene

View File

@ -7,7 +7,6 @@
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "IQ3Shader.h"

View File

@ -8,7 +8,6 @@
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "ICameraSceneNode.h"
#include "os.h"
namespace irr
{

View File

@ -6,7 +6,7 @@
#define IRR_C_BILLBOARD_SCENE_NODE_H_INCLUDED
#include "IBillboardSceneNode.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
namespace irr
{

View File

@ -18,7 +18,7 @@
#include "SMesh.h"
#include "IVideoDriver.h"
#include "SAnimatedMesh.h"
#include "SMeshBufferLightMap.h"
#include "CMeshBuffer.h"
#ifdef _DEBUG
#define _IRR_DEBUG_CSM_LOADER_

View File

@ -38,9 +38,7 @@
#ifndef __CSM_LOADER_H_INCLUDED__
#define __CSM_LOADER_H_INCLUDED__
#include "irrArray.h"
#include "IMesh.h"
#include "irrString.h"
#include "IFileSystem.h"
#include "IMeshLoader.h"

View File

@ -7,6 +7,7 @@
#include "CColladaFileLoader.h"
#include "CMeshTextureLoader.h"
#include "CAttributes.h"
#include "os.h"
#include "IXMLReader.h"
#include "IDummyTransformationSceneNode.h"
@ -21,6 +22,7 @@
#include "IMeshCache.h"
#include "IMeshSceneNode.h"
#include "CDynamicMeshBuffer.h"
#include "IVideoDriver.h"
#include "irrMap.h"
#ifdef _DEBUG

View File

@ -7,12 +7,11 @@
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMesh.h"
#include "ISceneManager.h"
#include "irrMap.h"
#include "CAttributes.h"
#include "IAttributes.h"
namespace irr
{

View File

@ -14,7 +14,6 @@
#include "IWriteFile.h"
#include "IXMLWriter.h"
#include "IMesh.h"
#include "IAttributes.h"
#include "IAnimatedMeshSceneNode.h"
#include "IMeshSceneNode.h"
#include "ITerrainSceneNode.h"

View File

@ -3,9 +3,8 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CColorConverter.h"
#include "SColor.h"
#include "IImage.h"
#include "os.h"
#include "irrString.h"
namespace irr
{

View File

@ -6,7 +6,7 @@
#define IRR_C_COLOR_CONVERTER_H_INCLUDED
#include "irrTypes.h"
#include "IImage.h"
#include "SColor.h"
namespace irr
{

View File

@ -7,9 +7,6 @@
#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

View File

@ -6,7 +6,7 @@
#define IRR_C_CUBE_SCENE_NODE_H_INCLUDED
#include "IMeshSceneNode.h"
#include "SMesh.h"
#include "IMesh.h"
#include "IGeometryCreator.h"
namespace irr

View File

@ -25,10 +25,11 @@
#include "CMeshTextureLoader.h"
#include "ISceneManager.h"
#include "IAttributes.h"
#include "IVideoDriver.h"
#include "SAnimatedMesh.h"
#include "SSkinMeshBuffer.h"
#include "SMesh.h"
#include "irrString.h"
#include "irrMath.h"
#include "dmfsupport.h"
namespace irr

View File

@ -33,10 +33,7 @@
#include "IMeshLoader.h"
#include "IReadFile.h"
#include "IFileSystem.h"
#include "SMesh.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "SAnimatedMesh.h"
namespace irr
{

View File

@ -3,11 +3,10 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CFileList.h"
#include "IrrCompileConfig.h"
#include "irrArray.h"
#include "coreutil.h"
#include "os.h"
#include "os.h" // debug logging
namespace irr
{

View File

@ -12,10 +12,6 @@
#include "IGUIButton.h"
#include "IGUIStaticText.h"
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
#include "IFileList.h"
#include "os.h"
#include "fast_atof.h"
namespace irr
{

View File

@ -6,13 +6,11 @@
#ifdef _IRR_COMPILE_WITH_GUI_
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIFont.h"
#include "IGUIButton.h"
#include "CGUIListBox.h"
#include "os.h"
namespace irr
{

View File

@ -8,7 +8,6 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
#include "os.h"

View File

@ -8,7 +8,6 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIFont.h"
#include "IVideoDriver.h"
#include "rect.h"
#include "os.h"
#include "Keycodes.h"

View File

@ -9,13 +9,9 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIStaticText.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
#include "IFileList.h"
#include "os.h"
namespace irr
{

View File

@ -8,7 +8,6 @@
#include "CGUIListBox.h"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "IGUISpriteBank.h"
#include "CGUIScrollBar.h"

View File

@ -7,12 +7,9 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "IGUIWindow.h"
#include "os.h"
namespace irr
{
namespace gui

View File

@ -8,7 +8,6 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "ITexture.h"
namespace irr

View File

@ -11,7 +11,6 @@
#include "CGUIWindow.h"
#include "IGUIStaticText.h"
#include "IGUIImage.h"
#include "irrArray.h"
namespace irr
{

View File

@ -7,7 +7,6 @@
#include "IGUIEnvironment.h"
#include "os.h"
#include "IVideoDriver.h"
#include "IGUISkin.h"
namespace irr

View File

@ -8,7 +8,7 @@
#include "IGUITable.h"
#include "IGUIScrollBar.h"
#include "IGUIEnvironment.h"
#include "CProfiler.h"
#include "IProfiler.h"
namespace irr
{

View File

@ -7,11 +7,7 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "CGUIButton.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
#include "os.h"
namespace irr
{

View File

@ -4,12 +4,11 @@
#include "CGUISpinBox.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIEditBox.h"
#include "CGUIButton.h"
#include "IGUIEditBox.h"
#include "IGUIButton.h"
#include "IGUIEnvironment.h"
#include "IEventReceiver.h"
#include "fast_atof.h"
#include <wchar.h>
namespace irr
@ -131,7 +130,7 @@ void CGUISpinBox::setRange(f32 min, f32 max)
RangeMin = min;
RangeMax = max;
// we have to round the range - otherwise we can get into an infinte setValue/verifyValueRange cycle.
// we have to round the range - otherwise we can get into an infinite setValue/verifyValueRange cycle.
wchar_t str[100];
swprintf_irr(str, 99, FormatString.c_str(), RangeMin);
RangeMin = core::fast_atof(core::stringc(str).c_str());

View File

@ -5,13 +5,12 @@
#include "CGUITabControl.h"
#ifdef _IRR_COMPILE_WITH_GUI_
#include "CGUIButton.h"
#include "IGUIButton.h"
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IGUIFont.h"
#include "IVideoDriver.h"
#include "rect.h"
#include "os.h"
namespace irr
{

View File

@ -10,7 +10,6 @@
#include "IGUITabControl.h"
#include "irrArray.h"
#include "IGUISkin.h"
namespace irr
{

View File

@ -12,8 +12,7 @@
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "CGUIScrollBar.h"
#include "os.h"
#include "IGUIScrollBar.h"
#define ARROW_PAD 15

View File

@ -7,7 +7,6 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "CGUIButton.h"

View File

@ -13,7 +13,6 @@
#include "IVideoDriver.h"
#include "IGUIFont.h"
#include "CGUIScrollBar.h"
#include "os.h"
namespace irr
{

View File

@ -7,10 +7,8 @@
#include "IGUISkin.h"
#include "IGUIEnvironment.h"
#include "IVideoDriver.h"
#include "IGUIButton.h"
#include "IGUIFont.h"
#include "IGUIFontBitmap.h"
namespace irr
{

View File

@ -3,8 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CGeometryCreator.h"
#include "SAnimatedMesh.h"
#include "SMeshBuffer.h"
#include "SMesh.h"
#include "IMesh.h"
#include "IVideoDriver.h"

View File

@ -6,7 +6,7 @@
#define IRR_C_GEOMETRY_CREATOR_H_INCLUDED
#include "IGeometryCreator.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
namespace irr
{

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CImage.h"
#include "irrString.h"
#include "CColorConverter.h"
#include "CBlit.h"
#include "os.h"

View File

@ -11,7 +11,6 @@
#include "CColorConverter.h"
#include "CImage.h"
#include "os.h"
#include "irrString.h"
namespace irr
{
@ -48,19 +47,35 @@ bool CImageLoaderBMP::isALoadableFileFormat(io::IReadFile* file) const
}
// UB-safe overflow check
static inline bool doesOverflow(const void *base, size_t numElements, const void *end)
{
// TODO: uintptr_t (as in original patch from sfan5) would be nicer than size_t, use once we allow c++11
size_t baseI = reinterpret_cast<size_t>(base);
size_t endI = reinterpret_cast<size_t>(end);
return baseI > endI || numElements >= (endI - baseI);
}
// check whether &p[0] to &p[_off - 1] can be accessed
#define EXIT_P_OVERFLOW(_off) if (doesOverflow(p, _off, pEnd)) goto exit
// same for d
#define EXIT_D_OVERFLOW(_off) if (doesOverflow(d, _off, destEnd)) goto exit
void CImageLoaderBMP::decompress8BitRLE(u8*& bmpData, s32 size, s32 width, s32 height, s32 pitch) const
{
u8* p = bmpData;
const u8* pEnd = bmpData + size;
u8* newBmp = new u8[(width+pitch)*height];
u8* d = newBmp;
u8* destEnd = newBmp + (width+pitch)*height;
const u8* destEnd = newBmp + (width+pitch)*height;
s32 line = 0;
while (bmpData - p < size && d < destEnd)
while (p < pEnd && d < destEnd)
{
if (*p == 0)
{
++p;
EXIT_P_OVERFLOW(1);
switch(*p)
{
@ -70,37 +85,43 @@ void CImageLoaderBMP::decompress8BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
d = newBmp + (line*(width+pitch));
break;
case 1: // end of bmp
delete [] bmpData;
bmpData = newBmp;
return;
goto exit;
case 2:
++p; d +=(u8)*p; // delta
++p; d += ((u8)*p)*(width+pitch);
++p;
EXIT_P_OVERFLOW(2);
d += (u8)*p; // delta
++p;
d += ((u8)*p)*(width+pitch);
++p;
break;
default:
{
// absolute mode
s32 count = (u8)*p; ++p;
s32 readAdditional = ((2-(count%2))%2);
s32 i;
const s32 count = (u8)*p;
++p;
for (i=0; i<count; ++i)
EXIT_P_OVERFLOW(count);
EXIT_D_OVERFLOW(count);
for (s32 i=0; i<count; ++i)
{
*d = *p;
++p;
++d;
}
for (i=0; i<readAdditional; ++i)
const s32 readAdditional = ((2-(count%2))%2);
EXIT_P_OVERFLOW(readAdditional);
for (s32 i=0; i<readAdditional; ++i)
++p;
}
}
}
else
{
s32 count = (u8)*p; ++p;
const s32 count = (u8)*p; ++p;
EXIT_P_OVERFLOW(1);
u8 color = *p; ++p;
EXIT_D_OVERFLOW(count);
for (s32 i=0; i<count; ++i)
{
*d = color;
@ -109,63 +130,97 @@ void CImageLoaderBMP::decompress8BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
}
}
exit:
delete [] bmpData;
bmpData = newBmp;
}
// how many new bytes will be touched given the current state of decompress4BitRLE
static inline u32 shiftedCount(s32 count, s32 shift)
{
IRR_DEBUG_BREAK_IF(count <= 0)
u32 ret = 0;
if ( shift == 0 ) // using up half of an old byte
{
--count;
}
ret += (count / 2) + (count % 2);
return ret;
}
// Ensure current row/line are inside width/height
// Didn't find any documentation how BMP's are supposed to handle this
// I think in general "good" bmp's are supposed to not go over line-ends
#define KEEP_ROW_LINE_INSIDE \
if ( row >= width ) \
{ \
line += row/width; \
row %= width; \
} \
if ( line >= height ) \
{ \
line = 0; /* bug anyway, this way more visible maybe */ \
}
void CImageLoaderBMP::decompress4BitRLE(u8*& bmpData, s32 size, s32 width, s32 height, s32 pitch) const
{
s32 lineWidth = (width+1)/2+pitch;
const s32 lineWidth = (width+1)/2+pitch;
u8* p = bmpData;
const u8* pEnd = bmpData + size;
u8* newBmp = new u8[lineWidth*height];
u8* d = newBmp;
u8* destEnd = newBmp + lineWidth*height;
memset(newBmp, 0, lineWidth*height); // Extra cost, but otherwise we have to code pixel skipping stuff
const u8* destEnd = newBmp + lineWidth*height;
s32 line = 0;
s32 shift = 4;
s32 row = 0;
while (bmpData - p < size && d < destEnd)
while (p < pEnd)
{
if (*p == 0)
{
++p;
EXIT_P_OVERFLOW(1);
switch(*p)
{
case 0: // end of line
++p;
++line;
d = newBmp + (line*lineWidth);
shift = 4;
row = 0;
break;
case 1: // end of bmp
delete [] bmpData;
bmpData = newBmp;
return;
case 2:
goto exit;
case 2: // delta
{
++p;
EXIT_P_OVERFLOW(2);
s32 x = (u8)*p; ++p;
s32 y = (u8)*p; ++p;
d += x/2 + y*lineWidth;
shift = x%2==0 ? 4 : 0;
row += x;
line += y;
}
break;
default:
{
// absolute mode
s32 count = (u8)*p; ++p;
s32 readAdditional = ((2-((count)%2))%2);
const u32 count = (u8)*p; ++p;
s32 readShift = 4;
s32 i;
for (i=0; i<count; ++i)
KEEP_ROW_LINE_INSIDE;
s32 shift = row%2 == 0 ? 4 : 0;
u8* d = newBmp + (lineWidth*line + row/2);
EXIT_P_OVERFLOW(shiftedCount(count, readShift));
EXIT_D_OVERFLOW(shiftedCount(count, shift));
for (u32 i=0; i<count; ++i)
{
s32 color = (((u8)*p) >> readShift) & 0x0f;
readShift -= 4;
if (readShift < 0)
{
++*p;
++p;
readShift = 4;
}
@ -178,26 +233,37 @@ void CImageLoaderBMP::decompress4BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
shift = 4;
++d;
}
}
row += count;
for (i=0; i<readAdditional; ++i)
// pixels always come in 2-byte packages with unused half-bytes filled with zeroes
const u32 modCount = (count%4);
const u32 readAdditional = modCount == 1 ? 2 : (modCount==0?0:1); // jump 2,1,1,0 for count 1,2,3,4
EXIT_P_OVERFLOW(readAdditional);
for (u32 i=0; i<readAdditional; ++i)
++p;
}
}
}
else
else // encoded mode
{
s32 count = (u8)*p; ++p;
s32 color1 = (u8)*p; color1 = color1 & 0x0f;
s32 color2 = (u8)*p; color2 = (color2 >> 4) & 0x0f;
const s32 count = (u8)*p; // pixels to draw
++p;
EXIT_P_OVERFLOW(1);
s32 color1 = (u8)*p; color1 = color1 & 0x0f; // lo bit (2nd,4th,... pixel)
s32 color2 = (u8)*p; color2 = (color2 >> 4) & 0x0f; // hi bits (1st,3rd,... pixel)
++p;
KEEP_ROW_LINE_INSIDE;
s32 shift = row%2 == 0 ? 4 : 0;
u8* d = newBmp + (lineWidth*line + row/2);
EXIT_D_OVERFLOW(shiftedCount(count, shift));
for (s32 i=0; i<count; ++i)
{
u8 mask = 0x0f << shift;
u8 toSet = (shift==0 ? color1 : color2) << shift;
*d = (*d & (~mask)) | (toSet & mask);
u8 toSet = ((i%2==0) ? color2 : color1) << shift;
*d = (*d & (~mask)) | toSet;
shift -= 4;
if (shift < 0)
@ -206,14 +272,18 @@ void CImageLoaderBMP::decompress4BitRLE(u8*& bmpData, s32 size, s32 width, s32 h
++d;
}
}
row += count;
}
}
exit:
delete [] bmpData;
bmpData = newBmp;
}
#undef EXIT_P_OVERFLOW
#undef EXIT_D_OVERFLOW
#undef KEEP_ROW_LINE_INSIDE
//! creates a surface from the file
IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
@ -239,12 +309,25 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
header.ImportantColors = os::Byteswap::byteswap(header.ImportantColors);
#endif
s32 pitch = 0;
//! return if the header is false
if (header.Id != 0x4d42)
bool topDown = false;
if (header.Id == 0x4d42) // BM = Windows header
{
// Sizes are signed integer with Windows header (unsigned with OS/2)
// Not sure if negative Width has any meaning, but negative height is for upside-down
header.Width = core::abs_((s32)header.Width);
if ( (s32)header.Height < 0 )
{
topDown = true;
header.Height = core::abs_((s32)header.Height);
}
}
else
{
os::Printer::log("BMP files with OS/2 Headers not supported.", ELL_ERROR);
return 0;
}
if (header.Compression > 2) // we'll only handle RLE-Compression
{
@ -282,14 +365,9 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
file->seek(header.BitmapDataOffset);
f32 t = (header.Width) * (header.BPP / 8.0f);
s32 widthInBytes = (s32)t;
t -= widthInBytes;
if (t!=0.0f)
++widthInBytes;
s32 lineData = widthInBytes + ((4-(widthInBytes%4)))%4;
pitch = lineData - widthInBytes;
const s32 widthInBytes = core::ceil32(header.Width * (header.BPP / 8.0f));
const s32 lineSize = widthInBytes + ((4-(widthInBytes%4)))%4;
const s32 pitch = lineSize - widthInBytes;
u8* bmpData = new u8[header.BitmapDataSize];
file->read(bmpData, header.BitmapDataSize);
@ -297,14 +375,25 @@ IImage* CImageLoaderBMP::loadImage(io::IReadFile* file) const
// decompress data if needed
switch(header.Compression)
{
case 1: // 8 bit rle
case 1: // 8 bit RLE
decompress8BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch);
header.BitmapDataSize = (header.Width + pitch) * header.Height;
break;
case 2: // 4 bit rle
case 2: // 4 bit RLE
decompress4BitRLE(bmpData, header.BitmapDataSize, header.Width, header.Height, pitch);
header.BitmapDataSize = ((header.Width+1)/2 + pitch) * header.Height;
break;
}
if (header.BitmapDataSize < lineSize * header.Height)
{
os::Printer::log("Bitmap data is cut off.", ELL_ERROR);
delete [] paletteData;
delete [] bmpData;
return 0;
}
// create surface
// no default constructor from packed area! ARM problem!
@ -359,6 +448,9 @@ cleanup:
delete [] paletteData;
delete [] bmpData;
if ( image && topDown )
image->flip(true, false);
return image;
}

View File

@ -18,9 +18,7 @@
#include "IReadFile.h"
#include "os.h"
#include "CColorConverter.h"
#include "CImage.h"
#include "irrString.h"
// Header flag values
#define DDSD_CAPS 0x00000001
@ -721,9 +719,8 @@ IImage* CImageLoaderDDS::loadImage(io::IReadFile* file) const
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(width, height));
if (DDSDecompress(&header, memFile, (u8*)image->lock()) == -1)
if (DDSDecompress(&header, memFile, (u8*)image->getData()) == -1)
{
image->unlock();
image->drop();
image = 0;
}

View File

@ -11,7 +11,6 @@
#include "CColorConverter.h"
#include "CImage.h"
#include "os.h"
#include "irrString.h"
namespace irr

View File

@ -15,7 +15,7 @@
#endif // _IRR_COMPILE_WITH_LIBPNG_
#include "CImage.h"
#include "CReadFile.h"
#include "IReadFile.h"
#include "os.h"
namespace irr

View File

@ -9,7 +9,6 @@
#include "IReadFile.h"
#include "os.h"
#include "CImage.h"
#include "irrString.h"
namespace irr

View File

@ -9,7 +9,6 @@
#include "IReadFile.h"
#include "os.h"
#include "CImage.h"
#include "irrString.h"
namespace irr
{

View File

@ -130,7 +130,6 @@ DUMMY - This 404 bytes of data should be set to 0. This makes the Header exactl
#include "CColorConverter.h"
#include "CImage.h"
#include "os.h"
#include "irrString.h"
namespace irr

View File

@ -10,7 +10,6 @@
#include "os.h"
#include "CColorConverter.h"
#include "CImage.h"
#include "irrString.h"
namespace irr
@ -33,10 +32,10 @@ u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader&
// This was written and sent in by Jon Pry, thank you very much!
// I only changed the formatting a little bit.
s32 bytesPerPixel = header.PixelDepth/8;
s32 imageSize = header.ImageHeight * header.ImageWidth * bytesPerPixel;
const u32 bytesPerPixel = header.PixelDepth/8;
const u32 imageSize = header.ImageHeight * header.ImageWidth * bytesPerPixel;
u8* data = new u8[imageSize];
s32 currentByte = 0;
u32 currentByte = 0;
while(currentByte < imageSize)
{
@ -47,8 +46,17 @@ u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader&
{
chunkheader++; // Add 1 To The Value To Get Total Number Of Raw Pixels
file->read(&data[currentByte], bytesPerPixel * chunkheader);
currentByte += bytesPerPixel * chunkheader;
const u32 bytesToRead = bytesPerPixel * chunkheader;
if ( currentByte+bytesToRead < imageSize )
{
file->read(&data[currentByte], bytesToRead);
currentByte += bytesToRead;
}
else
{
os::Printer::log("Compressed TGA file RAW chunk tries writing beyond buffer", file->getFileName(), ELL_WARNING);
break;
}
}
else
{
@ -57,15 +65,27 @@ u8 *CImageLoaderTGA::loadCompressedImage(io::IReadFile *file, const STGAHeader&
// If It's An RLE Header
chunkheader -= 127; // Subtract 127 To Get Rid Of The ID Bit
s32 dataOffset = currentByte;
file->read(&data[dataOffset], bytesPerPixel);
currentByte += bytesPerPixel;
for(s32 counter = 1; counter < chunkheader; counter++)
u32 dataOffset = currentByte;
if ( dataOffset+bytesPerPixel < imageSize )
{
for(s32 elementCounter=0; elementCounter < bytesPerPixel; elementCounter++)
data[currentByte + elementCounter] = data[dataOffset + elementCounter];
file->read(&data[dataOffset], bytesPerPixel);
currentByte += bytesPerPixel;
}
else
{
os::Printer::log("Compressed TGA file RLE headertries writing beyond buffer", file->getFileName(), ELL_WARNING);
break;
}
for(u32 counter = 1; counter < chunkheader; counter++)
{
if ( currentByte + bytesPerPixel <= imageSize )
{
for(u32 elementCounter=0; elementCounter < bytesPerPixel; elementCounter++)
{
data[currentByte + elementCounter] = data[dataOffset + elementCounter];
}
}
currentByte += bytesPerPixel;
}
@ -118,8 +138,17 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
if (header.ColorMapType)
{
// create 32 bit palette
palette = new u32[ header.ColorMapLength];
// Create 32 bit palette
const irr::u16 paletteSize = core::max_((u16)256, header.ColorMapLength); // ColorMapLength can lie, but so far we only use palette for 8-bit, so ensure it has 256 entries
palette = new u32[paletteSize];
if( paletteSize > header.ColorMapLength )
{
// To catch images using palette colors with invalid indices
const irr::u32 errorCol = irr::video::SColor(255,255, 0, 205).color; // bright magenta
for ( irr::u16 i = header.ColorMapLength; i< paletteSize; ++i )
palette[i] = errorCol;
}
// read color map
u8 * colorMap = new u8[header.ColorMapEntrySize/8 * header.ColorMapLength];
@ -150,7 +179,7 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
header.ImageType == 3 // Uncompressed, black and white images
)
{
const s32 imageSize = header.ImageHeight * header.ImageWidth * header.PixelDepth/8;
const s32 imageSize = header.ImageHeight * header.ImageWidth * (header.PixelDepth/8);
data = new u8[imageSize];
file->read(data, imageSize);
}
@ -185,14 +214,28 @@ IImage* CImageLoaderTGA::loadImage(io::IReadFile* file) const
}
else
{
image = new CImage(ECF_A1R5G5B5,
core::dimension2d<u32>(header.ImageWidth, header.ImageHeight));
if (image)
CColorConverter::convert8BitTo16Bit((u8*)data,
(s16*)image->getData(),
header.ImageWidth,header.ImageHeight,
(s32*) palette, 0,
(header.ImageDescriptor&0x20)==0);
switch ( header.ColorMapEntrySize )
{
case 16:
image = new CImage(ECF_A1R5G5B5, core::dimension2d<u32>(header.ImageWidth, header.ImageHeight));
if ( image )
CColorConverter::convert8BitTo16Bit((u8*)data,
(s16*)image->getData(),
header.ImageWidth,header.ImageHeight,
(s32*) palette, 0,
(header.ImageDescriptor&0x20)==0);
break;
// Note: 24 bit with palette would need a 24 bit palette, too lazy doing that now (textures will prefer 32-bit later anyway)
default:
image = new CImage(ECF_A8R8G8B8, core::dimension2d<u32>(header.ImageWidth, header.ImageHeight));
if ( image )
CColorConverter::convert8BitTo32Bit((u8*)data,
(u8*)image->getData(),
header.ImageWidth,header.ImageHeight,
(u8*) palette, 0,
(header.ImageDescriptor&0x20)==0);
break;
}
}
}
break;

View File

@ -9,8 +9,6 @@
#include "CImage.h"
#include "os.h"
#include "dimension2d.h"
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "IReadFile.h"
#include "irrString.h"

View File

@ -9,7 +9,6 @@
#include "CImageLoaderBMP.h"
#include "IWriteFile.h"
#include "CColorConverter.h"
#include "irrString.h"
#include "os.h"
namespace irr

View File

@ -8,8 +8,7 @@
#include "CColorConverter.h"
#include "IWriteFile.h"
#include "CImage.h"
#include "irrString.h"
#include "IImage.h"
#include "os.h"
#ifdef _IRR_COMPILE_WITH_LIBJPEG_

View File

@ -6,10 +6,9 @@
#ifdef _IRR_COMPILE_WITH_PCX_WRITER_
#include "CImageLoaderPCX.h"
#include "IWriteFile.h"
#include "IImage.h"
#include "os.h" // for logging
#include "irrString.h"
namespace irr
{

View File

@ -6,10 +6,9 @@
#ifdef _IRR_COMPILE_WITH_PNG_WRITER_
#include "CImageLoaderPNG.h"
#include "IImage.h"
#include "CColorConverter.h"
#include "IWriteFile.h"
#include "irrString.h"
#include "os.h" // for logging
#ifdef _IRR_COMPILE_WITH_LIBPNG_

View File

@ -9,7 +9,6 @@
#include "IWriteFile.h"
#include "IImage.h"
#include "dimension2d.h"
#include "irrString.h"
namespace irr
{

View File

@ -9,7 +9,6 @@
#include "CImageLoaderPSD.h"
#include "IWriteFile.h"
#include "os.h" // for logging
#include "irrString.h"
namespace irr
{

View File

@ -9,7 +9,6 @@
#include "CImageLoaderTGA.h"
#include "IWriteFile.h"
#include "CColorConverter.h"
#include "irrString.h"
#include "os.h"
namespace irr

View File

@ -26,7 +26,7 @@ namespace irr
class CIrrDeviceMacOSX;
}
@interface CIrrDelegateOSX : NSObject
@interface CIrrDelegateOSX : NSObject <NSApplicationDelegate, NSWindowDelegate>
- (id)initWithDevice:(irr::CIrrDeviceMacOSX*)device;
- (void)terminate:(id)sender;

View File

@ -579,7 +579,7 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
{
[[NSAutoreleasePool alloc] init];
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
[NSApp setDelegate:(id<NSApplicationDelegate>)[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];
[[NSApplication sharedApplication] setDelegate:[[[CIrrDelegateOSX alloc] initWithDevice:this] autorelease]];
// Create menu
@ -794,7 +794,7 @@ bool CIrrDeviceMacOSX::createWindow()
{
if (Window)
{
[Window setDelegate:(id<NSWindowDelegate>)[NSApp delegate]];
[Window setDelegate:(CIrrDelegateOSX *)[NSApp delegate]];
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
@ -867,7 +867,7 @@ void CIrrDeviceMacOSX::createDriver()
SoftwareRendererType = 2;
if (Window)
{
Window.contentView.wantsLayer = YES;
[[Window contentView] setWantsLayer:YES];
}
#else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
@ -880,7 +880,7 @@ void CIrrDeviceMacOSX::createDriver()
SoftwareRendererType = 1;
if (Window)
{
Window.contentView.wantsLayer = YES;
[[Window contentView] setWantsLayer:YES];
[ Window setOpaque:YES];
}
@ -1602,7 +1602,7 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
NSImage *image = [[[NSImage alloc] initWithSize: imageSize] autorelease];
[image addRepresentation: rep];
Window.contentView.layer.contents = image;
[[[Window contentView] layer] setContents:image];
}
return true;
}

View File

@ -9,8 +9,6 @@
#ifdef _IRR_COMPILE_WITH_WINDOWS_DEVICE_
#include "CIrrDeviceStub.h"
#include "IrrlichtDevice.h"
#include "IImagePresenter.h"
#define WIN32_LEAN_AND_MEAN
#if !defined(_IRR_XBOX_PLATFORM_)
@ -71,7 +69,7 @@ namespace irr
virtual video::IVideoModeList* getVideoModeList() IRR_OVERRIDE;
//! Notifies the device, that it has been resized
/** Must be publis as it is called from free function (event handler) */
/** Must be public as it is called from free function (event handler) */
void OnResized();
//! Sets if the window should be resizable in windowed mode.

View File

@ -9,12 +9,12 @@
#include "os.h"
#include "IXMLReader.h"
#include "SAnimatedMesh.h"
#include "SMesh.h"
#include "fast_atof.h"
#include "IReadFile.h"
#include "IAttributes.h"
#include "IMeshSceneNode.h"
#include "IVideoDriver.h"
#include "CDynamicMeshBuffer.h"
#include "SMeshBufferLightMap.h"
namespace irr
{

View File

@ -7,10 +7,6 @@
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "CDynamicMeshBuffer.h"
#include "ISceneManager.h"

View File

@ -70,13 +70,12 @@ Version 1.0 - 29 July 2004
#include "CLMTSMeshFileLoader.h"
#include "CMeshTextureLoader.h"
#include "SMeshBufferLightMap.h"
#include "CMeshBuffer.h"
#include "SAnimatedMesh.h"
#include "SMeshBuffer.h"
#include "SceneParameters.h"
#include "irrString.h"
#include "IReadFile.h"
#include "IAttributes.h"
#include "ISceneManager.h"
#include "os.h"
namespace irr

View File

@ -6,7 +6,7 @@
#define IRR_C_LWO_MESH_FILE_LOADER_H_INCLUDED
#include "IMeshLoader.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
#include "irrString.h"
namespace irr

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CLimitReadFile.h"
#include "irrString.h"
namespace irr
{

View File

@ -6,7 +6,6 @@
#define IRR_C_LIMIT_READ_FILE_H_INCLUDED
#include "IReadFile.h"
#include "irrString.h"
namespace irr
{

View File

@ -3,6 +3,8 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CLogger.h"
#include "os.h"
#include "irrString.h"
namespace irr
{

View File

@ -6,8 +6,6 @@
#define IRR_C_LOGGER_H_INCLUDED
#include "ILogger.h"
#include "os.h"
#include "irrString.h"
#include "IEventReceiver.h"
namespace irr

View File

@ -7,6 +7,8 @@
#include "CMD2MeshFileLoader.h"
#include "CAnimatedMeshMD2.h"
#include "coreutil.h"
#include "IReadFile.h"
#include "os.h"
namespace irr

View File

@ -7,7 +7,7 @@
#include "CMD3MeshFileLoader.h"
#include "CAnimatedMeshMD3.h"
#include "irrString.h"
#include "IVideoDriver.h"
namespace irr
{

View File

@ -6,10 +6,7 @@
#define IRR_C_MD3_MESH_FILE_LOADER_H_INCLUDED
#include "IMeshLoader.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "IQ3Shader.h"
namespace irr
{

View File

@ -15,7 +15,7 @@
#include "CMeshTextureLoader.h"
#include "SAnimatedMesh.h"
#include "SMeshBuffer.h"
#include "SMesh.h"
#include "IReadFile.h"
#include "IAttributes.h"

View File

@ -29,8 +29,7 @@
#include "IMeshLoader.h"
#include "SMesh.h"
#include "SMeshBufferLightMap.h"
#include "CMeshBuffer.h"
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"

View File

@ -3,7 +3,6 @@
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CMemoryFile.h"
#include "irrString.h"
namespace irr
{

View File

@ -7,7 +7,6 @@
#include "IMemoryReadFile.h"
#include "IWriteFile.h"
#include "irrString.h"
namespace irr
{

View File

@ -6,11 +6,8 @@
#include "CBufferRenderNode.h"
#include "IVideoDriver.h"
#include "ISceneManager.h"
#include "S3DVertex.h"
#include "ICameraSceneNode.h"
#include "IMeshCache.h"
#include "IAnimatedMesh.h"
#include "IMaterialRenderer.h"
#include "IFileSystem.h"
#ifdef _IRR_COMPILE_WITH_SHADOW_VOLUME_SCENENODE_
#include "CShadowVolumeSceneNode.h"

View File

@ -7,7 +7,6 @@
#ifdef __IRR_COMPILE_WITH_MOUNT_ARCHIVE_LOADER_
#include "CReadFile.h"
#include "os.h"
namespace irr
{

View File

@ -10,9 +10,7 @@
#ifdef __IRR_COMPILE_WITH_NPK_ARCHIVE_LOADER_
#include "IReferenceCounted.h"
#include "IReadFile.h"
#include "irrArray.h"
#include "irrString.h"
#include "IFileSystem.h"
#include "CFileList.h"

View File

@ -11,6 +11,7 @@
#include "IImageLoader.h"
#include "IImageWriter.h"
#include "IMaterialRenderer.h"
#include "IMeshSceneNode.h"
#include "IAnimatedMeshSceneNode.h"
#include "CMeshManipulator.h"
#include "CColorConverter.h"

View File

@ -7,7 +7,6 @@
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "IImagePresenter.h"
#include "IGPUProgrammingServices.h"
#include "irrArray.h"
#include "irrString.h"

View File

@ -10,7 +10,6 @@
#include "IMeshManipulator.h"
#include "IVideoDriver.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "SAnimatedMesh.h"
#include "IReadFile.h"
#include "IAttributes.h"
@ -68,13 +67,26 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
{
if (!file)
return 0;
size_t filesize = file->getSize();
if (filesize == 0 || filesize == (size_t)-1L)
return 0;
const io::path fullName = file->getFileName();
const io::path relPath = FileSystem->getFileDir(fullName)+"/";
c8* buf = new c8[filesize+1]; // plus null-terminator (some string functions used in parsing)
filesize = file->read((void*)buf, filesize);
if ( filesize == 0 )
{
delete[] buf;
return 0;
}
buf[filesize] = 0;
if ( getMeshTextureLoader() )
getMeshTextureLoader()->setMeshFile(file);
const long filesize = file->getSize();
if (!filesize)
return 0;
const c8* const bufEnd = buf+filesize;
const u32 WORD_BUFFER_LENGTH = 512;
@ -86,14 +98,6 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
Materials.push_back(currMtl);
u32 smoothingGroup=0;
const io::path fullName = file->getFileName();
const io::path relPath = FileSystem->getFileDir(fullName)+"/";
c8* buf = new c8[filesize];
memset(buf, 0, filesize);
file->read((void*)buf, filesize);
const c8* const bufEnd = buf+filesize;
// Process obj information
const c8* bufPtr = buf;
core::stringc grpName, mtlName;
@ -246,19 +250,20 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
u32 wlength = copyWord(vertexWord, linePtr, WORD_BUFFER_LENGTH, endPtr);
// this function will also convert obj's 1-based index to c++'s 0-based index
retrieveVertexIndices(vertexWord, Idx, vertexWord+wlength+1, vertexBuffer.size(), textureCoordBuffer.size(), normalsBuffer.size());
if ( -1 != Idx[0] && Idx[0] < (irr::s32)vertexBuffer.size() )
if ( Idx[0] >= 0 && Idx[0] < (irr::s32)vertexBuffer.size() )
v.Pos = vertexBuffer[Idx[0]];
else
{
os::Printer::log("Invalid vertex index in this line", wordBuffer.c_str(), ELL_ERROR);
delete [] buf;
cleanUp();
return 0;
}
if ( -1 != Idx[1] && Idx[1] < (irr::s32)textureCoordBuffer.size() )
if ( Idx[1] >= 0 && Idx[1] < (irr::s32)textureCoordBuffer.size() )
v.TCoords = textureCoordBuffer[Idx[1]];
else
v.TCoords.set(0.0f,0.0f);
if ( -1 != Idx[2] && Idx[2] < (irr::s32)normalsBuffer.size() )
if ( Idx[2] >= 0 && Idx[2] < (irr::s32)normalsBuffer.size() )
v.Normal = normalsBuffer[Idx[2]];
else
{
@ -286,23 +291,30 @@ IAnimatedMesh* COBJMeshFileLoader::createMesh(io::IReadFile* file)
}
// triangulate the face
const int c = faceCorners[0];
for ( u32 i = 1; i < faceCorners.size() - 1; ++i )
if ( faceCorners.size() >= 3)
{
// Add a triangle
const int a = faceCorners[i + 1];
const int b = faceCorners[i];
if (a != b && a != c && b != c) // ignore degenerated faces. We can get them when we merge vertices above in the VertMap.
const int c = faceCorners[0];
for ( u32 i = 1; i < faceCorners.size() - 1; ++i )
{
mbIndexBuffer.push_back(a);
mbIndexBuffer.push_back(b);
mbIndexBuffer.push_back(c);
}
else
{
++degeneratedFaces;
// Add a triangle
const int a = faceCorners[i + 1];
const int b = faceCorners[i];
if (a != b && a != c && b != c) // ignore degenerated faces. We can get them when we merge vertices above in the VertMap.
{
mbIndexBuffer.push_back(a);
mbIndexBuffer.push_back(b);
mbIndexBuffer.push_back(c);
}
else
{
++degeneratedFaces;
}
}
}
else
{
os::Printer::log("Too few vertices in this line", wordBuffer.c_str());
}
}
break;

View File

@ -10,9 +10,7 @@
#include "os.h"
#include "IMesh.h"
#include "IMeshBuffer.h"
#include "IAttributes.h"
#include "ISceneManager.h"
#include "IMeshCache.h"
#include "IWriteFile.h"
#include "IFileSystem.h"
#include "ITexture.h"

View File

@ -17,8 +17,9 @@
#include "IVideoDriver.h"
#include "IFileSystem.h"
#include "os.h"
#include "SMesh.h"
#include "SAnimatedMesh.h"
#include "SMeshBufferLightMap.h"
#include "CMeshBuffer.h"
#include "irrString.h"
#include "ISceneManager.h"

View File

@ -45,8 +45,6 @@
#include "IMeshLoader.h"
#include "IReadFile.h"
#include "SMesh.h"
#include "irrString.h"
namespace irr
{

View File

@ -9,7 +9,8 @@
#include "COgreMeshFileLoader.h"
#include "CMeshTextureLoader.h"
#include "os.h"
#include "SMeshBuffer.h"
#include "CMeshBuffer.h"
#include "SMesh.h"
#include "SAnimatedMesh.h"
#include "IReadFile.h"
#include "fast_atof.h"

View File

@ -10,12 +10,8 @@
#include "IFileSystem.h"
#include "IVideoDriver.h"
#include "irrString.h"
#include "SMesh.h"
#include "SMeshBuffer.h"
#include "SMeshBufferLightMap.h"
#include "IMeshManipulator.h"
#include "matrix4.h"
#include "quaternion.h"
#include "CMeshBuffer.h"
#include "CSkinnedMesh.h"
namespace irr

View File

@ -11,8 +11,6 @@
#include "COpenGLCommon.h"
#include "COpenGLCoreFeature.h"
#include "COpenGLCoreTexture.h"
#include "COpenGLCoreCacheHandler.h"
namespace irr

View File

@ -9,6 +9,8 @@
#if defined(_IRR_COMPILE_WITH_OPENGL_) || defined(_IRR_COMPILE_WITH_OGLES1_) || defined(_IRR_COMPILE_WITH_OGLES2_)
#include "COpenGLCoreFeature.h"
#include "COpenGLCoreTexture.h"
#include "SMaterial.h"
#include "ITexture.h"

View File

@ -6,8 +6,6 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "IGPUProgrammingServices.h"
#include "IShaderConstantSetCallBack.h"
#include "IVideoDriver.h"
#include "os.h"

View File

@ -6,8 +6,6 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "IGPUProgrammingServices.h"
#include "IShaderConstantSetCallBack.h"
#include "IVideoDriver.h"
#include "os.h"

View File

@ -14,7 +14,6 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "IGPUProgrammingServices.h"
#include "IShaderConstantSetCallBack.h"
#include "IMaterialRendererServices.h"
#include "IVideoDriver.h"
@ -22,7 +21,6 @@
#include "COpenGLDriver.h"
#include "COpenGLCacheHandler.h"
#include "COpenGLMaterialRenderer.h"
#include "COpenGLCoreFeature.h"

View File

@ -6,14 +6,12 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "IGPUProgrammingServices.h"
#include "IShaderConstantSetCallBack.h"
#include "IVideoDriver.h"
#include "os.h"
#include "COpenGLDriver.h"
#include "COpenGLCacheHandler.h"
#include "COpenGLMaterialRenderer.h"
namespace irr
{

View File

@ -10,6 +10,7 @@
#ifdef _IRR_COMPILE_WITH_OPENGL_
#include "IMaterialRenderer.h"
#include "irrArray.h"
#include "COpenGLCommon.h"

View File

@ -9,10 +9,7 @@
#ifdef __IRR_COMPILE_WITH_PAK_ARCHIVE_LOADER_
#include "IReferenceCounted.h"
#include "IReadFile.h"
#include "irrArray.h"
#include "irrString.h"
#include "IFileSystem.h"
#include "CFileList.h"

Some files were not shown because too many files have changed in this diff Show More