Kaynağa Gözat

ignore directories as texture filenames

David Rose 21 yıl önce
ebeveyn
işleme
c292cfc628

+ 2 - 2
pandatool/src/maya/mayaShader.cxx

@@ -166,7 +166,7 @@ read_surface_shader(MObject shader) {
     color_plug.connectedTo(color_pa, true, false);
 
     for (size_t i = 0; i < color_pa.length(); i++) {
-      _color.read_surface_color(color_pa[0].node());
+      _color.read_surface_color(this, color_pa[0].node());
     }
   }
 
@@ -181,7 +181,7 @@ read_surface_shader(MObject shader) {
     trans_plug.connectedTo(trans_pa, true, false);
 
     for (size_t i = 0; i < trans_pa.length(); i++) {
-      _transparency.read_surface_color(trans_pa[0].node());
+      _transparency.read_surface_color(this, trans_pa[0].node());
     }
   }
 

+ 10 - 2
pandatool/src/maya/mayaShaderColorDef.cxx

@@ -17,6 +17,7 @@
 ////////////////////////////////////////////////////////////////////
 
 #include "mayaShaderColorDef.h"
+#include "mayaShader.h"
 #include "maya_funcs.h"
 #include "config_maya.h"
 #include "string_utils.h"
@@ -181,7 +182,7 @@ reset_maya_texture(const Filename &texture) {
 //               properties.
 ////////////////////////////////////////////////////////////////////
 void MayaShaderColorDef::
-read_surface_color(MObject color) {
+read_surface_color(const MayaShader *shader, MObject color) {
   RGBColorf color_gain;
   if (get_vec3f_attribute(color, "colorGain", color_gain)) {
     _color_gain[0] *= color_gain[0];
@@ -199,6 +200,13 @@ read_surface_color(MObject color) {
     _has_texture = get_string_attribute(color, "fileTextureName", filename);
     if (_has_texture) {
       _texture = Filename::from_os_specific(filename);
+      if (_texture.is_directory()) {
+        maya_cat.warning()
+          << "Shader " << shader->get_name() 
+          << " references texture filename " << filename
+          << " which is a directory; ignoring.\n";
+        _has_texture = false;
+      }
     }
 
     get_vec2f_attribute(color, "coverage", _coverage);
@@ -224,7 +232,7 @@ read_surface_color(MObject color) {
       image_plug.connectedTo(image_pa, true, false);
       
       for (size_t i = 0; i < image_pa.length(); i++) {
-        read_surface_color(image_pa[0].node());
+        read_surface_color(shader, image_pa[0].node());
       }
     }
 

+ 2 - 1
pandatool/src/maya/mayaShaderColorDef.h

@@ -25,6 +25,7 @@
 #include "lmatrix.h"
 
 class MObject;
+class MayaShader;
 
 ////////////////////////////////////////////////////////////////////
 //       Class : MayaShaderColorDef
@@ -82,7 +83,7 @@ public:
   double _rotate_uv;
   
 private:
-  void read_surface_color(MObject color);
+  void read_surface_color(const MayaShader *shader, MObject color);
   void set_projection_type(const string &type);
 
   LPoint2d map_planar(const LPoint3d &pos, const LPoint3d &centroid) const;