shadmar Posted August 16, 2017 Posted August 16, 2017 In lua I would do this : --index which vary on each recurisive run. local mid=-dim..":"..-df..":"..dim..":"..df..":"..xfactor..":"..yfactor..":"..division..":"..factor..":"..orientation.x..":"..orientation.y..":"..orientation.z --create model if the index "mid" doesn't exist in table models if models[mid]==nil then model = Model:Create() model:SetRotation(orientation) models[mid] = model end Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB
shadmar Posted August 16, 2017 Author Posted August 16, 2017 nevermind I kind of solved it Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB
Ma-Shell Posted August 16, 2017 Posted August 16, 2017 #include <stdio.h> #include <unordered_map> unordered_map<std::string, Model*> models; ... std::stringstream mid_stream; mid_stream << -dim << ":" << -df << ":" << dim << (...) std::string mid = mid_stream.str(); if (models.find(mid) == models.end()) { Model* model = Model::Create(); model->SetRotation(orientation); models[mid] = model; } Edit: meh, 5 minutes too late 1 Quote
shadmar Posted August 16, 2017 Author Posted August 16, 2017 Oh yours were much nicer than mine, I used 2 std::vectors one for the text index (I used stringstream) and one to store the models. Thank you! Quote HP Omen - 16GB - i7 - Nvidia GTX 1060 6GB
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.