浏览代码

Merge branch 'release/1.9.x'

rdb 10 年之前
父节点
当前提交
4486fda042
共有 3 个文件被更改,包括 23 次插入7 次删除
  1. 1 1
      panda/src/gobj/shader.I
  2. 10 4
      panda/src/gobj/texture.cxx
  3. 12 2
      panda/src/rocket/rocketFileInterface.cxx

+ 1 - 1
panda/src/gobj/shader.I

@@ -865,7 +865,7 @@ get_filename_from_index(int index, ShaderType type) const {
     if (!fn.empty()) {
       return fn;
     }
-  } else if (glsl_preprocess && index > 2048 &&
+  } else if (glsl_preprocess && index >= 2048 &&
              (index - 2048) < (int)_included_files.size()) {
     return _included_files[index - 2048];
   }

+ 10 - 4
panda/src/gobj/texture.cxx

@@ -3080,10 +3080,16 @@ do_read_one(CData *cdata, const Filename &fullpath, const Filename &alpha_fullpa
 
     if (alpha_file_channel == 4 ||
         (alpha_file_channel == 2 && alpha_image.get_num_channels() == 2)) {
-      // Use the alpha channel.
-      for (int x = 0; x < image.get_x_size(); x++) {
-        for (int y = 0; y < image.get_y_size(); y++) {
-          image.set_alpha(x, y, alpha_image.get_alpha(x, y));
+
+      if (!alpha_image.has_alpha()) {
+        gobj_cat.error()
+          << alpha_fullpath.get_basename() << " has no channel " << alpha_file_channel << ".\n";
+      } else {
+        // Use the alpha channel.
+        for (int x = 0; x < image.get_x_size(); x++) {
+          for (int y = 0; y < image.get_y_size(); y++) {
+            image.set_alpha(x, y, alpha_image.get_alpha(x, y));
+          }
         }
       }
       cdata->_alpha_file_channel = alpha_image.get_num_channels();

+ 12 - 2
panda/src/rocket/rocketFileInterface.cxx

@@ -41,8 +41,18 @@ Open(const Rocket::Core::String& path) {
 
   PT(VirtualFile) file = _vfs->get_file(fn);
   if (file == NULL) {
-    rocket_cat.error() << "Failed to find " << fn << "\n";
-    return (Rocket::Core::FileHandle) NULL;
+    // failed?  Try model-path as a Panda-friendly fallback.
+    if (!_vfs->resolve_filename(fn, get_model_path())) {
+      rocket_cat.error() << "Could not resolve " << fn
+          << " along the model-path (currently: " << get_model_path() << ")\n";
+      return (Rocket::Core::FileHandle) NULL;
+    }
+
+    file = _vfs->get_file(fn);
+    if (file == NULL) {
+      rocket_cat.error() << "Failed to get " << fn << ", found on model-path\n";
+      return (Rocket::Core::FileHandle) NULL;
+    }
   }
 
   istream *str = file->open_read_file(true);