From 2cd032a79e98d669fa3f103c8ae078f20483335b Mon Sep 17 00:00:00 2001 From: aap Date: Fri, 5 Aug 2016 01:13:41 +0200 Subject: [PATCH] some texture fixes --- src/engine.cpp | 2 ++ src/geometry.cpp | 2 -- src/image.cpp | 14 ++++++-------- src/rwengine.h | 4 ++++ src/rwobjects.h | 6 +++--- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/engine.cpp b/src/engine.cpp index a83b101..d58b0cc 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -33,6 +33,8 @@ Engine::init(void) engine->currentCamera = nil; engine->currentWorld = nil; engine->currentTexDictionary = nil; + engine->loadTextures = 1; + engine->makeDummies = 1; engine->beginUpdate = null::beginUpdate; engine->endUpdate = null::endUpdate; diff --git a/src/geometry.cpp b/src/geometry.cpp index 6d2c5be..b194039 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -635,8 +635,6 @@ Material::streamRead(Stream *stream) goto fail; } Texture *t = Texture::streamRead(stream); - if(t == nil) - goto fail; mat->setTexture(t); } diff --git a/src/image.cpp b/src/image.cpp index 1c3b15b..f296a57 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -45,6 +45,8 @@ TexDictionary::create(void) void TexDictionary::destroy(void) { + if(engine->currentTexDictionary == this) + engine->currentTexDictionary = nil; FORLIST(lnk, this->textures) Texture::fromDict(lnk)->destroy(); s_plglist.destruct(this); @@ -54,13 +56,12 @@ TexDictionary::destroy(void) void TexDictionary::add(Texture *t) { - if(engine->currentTexDictionary == this) - engine->currentTexDictionary = nil; if(t->dict) t->inDict.remove(); t->dict = this; this->textures.append(&t->inDict); } + Texture* TexDictionary::find(const char *name) { @@ -152,8 +153,6 @@ TexDictionary::getCurrent(void) // Texture // -bool32 loadTextures; - static Texture *defaultFindCB(const char *name); static Texture *defaultReadCB(const char *name, const char *mask); @@ -234,12 +233,11 @@ Texture::read(const char *name, const char *mask) tex->refCount++; return tex; } - if(loadTextures){ + if(engine->loadTextures){ tex = Texture::readCB(name, mask); if(tex == nil) goto dummytex; - }else{ - dummytex: + }else dummytex: if(engine->makeDummies){ tex = Texture::create(nil); if(tex == nil) return nil; @@ -249,7 +247,7 @@ Texture::read(const char *name, const char *mask) raster = Raster::create(0, 0, 0, Raster::DONTALLOCATE); tex->raster = raster; } - if(engine->currentTexDictionary){ + if(tex && engine->currentTexDictionary){ if(tex->dict) tex->inDict.remove(); engine->currentTexDictionary->add(tex); diff --git a/src/rwengine.h b/src/rwengine.h index 0b6bfad..c3c40c6 100644 --- a/src/rwengine.h +++ b/src/rwengine.h @@ -50,7 +50,11 @@ struct Engine { void *currentCamera; void *currentWorld; + TexDictionary *currentTexDictionary; + bool32 loadTextures; // load textures from files + bool32 makeDummies; // create dummy textures to store just names + // Device float32 zNear, zFar; diff --git a/src/rwobjects.h b/src/rwobjects.h index 20a4fcb..7239da1 100644 --- a/src/rwobjects.h +++ b/src/rwobjects.h @@ -159,8 +159,10 @@ struct ObjectWithFrame if(this->object.parent) this->inFrame.remove(); this->object.parent = f; - if(f) + if(f){ f->objectList.add(&this->inFrame); + f->updateObjects(); + } } void sync(void){ this->syncCB(this); } static ObjectWithFrame *fromFrame(LLLink *lnk){ @@ -258,8 +260,6 @@ struct Raster : PluginBase }; }; -extern bool32 loadTextures; - #define IGNORERASTERIMP 0 struct TexDictionary;