improved CodeParse in MaterialFileLoader.cpp

This commit is contained in:
hyzboy 2023-10-09 01:23:06 +08:00
parent 3a3f9d10b7
commit aaff0c23c9
No known key found for this signature in database
GPG Key ID: 067EE4525D4FB6D3

View File

@ -85,11 +85,41 @@ namespace
} }
};//struct MaterialStateParse };//struct MaterialStateParse
struct CodeParse:public MaterialFileParse
{
const char *start =nullptr;
const char *end =nullptr;
public:
bool OnLine(const char *text,const int len) override
{
if(!text||!*text||len<=0)
return(false);
if(*text=='{')
{
++text;
while(*text=='\r'||*text=='\n')++text;
start=text;
return(false);
}
if(*text=='}')
{
end=text;
return(true);
}
return(false);
}
};
struct MaterialInstanceStateParse:public MaterialFileParse struct MaterialInstanceStateParse:public MaterialFileParse
{ {
bool code =false; bool code =false;
const char * code_sp =nullptr; CodeParse code_parse;
const char * code_ep =nullptr;
uint mi_bytes =0; uint mi_bytes =0;
uint32_t shader_stage_flag_bits =0; uint32_t shader_stage_flag_bits =0;
@ -103,21 +133,8 @@ namespace
if(code) if(code)
{ {
if(*text=='{') if(code_parse.OnLine(text,len))
{
++text;
while(*text=='\r'||*text=='\n')++text;
code_sp=text;
return(true);
}
if(*text=='}')
{
code_ep=text;
code=false; code=false;
return(true);
}
} }
if(hgl::stricmp(text,"Code",4)==0) if(hgl::stricmp(text,"Code",4)==0)