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})
set(SHINY_LIBRARY ${SHINY_LIBRARY} PARENT_SCOPE)
set(SHINY_OGREPLATFORM_LIBRARY ${SHINY_OGREPLATFORM_LIBRARY} PARENT_SCOPE)

@ -224,7 +224,7 @@ namespace sh
if (!mShadersEnabled)
newInstance.setShadersEnabled (false);
newInstance.setSourceFile (it->second->m_fileName);
newInstance.setSourceFile (it->second->mFileName);
std::vector<ScriptNode*> props = it->second->getChildren();
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();
}
bool useShaders = mShadersEnabled || !allowFixedFunction;
// get passes of the top-most parent
PassVector passes = getPasses();
if (passes.size() == 0)
@ -91,7 +93,7 @@ namespace sh
// create or retrieve shaders
bool hasVertex = it->hasProperty("vertex_program");
bool hasFragment = it->hasProperty("fragment_program");
if (mShadersEnabled || !allowFixedFunction)
if (useShaders)
{
it->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 foundFragment = std::find(usedTextureSamplersFragment.begin(), usedTextureSamplersFragment.end(), texIt->getName()) != usedTextureSamplersFragment.end();
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 ();
texIt->copyAll (texUnit.get(), context);
@ -152,7 +154,7 @@ namespace sh
mTexUnits.push_back(texUnit);
// 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);

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

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

Loading…
Cancel
Save