Merge remote-tracking branch 'upstream/master'

This commit is contained in:
John Cote 2024-11-19 22:08:41 -05:00
commit 47e257eedb
5 changed files with 60 additions and 7 deletions

View File

@ -19,6 +19,7 @@
#include "renderState.h"
#include "cullFaceAttrib.h"
#include "colorWriteAttrib.h"
#include "lightAttrib.h"
#include "graphicsStateGuardianBase.h"
TypeHandle LightLensNode::_type_handle;
@ -37,10 +38,14 @@ LightLensNode(const std::string &name, Lens *lens) :
_shadow_caster = false;
_sb_size.set(512, 512);
_sb_sort = -10;
// set_initial_state(RenderState::make(ShaderAttrib::make_off(), 1000));
// Backface culling helps eliminating artifacts.
set_initial_state(RenderState::make(CullFaceAttrib::make_reverse(),
ColorWriteAttrib::make(ColorWriteAttrib::C_off)));
static CPT(RenderState) default_initial_state =
RenderState::make(
CullFaceAttrib::make_reverse(),
ColorWriteAttrib::make(ColorWriteAttrib::C_off)
)->set_attrib(LightAttrib::make_all_off(), RenderState::get_max_priority());
set_initial_state(default_initial_state);
}
/**

View File

@ -89,12 +89,16 @@ get_num_off_bits() const {
/**
* Returns the index of the lowest 1 bit in the array. Returns -1 if there
* are no 1 bits or if there are an infinite number of 1 bits.
* are no 1 bits and 0 if there are an infinite number of 1 bits.
*/
int SparseArray::
get_lowest_on_bit() const {
if (_inverse) {
return -1;
if (_subranges.empty() || _subranges[0]._begin > 0) {
return 0;
} else {
return _subranges[0]._end;
}
}
if (_subranges.empty()) {
@ -111,7 +115,11 @@ get_lowest_on_bit() const {
int SparseArray::
get_lowest_off_bit() const {
if (!_inverse) {
return -1;
if (_subranges.empty() || _subranges[0]._begin > 0) {
return 0;
} else {
return _subranges[0]._end;
}
}
if (_subranges.empty()) {

View File

@ -1368,6 +1368,11 @@ adjust_z_order() {
void WinGraphicsWindow::
adjust_z_order(WindowProperties::ZOrder last_z_order,
WindowProperties::ZOrder this_z_order) {
// Prevent calling this recursively.
if (_in_adjust_z_order) {
return;
}
HWND order;
bool do_change = false;
@ -1397,8 +1402,10 @@ adjust_z_order(WindowProperties::ZOrder last_z_order,
break;
}
if (do_change) {
_in_adjust_z_order = true;
BOOL result = SetWindowPos(_hWnd, order, 0,0,0,0,
SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE);
_in_adjust_z_order = false;
if (!result) {
windisplay_cat.warning()
<< "SetWindowPos failed.\n";
@ -1690,7 +1697,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
if (_hWnd != nullptr) {
handle_reshape();
}
adjust_z_order();
if (!_in_adjust_z_order) {
adjust_z_order();
}
return 0;
case WM_PAINT:

View File

@ -199,6 +199,8 @@ private:
UINT _num_touches;
TOUCHINPUT _touches[MAX_TOUCHES];
bool _in_adjust_z_order = false;
private:
// We need this map to support per-window calls to window_proc().
typedef std::map<HWND, WinGraphicsWindow *> WindowHandles;

View File

@ -251,6 +251,35 @@ def test_sparse_array_nonzero():
assert sa
def test_sparse_array_lowest_bit():
sa = core.SparseArray()
assert sa.get_lowest_off_bit() == 0
assert sa.get_lowest_on_bit() == -1
sa.invert_in_place()
assert sa.get_lowest_off_bit() == -1
assert sa.get_lowest_on_bit() == 0
sa = core.SparseArray()
sa.set_bit(0)
sa.set_bit(1)
assert sa.get_lowest_off_bit() == 2
assert sa.get_lowest_on_bit() == 0
sa.invert_in_place()
assert sa.get_lowest_off_bit() == 0
assert sa.get_lowest_on_bit() == 2
sa = core.SparseArray()
sa.set_bit(2)
assert sa.get_lowest_off_bit() == 0
assert sa.get_lowest_on_bit() == 2
sa.invert_in_place()
assert sa.get_lowest_off_bit() == 2
assert sa.get_lowest_on_bit() == 0
def test_sparse_array_getstate():
sa = core.SparseArray()
assert sa.__getstate__() == ()