From 9278348147dd630b2940a3097739b4a7117b9858 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 31 Jul 2009 06:17:25 +0000 Subject: [PATCH] Support structs in Cg shaders --- panda/src/gobj/shader.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/shader.cxx b/panda/src/gobj/shader.cxx index 29fd521c5b..742302e635 100755 --- a/panda/src/gobj/shader.cxx +++ b/panda/src/gobj/shader.cxx @@ -433,8 +433,18 @@ compile_parameter(const ShaderArgId &arg_id, if (p._id._name.size() == 0) return true; if (p._id._name[0] == '$') return true; + + // It could be inside a struct, strip off + // everything before the last dot. + size_t loc = p._id._name.find_last_of('.'); + string basename (p._id._name); + if (loc < string::npos) { + basename = p._id._name.substr(loc + 1); + } + + // Split it at the underscores. vector_string pieces; - tokenize(p._id._name, pieces, "_"); + tokenize(basename, pieces, "_"); if (pieces.size() < 2) { cp_report_error(p, "invalid parameter name"); @@ -910,7 +920,7 @@ compile_parameter(const ShaderArgId &arg_id, (!cp_errchk_parameter_uniform(p))) return false; // In the case of k-parameters, we allow underscores in the name. - PT(InternalName) kinputname = InternalName::make(p._id._name.substr(2)); + PT(InternalName) kinputname = InternalName::make(basename.substr(2)); switch (p._type) { case SAT_float1: case SAT_float2: