Ref<T> LazyDict<T>::Get(unsigned int i)
{
+ return Ref<T>(mObjs, i);
+
+}
+
+template<class T>
+Ref<T> LazyDict<T>::Retrieve(unsigned int i)
+{
+
std::string id = std::string(mDictId) + "[" + std::to_string(i) + "]";
typename Dict::iterator it = mObjsById.find(id);
{
if (Value* bufferVal = FindUInt(obj, "buffer")) {
- buffer = r.buffers.Get(bufferVal->GetUint());
+ buffer = r.buffers.Retrieve(bufferVal->GetUint());
}
byteOffset = MemberOrDefault(obj, "byteOffset", 0u);
{
if (Value* bufferViewVal = FindUInt(obj, "bufferView")) {
- bufferView = r.bufferViews.Get(bufferViewVal->GetUint());
+ bufferView = r.bufferViews.Retrieve(bufferViewVal->GetUint());
}
byteOffset = MemberOrDefault(obj, "byteOffset", 0u);
ReadMember(*ext, "mimeType", mimeType);
if (Value* bufferViewVal = FindUInt(*ext, "bufferView")) {
- Ref<BufferView> bv = r.bufferViews.Get(bufferViewVal->GetUint());
+ Ref<BufferView> bv = r.bufferViews.Retrieve(bufferViewVal->GetUint());
if (bv) {
mDataLength = bv->byteLength;
mData = new uint8_t[mDataLength];
inline void Texture::Read(Value& obj, Asset& r)
{
if (Value* sourceVal = FindUInt(obj, "source")) {
- source = r.images.Get(sourceVal->GetUint());
+ source = r.images.Retrieve(sourceVal->GetUint());
}
if (Value* samplerVal = FindUInt(obj, "sampler")) {
- sampler = r.samplers.Get(samplerVal->GetUint());
+ sampler = r.samplers.Retrieve(samplerVal->GetUint());
}
}
//@TODO: update this format
if (Value* prop = FindMember(vals, propName)) {
if (prop->IsUint()) {
- out.texture = r.textures.Get(prop->GetUint());
+ out.texture = r.textures.Retrieve(prop->GetUint());
}
else {
ReadValue(*prop, out.color);
if (Value* attrs = FindObject(primitive, "attributes")) {
for (Value::MemberIterator it = attrs->MemberBegin(); it != attrs->MemberEnd(); ++it) {
- if (!it->value.IsString()) continue;
+ if (!it->value.IsUint()) continue;
const char* attr = it->name.GetString();
// Valid attribute semantics include POSITION, NORMAL, TEXCOORD, COLOR, JOINT, JOINTMATRIX,
// and WEIGHT.Attribute semantics can be of the form[semantic]_[set_index], e.g., TEXCOORD_0, TEXCOORD_1, etc.
if (GetAttribVector(prim, attr, vec, undPos)) {
size_t idx = (attr[undPos] == '_') ? atoi(attr + undPos + 1) : 0;
if ((*vec).size() <= idx) (*vec).resize(idx + 1);
- (*vec)[idx] = pAsset_Root.accessors.Get(it->value.GetUint());
+ (*vec)[idx] = pAsset_Root.accessors.Retrieve(it->value.GetUint());
}
}
}
if (Value* indices = FindUInt(primitive, "indices")) {
- prim.indices = pAsset_Root.accessors.Get(indices->GetUint());
+ prim.indices = pAsset_Root.accessors.Retrieve(indices->GetUint());
}
if (Value* material = FindUInt(primitive, "material")) {
- prim.material = pAsset_Root.materials.Get(material->GetUint());
+ prim.material = pAsset_Root.materials.Retrieve(material->GetUint());
}
}
}
this->children.reserve(children->Size());
for (unsigned int i = 0; i < children->Size(); ++i) {
Value& child = (*children)[i];
- if (child.IsNumber()) {
+ if (child.IsUint()) {
// get/create the child node
- Ref<Node> chn = r.nodes.Get(child.GetUint());
+ Ref<Node> chn = r.nodes.Retrieve(child.GetUint());
if (chn) this->children.push_back(chn);
}
}
ReadMember(obj, "rotation", rotation);
}
- if (Value* meshes = FindArray(obj, "meshes")) {
- unsigned numMeshes = (unsigned)meshes->Size();
+ if (Value* mesh = FindUInt(obj, "mesh")) {
+ //unsigned numMeshes = (unsigned)meshes->Size();
+ unsigned numMeshes = 1;
- std::vector<unsigned int> meshList;
+ //std::vector<unsigned int> meshList;
this->meshes.reserve(numMeshes);
- for (unsigned i = 0; i < numMeshes; ++i) {
- if ((*meshes)[i].IsNumber()) {
- Ref<Mesh> mesh = r.meshes.Get((*meshes)[i].GetUint());
- if (mesh) this->meshes.push_back(mesh);
- }
- }
+
+ Ref<Mesh> meshRef = r.meshes.Retrieve((*mesh).GetUint());
+
+ if (meshRef) this->meshes.push_back(meshRef);
}
if (Value* camera = FindUInt(obj, "camera")) {
- this->camera = r.cameras.Get(camera->GetUint());
+ this->camera = r.cameras.Retrieve(camera->GetUint());
if (this->camera)
this->camera->id = this->id;
}
if (Value* ext = FindObject(*extensions, "KHR_materials_common")) {
if (Value* light = FindUInt(*ext, "light")) {
- this->light = r.lights.Get(light->GetUint());
+ this->light = r.lights.Retrieve(light->GetUint());
}
}
{
if (Value* array = FindArray(obj, "nodes")) {
for (unsigned int i = 0; i < array->Size(); ++i) {
- if (!(*array)[i].IsNumber()) continue;
- Ref<Node> node = r.nodes.Get((*array)[i].GetUint());
+ if (!(*array)[i].IsUint()) continue;
+ Ref<Node> node = r.nodes.Retrieve((*array)[i].GetUint());
if (node)
this->nodes.push_back(node);
}
if (Value* scene = FindUInt(doc, "scene")) {
unsigned int sceneIndex = scene->GetUint();
- Ref<Scene> s = scenes.Get(sceneIndex);
+ Ref<Scene> s = scenes.Retrieve(sceneIndex);
this->scene = s;
}