Browse Source

Allow underscores in k-parameters

rdb 17 years ago
parent
commit
772440c93c
1 changed files with 9 additions and 8 deletions
  1. 9 8
      panda/src/gobj/shader.cxx

+ 9 - 8
panda/src/gobj/shader.cxx

@@ -830,10 +830,11 @@ compile_parameter(const ShaderArgId  &arg_id,
   // Keywords to access constants.
   // Keywords to access constants.
 
 
   if (pieces[0] == "k") {
   if (pieces[0] == "k") {
-    if ((!cp_errchk_parameter_words(p,2)) ||
-        (!cp_errchk_parameter_in(p)) ||
+    if ((!cp_errchk_parameter_in(p)) ||
         (!cp_errchk_parameter_uniform(p)))
         (!cp_errchk_parameter_uniform(p)))
       return false;
       return false;
+    // In the case of k-parameters, we allow underscores in the name.
+    PT(InternalName) kinputname = InternalName::make(p._id._name.substr(2));
     switch (p._type) {
     switch (p._type) {
     case SAT_float4: {
     case SAT_float4: {
       ShaderMatSpec bind;
       ShaderMatSpec bind;
@@ -841,7 +842,7 @@ compile_parameter(const ShaderArgId  &arg_id,
       bind._piece = SMP_row3;
       bind._piece = SMP_row3;
       bind._func = SMF_first;
       bind._func = SMF_first;
       bind._part[0] = SMO_vec_constant_x;
       bind._part[0] = SMO_vec_constant_x;
-      bind._arg[0] = InternalName::make(pieces[1]);
+      bind._arg[0] = kinputname;
       bind._part[1] = SMO_identity;
       bind._part[1] = SMO_identity;
       bind._arg[1] = NULL;
       bind._arg[1] = NULL;
       cp_optimize_mat_spec(bind);
       cp_optimize_mat_spec(bind);
@@ -854,7 +855,7 @@ compile_parameter(const ShaderArgId  &arg_id,
       bind._piece = SMP_whole;
       bind._piece = SMP_whole;
       bind._func = SMF_first;
       bind._func = SMF_first;
       bind._part[0] = SMO_vec_constant_x;
       bind._part[0] = SMO_vec_constant_x;
-      bind._arg[0] = InternalName::make(pieces[1]);
+      bind._arg[0] = kinputname;
       bind._part[1] = SMO_identity;
       bind._part[1] = SMO_identity;
       bind._arg[1] = NULL;
       bind._arg[1] = NULL;
       cp_optimize_mat_spec(bind);
       cp_optimize_mat_spec(bind);
@@ -864,7 +865,7 @@ compile_parameter(const ShaderArgId  &arg_id,
     case SAT_sampler1d: {
     case SAT_sampler1d: {
       ShaderTexSpec bind;
       ShaderTexSpec bind;
       bind._id = arg_id;
       bind._id = arg_id;
-      bind._name = InternalName::make(pieces[1]);
+      bind._name = kinputname;
       bind._desired_type=Texture::TT_1d_texture;
       bind._desired_type=Texture::TT_1d_texture;
       _tex_spec.push_back(bind);
       _tex_spec.push_back(bind);
       break;
       break;
@@ -872,7 +873,7 @@ compile_parameter(const ShaderArgId  &arg_id,
     case SAT_sampler2d: {
     case SAT_sampler2d: {
       ShaderTexSpec bind;
       ShaderTexSpec bind;
       bind._id = arg_id;
       bind._id = arg_id;
-      bind._name = InternalName::make(pieces[1]);
+      bind._name = kinputname;
       bind._desired_type=Texture::TT_2d_texture;
       bind._desired_type=Texture::TT_2d_texture;
       _tex_spec.push_back(bind);
       _tex_spec.push_back(bind);
       break;
       break;
@@ -880,7 +881,7 @@ compile_parameter(const ShaderArgId  &arg_id,
     case SAT_sampler3d: {
     case SAT_sampler3d: {
       ShaderTexSpec bind;
       ShaderTexSpec bind;
       bind._id = arg_id;
       bind._id = arg_id;
-      bind._name = InternalName::make(pieces[1]);
+      bind._name = kinputname;
       bind._desired_type=Texture::TT_3d_texture;
       bind._desired_type=Texture::TT_3d_texture;
       _tex_spec.push_back(bind);
       _tex_spec.push_back(bind);
       break;
       break;
@@ -888,7 +889,7 @@ compile_parameter(const ShaderArgId  &arg_id,
     case SAT_samplercube: {
     case SAT_samplercube: {
       ShaderTexSpec bind;
       ShaderTexSpec bind;
       bind._id = arg_id;
       bind._id = arg_id;
-      bind._name = InternalName::make(pieces[1]);
+      bind._name = kinputname;
       bind._desired_type = Texture::TT_cube_map;
       bind._desired_type = Texture::TT_cube_map;
       _tex_spec.push_back(bind);
       _tex_spec.push_back(bind);
       break;
       break;