mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
Use a bitmask for storing clear-active flags
This commit is contained in:
parent
2b7ef9c787
commit
d3071d1e50
@ -17,10 +17,10 @@
|
|||||||
INLINE DrawableRegion::
|
INLINE DrawableRegion::
|
||||||
DrawableRegion() :
|
DrawableRegion() :
|
||||||
_screenshot_buffer_type(RenderBuffer::T_front),
|
_screenshot_buffer_type(RenderBuffer::T_front),
|
||||||
_draw_buffer_type(RenderBuffer::T_back)
|
_draw_buffer_type(RenderBuffer::T_back),
|
||||||
|
_clear_mask(0)
|
||||||
{
|
{
|
||||||
for (int i=0; i<RTP_COUNT; i++) {
|
for (int i = 0; i < RTP_COUNT; ++i) {
|
||||||
_clear_active[i] = false;
|
|
||||||
_clear_value[i] = LColor(0.0f, 0.0f, 0.0f, 0.0f);
|
_clear_value[i] = LColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
_clear_value[RTP_depth] = LColor(1.0f,1.0f,1.0f,1.0f);
|
_clear_value[RTP_depth] = LColor(1.0f,1.0f,1.0f,1.0f);
|
||||||
@ -35,11 +35,11 @@ INLINE DrawableRegion::
|
|||||||
DrawableRegion(const DrawableRegion ©) :
|
DrawableRegion(const DrawableRegion ©) :
|
||||||
_screenshot_buffer_type(copy._screenshot_buffer_type),
|
_screenshot_buffer_type(copy._screenshot_buffer_type),
|
||||||
_draw_buffer_type(copy._draw_buffer_type),
|
_draw_buffer_type(copy._draw_buffer_type),
|
||||||
|
_clear_mask(copy._clear_mask),
|
||||||
_pixel_zoom(copy._pixel_zoom),
|
_pixel_zoom(copy._pixel_zoom),
|
||||||
_pixel_factor(copy._pixel_factor)
|
_pixel_factor(copy._pixel_factor)
|
||||||
{
|
{
|
||||||
for (int i=0; i<RTP_COUNT; i++) {
|
for (int i = 0; i < RTP_COUNT; ++i) {
|
||||||
_clear_active[i] = copy._clear_active[i];
|
|
||||||
_clear_value[i] = copy._clear_value[i];
|
_clear_value[i] = copy._clear_value[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -51,8 +51,8 @@ INLINE void DrawableRegion::
|
|||||||
operator = (const DrawableRegion ©) {
|
operator = (const DrawableRegion ©) {
|
||||||
_screenshot_buffer_type = copy._screenshot_buffer_type;
|
_screenshot_buffer_type = copy._screenshot_buffer_type;
|
||||||
_draw_buffer_type = copy._draw_buffer_type;
|
_draw_buffer_type = copy._draw_buffer_type;
|
||||||
for (int i=0; i<RTP_COUNT; i++) {
|
_clear_mask = copy._clear_mask;
|
||||||
_clear_active[i] = copy._clear_active[i];
|
for (int i = 0; i < RTP_COUNT; ++i) {
|
||||||
_clear_value[i] = copy._clear_value[i];
|
_clear_value[i] = copy._clear_value[i];
|
||||||
}
|
}
|
||||||
_pixel_zoom = copy._pixel_zoom;
|
_pixel_zoom = copy._pixel_zoom;
|
||||||
@ -64,8 +64,8 @@ operator = (const DrawableRegion ©) {
|
|||||||
*/
|
*/
|
||||||
INLINE void DrawableRegion::
|
INLINE void DrawableRegion::
|
||||||
copy_clear_settings(const DrawableRegion ©) {
|
copy_clear_settings(const DrawableRegion ©) {
|
||||||
for (int i=0; i<RTP_COUNT; i++) {
|
_clear_mask = copy._clear_mask;
|
||||||
_clear_active[i] = copy._clear_active[i];
|
for (int i = 0; i < RTP_COUNT; ++i) {
|
||||||
_clear_value[i] = copy._clear_value[i];
|
_clear_value[i] = copy._clear_value[i];
|
||||||
}
|
}
|
||||||
update_pixel_factor();
|
update_pixel_factor();
|
||||||
|
@ -27,8 +27,12 @@ DrawableRegion::
|
|||||||
*/
|
*/
|
||||||
void DrawableRegion::
|
void DrawableRegion::
|
||||||
set_clear_active(int n, bool clear_active) {
|
set_clear_active(int n, bool clear_active) {
|
||||||
nassertv((n >= 0)&&(n < RTP_COUNT));
|
nassertv(n >= 0 && n < RTP_COUNT);
|
||||||
_clear_active[n] = clear_active;
|
if (clear_active) {
|
||||||
|
_clear_mask |= 1 << n;
|
||||||
|
} else {
|
||||||
|
_clear_mask &= ~(1 << n);
|
||||||
|
}
|
||||||
update_pixel_factor();
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +41,8 @@ set_clear_active(int n, bool clear_active) {
|
|||||||
*/
|
*/
|
||||||
bool DrawableRegion::
|
bool DrawableRegion::
|
||||||
get_clear_active(int n) const {
|
get_clear_active(int n) const {
|
||||||
nassertr((n >= 0)&&(n < RTP_COUNT), false);
|
nassertr(n >= 0 && n < RTP_COUNT, false);
|
||||||
return _clear_active[n];
|
return (_clear_mask & (1 << n)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,9 +70,7 @@ get_clear_value(int n) const {
|
|||||||
*/
|
*/
|
||||||
void DrawableRegion::
|
void DrawableRegion::
|
||||||
disable_clears() {
|
disable_clears() {
|
||||||
for (int i = 0; i < RTP_COUNT; ++i) {
|
_clear_mask = 0;
|
||||||
_clear_active[i] = false;
|
|
||||||
}
|
|
||||||
update_pixel_factor();
|
update_pixel_factor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +81,7 @@ disable_clears() {
|
|||||||
*/
|
*/
|
||||||
bool DrawableRegion::
|
bool DrawableRegion::
|
||||||
is_any_clear_active() const {
|
is_any_clear_active() const {
|
||||||
for (int i = 0; i < RTP_COUNT; ++i) {
|
return (_clear_mask != 0);
|
||||||
if (get_clear_active(i)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -109,9 +109,9 @@ protected:
|
|||||||
protected:
|
protected:
|
||||||
int _screenshot_buffer_type;
|
int _screenshot_buffer_type;
|
||||||
int _draw_buffer_type;
|
int _draw_buffer_type;
|
||||||
|
int _clear_mask;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _clear_active[RTP_COUNT];
|
|
||||||
LColor _clear_value[RTP_COUNT];
|
LColor _clear_value[RTP_COUNT];
|
||||||
|
|
||||||
PN_stdfloat _pixel_zoom;
|
PN_stdfloat _pixel_zoom;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user