* Irrlicht keeps a Mesh and Texture Cache - no need to duplicate that
This commit is contained in:
parent
eae3e6cc9a
commit
74d4945a72
@ -26,9 +26,8 @@ CMDHReadFile::CMDHReadFile(void* memory, long len, const c8* fileName)
|
||||
|
||||
CMDHReadFile::~CMDHReadFile()
|
||||
{
|
||||
// We should not drop the memory here... this model will possibly be loaded more than once
|
||||
//if(getReferenceCount() <= 1)
|
||||
// MemoryDataHolder::Delete(getFileName());
|
||||
// Drop the Memory, Irrlicht keeps a Model Cache of loaded models
|
||||
MemoryDataHolder::Delete(getFileName());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -310,14 +310,22 @@ for(u32 i=0;i<submeshes.size();i++)//The mesh has to be split into submeshes bec
|
||||
// std::transform(TexName.begin(), TexName.end(), TexName.begin(), tolower);
|
||||
char buf[1000];
|
||||
MemoryDataHolder::MakeTextureFilename(buf,WMOMTextureFiles[WMOMTexData[lastindex].textureID].c_str());
|
||||
video::ITexture* tex = Device->getVideoDriver()->findTexture(buf);
|
||||
if(!tex)
|
||||
{
|
||||
io::IReadFile* TexFile = io::IrrCreateIReadFileBasic(Device, buf);
|
||||
// logdebug("Texture %s loading",M2MTextureFiles[M2MTextureLookup[M2MTextureUnit[j].textureIndex]].c_str());
|
||||
if (!TexFile)
|
||||
{
|
||||
logerror("Error! Texture file not found: %s", buf);
|
||||
logerror("CM2MeshFileLoader: Texture file not found: %s", buf);
|
||||
continue;
|
||||
}
|
||||
// logdebug("Texture %s loaded",M2MTextureFiles[M2MTextureLookup[M2MTextureUnit[j].textureIndex]].c_str());
|
||||
tex = Device->getVideoDriver()->getTexture(TexFile);
|
||||
TexFile->drop();
|
||||
}
|
||||
|
||||
MeshBuffer->getMaterial().setTexture(0,Device->getVideoDriver()->getTexture(TexFile));
|
||||
MeshBuffer->getMaterial().setTexture(0,tex);
|
||||
if(WMOMTexDefinition[WMOMTexData[lastindex].textureID].blendMode==1)
|
||||
MeshBuffer->getMaterial().MaterialType=video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
MeshBuffer->recalculateBoundingBox();
|
||||
|
||||
@ -634,13 +634,23 @@ void SceneWorld::UpdateTerrain(void)
|
||||
//because there is no point in loading them separately
|
||||
|
||||
// logdebug("loading Doodad %s",filename.c_str());
|
||||
scene::IAnimatedMesh *mesh;
|
||||
if(!smgr->getMeshCache()->isMeshLoaded(filename.c_str()))
|
||||
{
|
||||
io::IReadFile* modelfile = io::IrrCreateIReadFileBasic(device, filename.c_str());
|
||||
if (!modelfile)
|
||||
{
|
||||
logerror("Error! modelfile not found: %s", d->MPQpath.c_str());
|
||||
logerror("Error! modelfile not found: %s", filename.c_str());
|
||||
continue;
|
||||
}
|
||||
scene::IAnimatedMesh *mesh = smgr->getMesh(modelfile);
|
||||
mesh = smgr->getMesh(modelfile);
|
||||
modelfile->drop();
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh = smgr->getMeshCache()->getMeshByFilename(filename.c_str());
|
||||
}
|
||||
|
||||
if(mesh)
|
||||
{
|
||||
scene::IAnimatedMeshSceneNode *doodad = smgr->addAnimatedMeshSceneNode(mesh);
|
||||
@ -674,6 +684,10 @@ void SceneWorld::UpdateTerrain(void)
|
||||
_doodads[d->uniqueid] = gp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("No mesh provided");
|
||||
}
|
||||
}
|
||||
}
|
||||
// create WorldMapObjects (WMOs)
|
||||
@ -692,14 +706,24 @@ void SceneWorld::UpdateTerrain(void)
|
||||
{
|
||||
filename= wmo->model.c_str();
|
||||
}
|
||||
// logdebug("loading WMO %s",filename.c_str());
|
||||
|
||||
scene::IAnimatedMesh *mesh;
|
||||
if(!smgr->getMeshCache()->isMeshLoaded(filename.c_str()))
|
||||
{
|
||||
io::IReadFile* modelfile = io::IrrCreateIReadFileBasic(device, filename.c_str());
|
||||
if (!modelfile)
|
||||
{
|
||||
logerror("Error! WMO file not found: %s", wmo->MPQpath.c_str());
|
||||
logerror("Error! modelfile not found: %s", filename.c_str());
|
||||
continue;
|
||||
}
|
||||
scene::IAnimatedMesh *mesh = smgr->getMesh(modelfile);
|
||||
mesh = smgr->getMesh(modelfile);
|
||||
modelfile->drop();
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh = smgr->getMeshCache()->getMeshByFilename(filename.c_str());
|
||||
}
|
||||
|
||||
if(mesh)
|
||||
{
|
||||
scene::IAnimatedMeshSceneNode *wmo_node = smgr->addAnimatedMeshSceneNode(mesh);
|
||||
|
||||
@ -22,16 +22,7 @@ struct OpcodeHandler
|
||||
void (WorldSession::*handler)(WorldPacket& recvPacket);
|
||||
};
|
||||
|
||||
uint32 Object::maxvalues[TYPEID_MAX]={ 0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0};
|
||||
uint32 Object::maxvalues[TYPEID_MAX];
|
||||
|
||||
WorldSession::WorldSession(PseuInstance *in)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user