Commit c2ec44c7 authored by hybrid's avatar hybrid

Minor cleanup.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@761 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 64ea350e
...@@ -164,7 +164,6 @@ unsigned long process_comp( ...@@ -164,7 +164,6 @@ unsigned long process_comp(
// we're starting a repeating chunk - end the non-repeaters // we're starting a repeating chunk - end the non-repeaters
flush_outbuf(out_buf, out_buf_size); flush_outbuf(out_buf, out_buf_size);
while (get_byte(&ch, buf, buf_size, out_buf, out_buf_size) != (int)EOD) while (get_byte(&ch, buf, buf_size, out_buf, out_buf_size) != (int)EOD)
{ {
if (ch != tmpbuf[1]) if (ch != tmpbuf[1])
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "SMeshBuffer.h" #include "SMeshBuffer.h"
#include "IReadFile.h" #include "IReadFile.h"
#include "IAttributes.h" #include "IAttributes.h"
#include "CImage.h"
#include "CColorConverter.h"
#include "CMY3DHelper.h" #include "CMY3DHelper.h"
#include "os.h" #include "os.h"
...@@ -117,7 +119,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -117,7 +119,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
file->read(&id, sizeof(id)); file->read(&id, sizeof(id));
s32 texCount=0, ligCount=0, matCount=0; s32 texCount=0, matCount=0;
c8 name[256]; c8 name[256];
for (s32 m=0; m<sceneHeader.MaterialCount; ++m) for (s32 m=0; m<sceneHeader.MaterialCount; ++m)
{ {
...@@ -244,7 +246,6 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -244,7 +246,6 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
// here decoded data // here decoded data
data = output_buffer; data = output_buffer;
} }
else if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_SIMPLE_ID) else if (texDataHeader.ComprMode==MY_TEXDATA_COMPR_SIMPLE_ID)
{ {
...@@ -254,7 +255,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -254,7 +255,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
else else
data = (void*) new SMyPixelColor16[num_pixels]; data = (void*) new SMyPixelColor16[num_pixels];
u32 nReadedPixels =0, nToRead =0; u32 nReadedPixels=0, nToRead=0;
while (true) while (true)
{ {
file->read(&nToRead, sizeof(nToRead)); file->read(&nToRead, sizeof(nToRead));
...@@ -277,10 +278,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -277,10 +278,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
SMyPixelColor16 col16; SMyPixelColor16 col16;
file->read(&col16, sizeof(SMyPixelColor16)); file->read(&col16, sizeof(SMyPixelColor16));
for (u32 p=0; p<nToRead; p++) for (u32 p=0; p<nToRead; p++)
{
((SMyPixelColor16*)data)[nReadedPixels+p].argb = col16.argb; ((SMyPixelColor16*)data)[nReadedPixels+p].argb = col16.argb;
} }
}
nReadedPixels+=nToRead; nReadedPixels+=nToRead;
...@@ -315,29 +314,25 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -315,29 +314,25 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
data, true); data, true);
} }
bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); const bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
me.Texture2 = Driver->addTexture(LightMapName, light_img); me.Texture2 = Driver->addTexture(LightMapName, light_img);
ligCount++;
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);
light_img->drop(); light_img->drop();
GetLightMap = true; GetLightMap = true;
} }
core::stringc Name = name; const core::stringc Name = name;
int pos2 = Name.findLast('.'); const s32 pos2 = Name.findLast('.');
core::stringc LightingMapStr = "LightingMap"; const core::stringc LightingMapStr = "LightingMap";
int ls = LightingMapStr.size(); const u32 ls = LightingMapStr.size();
core::stringc sub = Name.subString(core::max_(0, (pos2 - ls)), ls); const bool isSubString = (LightingMapStr == Name.subString(core::max_(0u, (pos2 - ls)), ls));
if ((sub == LightingMapStr || (Name[pos2-1]=='m' && if ((isSubString || (Name[pos2-1]=='m' &&
Name[pos2-2]=='l' && Name[pos2-3]=='_')) && Name[pos2-2]=='l' && Name[pos2-3]=='_')) &&
!GetLightMap) !GetLightMap)
{ {
bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS); const bool oldMipMapState = Driver->getTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS);
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false); Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, false);
me.Texture2FileName = texturePath.size() ? texturePath : filepath; me.Texture2FileName = texturePath.size() ? texturePath : filepath;
...@@ -345,14 +340,10 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -345,14 +340,10 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
me.Texture2FileName.append(Name); me.Texture2FileName.append(Name);
if (Name.size()>0) if (Name.size()>0)
{
me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str()); me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
ligCount++;
}
GetLightMap = true;
me.MaterialType = video::EMT_LIGHTMAP_M2; me.MaterialType = video::EMT_LIGHTMAP_M2;
GetLightMap = true;
Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState); Driver->setTextureCreationFlag(video::ETCF_CREATE_MIP_MAPS, oldMipMapState);
} }
...@@ -363,10 +354,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -363,10 +354,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
me.Texture2FileName.append(Name); me.Texture2FileName.append(Name);
if (Name.size()) if (Name.size())
{
me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str()); me.Texture2 = Driver->getTexture(me.Texture2FileName.c_str());
ligCount++;
}
me.MaterialType = video::EMT_REFLECTION_2_LAYER; me.MaterialType = video::EMT_REFLECTION_2_LAYER;
} }
...@@ -393,7 +381,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -393,7 +381,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
file->read(&id, sizeof(id)); file->read(&id, sizeof(id));
} }
// override materials types from they names // override material types based on their names
if (!strncmp(me.Header.Name, "AlphaChannel-", 13)) if (!strncmp(me.Header.Name, "AlphaChannel-", 13))
me.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL; me.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
else else
...@@ -479,7 +467,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -479,7 +467,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
file->read(&id, sizeof(id)); file->read(&id, sizeof(id));
if (id!=MY_TVERTS_ID) if (id!=MY_TVERTS_ID)
{ msg="Can not find MY_TVERTS_ID ("; {
msg="Can not find MY_TVERTS_ID (";
msg.append(tex); msg.append(tex);
msg.append("texture channel), loading failed!"); msg.append("texture channel), loading failed!");
os::Printer::log(msg.c_str(), ELL_ERROR); os::Printer::log(msg.c_str(), ELL_ERROR);
...@@ -514,7 +503,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -514,7 +503,8 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
file->read(&id, sizeof(id)); file->read(&id, sizeof(id));
if (id!=MY_TFACES_ID) if (id!=MY_TFACES_ID)
{ msg="Can not find MY_TFACES_ID ("; {
msg="Can not find MY_TFACES_ID (";
msg.append(tex); msg.append(tex);
msg.append("texture channel), loading failed!"); msg.append("texture channel), loading failed!");
os::Printer::log(msg.c_str(), ELL_ERROR); os::Printer::log(msg.c_str(), ELL_ERROR);
...@@ -637,8 +627,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file) ...@@ -637,8 +627,7 @@ IAnimatedMesh* CMY3DMeshFileLoader::createMesh(io::IReadFile* file)
else if ( else if (
!buffer->Material.Textures[1] && !buffer->Material.Textures[1] &&
buffer->Material.MaterialType != video::EMT_TRANSPARENT_ALPHA_CHANNEL && buffer->Material.MaterialType != video::EMT_TRANSPARENT_ALPHA_CHANNEL &&
buffer->Material.MaterialType != video::EMT_SPHERE_MAP buffer->Material.MaterialType != video::EMT_SPHERE_MAP)
)
{ {
buffer->Material.MaterialType = video::EMT_SOLID; buffer->Material.MaterialType = video::EMT_SOLID;
buffer->Material.Lighting = true; buffer->Material.Lighting = true;
......
...@@ -77,7 +77,7 @@ private: ...@@ -77,7 +77,7 @@ private:
{ {
SMyMaterialEntry () SMyMaterialEntry ()
: Texture1FileName("null"), Texture2FileName("null"), : Texture1FileName("null"), Texture2FileName("null"),
Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {;} Texture1(0), Texture2(0), MaterialType(video::EMT_SOLID) {}
SMyMaterialHeader Header; SMyMaterialHeader Header;
core::stringc Texture1FileName; core::stringc Texture1FileName;
...@@ -91,18 +91,18 @@ private: ...@@ -91,18 +91,18 @@ private:
{ {
SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {} SMyMeshBufferEntry() : MaterialIndex(-1), MeshBuffer(0) {}
SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb) SMyMeshBufferEntry(s32 mi, SMeshBufferLightMap* mb)
: MaterialIndex(mi), MeshBuffer(mb) {;} : MaterialIndex(mi), MeshBuffer(mb) {}
s32 MaterialIndex; s32 MaterialIndex;
SMeshBufferLightMap* MeshBuffer; SMeshBufferLightMap* MeshBuffer;
}; };
core::array<SMyMaterialEntry> MaterialEntry;
core::array<SMyMeshBufferEntry> MeshBufferEntry;
SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd); SMyMaterialEntry* getMaterialEntryByIndex (u32 matInd);
SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd); SMeshBufferLightMap* getMeshBufferByMaterialIndex(u32 matInd);
core::array<SMyMaterialEntry> MaterialEntry;
core::array<SMyMeshBufferEntry> MeshBufferEntry;
core::array<ISceneNode*> ChildNodes; core::array<ISceneNode*> ChildNodes;
}; };
......
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