Updated shiny again. Some recent changes were accidently overwritten by eduard on 12/30/2012

actorid
scrawl 12 years ago
parent c6ff58d5b5
commit e18cf452d4

1
.gitmodules vendored

@ -1 +0,0 @@

@ -70,3 +70,6 @@ endif()
link_directories(${CMAKE_CURRENT_BINARY_DIR}) link_directories(${CMAKE_CURRENT_BINARY_DIR})
set(SHINY_LIBRARY ${SHINY_LIBRARY} PARENT_SCOPE)
set(SHINY_OGREPLATFORM_LIBRARY ${SHINY_OGREPLATFORM_LIBRARY} PARENT_SCOPE)

@ -224,7 +224,7 @@ namespace sh
if (!mShadersEnabled) if (!mShadersEnabled)
newInstance.setShadersEnabled (false); newInstance.setShadersEnabled (false);
newInstance.setSourceFile (it->second->m_fileName); newInstance.setSourceFile (it->second->mFileName);
std::vector<ScriptNode*> props = it->second->getChildren(); std::vector<ScriptNode*> props = it->second->getChildren();
for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt) for (std::vector<ScriptNode*>::const_iterator propIt = props.begin(); propIt != props.end(); ++propIt)

@ -72,6 +72,8 @@ namespace sh
allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get(); allowFixedFunction = retrieveValue<BooleanValue>(getProperty("allow_fixed_function"), NULL).get();
} }
bool useShaders = mShadersEnabled || !allowFixedFunction;
// get passes of the top-most parent // get passes of the top-most parent
PassVector passes = getPasses(); PassVector passes = getPasses();
if (passes.size() == 0) if (passes.size() == 0)
@ -91,7 +93,7 @@ namespace sh
// create or retrieve shaders // create or retrieve shaders
bool hasVertex = it->hasProperty("vertex_program"); bool hasVertex = it->hasProperty("vertex_program");
bool hasFragment = it->hasProperty("fragment_program"); bool hasFragment = it->hasProperty("fragment_program");
if (mShadersEnabled || !allowFixedFunction) if (useShaders)
{ {
it->setContext(context); it->setContext(context);
it->mShaderProperties.setContext(context); it->mShaderProperties.setContext(context);
@ -144,7 +146,7 @@ namespace sh
bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end(); bool foundVertex = std::find(usedTextureSamplersVertex.begin(), usedTextureSamplersVertex.end(), texIt->getName()) != usedTextureSamplersVertex.end();
bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end(); bool foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end();
if ( (foundVertex || foundFragment) if ( (foundVertex || foundFragment)
|| (((!mShadersEnabled || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get())) || (((!useShaders || (!hasVertex || !hasFragment)) && allowFixedFunction) && texIt->hasProperty("create_in_ffp") && retrieveValue<BooleanValue>(texIt->getProperty("create_in_ffp"), this).get()))
{ {
boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState (); boost::shared_ptr<TextureUnitState> texUnit = pass->createTextureUnitState ();
texIt->copyAll (texUnit.get(), context); texIt->copyAll (texUnit.get(), context);
@ -152,7 +154,7 @@ namespace sh
mTexUnits.push_back(texUnit); mTexUnits.push_back(texUnit);
// set texture unit indices (required by GLSL) // set texture unit indices (required by GLSL)
if (mShadersEnabled && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL) if (useShaders && ((hasVertex && foundVertex) || (hasFragment && foundFragment)) && mFactory->getCurrentLanguage () == Language_GLSL)
{ {
pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i); pass->setTextureUnitIndex (foundVertex ? GPT_Vertex : GPT_Fragment, texIt->getName(), i);

@ -14,9 +14,9 @@ namespace sh
for ( boost::filesystem::recursive_directory_iterator end, dir(path); dir != end; ++dir ) for ( boost::filesystem::recursive_directory_iterator end, dir(path); dir != end; ++dir )
{ {
boost::filesystem::path p(*dir); boost::filesystem::path p(*dir);
if(p.extension() == c->m_fileEnding) if(p.extension() == c->mFileEnding)
{ {
c->m_currentFileName = (*dir).path().string(); c->mCurrentFileName = (*dir).path().string();
std::ifstream in((*dir).path().string().c_str(), std::ios::binary); std::ifstream in((*dir).path().string().c_str(), std::ios::binary);
c->parseScript(in); c->parseScript(in);
} }
@ -25,7 +25,7 @@ namespace sh
ScriptLoader::ScriptLoader(const std::string& fileEnding) ScriptLoader::ScriptLoader(const std::string& fileEnding)
{ {
m_fileEnding = fileEnding; mFileEnding = fileEnding;
} }
ScriptLoader::~ScriptLoader() ScriptLoader::~ScriptLoader()
@ -70,7 +70,7 @@ namespace sh
{ {
//Get first token //Get first token
_nextToken(stream); _nextToken(stream);
if (tok == TOKEN_EOF) if (mToken == TOKEN_EOF)
{ {
stream.close(); stream.close();
return; return;
@ -87,7 +87,7 @@ namespace sh
//EOF token //EOF token
if (!stream.good()) if (!stream.good())
{ {
tok = TOKEN_EOF; mToken = TOKEN_EOF;
return; return;
} }
@ -101,7 +101,7 @@ namespace sh
if (!stream.good()) if (!stream.good())
{ {
tok = TOKEN_EOF; mToken = TOKEN_EOF;
return; return;
} }
@ -115,21 +115,21 @@ namespace sh
stream.unget(); stream.unget();
tok = TOKEN_NewLine; mToken = TOKEN_NewLine;
return; return;
} }
//Open brace token //Open brace token
else if (ch == '{') else if (ch == '{')
{ {
tok = TOKEN_OpenBrace; mToken = TOKEN_OpenBrace;
return; return;
} }
//Close brace token //Close brace token
else if (ch == '}') else if (ch == '}')
{ {
tok = TOKEN_CloseBrace; mToken = TOKEN_CloseBrace;
return; return;
} }
@ -139,8 +139,8 @@ namespace sh
throw std::runtime_error("Parse Error: Invalid character, ConfigLoader::load()"); throw std::runtime_error("Parse Error: Invalid character, ConfigLoader::load()");
} }
tokVal = ""; mTokenValue = "";
tok = TOKEN_Text; mToken = TOKEN_Text;
do do
{ {
//Skip comments //Skip comments
@ -157,13 +157,13 @@ namespace sh
ch = stream.get(); ch = stream.get();
} while (ch != '\r' && ch != '\n' && !stream.eof()); } while (ch != '\r' && ch != '\n' && !stream.eof());
tok = TOKEN_NewLine; mToken = TOKEN_NewLine;
return; return;
} }
} }
//Add valid char to tokVal //Add valid char to tokVal
tokVal += (char)ch; mTokenValue += (char)ch;
//Next char //Next char
ch = stream.get(); ch = stream.get();
@ -177,7 +177,7 @@ namespace sh
void ScriptLoader::_skipNewLines(std::ifstream &stream) void ScriptLoader::_skipNewLines(std::ifstream &stream)
{ {
while (tok == TOKEN_NewLine) while (mToken == TOKEN_NewLine)
{ {
_nextToken(stream); _nextToken(stream);
} }
@ -189,7 +189,7 @@ namespace sh
while (true) while (true)
{ {
switch (tok) switch (mToken)
{ {
//Node //Node
case TOKEN_Text: case TOKEN_Text:
@ -198,23 +198,23 @@ namespace sh
ScriptNode *newNode; ScriptNode *newNode;
if (parent) if (parent)
{ {
newNode = parent->addChild(tokVal); newNode = parent->addChild(mTokenValue);
} }
else else
{ {
newNode = new ScriptNode(0, tokVal); newNode = new ScriptNode(0, mTokenValue);
} }
//Get values //Get values
_nextToken(stream); _nextToken(stream);
std::string valueStr; std::string valueStr;
int i=0; int i=0;
while (tok == TOKEN_Text) while (mToken == TOKEN_Text)
{ {
if (i == 0) if (i == 0)
valueStr += tokVal; valueStr += mTokenValue;
else else
valueStr += " " + tokVal; valueStr += " " + mTokenValue;
_nextToken(stream); _nextToken(stream);
++i; ++i;
} }
@ -235,13 +235,13 @@ namespace sh
_skipNewLines(stream); _skipNewLines(stream);
//Add any sub-nodes //Add any sub-nodes
if (tok == TOKEN_OpenBrace) if (mToken == TOKEN_OpenBrace)
{ {
//Parse nodes //Parse nodes
_nextToken(stream); _nextToken(stream);
_parseNodes(stream, newNode); _parseNodes(stream, newNode);
//Check for matching closing brace //Check for matching closing brace
if (tok != TOKEN_CloseBrace) if (mToken != TOKEN_CloseBrace)
{ {
throw std::runtime_error("Parse Error: Expecting closing brace"); throw std::runtime_error("Parse Error: Expecting closing brace");
} }
@ -249,7 +249,7 @@ namespace sh
_skipNewLines(stream); _skipNewLines(stream);
} }
newNode->m_fileName = m_currentFileName; newNode->mFileName = mCurrentFileName;
break; break;
} }
@ -276,16 +276,16 @@ namespace sh
ScriptNode::ScriptNode(ScriptNode *parent, const std::string &name) ScriptNode::ScriptNode(ScriptNode *parent, const std::string &name)
{ {
m_name = name; mName = name;
m_parent = parent; mParent = parent;
_removeSelf = true; //For proper destruction mRemoveSelf = true; //For proper destruction
m_lastChildFound = -1; mLastChildFound = -1;
//Add self to parent's child list (unless this is the root node being created) //Add self to parent's child list (unless this is the root node being created)
if (parent != NULL) if (parent != NULL)
{ {
m_parent->m_children.push_back(this); mParent->mChildren.push_back(this);
_iter = --(m_parent->m_children.end()); mIter = --(mParent->mChildren.end());
} }
} }
@ -293,18 +293,18 @@ namespace sh
{ {
//Delete all children //Delete all children
std::vector<ScriptNode*>::iterator i; std::vector<ScriptNode*>::iterator i;
for (i = m_children.begin(); i != m_children.end(); i++) for (i = mChildren.begin(); i != mChildren.end(); i++)
{ {
ScriptNode *node = *i; ScriptNode *node = *i;
node->_removeSelf = false; node->mRemoveSelf = false;
delete node; delete node;
} }
m_children.clear(); mChildren.clear();
//Remove self from parent's child list //Remove self from parent's child list
if (_removeSelf && m_parent != NULL) if (mRemoveSelf && mParent != NULL)
{ {
m_parent->m_children.erase(_iter); mParent->mChildren.erase(mIter);
} }
} }
@ -324,20 +324,20 @@ namespace sh
ScriptNode *ScriptNode::findChild(const std::string &name, bool recursive) ScriptNode *ScriptNode::findChild(const std::string &name, bool recursive)
{ {
int indx, prevC, nextC; int indx, prevC, nextC;
int childCount = (int)m_children.size(); int childCount = (int)mChildren.size();
if (m_lastChildFound != -1) if (mLastChildFound != -1)
{ {
//If possible, try checking the nodes neighboring the last successful search //If possible, try checking the nodes neighboring the last successful search
//(often nodes searched for in sequence, so this will boost search speeds). //(often nodes searched for in sequence, so this will boost search speeds).
prevC = m_lastChildFound-1; if (prevC < 0) prevC = 0; else if (prevC >= childCount) prevC = childCount-1; prevC = mLastChildFound-1; if (prevC < 0) prevC = 0; else if (prevC >= childCount) prevC = childCount-1;
nextC = m_lastChildFound+1; if (nextC < 0) nextC = 0; else if (nextC >= childCount) nextC = childCount-1; nextC = mLastChildFound+1; if (nextC < 0) nextC = 0; else if (nextC >= childCount) nextC = childCount-1;
for (indx = prevC; indx <= nextC; ++indx) for (indx = prevC; indx <= nextC; ++indx)
{ {
ScriptNode *node = m_children[indx]; ScriptNode *node = mChildren[indx];
if (node->m_name == name) if (node->mName == name)
{ {
m_lastChildFound = indx; mLastChildFound = indx;
return node; return node;
} }
} }
@ -346,17 +346,17 @@ namespace sh
//already searched area above. //already searched area above.
for (indx = nextC + 1; indx < childCount; ++indx) for (indx = nextC + 1; indx < childCount; ++indx)
{ {
ScriptNode *node = m_children[indx]; ScriptNode *node = mChildren[indx];
if (node->m_name == name) { if (node->mName == name) {
m_lastChildFound = indx; mLastChildFound = indx;
return node; return node;
} }
} }
for (indx = 0; indx < prevC; ++indx) for (indx = 0; indx < prevC; ++indx)
{ {
ScriptNode *node = m_children[indx]; ScriptNode *node = mChildren[indx];
if (node->m_name == name) { if (node->mName == name) {
m_lastChildFound = indx; mLastChildFound = indx;
return node; return node;
} }
} }
@ -365,9 +365,9 @@ namespace sh
{ {
//Search for the node from start to finish //Search for the node from start to finish
for (indx = 0; indx < childCount; ++indx){ for (indx = 0; indx < childCount; ++indx){
ScriptNode *node = m_children[indx]; ScriptNode *node = mChildren[indx];
if (node->m_name == name) { if (node->mName == name) {
m_lastChildFound = indx; mLastChildFound = indx;
return node; return node;
} }
} }
@ -378,7 +378,7 @@ namespace sh
{ {
for (indx = 0; indx < childCount; ++indx) for (indx = 0; indx < childCount; ++indx)
{ {
m_children[indx]->findChild(name, recursive); mChildren[indx]->findChild(name, recursive);
} }
} }
@ -389,13 +389,13 @@ namespace sh
void ScriptNode::setParent(ScriptNode *newParent) void ScriptNode::setParent(ScriptNode *newParent)
{ {
//Remove self from current parent //Remove self from current parent
m_parent->m_children.erase(_iter); mParent->mChildren.erase(mIter);
//Set new parent //Set new parent
m_parent = newParent; mParent = newParent;
//Add self to new parent //Add self to new parent
m_parent->m_children.push_back(this); mParent->mChildren.push_back(this);
_iter = --(m_parent->m_children.end()); mIter = --(mParent->mChildren.end());
} }
} }

@ -23,7 +23,7 @@ namespace sh
ScriptLoader(const std::string& fileEnding); ScriptLoader(const std::string& fileEnding);
virtual ~ScriptLoader(); virtual ~ScriptLoader();
std::string m_fileEnding; std::string mFileEnding;
// For a line like // For a line like
// entity animals/dog // entity animals/dog
@ -38,11 +38,11 @@ namespace sh
void parseScript(std::ifstream &stream); void parseScript(std::ifstream &stream);
std::string m_currentFileName; std::string mCurrentFileName;
protected: protected:
float m_LoadOrder; float mLoadOrder;
// like "*.object" // like "*.object"
std::map <std::string, ScriptNode*> m_scriptList; std::map <std::string, ScriptNode*> m_scriptList;
@ -56,8 +56,8 @@ namespace sh
TOKEN_EOF TOKEN_EOF
}; };
Token tok, lastTok; Token mToken, mLastToken;
std::string tokVal; std::string mTokenValue;
void _parseNodes(std::ifstream &stream, ScriptNode *parent); void _parseNodes(std::ifstream &stream, ScriptNode *parent);
void _nextToken(std::ifstream &stream); void _nextToken(std::ifstream &stream);
@ -74,22 +74,22 @@ namespace sh
inline void setName(const std::string &name) inline void setName(const std::string &name)
{ {
this->m_name = name; this->mName = name;
} }
inline std::string &getName() inline std::string &getName()
{ {
return m_name; return mName;
} }
inline void setValue(const std::string &value) inline void setValue(const std::string &value)
{ {
m_value = value; mValue = value;
} }
inline std::string &getValue() inline std::string &getValue()
{ {
return m_value; return mValue;
} }
ScriptNode *addChild(const std::string &name = "untitled", bool replaceExisting = false); ScriptNode *addChild(const std::string &name = "untitled", bool replaceExisting = false);
@ -97,36 +97,36 @@ namespace sh
inline std::vector<ScriptNode*> &getChildren() inline std::vector<ScriptNode*> &getChildren()
{ {
return m_children; return mChildren;
} }
inline ScriptNode *getChild(unsigned int index = 0) inline ScriptNode *getChild(unsigned int index = 0)
{ {
assert(index < m_children.size()); assert(index < mChildren.size());
return m_children[index]; return mChildren[index];
} }
void setParent(ScriptNode *newParent); void setParent(ScriptNode *newParent);
inline ScriptNode *getParent() inline ScriptNode *getParent()
{ {
return m_parent; return mParent;
} }
std::string m_fileName; std::string mFileName;
private: private:
std::string m_name; std::string mName;
std::string m_value; std::string mValue;
std::vector<ScriptNode*> m_children; std::vector<ScriptNode*> mChildren;
ScriptNode *m_parent; ScriptNode *mParent;
int m_lastChildFound; //The last child node's index found with a call to findChild() int mLastChildFound; //The last child node's index found with a call to findChild()
std::vector<ScriptNode*>::iterator _iter; std::vector<ScriptNode*>::iterator mIter;
bool _removeSelf; bool mRemoveSelf;
}; };
} }

Loading…
Cancel
Save