Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions panda/src/audio/audioManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "config_audio.h"
#include "audioManager.h"
#include "atomicAdjust.h"
#include "nullAudioManager.h"
#include "windowsRegistry.h"
#include "virtualFileSystem.h"
Expand Down Expand Up @@ -123,17 +122,17 @@ 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);
}
}

/**
*
*/
AudioManager::
AudioManager() {
_null_sound = nullptr;
AudioManager() : _null_sound(nullptr) {
}

/**
Expand All @@ -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;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions panda/src/audio/audioManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "luse.h"
#include "filterProperties.h"
#include "movieAudio.h"
#include "atomicAdjust.h"
#include "patomic.h"

typedef AudioManager *Create_AudioManager_proc();

Expand Down Expand Up @@ -187,7 +187,7 @@ class EXPCL_PANDA_AUDIO AudioManager : public TypedReferenceCount {
// flexibility.

static Create_AudioManager_proc* _create_AudioManager;
AtomicAdjust::Pointer _null_sound;
patomic<AudioSound *> _null_sound;

AudioManager();

Expand Down
4 changes: 2 additions & 2 deletions panda/src/grutil/shaderTerrainMesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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."));
Expand Down
28 changes: 16 additions & 12 deletions panda/src/pgraph/pandaNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<CPT(BoundingVolume) > child_volumes_ref;
if (update_bounds) {
Expand Down Expand Up @@ -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
Expand Down
43 changes: 34 additions & 9 deletions panda/src/windisplay/winGraphicsWindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;

Expand Down
Loading