Merge branch 'jester/aptsign'

This commit is contained in:
Tim Moore
2010-01-11 07:14:51 +01:00
+26 -21
View File
@@ -106,6 +106,10 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content)
osg::Group* object = new osg::Group; osg::Group* object = new osg::Group;
object->setName(content); object->setName(content);
SGMaterial *material = 0;
Effect *lighted_state = 0;
Effect *unlighted_state = 0;
// Part I: parse & measure // Part I: parse & measure
for (const char *s = content.data(); *s; s++) { for (const char *s = content.data(); *s; s++) {
string name; string name;
@@ -215,30 +219,31 @@ SGMakeSign(SGMaterialLib *matlib, const string& path, const string& content)
} }
} }
if (newmat.size()) {
SGMaterial *m = matlib->find(newmat);
if (!m) {
// log error, but keep using previous material to at least show something
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
} else {
material = m;
// set material states (lighted & unlighted)
lighted_state = material->get_effect();
newmat.append(".unlighted");
if (newmat.size() == 0 ) m = matlib->find(newmat);
continue; if (m) {
unlighted_state = m->get_effect();
SGMaterial *material = matlib->find(newmat); } else {
if (!material) { SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\'');
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << newmat << '\''); unlighted_state = lighted_state;
continue; }
}
newmat.clear();
} }
// This can only happen if the default material is missing.
// set material states (lighted & unlighted) // Error has been already logged in the block above.
Effect *lighted_state = material->get_effect(); if (!material) continue;
Effect *unlighted_state;
string u = newmat + ".unlighted";
SGMaterial *m = matlib->find(u);
if (m) {
unlighted_state = m->get_effect();
} else {
SG_LOG(SG_TERRAIN, SG_ALERT, SIGN "ignoring unknown material `" << u << '\'');
unlighted_state = lighted_state;
}
newmat = "";
SGMaterialGlyph *glyph = material->get_glyph(name); SGMaterialGlyph *glyph = material->get_glyph(name);
if (!glyph) { if (!glyph) {