Cleaned up and refactored some code
This commit is contained in:
parent
57328bc9a3
commit
ad6d2add1b
7 changed files with 135 additions and 110 deletions
23
src/ShaderDirectiveParser.gd
Normal file
23
src/ShaderDirectiveParser.gd
Normal file
|
@ -0,0 +1,23 @@
|
|||
extends Node
|
||||
|
||||
var _load_regex: RegEx
|
||||
var _load_additional_regex: RegEx
|
||||
|
||||
func _ready():
|
||||
self._load_regex = RegEx.new()
|
||||
self._load_additional_regex = RegEx.new()
|
||||
self._load_regex.compile(r'\/\/!load\s(.*)')
|
||||
self._load_additional_regex.compile(r'\/\/!load\+\s(\w*)\s(.*)')
|
||||
|
||||
func parse_load_directive(shader: Shader) -> PackedStringArray:
|
||||
var regex_match = self._load_regex.search(Filesystem.shader.code)
|
||||
if regex_match == null: # Error!
|
||||
printerr("Didn't find any load directives!")
|
||||
return []
|
||||
return regex_match.strings
|
||||
|
||||
func parse_load_additional_directive(shader: Shader) -> Array[PackedStringArray]:
|
||||
var results : Array[PackedStringArray] = []
|
||||
for m in self._load_additional_regex.search_all(shader.code):
|
||||
results.append(m.strings)
|
||||
return results
|
Loading…
Add table
Add a link
Reference in a new issue