This will be useless soon enough but if anyone hasn’t update one of there old glsl POPs to the new function naming scheme here is a regex to do so
i(?:(\d+)|(?=[A-Za-z]))([A-Za-z_]\w*)\[(\w+)\](?:\[(\w+)\])?(?!\s*=)
TDIn_\2\((?{1}\1:0),\3(?{4},\4:)\)
you’ll need support for conditional regexes a la Boost extended format string syntax
I did this in notepad++
4 Likes
and the beginning of a perl script for the glsl advanced since this is a bit more complex
#!/usr/bin/perl
use strict;
use warnings;
my %prefix_map = (
pt => "Point",
prim => "Prim",
vert => "Vert",
);
my @lines = <>;
foreach my $line (@lines) {
# Replace TDPrimID() with id
$line =~ s/\bTDPrimID\(\)/id/g;
# Special cases
$line =~ s/\biI\[(\w+)\]/TDInputPointIndex(0, $1)/g;
$line =~ s/\bTDVertsStartID\(\)/TDInputPrimVertsStartIndex()/g;
$line =~ s/\bTDNumVertsPerPrim\(\)/TDInputNumVertsPerPrim()/g;
# LHS assignment: oTD output
$line =~ s/\b(pt|prim|vert)([A-Z]\w*)\s*\[\s*([^\]]+?)\s*\](\.\w+)?(?=\s*=)/
"oTD" . $prefix_map{$1} . "_$2\[$3\]" . ($4 ? $4 : '')
/ge;
# RHS and general: TDIn input
$line =~ s/\bi(pt|prim|vert)([A-Z]\w*)\s*\[\s*([^\]]+)\s*\]/"TDIn" . $prefix_map{$1} . "_$2(0, $3)"/ge;
print $line;
}
3 Likes