From e8fca5668c9fb58c69d6eb4c855d560bede90a83 Mon Sep 17 00:00:00 2001 From: Ed Swartz Date: Tue, 5 May 2015 10:33:01 -0500 Subject: [PATCH 1/4] Fix a rash of asserts from PNMImage::get_alpha_val -- originally the code had an explicit check for a missing alpha channel, that went away in 22120524a2f9a1f9330cdfa2b35bbcdf15d721d4 --- panda/src/gobj/texture.cxx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 279dcc41e2..a452ffa8a7 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -3071,10 +3071,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(); From 541c684114e5429ab68a1f8871c45e7aebde1f32 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 6 May 2015 15:46:16 +0200 Subject: [PATCH 2/4] Fix filename substitution in shader error reporting for first included file --- panda/src/gobj/shader.I | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/gobj/shader.I b/panda/src/gobj/shader.I index e101a07dfc..1c00d40197 100644 --- a/panda/src/gobj/shader.I +++ b/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]; } From bb98d8a8a0b7baf00cc7c46fceb564d5f70b74b7 Mon Sep 17 00:00:00 2001 From: Ed Swartz Date: Thu, 7 May 2015 09:39:48 -0500 Subject: [PATCH 3/4] Use model-path as a fallback for rocket asset lookup --- panda/src/rocket/rocketFileInterface.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index f7d91ee76f..04bc27c96a 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/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 (!fn.resolve_filename(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); From 1fb49dc3f7893cdb4ffd9a18fbbbffde978da595 Mon Sep 17 00:00:00 2001 From: Ed Swartz Date: Thu, 7 May 2015 15:32:13 -0500 Subject: [PATCH 4/4] Fix Rocket asset lookup to use VFS correctly for .p3d --- panda/src/rocket/rocketFileInterface.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/rocket/rocketFileInterface.cxx b/panda/src/rocket/rocketFileInterface.cxx index 04bc27c96a..ba519760f9 100644 --- a/panda/src/rocket/rocketFileInterface.cxx +++ b/panda/src/rocket/rocketFileInterface.cxx @@ -42,7 +42,7 @@ Open(const Rocket::Core::String& path) { PT(VirtualFile) file = _vfs->get_file(fn); if (file == NULL) { // failed? Try model-path as a Panda-friendly fallback. - if (!fn.resolve_filename(get_model_path())) { + 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;