Remove need for Has by returning an empty Ref in Get
authorDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Tue, 5 Sep 2017 18:40:27 +0000 (14:40 -0400)
committerDaniel Hritzkiv <daniel.hritzkiv@gmail.com>
Mon, 11 Sep 2017 15:02:13 +0000 (11:02 -0400)
code/glTF2Asset.h
code/glTF2Asset.inl
code/glTF2Exporter.cpp

index aabd462..9a70ff4 100644 (file)
@@ -958,8 +958,6 @@ namespace glTF2
         Ref<T> Get(unsigned int i);
         Ref<T> Get(const char* id);
 
-        bool Has(const char* id);
-
         Ref<T> Create(const char* id);
         Ref<T> Create(const std::string& id)
             { return Create(id.c_str()); }
index 88dbfcf..1c75d00 100644 (file)
@@ -244,17 +244,7 @@ Ref<T> LazyDict<T>::Get(const char* id)
         return Ref<T>(mObjs, it->second);
     }
 
-    return Create(id);
-}
-
-template<class T>
-bool LazyDict<T>::Has(const char* id)
-{
-    id = T::TranslateId(mAsset, id);
-
-    typename IdDict::iterator it = mObjsById.find(id);
-
-    return it != mObjsById.end();
+    return Ref<T>();
 }
 
 template<class T>
index fec7236..073309b 100644 (file)
@@ -248,8 +248,8 @@ void glTF2Exporter::GetTexSampler(const aiMaterial* mat, Ref<Texture> texture, a
         id = aId.C_Str();
     }
 
-    if (mAsset->samplers.Has(id.c_str())) {
-        texture->sampler = mAsset->samplers.Get(id.c_str());
+    if (Ref<Sampler> ref = mAsset->samplers.Get(id.c_str())) {
+        texture->sampler = ref;
     } else {
         id = mAsset->FindUniqueID(id, "sampler");