#include <regex>
#include "metascene.h"
#include "scene.h"
-#include "datamap.h"
#include "treestore.h"
#include "logger.h"
static bool proc_node(MetaScene *mscn, struct ts_node *node);
static bool proc_scenefile(MetaScene *mscn, struct ts_node *node);
-static bool proc_mtledit(MaterialEdit *med, struct ts_node *node, TextureSet *texset);
+static bool proc_mtledit(MetaScene *mscn, MaterialEdit *med, struct ts_node *node, TextureSet *texset);
static void apply_mtledit(Scene *scn, const MaterialEdit &med);
static void apply_mtledit(Material *mtl, const MaterialEdit &med);
static struct ts_attr *attr_inscope(struct ts_node *node, const char *name);
const char *match = ts_get_attr_str(node, "match");
const char *replace = ts_get_attr_str(node, "replace");
if(match && replace) {
- datamap_map(match, replace);
+ mscn->datamap.map(match, replace);
}
}
struct ts_attr *adpath = attr_inscope(node, "datapath");
if(adpath && adpath->val.type == TS_STRING) {
info_log("adding data path: %s\n", adpath->val.str);
- datamap_set_path(adpath->val.str);
+ mscn->datamap.set_path(adpath->val.str);
}
// walkmesh
sdat->walkmesh_regexp = std::string(awmesh->val.str);
}
- int namesz = datamap_lookup(fname, 0, 0);
+ int namesz = mscn->datamap.lookup(fname, 0, 0);
char *namebuf = (char*)alloca(namesz + 1);
- if(datamap_lookup(fname, namebuf, namesz + 1)) {
+ if(mscn->datamap.lookup(fname, namebuf, namesz + 1)) {
fname = namebuf;
}
struct ts_node *child = node->child_list;
while(child) {
MaterialEdit medit;
- if(proc_mtledit(&medit, child, mscn->texman)) {
+ if(proc_mtledit(mscn, &medit, child, mscn->texman)) {
sdat->mtledit.push_back(medit);
}
child = child->next;
}
Scene *newscn = mscn->sceneman->get(fname);
- /* NOTE: setting this after get() is not a race condition, because
+ /* NOTE: setting all these after get() is not a race condition, because
* scene_loaded() which uses this, will only run in our main loop during
* SceneSet::update() on the main thread.
*/
+ newscn->datamap = mscn->datamap;
+ mscn->datamap.clear();
+
newscn->metascn = mscn;
mscn->scndata[newscn] = sdat;
}
return true;
}
-static bool proc_mtledit(MaterialEdit *med, struct ts_node *node, TextureSet *texset)
+static bool proc_mtledit(MetaScene *mscn, MaterialEdit *med, struct ts_node *node, TextureSet *texset)
{
if(strcmp(node->name, "mtledit") != 0) {
return false;
// remove
med->tex = 0;
} else {
- med->tex = texset->get_texture(afile->val.str, TEX_2D);
+ med->tex = texset->get_texture(afile->val.str, TEX_2D, &mscn->datamap);
}
}
// TODO add more edit modes