From 3963c5de043ca6d34eab5c908a5bea4f30322c26 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 11:43:33 +0100 Subject: [PATCH 1/5] x11: fix raw key down being sent repeatedly when holding key Fixes #874 --- panda/src/x11display/x11GraphicsWindow.cxx | 30 +++++++++++++++++++++- panda/src/x11display/x11GraphicsWindow.h | 1 + 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/panda/src/x11display/x11GraphicsWindow.cxx b/panda/src/x11display/x11GraphicsWindow.cxx index 2d6b75740f..b0d85e24ac 100644 --- a/panda/src/x11display/x11GraphicsWindow.cxx +++ b/panda/src/x11display/x11GraphicsWindow.cxx @@ -329,7 +329,7 @@ process_events() { // We thought about not generating the keypress event, but we need // that repeat for backspace. Rethink later. - handle_keypress(event.xkey); + handle_keyrepeat(event.xkey); continue; } else { @@ -1499,6 +1499,34 @@ handle_keypress(XKeyEvent &event) { } } +/** + * Generates a keyrepeat corresponding to the indicated X KeyPress event. + */ +void x11GraphicsWindow:: +handle_keyrepeat(XKeyEvent &event) { + if (_properties.get_mouse_mode() != WindowProperties::M_relative) { + _input->set_pointer_in_window(event.x, event.y); + } + + // Now get the raw unshifted button. + ButtonHandle button = get_button(event, false); + if (button != ButtonHandle::none()) { + if (button == KeyboardButton::lcontrol() || button == KeyboardButton::rcontrol()) { + _input->button_down(KeyboardButton::control()); + } + if (button == KeyboardButton::lshift() || button == KeyboardButton::rshift()) { + _input->button_down(KeyboardButton::shift()); + } + if (button == KeyboardButton::lalt() || button == KeyboardButton::ralt()) { + _input->button_down(KeyboardButton::alt()); + } + if (button == KeyboardButton::lmeta() || button == KeyboardButton::rmeta()) { + _input->button_down(KeyboardButton::meta()); + } + _input->button_down(button); + } +} + /** * Generates a keyrelease corresponding to the indicated X KeyRelease event. */ diff --git a/panda/src/x11display/x11GraphicsWindow.h b/panda/src/x11display/x11GraphicsWindow.h index f512b16a19..56235d96df 100644 --- a/panda/src/x11display/x11GraphicsWindow.h +++ b/panda/src/x11display/x11GraphicsWindow.h @@ -59,6 +59,7 @@ protected: virtual void setup_colormap(XVisualInfo *visual); void handle_keystroke(XKeyEvent &event); void handle_keypress(XKeyEvent &event); + void handle_keyrepeat(XKeyEvent &event); void handle_keyrelease(XKeyEvent &event); ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift); From f98c14c2907e85f7fb11af08e8c43f9d99053dee Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 12:10:20 +0100 Subject: [PATCH 2/5] tform: prevent MouseWatcherRegion leave event being fired twice Fixes #858 --- panda/src/tform/mouseWatcher.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/panda/src/tform/mouseWatcher.cxx b/panda/src/tform/mouseWatcher.cxx index 9344d51d7d..74cb7692d3 100644 --- a/panda/src/tform/mouseWatcher.cxx +++ b/panda/src/tform/mouseWatcher.cxx @@ -726,6 +726,9 @@ clear_current_regions() { MouseWatcherRegion *old_region = (*old_ri); old_region->exit_region(param); throw_event_pattern(_leave_pattern, old_region, ButtonHandle::none()); + if (_preferred_region == old_region) { + _preferred_region = nullptr; + } ++old_ri; } From 1c357f32cae2576bf33116ee58619e57d3aff65d Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 15:08:05 +0100 Subject: [PATCH 3/5] putil: fix asserts when model-cache-dir cannot be created Fixes #790 --- panda/src/express/virtualFileSystem.cxx | 3 +-- panda/src/putil/bamCache.cxx | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/panda/src/express/virtualFileSystem.cxx b/panda/src/express/virtualFileSystem.cxx index eda84c4075..1e279fc2c4 100644 --- a/panda/src/express/virtualFileSystem.cxx +++ b/panda/src/express/virtualFileSystem.cxx @@ -497,8 +497,7 @@ make_directory_full(const Filename &filename) { // Now make the last one, and check the return value. PT(VirtualFile) result = do_get_file(filename, OF_make_directory); _lock.unlock(); - nassertr_always(result != nullptr, false); - return result->is_directory(); + return (result != nullptr) ? result->is_directory() : false; } /** diff --git a/panda/src/putil/bamCache.cxx b/panda/src/putil/bamCache.cxx index 4dbcf06966..88f993825b 100644 --- a/panda/src/putil/bamCache.cxx +++ b/panda/src/putil/bamCache.cxx @@ -133,10 +133,16 @@ set_root(const Filename &root) { delete _index; _index = new BamCacheIndex; _index_stale_since = 0; + + if (!vfs->is_directory(_root)) { + util_cat.error() + << "Unable to make directory " << _root << ", caching disabled.\n"; + _active = false; + return; + } + read_index(); check_cache_size(); - - nassertv(vfs->is_directory(_root)); } /** From 9431d5013f5a7a477b2ede37cc6562a4edeba6d7 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 16:21:47 +0100 Subject: [PATCH 4/5] ShaderGenerator: fix texture transforms applied to normal map Fixes #808 --- panda/src/pgraphnodes/shaderGenerator.cxx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraphnodes/shaderGenerator.cxx b/panda/src/pgraphnodes/shaderGenerator.cxx index 7198024648..455f4d4be6 100644 --- a/panda/src/pgraphnodes/shaderGenerator.cxx +++ b/panda/src/pgraphnodes/shaderGenerator.cxx @@ -1241,12 +1241,23 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) { const ShaderKey::TextureInfo &tex = key._textures[i]; if (tex._flags & ShaderKey::TF_map_normal) { if (is_first) { - text << "\t float3 tsnormal = normalize((tex" << i << ".xyz * 2) - 1);\n"; + if (tex._flags & ShaderKey::TF_has_texscale) { + text << "\t float3 tsnormal = normalize(((tex" << i << ".xyz * 2) - 1) * texscale_" << i << ");\n"; + } else if (tex._flags & ShaderKey::TF_has_texmat) { + text << "\t float3 tsnormal = normalize(mul(texmat_" << i << ", float4((tex" << i << ".xyz * 2) - 1, 0)).xyz);\n"; + } else { + text << "\t float3 tsnormal = normalize((tex" << i << ".xyz * 2) - 1);\n"; + } is_first = false; continue; } text << "\t tsnormal.z += 1;\n"; text << "\t float3 tmp" << i << " = tex" << i << ".xyz * float3(-2, -2, 2) + float3(1, 1, -1);\n"; + if (tex._flags & ShaderKey::TF_has_texscale) { + text << "\t tmp" << i << " *= texscale_" << i << ";\n"; + } else if (tex._flags & ShaderKey::TF_has_texmat) { + text << "\t tmp" << i << " = mul(texmat_" << i << ", float4(tmp" << i << ", 0)).xyz;\n"; + } text << "\t tsnormal = normalize(tsnormal * dot(tsnormal, tmp" << i << ") - tmp" << i << " * tsnormal.z);\n"; } } From 54ff2a8dda972be4e3849da9362a61b2c8e95a13 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 29 Feb 2020 16:55:14 +0100 Subject: [PATCH 5/5] makepanda: support --cggl-incdir and --cggl-libdir options It's quite hacky right now, but that doesn't matter as we're switching to CMake anyway --- makepanda/makepanda.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 4af9d6402b..8f04251970 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -188,6 +188,7 @@ def parseopts(args): "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=", "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl", "universal", "target=", "arch=", "git-commit=", "no-copy-python", + "cggl-incdir=", "cggl-libdir=", ] + removedopts anything = 0 @@ -257,7 +258,7 @@ def parseopts(args): elif (option[2:] in removedopts): Warn("Ignoring removed option %s" % (option)) else: - for pkg in PkgListGet(): + for pkg in PkgListGet() + ['CGGL']: if option == "--use-" + pkg.lower(): PkgEnable(pkg) break