diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index 39f75883076..4bae8f42e15 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -14,7 +14,6 @@ #include "config_audio.h" #include "audioManager.h" -#include "atomicAdjust.h" #include "nullAudioManager.h" #include "windowsRegistry.h" #include "virtualFileSystem.h" @@ -123,8 +122,9 @@ PT(AudioManager) AudioManager::create_AudioManager() { */ AudioManager:: ~AudioManager() { - if (_null_sound != nullptr) { - unref_delete((AudioSound *)_null_sound); + AudioSound *null_sound = _null_sound.load(std::memory_order_acquire); + if (null_sound != nullptr) { + unref_delete(null_sound); } } @@ -132,8 +132,7 @@ AudioManager:: * */ AudioManager:: -AudioManager() { - _null_sound = nullptr; +AudioManager() : _null_sound(nullptr) { } /** @@ -153,19 +152,21 @@ shutdown() { */ PT(AudioSound) AudioManager:: get_null_sound() { - if (_null_sound == nullptr) { - AudioSound *new_sound = new NullAudioSound; - new_sound->ref(); - void *result = AtomicAdjust::compare_and_exchange_ptr(_null_sound, nullptr, (void *)new_sound); - if (result != nullptr) { + AudioSound *sound = _null_sound.load(std::memory_order_acquire); + + if (sound == nullptr) { + sound = new NullAudioSound; + sound->ref(); + AudioSound *old_sound = nullptr; + if (!_null_sound.compare_exchange_strong(old_sound, sound, std::memory_order_release, std::memory_order_acquire)) { // Someone else must have assigned the AudioSound first. OK. - nassertr(_null_sound != new_sound, nullptr); - unref_delete(new_sound); + unref_delete(sound); + sound = old_sound; } - nassertr(_null_sound != nullptr, nullptr); + nassertr(sound != nullptr, nullptr); } - return (AudioSound *)_null_sound; + return sound; } /** diff --git a/panda/src/audio/audioManager.h b/panda/src/audio/audioManager.h index a94fd8f2b6a..76bfb36a2a8 100644 --- a/panda/src/audio/audioManager.h +++ b/panda/src/audio/audioManager.h @@ -20,7 +20,7 @@ #include "luse.h" #include "filterProperties.h" #include "movieAudio.h" -#include "atomicAdjust.h" +#include "patomic.h" typedef AudioManager *Create_AudioManager_proc(); @@ -187,7 +187,7 @@ class EXPCL_PANDA_AUDIO AudioManager : public TypedReferenceCount { // flexibility. static Create_AudioManager_proc* _create_AudioManager; - AtomicAdjust::Pointer _null_sound; + patomic _null_sound; AudioManager(); diff --git a/panda/src/grutil/shaderTerrainMesh.cxx b/panda/src/grutil/shaderTerrainMesh.cxx index 4b42a359384..cd128e77711 100644 --- a/panda/src/grutil/shaderTerrainMesh.cxx +++ b/panda/src/grutil/shaderTerrainMesh.cxx @@ -46,13 +46,13 @@ ConfigVariableBool stm_use_hexagonal_layout "visible due to the vertices not matching exactly.")); ConfigVariableInt stm_max_chunk_count -("stm-max-chunk-count", 2048, +("stm-max-chunk-count", 1024, PRC_DESC("Controls the maximum amount of chunks the Terrain can display. If you use " "a high LOD, you might have to increment this value. The lower this value is " "the less data has to be transferred to the GPU.")); ConfigVariableInt stm_max_views -("stm-max-views", 8, +("stm-max-views", 4, PRC_DESC("Controls the maximum amount of different views the Terrain can be rendered " "with. Each camera rendering the terrain corresponds to a view. Lowering this " "value will reduce the data that has to be transferred to the GPU.")); diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 037410a7cf4..e71e4bae439 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -3289,7 +3289,7 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe // environment the pointers might go away while we're working (since we're // not holding a lock on our set of children right now). But we also need // the regular pointers, to pass to BoundingVolume::around(). - const BoundingVolume **child_volumes; + const BoundingVolume **child_volumes = nullptr; #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) pvector child_volumes_ref; if (update_bounds) { @@ -3353,17 +3353,21 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe // the pairing of the corresponding bit from the control mask and // from the show mask: - // 00 : not a renderable node (control 0, show 0) 01 : a normally - // visible node (control 0, show 1) 10 : a hidden node - // (control 1, show 0) 11 : a show-through node (control 1, show - // 1) - - // Now, when we accumulate these masks, we want to do so according - // to the following table, for each bit position: - - // 00 01 10 11 (child) --------------------- 00 | 00 01 - // 10 11 01 | 01 01 01* 11 10 | 10 01* 10 11 11 | 11 - // 11 11 11 (parent) + // 00 : not a renderable node (control 0, show 0) + // 01 : a normally visible node (control 0, show 1) + // 10 : a hidden node (control 1, show 0) + // 11 : a show-through node (control 1, show 1) + + // Now, when we accumulate these masks, we want to do so + // according to the following table, for each bit position: + + // 00 01 10 11 (child) + // --------------------- + // 00 | 00 01 10 11 + // 01 | 01 01 01* 11 + // 10 | 10 01* 10 11 + // 11 | 11 11 11 11 + // (parent) // This table is almost the same as the union of both masks, with // one exception, marked with a * in the above table: if one is 10 diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 266722aa1bd..ee97911e66d 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2149,11 +2149,12 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { get_message_time()); handle_raw_keypress(lookup_raw_key(lparam), get_message_time()); - // wparam does not contain leftright information for SHIFT, CONTROL, or + // wparam does not contain left/right information for SHIFT, CONTROL, or // ALT, so we have to track their status and do the right thing. We'll - // send the leftright specific key event along with the general key + // send the left/right-specific key event along with the general key // event. - if (wparam == VK_SHIFT) { + switch (wparam) { + case VK_SHIFT: if ((GetKeyState(VK_LSHIFT) & 0x8000) != 0 && ! _lshift_down) { handle_keypress(KeyboardButton::lshift(), point.x, point.y, get_message_time()); @@ -2164,7 +2165,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { get_message_time()); _rshift_down = true; } - } else if(wparam == VK_CONTROL) { + break; + + case VK_CONTROL: if ((GetKeyState(VK_LCONTROL) & 0x8000) != 0 && ! _lcontrol_down) { handle_keypress(KeyboardButton::lcontrol(), point.x, point.y, get_message_time()); @@ -2175,6 +2178,15 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { get_message_time()); _rcontrol_down = true; } + break; + + case VK_LWIN: + case VK_RWIN: + // The opposite problem: there is no VK_WIN sent, so we explicitly have + // to send a generic meta() event. + handle_keypress(KeyboardButton::meta(), point.x, point.y, + get_message_time()); + break; } // Handle Cntrl-V paste from clipboard. Is there a better way to detect @@ -2274,10 +2286,11 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_keyrelease(lookup_key(wparam), get_message_time()); handle_raw_keyrelease(lookup_raw_key(lparam), get_message_time()); - // wparam does not contain leftright information for SHIFT, CONTROL, or + // wparam does not contain left/right information for SHIFT, CONTROL, or // ALT, so we have to track their status and do the right thing. We'll - // send the leftright specific key event along with the general key event. - if (wparam == VK_SHIFT) { + // send the left/right specific key event along with the general key event. + switch (wparam) { + case VK_SHIFT: if ((GetKeyState(VK_LSHIFT) & 0x8000) == 0 && _lshift_down) { handle_keyrelease(KeyboardButton::lshift(), get_message_time()); _lshift_down = false; @@ -2286,7 +2299,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_keyrelease(KeyboardButton::rshift(), get_message_time()); _rshift_down = false; } - } else if(wparam == VK_CONTROL) { + break; + + case VK_CONTROL: if ((GetKeyState(VK_LCONTROL) & 0x8000) == 0 && _lcontrol_down) { handle_keyrelease(KeyboardButton::lcontrol(), get_message_time()); _lcontrol_down = false; @@ -2295,7 +2310,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_keyrelease(KeyboardButton::rcontrol(), get_message_time()); _rcontrol_down = false; } - } else if(wparam == VK_MENU) { + break; + + case VK_MENU: if ((GetKeyState(VK_LMENU) & 0x8000) == 0 && _lalt_down) { handle_keyrelease(KeyboardButton::lalt(), get_message_time()); _lalt_down = false; @@ -2304,6 +2321,14 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { handle_keyrelease(KeyboardButton::ralt(), get_message_time()); _ralt_down = false; } + break; + + case VK_LWIN: + case VK_RWIN: + // The opposite problem: there is no VK_WIN sent, so we explicitly have + // to send the generic meta() event here. + handle_keyrelease(KeyboardButton::meta(), get_message_time()); + break; } break;