Commit c2236586 authored by hybrid's avatar hybrid

Merged revisions 2407:2436 from 1.5 branch. CopyToScaling bug fix, big endian...

Merged revisions 2407:2436 from 1.5 branch. CopyToScaling bug fix, big endian .x bug fix, STL loading fixed, binary attributes loading fixed.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2440 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 8e9c3de2
......@@ -488,7 +488,7 @@ namespace video
const f32 maxVal = (f32)core::max_(color.getRed(), color.getGreen(), color.getBlue());
const f32 minVal = (f32)core::min_(color.getRed(), color.getGreen(), color.getBlue());
Luminance = (maxVal/minVal)*0.5f;
if (maxVal==minVal)
if (core::equals(maxVal, minVal))
{
Hue=0.f;
Saturation=0.f;
......@@ -506,7 +506,7 @@ namespace video
}
if (maxVal==color.getRed())
Hue = (color.getRed()-color.getBlue())/delta;
Hue = (color.getGreen()-color.getBlue())/delta;
else if (maxVal==color.getGreen())
Hue = 2+(color.getBlue()-color.getRed())/delta;
else if (maxVal==color.getBlue())
......@@ -520,12 +520,12 @@ namespace video
inline void SColorHSL::toRGB(SColor &color) const
{
if ( Saturation == 0.0f) // grey
if (core::iszero(Saturation)) // grey
{
u8 c = (u8) ( Luminance * 255.0 );
color.setRed ( c );
color.setGreen ( c );
color.setBlue ( c );
color.setRed(c);
color.setGreen(c);
color.setBlue(c);
return;
}
......
......@@ -338,8 +338,8 @@ public:
}
//! Get size of array.
/** \return Size of elements used in the array. */
//! Get number of occupied elements of the array.
/** \return Size of elements in the array which are actually occupied. */
u32 size() const
{
return used;
......@@ -348,7 +348,7 @@ public:
//! Get amount of memory allocated.
/** \return Amount of memory allocated. The amount of bytes
allocated would be allocated_size() * sizeof(ElementsUsed); */
allocated would be allocated_size() * sizeof(ElementTypeUsed); */
u32 allocated_size() const
{
return allocated;
......
......@@ -1692,9 +1692,9 @@ public:
return L"string";
}
virtual void getBinary(void* outdata, s32 maxLenght)
virtual void getBinary(void* outdata, s32 maxLength)
{
s32 dataSize = maxLenght;
s32 dataSize = maxLength;
c8* datac8 = (c8*)(outdata);
s32 p = 0;
const c8* dataString = Value.c_str();
......@@ -1714,9 +1714,9 @@ public:
}
};
virtual void setBinary(void* data, s32 maxLenght)
virtual void setBinary(void* data, s32 maxLength)
{
s32 dataSize = maxLenght;
s32 dataSize = maxLength;
c8* datac8 = (c8*)(data);
char tmp[3];
tmp[2] = 0;
......
......@@ -1366,6 +1366,12 @@ void CAttributes::readAttributeFromXML(io::IXMLReader* reader)
Attributes.getLast()->setString(reader->getAttributeValue(L"value"));
}
else
if (element == L"binary")
{
addBinary(name.c_str(), 0, 0);
Attributes.getLast()->setString(reader->getAttributeValue(L"value"));
}
else
if (element == L"color")
{
addColor(name.c_str(), video::SColor());
......
......@@ -273,7 +273,7 @@ void CGUIButton::draw()
if (Text.size())
{
rect = AbsoluteRect;
if (Pressed)
if (Pressed)
rect.UpperLeftCorner.Y += 2;
if (font)
......@@ -305,8 +305,8 @@ void CGUIButton::setOverrideFont(IGUIFont* font)
//! Sets an image which should be displayed on the button when it is in normal state.
void CGUIButton::setImage(video::ITexture* image)
{
if (image)
image->grab();
if (image)
image->grab();
if (Image)
Image->drop();
......@@ -325,8 +325,8 @@ void CGUIButton::setImage(video::ITexture* image)
//! Sets the image which should be displayed on the button when it is in its normal state.
void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
{
if (image)
image->grab();
if (image)
image->grab();
if (Image)
Image->drop();
......@@ -341,8 +341,8 @@ void CGUIButton::setImage(video::ITexture* image, const core::rect<s32>& pos)
//! Sets an image which should be displayed on the button when it is in pressed state.
void CGUIButton::setPressedImage(video::ITexture* image)
{
if (image)
image->grab();
if (image)
image->grab();
if (PressedImage)
PressedImage->drop();
......@@ -350,7 +350,7 @@ void CGUIButton::setPressedImage(video::ITexture* image)
PressedImage = image;
if (image)
{
core::dimension2di signedSize(image->getOriginalSize());
const core::dimension2di signedSize(image->getOriginalSize());
PressedImageRect = core::rect<s32>(core::position2d<s32>(0,0), signedSize);
}
}
......@@ -359,8 +359,8 @@ void CGUIButton::setPressedImage(video::ITexture* image)
//! Sets the image which should be displayed on the button when it is in its pressed state.
void CGUIButton::setPressedImage(video::ITexture* image, const core::rect<s32>& pos)
{
if (image)
image->grab();
if (image)
image->grab();
if (PressedImage)
PressedImage->drop();
......
......@@ -1410,14 +1410,17 @@ void CImage::copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT fo
else
{
u8* tgtpos = (u8*) target;
u8* dstpos = (u8*) Data;
u8* srcpos = (u8*) Data;
const u32 bwidth = width*bpp;
const u32 rest = pitch-bwidth;
for (u32 y=0; y<height; ++y)
{
memcpy(target, Data, height*pitch);
memset(tgtpos+width, 0, pitch-bwidth);
// copy scanline
memcpy(tgtpos, srcpos, bwidth);
// clear pitch
memset(tgtpos+bwidth, 0, rest);
tgtpos += pitch;
dstpos += Pitch;
srcpos += Pitch;
}
return;
}
......
......@@ -140,13 +140,16 @@ IAnimatedMesh* CSTLMeshFileLoader::createMesh(io::IReadFile* file)
video::SColor color(0xffffffff);
if (attrib & 0x8000)
color = video::A1R5G5B5toA8R8G8B8(attrib);
mb->Vertices.push_back(video::S3DVertex(vertex[0],normal,color, core::vector2df()));
mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color, core::vector2df()));
if (normal==core::vector3df())
normal=core::plane3df(vertex[2],vertex[1],vertex[0]).Normal;
mb->Vertices.push_back(video::S3DVertex(vertex[2],normal,color, core::vector2df()));
mb->Vertices.push_back(video::S3DVertex(vertex[1],normal,color, core::vector2df()));
mb->Vertices.push_back(video::S3DVertex(vertex[0],normal,color, core::vector2df()));
mb->Indices.push_back(vCount);
mb->Indices.push_back(vCount+1);
mb->Indices.push_back(vCount+2);
} // end while (file->getPos() < filesize)
mesh->getMeshBuffer(0)->recalculateBoundingBox();
// Create the Animated mesh if there's anything in the mesh
SAnimatedMesh* pAM = 0;
......@@ -205,6 +208,7 @@ void CSTLMeshFileLoader::getNextVector(io::IReadFile* file, core::vector3df& vec
getNextToken(file, tmp);
core::fast_atof_move(tmp.c_str(), vec.Z);
}
vec.X=-vec.X;
}
......
......@@ -118,13 +118,13 @@ core::vector3df CSceneNodeAnimatorCollisionResponse::getEllipsoidTranslation() c
//! the scene node may collide.
void CSceneNodeAnimatorCollisionResponse::setWorld(ITriangleSelector* newWorld)
{
if (newWorld)
newWorld->grab();
if (newWorld)
newWorld->grab();
if (World)
World->drop();
if (World)
World->drop();
World = newWorld;
World = newWorld;
FirstUpdate = true;
}
......@@ -265,16 +265,16 @@ ISceneNodeAnimator* CSceneNodeAnimatorCollisionResponse::createClone(ISceneNode*
if (!newManager) newManager = SceneManager;
CSceneNodeAnimatorCollisionResponse * newAnimator =
new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius, (Gravity * 1000.0f), Translation,
SlidingSpeed);
new CSceneNodeAnimatorCollisionResponse(newManager, World, Object, Radius,
(Gravity * 1000.0f), Translation, SlidingSpeed);
return newAnimator;
}
void CSceneNodeAnimatorCollisionResponse::setCollisionCallback(ICollisionCallback* callback)
{
if ( CollisionCallback == callback )
return;
if ( CollisionCallback == callback )
return;
if (CollisionCallback)
CollisionCallback->drop();
......
......@@ -2257,9 +2257,11 @@ void CXMeshFileLoader::readUntilEndOfLine()
u16 CXMeshFileLoader::readBinWord()
{
u8 *Q = (u8 *)P;
u16 tmp = 0;
tmp = Q[0] + (Q[1] << 8);
#ifdef __BIG_ENDIAN__
const u16 tmp = os::Byteswap::byteswap(*(u16 *)P);
#else
const u16 tmp = *(u16 *)P;
#endif
P += 2;
return tmp;
}
......@@ -2267,9 +2269,11 @@ u16 CXMeshFileLoader::readBinWord()
u32 CXMeshFileLoader::readBinDWord()
{
u8 *Q = (u8 *)P;
u32 tmp = 0;
tmp = Q[0] + (Q[1] << 8) + (Q[2] << 16) + (Q[3] << 24);
#ifdef __BIG_ENDIAN__
const u32 tmp = os::Byteswap::byteswap(*(u32 *)P);
#else
const u32 tmp = *(u32 *)P;
#endif
P += 4;
return tmp;
}
......@@ -2281,7 +2285,7 @@ u32 CXMeshFileLoader::readInt()
{
if (!BinaryNumCount)
{
u16 tmp = readBinWord(); // 0x06 or 0x03
const u16 tmp = readBinWord(); // 0x06 or 0x03
if (tmp == 0x06)
BinaryNumCount = readBinDWord();
else
......@@ -2304,7 +2308,7 @@ f32 CXMeshFileLoader::readFloat()
{
if (!BinaryNumCount)
{
u16 tmp = readBinWord(); // 0x07 or 0x42
const u16 tmp = readBinWord(); // 0x07 or 0x42
if (tmp == 0x07)
BinaryNumCount = readBinDWord();
else
......@@ -2313,17 +2317,26 @@ f32 CXMeshFileLoader::readFloat()
--BinaryNumCount;
if (FloatSize == 8)
{
char tmp[8];
memcpy(tmp, P, 8);
#ifdef __BIG_ENDIAN__
c8 ctmp[8];
*((f32*)(ctmp+4)) = os::Byteswap::byteswap(*(f32 *)P);
*((f32*)(ctmp)) = os::Byteswap::byteswap(*(f32 *)P+4);
const f32 tmp = (f32)(*(f64 *)ctmp);
#else
const f32 tmp = (f32)(*(f64 *)P);
#endif
P += 8;
return (f32)(*(f64 *)tmp);
return tmp;
}
else
{
char tmp[4];
memcpy(tmp, P, 4);
#ifdef __BIG_ENDIAN__
const f32 tmp = os::Byteswap::byteswap(*(f32 *)P);
#else
const f32 tmp = *(f32 *)P;
#endif
P += 4;
return *(f32 *)tmp;
return tmp;
}
}
findNextNoneWhiteSpaceNumber();
......
......@@ -10,11 +10,11 @@
#include "IrrCompileConfig.h"
#ifdef _IRR_COMPILE_WITH_ZLIB_
#ifndef _IRR_USE_NON_SYSTEM_ZLIB_
#include <zlib.h> // use system lib
#else // _IRR_USE_NON_SYSTEM_ZLIB_
#include "zlib/zlib.h"
#endif // _IRR_USE_NON_SYSTEM_ZLIB_
#ifndef _IRR_USE_NON_SYSTEM_ZLIB_
#include <zlib.h> // use system lib
#else // _IRR_USE_NON_SYSTEM_ZLIB_
#include "zlib/zlib.h"
#endif // _IRR_USE_NON_SYSTEM_ZLIB_
#endif // _IRR_COMPILE_WITH_ZLIB_
namespace irr
......@@ -603,8 +603,8 @@ void CMountPointReader::buildDirectory ( )
//! opens a file by file name
IReadFile* CMountPointReader::openFile(const core::string<c16>& filename)
{
if ( !filename.size() )
return 0;
if ( !filename.size() )
return 0;
core::string<c16> fname ( Base );
fname += filename;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment