Merge remote-tracking branch 'upstream/development' into PhysicsDiscovery-tests

This commit is contained in:
marauder2k7 2024-06-25 13:17:39 +01:00
commit 547b8c8c8c
35 changed files with 242 additions and 630 deletions

View file

@ -57,7 +57,7 @@ struct Move
bool trigger[MaxTriggerKeys];
Move();
virtual ~Move() {};
virtual void pack(BitStream *stream, const Move * move = NULL);
virtual void unpack(BitStream *stream, const Move * move = NULL);
virtual void clamp();

View file

@ -4014,9 +4014,9 @@ void Player::updateActionThread()
mActionAnimation.callbackTripped = true;
}
if ((mActionAnimation.action == PlayerData::NullAnimation) ||
((!mActionAnimation.waitForEnd || mActionAnimation.atEnd) &&
(!mActionAnimation.holdAtEnd && (mActionAnimation.delayTicks -= !mMountPending) <= 0)))
if (mActionAnimation.action == PlayerData::NullAnimation || !mActionAnimation.waitForEnd || //either no animation or not waiting till the end
((mActionAnimation.atEnd && !mActionAnimation.holdAtEnd) && //or not holding that state and
(mActionAnimation.delayTicks -= mMountPending) <= 0)) //not waiting to mount
{
pickActionAnimation();
}

View file

@ -246,6 +246,7 @@ public:
return s == StringTable->EmptyString() ? 0 : dAtoi(s);
if (type == ConsoleValueType::cvString)
return dStrcmp(s, "") == 0 ? 0 : dAtoi(s);
return dAtoi(getConsoleData());
}

View file

@ -1301,7 +1301,8 @@ case 5:
/* rule 5 can match eol */
YY_RULE_SETUP
#line 120 "CMDscan.l"
{ yycolumn = 1;
{
yycolumn = 1;
lines.push_back(String::ToString("%s", yytext+1));
if (lines.size() > Con::getIntVariable("$scriptErrorLineCount", 10))
lines.erase(lines.begin());
@ -1311,162 +1312,162 @@ YY_RULE_SETUP
YY_BREAK
case 6:
YY_RULE_SETUP
#line 127 "CMDscan.l"
#line 128 "CMDscan.l"
{ return(Sc_ScanString(STRATOM)); }
YY_BREAK
case 7:
YY_RULE_SETUP
#line 128 "CMDscan.l"
#line 129 "CMDscan.l"
{ return(Sc_ScanString(TAGATOM)); }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 129 "CMDscan.l"
#line 130 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opEQ, yylineno ); return opEQ; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 130 "CMDscan.l"
#line 131 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opNE, yylineno ); return opNE; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 131 "CMDscan.l"
#line 132 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opGE, yylineno ); return opGE; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 132 "CMDscan.l"
#line 133 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opLE, yylineno ); return opLE; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 133 "CMDscan.l"
#line 134 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opAND, yylineno ); return opAND; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 134 "CMDscan.l"
#line 135 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opOR, yylineno ); return opOR; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 135 "CMDscan.l"
#line 136 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opCOLONCOLON, yylineno ); return opCOLONCOLON; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 136 "CMDscan.l"
#line 137 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opMINUSMINUS, yylineno ); return opMINUSMINUS; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 137 "CMDscan.l"
#line 138 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opPLUSPLUS, yylineno ); return opPLUSPLUS; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 138 "CMDscan.l"
#line 139 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSTREQ, yylineno ); return opSTREQ; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 139 "CMDscan.l"
#line 140 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSTRNE, yylineno ); return opSTRNE; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 140 "CMDscan.l"
#line 141 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSHL, yylineno ); return opSHL; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 141 "CMDscan.l"
#line 142 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSHR, yylineno ); return opSHR; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 142 "CMDscan.l"
#line 143 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opPLASN, yylineno ); return opPLASN; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 143 "CMDscan.l"
#line 144 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opMIASN, yylineno ); return opMIASN; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 144 "CMDscan.l"
#line 145 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opMLASN, yylineno ); return opMLASN; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 145 "CMDscan.l"
#line 146 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opDVASN, yylineno ); return opDVASN; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 146 "CMDscan.l"
#line 147 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opMODASN, yylineno ); return opMODASN; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 147 "CMDscan.l"
#line 148 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opANDASN, yylineno ); return opANDASN; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 148 "CMDscan.l"
#line 149 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opXORASN, yylineno ); return opXORASN; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 149 "CMDscan.l"
#line 150 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opORASN, yylineno ); return opORASN; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 150 "CMDscan.l"
#line 151 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSLASN, yylineno ); return opSLASN; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 151 "CMDscan.l"
#line 152 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opSRASN, yylineno ); return opSRASN; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 152 "CMDscan.l"
#line 153 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opINTNAME, yylineno ); return opINTNAME; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 153 "CMDscan.l"
#line 154 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( opINTNAMER, yylineno ); return opINTNAMER; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 154 "CMDscan.l"
#line 155 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( '\n', yylineno ); return '@'; }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 155 "CMDscan.l"
#line 156 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( '\t', yylineno ); return '@'; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 156 "CMDscan.l"
#line 157 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( ' ', yylineno ); return '@'; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 157 "CMDscan.l"
#line 158 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( 0, yylineno ); return '@'; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 158 "CMDscan.l"
#line 159 "CMDscan.l"
{ /* this comment stops syntax highlighting from getting messed up when editing the lexer in TextPad */
int c = 0, l;
for ( ; ; )
@ -1488,222 +1489,222 @@ YY_RULE_SETUP
}
YY_BREAK
case 38:
#line 178 "CMDscan.l"
case 39:
#line 179 "CMDscan.l"
case 40:
case 39:
#line 180 "CMDscan.l"
case 41:
case 40:
#line 181 "CMDscan.l"
case 42:
case 41:
#line 182 "CMDscan.l"
case 43:
case 42:
#line 183 "CMDscan.l"
case 44:
case 43:
#line 184 "CMDscan.l"
case 45:
case 44:
#line 185 "CMDscan.l"
case 46:
case 45:
#line 186 "CMDscan.l"
case 47:
case 46:
#line 187 "CMDscan.l"
case 48:
case 47:
#line 188 "CMDscan.l"
case 49:
case 48:
#line 189 "CMDscan.l"
case 50:
case 49:
#line 190 "CMDscan.l"
case 51:
case 50:
#line 191 "CMDscan.l"
case 52:
case 51:
#line 192 "CMDscan.l"
case 53:
case 52:
#line 193 "CMDscan.l"
case 54:
case 53:
#line 194 "CMDscan.l"
case 55:
case 54:
#line 195 "CMDscan.l"
case 56:
case 55:
#line 196 "CMDscan.l"
case 57:
case 56:
#line 197 "CMDscan.l"
case 58:
case 57:
#line 198 "CMDscan.l"
case 59:
case 58:
#line 199 "CMDscan.l"
case 60:
case 59:
#line 200 "CMDscan.l"
case 60:
#line 201 "CMDscan.l"
case 61:
YY_RULE_SETUP
#line 200 "CMDscan.l"
#line 201 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( CMDtext[ 0 ], yylineno ); return CMDtext[ 0 ]; }
YY_BREAK
case 62:
YY_RULE_SETUP
#line 201 "CMDscan.l"
#line 202 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwIN, yylineno ); return(rwIN); }
YY_BREAK
case 63:
YY_RULE_SETUP
#line 202 "CMDscan.l"
#line 203 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwCASEOR, yylineno ); return(rwCASEOR); }
YY_BREAK
case 64:
YY_RULE_SETUP
#line 203 "CMDscan.l"
#line 204 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwBREAK, yylineno ); return(rwBREAK); }
YY_BREAK
case 65:
YY_RULE_SETUP
#line 204 "CMDscan.l"
#line 205 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwRETURN, yylineno ); return(rwRETURN); }
YY_BREAK
case 66:
YY_RULE_SETUP
#line 205 "CMDscan.l"
#line 206 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwELSE, yylineno ); return(rwELSE); }
YY_BREAK
case 67:
YY_RULE_SETUP
#line 206 "CMDscan.l"
#line 207 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwASSERT, yylineno ); return(rwASSERT); }
YY_BREAK
case 68:
YY_RULE_SETUP
#line 207 "CMDscan.l"
#line 208 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwWHILE, yylineno ); return(rwWHILE); }
YY_BREAK
case 69:
YY_RULE_SETUP
#line 208 "CMDscan.l"
#line 209 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDO, yylineno ); return(rwDO); }
YY_BREAK
case 70:
YY_RULE_SETUP
#line 209 "CMDscan.l"
#line 210 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwIF, yylineno ); return(rwIF); }
YY_BREAK
case 71:
YY_RULE_SETUP
#line 210 "CMDscan.l"
#line 211 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwFOREACHSTR, yylineno ); return(rwFOREACHSTR); }
YY_BREAK
case 72:
YY_RULE_SETUP
#line 211 "CMDscan.l"
#line 212 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwFOREACH, yylineno ); return(rwFOREACH); }
YY_BREAK
case 73:
YY_RULE_SETUP
#line 212 "CMDscan.l"
#line 213 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwFOR, yylineno ); return(rwFOR); }
YY_BREAK
case 74:
YY_RULE_SETUP
#line 213 "CMDscan.l"
#line 214 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwCONTINUE, yylineno ); return(rwCONTINUE); }
YY_BREAK
case 75:
YY_RULE_SETUP
#line 214 "CMDscan.l"
#line 215 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDEFINE, yylineno ); return(rwDEFINE); }
YY_BREAK
case 76:
YY_RULE_SETUP
#line 215 "CMDscan.l"
#line 216 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDECLARE, yylineno ); return(rwDECLARE); }
YY_BREAK
case 77:
YY_RULE_SETUP
#line 216 "CMDscan.l"
#line 217 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDECLARESINGLETON, yylineno ); return(rwDECLARESINGLETON); }
YY_BREAK
case 78:
YY_RULE_SETUP
#line 217 "CMDscan.l"
#line 218 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDATABLOCK, yylineno ); return(rwDATABLOCK); }
YY_BREAK
case 79:
YY_RULE_SETUP
#line 218 "CMDscan.l"
#line 219 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwCASE, yylineno ); return(rwCASE); }
YY_BREAK
case 80:
YY_RULE_SETUP
#line 219 "CMDscan.l"
#line 220 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwSWITCHSTR, yylineno ); return(rwSWITCHSTR); }
YY_BREAK
case 81:
YY_RULE_SETUP
#line 220 "CMDscan.l"
#line 221 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwSWITCH, yylineno ); return(rwSWITCH); }
YY_BREAK
case 82:
YY_RULE_SETUP
#line 221 "CMDscan.l"
#line 222 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwDEFAULT, yylineno ); return(rwDEFAULT); }
YY_BREAK
case 83:
YY_RULE_SETUP
#line 222 "CMDscan.l"
#line 223 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwPACKAGE, yylineno ); return(rwPACKAGE); }
YY_BREAK
case 84:
YY_RULE_SETUP
#line 223 "CMDscan.l"
#line 224 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( rwNAMESPACE, yylineno ); return(rwNAMESPACE); }
YY_BREAK
case 85:
YY_RULE_SETUP
#line 224 "CMDscan.l"
#line 225 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( 1, yylineno ); return INTCONST; }
YY_BREAK
case 86:
YY_RULE_SETUP
#line 225 "CMDscan.l"
#line 226 "CMDscan.l"
{ CMDlval.i = MakeToken< int >( 0, yylineno ); return INTCONST; }
YY_BREAK
case 87:
YY_RULE_SETUP
#line 226 "CMDscan.l"
#line 227 "CMDscan.l"
{ return(Sc_ScanVar()); }
YY_BREAK
case 88:
YY_RULE_SETUP
#line 228 "CMDscan.l"
#line 229 "CMDscan.l"
{ return Sc_ScanIdent(); }
YY_BREAK
case 89:
YY_RULE_SETUP
#line 229 "CMDscan.l"
#line 230 "CMDscan.l"
return(Sc_ScanHex());
YY_BREAK
case 90:
YY_RULE_SETUP
#line 230 "CMDscan.l"
#line 231 "CMDscan.l"
{ CMDtext[CMDleng] = 0; CMDlval.i = MakeToken< int >( dAtoi(CMDtext), yylineno ); return INTCONST; }
YY_BREAK
case 91:
YY_RULE_SETUP
#line 231 "CMDscan.l"
#line 232 "CMDscan.l"
return Sc_ScanNum();
YY_BREAK
case 92:
YY_RULE_SETUP
#line 232 "CMDscan.l"
#line 233 "CMDscan.l"
return(ILLEGAL_TOKEN);
YY_BREAK
case 93:
YY_RULE_SETUP
#line 233 "CMDscan.l"
#line 234 "CMDscan.l"
return(ILLEGAL_TOKEN);
YY_BREAK
case 94:
YY_RULE_SETUP
#line 234 "CMDscan.l"
#line 235 "CMDscan.l"
ECHO;
YY_BREAK
#line 1706 "CMDscan.cpp"
#line 1707 "CMDscan.cpp"
case YY_STATE_EOF(INITIAL):
yyterminate();
@ -2679,7 +2680,7 @@ void yyfree (void * ptr )
#define YYTABLES_NAME "yytables"
#line 234 "CMDscan.l"
#line 235 "CMDscan.l"
static const char *scanBuffer;
@ -2741,6 +2742,8 @@ void CMDSetScanBuffer(const char *sb, const char *fn)
scanBuffer = sb;
fileName = fn;
scanIndex = 0;
yylineno = 1;
lines.clear();
}
int CMDgetc()

View file

@ -116,7 +116,8 @@ HEXDIGIT [a-fA-F0-9]
("///"([^/\n\r][^\n\r]*)?[\n\r]+)+ { return(Sc_ScanDocBlock()); }
"//"[^\n\r]* ;
[\r] ;
\n.* { yycolumn = 1;
\n.* {
yycolumn = 1;
lines.push_back(String::ToString("%s", yytext+1));
if (lines.size() > Con::getIntVariable("$scriptErrorLineCount", 10))
lines.erase(lines.begin());
@ -291,6 +292,8 @@ void CMDSetScanBuffer(const char *sb, const char *fn)
scanBuffer = sb;
fileName = fn;
scanIndex = 0;
yylineno = 1;
lines.clear();
}
int CMDgetc()

View file

@ -200,7 +200,9 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
U32 endifIp, elseIp;
addBreakLine(codeStream);
if (testExpr->getPreferredType() == TypeReqUInt)
TypeReq testType = testExpr->getPreferredType();
if (testType == TypeReqUInt)
{
integer = true;
}
@ -209,8 +211,16 @@ U32 IfStmtNode::compileStmt(CodeStream& codeStream, U32 ip)
integer = false;
}
ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat);
codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT);
if (testType == TypeReqString || testType == TypeReqNone)
{
ip = testExpr->compile(codeStream, ip, TypeReqString);
codeStream.emit(OP_JMPNOTSTRING);
}
else
{
ip = testExpr->compile(codeStream, ip, integer ? TypeReqUInt : TypeReqFloat);
codeStream.emit(integer ? OP_JMPIFNOT : OP_JMPIFFNOT);
}
if (elseBlock)
{

View file

@ -1144,6 +1144,15 @@ Con::EvalResult CodeBlock::exec(U32 ip, const char* functionName, Namespace* thi
ip++;
break;
}
ip = code[ip];
break;
case OP_JMPNOTSTRING:
if (stack[_STK--].getBool())
{
ip++;
break;
}
ip = code[ip];
break;
case OP_JMPIFF:

View file

@ -62,6 +62,7 @@ namespace Compiler
OP_JMPIFFNOT,
OP_JMPIFNOT,
OP_JMPNOTSTRING,
OP_JMPIFF,
OP_JMPIF,
OP_JMPIFNOT_NP,

View file

@ -85,18 +85,18 @@ FileObject::FileObject()
mFileBuffer = NULL;
mBufferSize = 0;
mCurPos = 0;
stream = NULL;
mStream = NULL;
}
FileObject::~FileObject()
{
SAFE_DELETE_ARRAY(mFileBuffer);
SAFE_DELETE(stream);
SAFE_DELETE(mStream);
}
void FileObject::close()
{
SAFE_DELETE(stream);
SAFE_DELETE(mStream);
SAFE_DELETE_ARRAY(mFileBuffer);
mFileBuffer = NULL;
mBufferSize = mCurPos = 0;
@ -112,10 +112,10 @@ bool FileObject::openForWrite(const char *fileName, const bool append)
if( !buffer[ 0 ] )
return false;
if((stream = FileStream::createAndOpen( fileName, append ? Torque::FS::File::WriteAppend : Torque::FS::File::Write )) == NULL)
if((mStream = FileStream::createAndOpen( fileName, append ? Torque::FS::File::WriteAppend : Torque::FS::File::Write )) == NULL)
return false;
stream->setPosition( stream->getStreamSize() );
mStream->setPosition(mStream->getStreamSize() );
return( true );
}
@ -225,17 +225,17 @@ void FileObject::peekLine( S32 peekLineOffset, U8* line, S32 length )
void FileObject::writeLine(const U8 *line)
{
stream->write(dStrlen((const char *) line), line);
stream->write(2, "\r\n");
mStream->write(dStrlen((const char *) line), line);
mStream->write(2, "\r\n");
}
void FileObject::writeObject( SimObject* object, const U8* objectPrepend )
{
if( objectPrepend == NULL )
stream->write(2, "\r\n");
mStream->write(2, "\r\n");
else
stream->write(dStrlen((const char *) objectPrepend), objectPrepend );
object->write( *stream, 0 );
mStream->write(dStrlen((const char *) objectPrepend), objectPrepend );
object->write( *mStream, 0 );
}
DefineEngineMethod( FileObject, openForRead, bool, ( const char* filename ),,

View file

@ -36,7 +36,7 @@ class FileObject : public SimObject
U8 *mFileBuffer;
U32 mBufferSize;
U32 mCurPos;
FileStream *stream;
FileStream *mStream;
public:
FileObject();
~FileObject();
@ -50,6 +50,8 @@ public:
bool isEOF();
void writeLine(const U8 *line);
void close();
bool writeObject(Stream* stream) override { Con::errorf("FileObject:Can Not write a file interface object to a file"); return false; }; //Don't allow writing FileObject *to* files
void writeObject( SimObject* object, const U8* objectPrepend = NULL );
DECLARE_CONOBJECT(FileObject);

View file

@ -259,9 +259,23 @@ extern S32 dStrcmp(const UTF16 *str1, const UTF16 *str2);
extern S32 dStrnatcmp( const char* str1, const char* str2 );
extern S32 dStrnatcasecmp( const char* str1, const char* str2 );
inline bool dAtob(const char *str)
inline bool dAtob(const char* str)
{
return !dStricmp(str, "true") || dAtof(str);
if (str && str[0] != '\0')
{
if (dStricmp(str, "0") == 0)
return false;
if (dStricmp(str, "0.0") == 0)
return false;
if (dStricmp(str, "0.0f") == 0)
return false;
if (dStricmp(str, "null") == 0)
return false;
if (dStricmp(str, "false") == 0)
return false;
return true;
}
return false;
}
bool dStrEqual(const char* str1, const char* str2);

View file

@ -263,7 +263,7 @@ class TheoraTexture : private IOutputStream< TheoraTextureFrame* >,
///
AsyncState( const ThreadSafeRef< OggInputStream >& oggStream, bool looping = false );
virtual ~AsyncState() {};
/// Return the Theora decoder substream.
OggTheoraDecoder* getTheora() const { return mTheoraDecoder; }

View file

@ -261,16 +261,16 @@ void GlowMapGLSL::processPix(Vector<ShaderComponent*>& componentList, const Mate
targ->setType("vec4");
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
targ->setStructName("OUT");
output = new GenOp("@ = vec4(@.rgb*@,0);", targ, texOp, glowMul);
output = new GenOp("@ = vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul);
}
else
{
output = new GenOp("@ += vec4(@.rgb*@,0);", targ, texOp, glowMul);
output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),0);", targ, texOp, glowMul);
}
}
else
{
output = new GenOp("@ += vec4(@.rgb*@,@.a);", targ, texOp, glowMul, targ);
output = new GenOp("@ += vec4(pow(max(@.rgb*@,0.0),vec3(3.54406804435,3.54406804435,3.54406804435)),@.a);", targ, texOp, glowMul, targ);
}
}

View file

@ -264,16 +264,16 @@ void GlowMapHLSL::processPix(Vector<ShaderComponent*> &componentList, const Mate
targ->setType("fragout");
targ->setName(getOutputTargetVarName(ShaderFeature::RenderTarget3));
targ->setStructName("OUT");
output = new GenOp("@ = float4(@.rgb*@,0);", targ, texOp, glowMul);
output = new GenOp("@ = float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul);
}
else
{
output = new GenOp("@ += float4(@.rgb*@,0);", targ, texOp, glowMul);
output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),0);", targ, texOp, glowMul);
}
}
else
{
output = new GenOp("@ += float4(@.rgb*@,@.a);", targ, texOp, glowMul, targ);
output = new GenOp("@ += float4(pow(max(@.rgb*@,0.0),3.54406804435),@.a);", targ, texOp, glowMul, targ);
}
}

View file

@ -56,6 +56,7 @@ ImplementFeatureType( MFT_AccuMap, MFG_PreLighting, 2.0f, true );
ImplementFeatureType(MFT_ReflectionProbes, MFG_Lighting, 1.0f, true);
ImplementFeatureType( MFT_RTLighting, MFG_Lighting, 2.0f, true );
ImplementFeatureType( MFT_GlowMap, MFG_Lighting, 3.0f, true );
ImplementFeatureType( MFT_GlowMask, MFG_Lighting, 3.1f, true );
ImplementFeatureType( MFT_LightMap, MFG_Lighting, 4.0f, true );
ImplementFeatureType( MFT_ToneMap, MFG_Lighting, 5.0f, true );
ImplementFeatureType( MFT_VertLitTone, MFG_Lighting, 6.0f, false );
@ -65,8 +66,6 @@ ImplementFeatureType( MFT_SubSurface, MFG_Lighting, 8.0f, true );
ImplementFeatureType( MFT_VertLit, MFG_Lighting, 9.0f, true );
ImplementFeatureType( MFT_MinnaertShading, MFG_Lighting, 10.0f, true );
ImplementFeatureType( MFT_GlowMask, MFG_PostLighting, 1.0f, true );
ImplementFeatureType( MFT_Visibility, MFG_PostLighting, 2.0f, true );
ImplementFeatureType( MFT_Fog, MFG_PostProcess, 3.0f, true );

View file

@ -197,7 +197,7 @@ void ProcessedMaterial::addStateBlockDesc(const GFXStateBlockDesc& sb)
mUserDefined = sb;
}
void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect)
void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect)
{
// Translucency
stateTranslucent.blendDefined = true;
@ -211,10 +211,6 @@ void ProcessedMaterial::_initStateBlockTemplates(GFXStateBlockDesc& stateTranslu
stateTranslucent.alphaTestFunc = GFXCmpGreaterEqual;
stateTranslucent.samplersDefined = true;
// Glow
stateGlow.zDefined = true;
stateGlow.zWriteEnable = false;
// Reflect
stateReflect.cullDefined = true;
stateReflect.cullMode = mMaterial->mDoubleSided ? GFXCullNone : GFXCullCW;
@ -316,11 +312,10 @@ void ProcessedMaterial::_initPassStateBlock( RenderPassData *rpd, GFXStateBlockD
void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
{
GFXStateBlockDesc stateTranslucent;
GFXStateBlockDesc stateGlow;
GFXStateBlockDesc stateReflect;
GFXStateBlockDesc statePass;
_initStateBlockTemplates( stateTranslucent, stateGlow, stateReflect );
_initStateBlockTemplates( stateTranslucent, stateReflect );
_initPassStateBlock( rpd, statePass );
// Ok, we've got our templates set up, let's combine them together based on state and
@ -333,8 +328,6 @@ void ProcessedMaterial::_initRenderStateStateBlocks( RenderPassData *rpd )
stateFinal.addDesc(stateReflect);
if (i & RenderPassData::STATE_TRANSLUCENT)
stateFinal.addDesc(stateTranslucent);
if (i & RenderPassData::STATE_GLOW)
stateFinal.addDesc(stateGlow);
stateFinal.addDesc(statePass);
@ -359,9 +352,6 @@ U32 ProcessedMaterial::_getRenderStateIndex( const SceneRenderState *sceneState,
// For example sgData.visibility would be bad to use
// in here without changing how RenderMeshMgr works.
if ( sgData.binType == SceneData::GlowBin )
currState |= RenderPassData::STATE_GLOW;
if ( sceneState && sceneState->isReflectPass() )
currState |= RenderPassData::STATE_REFLECT;

View file

@ -98,9 +98,8 @@ public:
{
STATE_REFLECT = 1,
STATE_TRANSLUCENT = 2,
STATE_GLOW = 4,
STATE_WIREFRAME = 8,
STATE_MAX = 16
STATE_WIREFRAME = 4,
STATE_MAX = 8
};
///
@ -301,7 +300,7 @@ protected:
/// @{
/// Creates the default state block templates, used by initStateBlocks.
virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateGlow, GFXStateBlockDesc& stateReflect);
virtual void _initStateBlockTemplates(GFXStateBlockDesc& stateTranslucent, GFXStateBlockDesc& stateReflect);
/// Does the base render state block setting, normally per pass.
virtual void _initPassStateBlock( RenderPassData *rpd, GFXStateBlockDesc& result);

View file

@ -348,7 +348,6 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
//
if ( features.hasFeature( MFT_UseInstancing ) &&
mMaxStages == 1 &&
!mMaterial->mGlow[0] &&
shaderVersion >= 3.0f )
fd.features.addFeature( MFT_UseInstancing );
@ -520,6 +519,9 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
if ( mMaterial->mVertColor[ stageNum ] &&
mVertexFormat->hasColor() )
fd.features.addFeature( MFT_DiffuseVertColor );
if (mMaterial->mGlow[stageNum])
fd.features.addFeature(MFT_GlowMask);
// Allow features to add themselves.
for ( U32 i = 0; i < FEATUREMGR->getFeatureCount(); i++ )

View file

@ -45,10 +45,6 @@ struct SceneData
/// the special bins we care about.
RegularBin = 0,
/// The glow render bin.
/// @see RenderGlowMgr
GlowBin,
/// The deferred render bin.
/// @RenderDeferredMgr
DeferredBin,

View file

@ -194,6 +194,8 @@ public:
inline void setModuleLocked( const bool status ) { mLocked = status; }
inline bool getModuleLocked( void ) const { return mLocked; }
inline ModuleManager* getModuleManager( void ) const { return mpModuleManager; }
using Parent::save;
bool save( void );
/// Declare Console Object.

View file

@ -111,6 +111,7 @@ private:
void compileCustomState( TamlWriteNode* pTamlWriteNode );
void compileCustomNodeState( TamlCustomNode* pCustomNode );
void write(Stream& stream, U32 tabStop, U32 flags = 0) override { Con::errorf("Taml:Can Not write a file interface object to a file"); }; //Don't allow writing Taml objects *to* files
bool write( FileStream& stream, SimObject* pSimObject, const TamlFormatMode formatMode );
SimObject* read( FileStream& stream, const TamlFormatMode formatMode );
template<typename T> inline T* read( FileStream& stream, const TamlFormatMode formatMode )

View file

@ -683,7 +683,8 @@ void ProcessedDeferredMaterial::_determineFeatures( U32 stageNum,
type == MFT_UseInstancing ||
type == MFT_DiffuseVertColor ||
type == MFT_DetailMap ||
type == MFT_DiffuseMapAtlas)
type == MFT_DiffuseMapAtlas||
type == MFT_GlowMask)
newFeatures.addFeature( type );
// Add any transform features.

View file

@ -1,282 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#include "platform/platform.h"
#include "renderInstance/renderGlowMgr.h"
#include "renderInstance/renderParticleMgr.h"
#include "scene/sceneManager.h"
#include "scene/sceneRenderState.h"
#include "materials/sceneData.h"
#include "materials/matInstance.h"
#include "materials/materialFeatureTypes.h"
#include "materials/processedMaterial.h"
#include "postFx/postEffect.h"
#include "gfx/gfxTransformSaver.h"
#include "gfx/gfxDebugEvent.h"
#include "math/util/matrixSet.h"
IMPLEMENT_CONOBJECT( RenderGlowMgr );
ConsoleDocClass( RenderGlowMgr,
"@brief A render bin for the glow pass.\n\n"
"When the glow buffer PostEffect is enabled this bin gathers mesh render "
"instances with glow materials and renders them to the #glowbuffer offscreen "
"render target.\n\n"
"This render target is then used by the 'GlowPostFx' PostEffect to blur and "
"render the glowing portions of the screen.\n\n"
"@ingroup RenderBin\n" );
const MatInstanceHookType RenderGlowMgr::GlowMaterialHook::Type( "Glow" );
RenderGlowMgr::GlowMaterialHook::GlowMaterialHook( BaseMatInstance *matInst )
: mGlowMatInst( NULL )
{
mGlowMatInst = (MatInstance*)matInst->getMaterial()->createMatInstance();
mGlowMatInst->getFeaturesDelegate().bind( &GlowMaterialHook::_overrideFeatures );
mGlowMatInst->setUserObject(matInst->getUserObject());
mGlowMatInst->init( matInst->getRequestedFeatures(),
matInst->getVertexFormat() );
}
RenderGlowMgr::GlowMaterialHook::~GlowMaterialHook()
{
SAFE_DELETE( mGlowMatInst );
}
void RenderGlowMgr::GlowMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
U32 stageNum,
MaterialFeatureData &fd,
const FeatureSet &features )
{
// If this isn't a glow pass... then add the glow mask feature.
if ( mat->getMaterial() &&
!mat->getMaterial()->mGlow[stageNum] )
fd.features.addFeature( MFT_GlowMask );
// Don't allow fog or HDR encoding on
// the glow materials.
fd.features.removeFeature( MFT_Fog );
fd.features.addFeature( MFT_Imposter );
}
RenderGlowMgr::RenderGlowMgr()
: RenderTexTargetBinManager( RenderPassManager::RIT_Mesh,
1.0f,
1.0f,
GFXFormatR8G8B8A8,
Point2I( 512, 512 ) )
{
notifyType( RenderPassManager::RIT_Decal );
notifyType( RenderPassManager::RIT_DecalRoad );
notifyType( RenderPassManager::RIT_Translucent );
notifyType( RenderPassManager::RIT_Particle );
mParticleRenderMgr = NULL;
mNamedTarget.registerWithName( "glowbuffer" );
mTargetSizeType = WindowSize;
}
RenderGlowMgr::~RenderGlowMgr()
{
}
PostEffect* RenderGlowMgr::getGlowEffect()
{
if ( !mGlowEffect )
mGlowEffect = dynamic_cast<PostEffect*>( Sim::findObject( "GlowPostFx" ) );
return mGlowEffect;
}
bool RenderGlowMgr::isGlowEnabled()
{
return getGlowEffect() && getGlowEffect()->isEnabled();
}
void RenderGlowMgr::addElement( RenderInst *inst )
{
// Skip out if we don't have the glow post
// effect enabled at this time.
if ( !isGlowEnabled() )
return;
// TODO: We need to get the scene state here in a more reliable
// manner so we can skip glow in a non-diffuse render pass.
//if ( !mParentManager->getSceneManager()->getSceneState()->isDiffusePass() )
//return RenderBinManager::arSkipped;
ParticleRenderInst *particleInst = NULL;
if(inst->type == RenderPassManager::RIT_Particle)
particleInst = static_cast<ParticleRenderInst*>(inst);
if(particleInst && particleInst->glow)
{
internalAddElement(inst);
return;
}
// Skip it if we don't have a glowing material.
BaseMatInstance *matInst = getMaterial( inst );
if ( !matInst || !matInst->hasGlow() )
return;
internalAddElement(inst);
}
void RenderGlowMgr::render( SceneRenderState *state )
{
PROFILE_SCOPE( RenderGlowMgr_Render );
if ( !isGlowEnabled() )
return;
const U32 binSize = mElementList.size();
// If this is a non-diffuse pass or we have no objects to
// render then tell the effect to skip rendering.
if ( !state->isDiffusePass() || binSize == 0 )
{
getGlowEffect()->setSkip( true );
return;
}
GFXDEBUGEVENT_SCOPE( RenderGlowMgr_Render, ColorI::GREEN );
GFXTransformSaver saver;
// Respect the current viewport
mNamedTarget.setViewport(GFX->getViewport());
// Tell the superclass we're about to render, preserve contents
const bool isRenderingToTarget = _onPreRender( state, true );
// Clear all the buffers to black.
GFX->clear( GFXClearTarget, ColorI::BLACK, 1.0f, 0);
// Restore transforms
MatrixSet &matrixSet = getRenderPass()->getMatrixSet();
matrixSet.restoreSceneViewProjection();
// init loop data
SceneData sgData;
sgData.init( state, SceneData::GlowBin );
for( U32 j=0; j<binSize; )
{
RenderInst *_ri = mElementList[j].inst;
if(_ri->type == RenderPassManager::RIT_Particle)
{
// Find the particle render manager (if we don't have it)
if(mParticleRenderMgr == NULL)
{
RenderPassManager *rpm = state->getRenderPass();
for( U32 i = 0; i < rpm->getManagerCount(); i++ )
{
RenderBinManager *bin = rpm->getManager(i);
if( bin->getRenderInstType() == RenderParticleMgr::RIT_Particles )
{
mParticleRenderMgr = reinterpret_cast<RenderParticleMgr *>(bin);
break;
}
}
}
ParticleRenderInst *ri = static_cast<ParticleRenderInst*>(_ri);
GFX->setStateBlock(mParticleRenderMgr->_getHighResStateBlock(ri));
mParticleRenderMgr->_getShaderConsts().mShaderConsts->setSafe(mParticleRenderMgr->_getShaderConsts().mModelViewProjSC, *ri->modelViewProj);
mParticleRenderMgr->renderParticle(ri, state);
j++;
continue;
}
MeshRenderInst *ri = static_cast<MeshRenderInst*>(_ri);
setupSGData( ri, sgData );
BaseMatInstance *mat = ri->matInst;
GlowMaterialHook *hook = mat->getHook<GlowMaterialHook>();
if ( !hook )
{
hook = new GlowMaterialHook( ri->matInst );
ri->matInst->addHook( hook );
}
BaseMatInstance *glowMat = hook->getMatInstance();
U32 matListEnd = j;
while( glowMat && glowMat->setupPass( state, sgData ) )
{
U32 a;
for( a=j; a<binSize; a++ )
{
if (mElementList[a].inst->type == RenderPassManager::RIT_Particle)
break;
MeshRenderInst *passRI = static_cast<MeshRenderInst*>(mElementList[a].inst);
if ( newPassNeeded( ri, passRI ) )
break;
matrixSet.setWorld(*passRI->objectToWorld);
matrixSet.setView(*passRI->worldToCamera);
matrixSet.setProjection(*passRI->projection);
glowMat->setTransforms(matrixSet, state);
// Setup HW skinning transforms if applicable
if (glowMat->usesHardwareSkinning())
{
glowMat->setNodeTransforms(passRI->mNodeTransforms, passRI->mNodeTransformCount);
}
//push along any overriden fields that are instance-specific as well
if (passRI->mCustomShaderData.size() > 0)
{
mat->setCustomShaderData(passRI->mCustomShaderData);
}
glowMat->setSceneInfo(state, sgData);
glowMat->setBuffers(passRI->vertBuff, passRI->primBuff);
if ( passRI->prim )
GFX->drawPrimitive( *passRI->prim );
else
GFX->drawPrimitive( passRI->primBuffIndex );
}
matListEnd = a;
setupSGData( ri, sgData );
}
// force increment if none happened, otherwise go to end of batch
j = ( j == matListEnd ) ? j+1 : matListEnd;
}
// Finish up.
if ( isRenderingToTarget )
_onPostRender();
// Make sure the effect is gonna render.
getGlowEffect()->setSkip( false );
}

View file

@ -1,90 +0,0 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _RENDERGLOWMGR_H_
#define _RENDERGLOWMGR_H_
#ifndef _TEXTARGETBIN_MGR_H_
#include "renderInstance/renderTexTargetBinManager.h"
#endif
#include <renderInstance/renderParticleMgr.h>
class PostEffect;
///
class RenderGlowMgr : public RenderTexTargetBinManager
{
typedef RenderTexTargetBinManager Parent;
public:
RenderGlowMgr();
virtual ~RenderGlowMgr();
/// Returns the glow post effect.
PostEffect* getGlowEffect();
/// Returns true if the glow post effect is
/// enabled and the glow buffer should be updated.
bool isGlowEnabled();
// RenderBinManager
void addElement( RenderInst *inst ) override;
void render( SceneRenderState *state ) override;
// ConsoleObject
DECLARE_CONOBJECT( RenderGlowMgr );
protected:
class GlowMaterialHook : public MatInstanceHook
{
public:
GlowMaterialHook( BaseMatInstance *matInst );
virtual ~GlowMaterialHook();
virtual BaseMatInstance *getMatInstance() { return mGlowMatInst; }
const MatInstanceHookType& getType() const override { return Type; }
/// Our material hook type.
static const MatInstanceHookType Type;
protected:
static void _overrideFeatures( ProcessedMaterial *mat,
U32 stageNum,
MaterialFeatureData &fd,
const FeatureSet &features );
BaseMatInstance *mGlowMatInst;
};
SimObjectPtr<PostEffect> mGlowEffect;
RenderParticleMgr *mParticleRenderMgr;
};
#endif // _RENDERGLOWMGR_H_

View file

@ -35,7 +35,6 @@
#include "renderInstance/renderObjectMgr.h"
#include "renderInstance/renderMeshMgr.h"
#include "renderInstance/renderTranslucentMgr.h"
#include "renderInstance/renderGlowMgr.h"
#include "renderInstance/renderTerrainMgr.h"
#include "core/util/safeDelete.h"
#include "math/util/matrixSet.h"

View file

@ -57,15 +57,14 @@ bool SFXSndStream::_readHeader()
bitsPerSample = 8;
break;
case SF_FORMAT_PCM_16:
case SF_FORMAT_VORBIS:
bitsPerSample = 16;
break;
case SF_FORMAT_VORBIS:
case SF_FORMAT_PCM_24:
bitsPerSample = 24;
break;
case SF_FORMAT_PCM_32:
case SF_FORMAT_FLOAT:
bitsPerSample = 32;
bitsPerSample = 16;
sf_command(sndFile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE);
break;
default:
// missed, set it to 16 anyway.
@ -105,14 +104,46 @@ void SFXSndStream::reset()
U32 SFXSndStream::read(U8* buffer, U32 length)
{
if (!sndFile)
{
Con::errorf("SFXSndStream - read: Called on uninitialized stream.");
return 0;
}
U32 framesToRead = length / mFormat.getBytesPerSample();
U32 framesRead = 0;
framesRead = sf_readf_short(sndFile, (short*)buffer, sfinfo.frames);
if (framesRead != sfinfo.frames)
switch (sfinfo.format & SF_FORMAT_SUBMASK)
{
case SF_FORMAT_PCM_S8:
case SF_FORMAT_PCM_U8:
framesRead = sf_readf_int(sndFile, (int*)buffer, framesToRead);
break;
case SF_FORMAT_PCM_16:
case SF_FORMAT_VORBIS:
case SF_FORMAT_PCM_24:
case SF_FORMAT_PCM_32:
case SF_FORMAT_FLOAT:
framesRead = sf_readf_short(sndFile, (short*)buffer, framesToRead);
break;
default:
Con::errorf("SFXSndStream - read: Unsupported format.");
return 0;
}
if (framesRead != framesToRead)
{
Con::errorf("SFXSndStream - read: %s", sf_strerror(sndFile));
}
// (convert to frames) - number of frames available < MAX_BUFFER? reset
if (((getPosition() / mFormat.getBytesPerSample()) - sfinfo.frames) < MAX_BUFFER)
{
// reset stream
setPosition(0);
}
return framesRead * mFormat.getBytesPerSample();
}

View file

@ -2519,23 +2519,22 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
//****************************************************************************
// GlowMask
//****************************************************************************
void GlowMaskGLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
output = NULL;
// Get the output color... and make it black to mask out
// glow passes rendered before us.
//
// The shader compiler will optimize out all the other
// code above that doesn't contribute to the alpha mask.
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
if ( color )
output = new GenOp( " @.rgb = vec3(0);\r\n", color );
//determine output target
ShaderFeature::OutputTarget inTarg, outTarg;
inTarg = outTarg = ShaderFeature::DefaultTarget;
if (fd.features[MFT_isDeferred])
{
inTarg = ShaderFeature::RenderTarget1;
outTarg = ShaderFeature::RenderTarget3;
}
Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg));
Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg));
output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol);
}
//****************************************************************************
// RenderTargetZero
//****************************************************************************

View file

@ -552,11 +552,9 @@ public:
class GlowMaskGLSL : public ShaderFeatureGLSL
{
public:
void processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) override;
Material::BlendOp getBlendOp() override { return Material::None; }
String getName() override
{
return "Glow Mask";

View file

@ -2592,23 +2592,22 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
//****************************************************************************
// GlowMask
//****************************************************************************
void GlowMaskHLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
output = NULL;
// Get the output color... and make it black to mask out
// glow passes rendered before us.
//
// The shader compiler will optimize out all the other
// code above that doesn't contribute to the alpha mask.
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
if ( color )
output = new GenOp( " @.rgb = 0;\r\n", color );
//determine output target
ShaderFeature::OutputTarget inTarg, outTarg;
inTarg = outTarg = ShaderFeature::DefaultTarget;
if (fd.features[MFT_isDeferred])
{
inTarg = ShaderFeature::RenderTarget1;
outTarg = ShaderFeature::RenderTarget3;
}
Var* inCol = (Var*)LangElement::find(getOutputTargetVarName(inTarg));
Var* outCol = (Var*)LangElement::find(getOutputTargetVarName(outTarg));
output = new GenOp(" @.rgb += @.rgb*10;\r\n", outCol, inCol);
}
//****************************************************************************
// RenderTargetZero
//****************************************************************************

View file

@ -555,11 +555,9 @@ public:
class GlowMaskHLSL : public ShaderFeatureHLSL
{
public:
void processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd ) override;
Material::BlendOp getBlendOp() override { return Material::None; }
String getName() override
{
return "Glow Mask";

View file

@ -52,6 +52,7 @@ public:
const UTF8 *value(const UTF8 *settingName, const UTF8 *defaultValue = "");
void remove(const UTF8 *settingName, bool includeDefaults = false);
void clearAllFields();
void write(Stream& stream, U32 tabStop, U32 flags = 0) override { Con::errorf("Settings: Can Not write a file interface object to a file"); }; //Don't allow writing Settings objects *to* files
bool write();
bool read();
void readLayer(SimXMLDocument *document, String groupStack = String(""));

View file

@ -407,7 +407,7 @@ singleton PostEffect( DepthOfFieldPostFX )
enabled = false;
renderTime = "PFXAfterBin";
renderBin = "GlowBin";
renderBin = "FogBin";
renderPriority = 0.1;
shader = PFX_DOFDownSampleShader;

View file

@ -20,29 +20,6 @@
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
singleton ShaderData( PFX_GlowBlurVertShader )
{
DXVertexShaderFile = "./glowBlurV.hlsl";
DXPixelShaderFile = "./glowBlurP.hlsl";
OGLVertexShaderFile = "./glowBlurV.glsl";
OGLPixelShaderFile = "./glowBlurP.glsl";
defines = "BLUR_DIR=float2(0.0,1.0)";
samplerNames[0] = "$diffuseMap";
pixVersion = 2.0;
};
singleton ShaderData( PFX_GlowBlurHorzShader : PFX_GlowBlurVertShader )
{
defines = "BLUR_DIR=float2(1.0,0.0)";
};
singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
{
// Use alpha test to save some fillrate
@ -59,54 +36,6 @@ singleton GFXStateBlockData( PFX_GlowCombineStateBlock : PFX_DefaultStateBlock )
blendDest = GFXBlendOne;
};
singleton PostEffect( GlowPostFX )
{
// Do not allow the glow effect to work in reflection
// passes by default so we don't do the extra drawing.
allowReflectPass = false;
renderTime = "PFXAfterBin";
renderBin = "GlowBin";
renderPriority = 1;
// First we down sample the glow buffer.
shader = PFX_PassthruShader;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "#glowbuffer";
target = "$outTex";
targetScale = "0.5 0.5";
enabled = true;
// Blur vertically
new PostEffect()
{
shader = PFX_GlowBlurVertShader;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "$inTex";
target = "$outTex";
};
// Blur horizontally
new PostEffect()
{
shader = PFX_GlowBlurHorzShader;
stateBlock = PFX_DefaultStateBlock;
texture[0] = "$inTex";
target = "$outTex";
};
// Upsample and combine with the back buffer.
new PostEffect()
{
shader = PFX_PassthruShader;
stateBlock = PFX_GlowCombineStateBlock;
texture[0] = "$inTex";
target = "$backBuffer";
};
};
singleton ShaderData( PFX_VolFogGlowBlurVertShader )
{
DXVertexShaderFile = "./glowBlurV.hlsl";

View file

@ -48,7 +48,7 @@ singleton PostEffect( TurbulencePostFX )
allowReflectPass = true;
renderTime = "PFXAfterDiffuse";
renderBin = "GlowBin";
renderBin = "FogBin";
renderPriority = 0.5; // Render after the glows themselves
shader = PFX_TurbulenceShader;

View file

@ -79,10 +79,7 @@ function initRenderManager()
DiffuseRenderPassManager.addManager( new RenderTranslucentMgr(TranslucentBin){ renderOrder = 1.4; processAddOrder = 1.4; } );
DiffuseRenderPassManager.addManager(new RenderObjectMgr(FogBin){ bintype = "ObjectVolumetricFog"; renderOrder = 1.45; processAddOrder = 1.45; } );
// Note that the GlowPostFx is triggered after this bin.
DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );
// We render any editor stuff from this bin. Note that the HDR is
// completed before this bin to keep editor elements from tone mapping.
DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );