From 7e20626915c50b044589a27e1ae088f4071816f5 Mon Sep 17 00:00:00 2001 From: Michael Wass Date: Tue, 28 Jun 2016 12:15:00 -0400 Subject: [PATCH 1/5] Fix a TypeError in direct.fsm.FSM --- direct/src/fsm/FSM.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/direct/src/fsm/FSM.py b/direct/src/fsm/FSM.py index 577c1232b7..3aa583f007 100644 --- a/direct/src/fsm/FSM.py +++ b/direct/src/fsm/FSM.py @@ -149,7 +149,7 @@ class FSM(DirectObject): def __init__(self, name): self.fsmLock = RLock() - self.name = name + self._name = name self.stateArray = [] self._serialNum = FSM.SerialNum FSM.SerialNum += 1 @@ -185,7 +185,7 @@ class FSM(DirectObject): # the messenger on every state change. The new and old states are # accessible as self.oldState and self.newState, and the transition # functions will already have been called. - return 'FSM-%s-%s-stateChange' % (self._serialNum, self.name) + return 'FSM-%s-%s-stateChange' % (self._serialNum, self._name) def getCurrentFilter(self): if not self.state: @@ -240,7 +240,7 @@ class FSM(DirectObject): try: assert isinstance(request, str) self.notify.debug("%s.forceTransition(%s, %s" % ( - self.name, request, str(args)[1:])) + self._name, request, str(args)[1:])) if not self.state: # Queue up the request. @@ -268,7 +268,7 @@ class FSM(DirectObject): try: assert isinstance(request, str) self.notify.debug("%s.demand(%s, %s" % ( - self.name, request, str(args)[1:])) + self._name, request, str(args)[1:])) if not self.state: # Queue up the request. self.__requestQueue.append(PythonUtil.Functor( @@ -307,7 +307,7 @@ class FSM(DirectObject): try: assert isinstance(request, str) self.notify.debug("%s.request(%s, %s" % ( - self.name, request, str(args)[1:])) + self._name, request, str(args)[1:])) filter = self.getCurrentFilter() result = filter(request, args) @@ -385,7 +385,7 @@ class FSM(DirectObject): # In either case, we quietly ignore unhandled command # (lowercase) requests. - assert self.notify.debug("%s ignoring request %s from state %s." % (self.name, request, self.state)) + assert self.notify.debug("%s ignoring request %s from state %s." % (self._name, request, self.state)) return None def filterOff(self, request, args): @@ -444,7 +444,7 @@ class FSM(DirectObject): # Internal function to change unconditionally to the indicated # state. assert self.state - assert self.notify.debug("%s to state %s." % (self.name, newState)) + assert self.notify.debug("%s to state %s." % (self._name, newState)) self.oldState = self.state self.newState = newState @@ -476,7 +476,7 @@ class FSM(DirectObject): if self.__requestQueue: request = self.__requestQueue.pop(0) - assert self.notify.debug("%s continued queued request." % (self.name)) + assert self.notify.debug("%s continued queued request." % (self._name)) request() def __callEnterFunc(self, name, *args): @@ -525,9 +525,9 @@ class FSM(DirectObject): try: className = self.__class__.__name__ if self.state: - str = ('%s FSM:%s in state "%s"' % (className, self.name, self.state)) + str = ('%s FSM:%s in state "%s"' % (className, self._name, self.state)) else: - str = ('%s FSM:%s in transition from \'%s\' to \'%s\'' % (className, self.name, self.oldState, self.newState)) + str = ('%s FSM:%s in transition from \'%s\' to \'%s\'' % (className, self._name, self.oldState, self.newState)) return str finally: self.fsmLock.release() From 54819dbcde1c1e4f31f205a51f97b51eaa7f0795 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 28 Jun 2016 19:11:58 +0200 Subject: [PATCH 2/5] Fix crash when using TextGraphic in texts --- panda/src/text/textAssembler.cxx | 42 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/panda/src/text/textAssembler.cxx b/panda/src/text/textAssembler.cxx index 996713a85a..933712c531 100644 --- a/panda/src/text/textAssembler.cxx +++ b/panda/src/text/textAssembler.cxx @@ -544,32 +544,34 @@ assemble_text() { } } - if (properties->has_shadow()) { + if (!placement._glyph.is_null()) { + if (properties->has_shadow()) { + if (_dynamic_merge) { + if (placement._glyph->has_quad()) { + placement.assign_quad_to(quad_shadow_map, shadow_state, shadow); + } else { + placement.assign_append_to(geom_shadow_collector_map, shadow_state, shadow); + } + } else { + placement.assign_to(shadow_geom_node, shadow_state, shadow); + } + + // Don't shadow the graphics. That can result in duplication of button + // objects, plus it looks weird. If you want a shadowed graphic, you + // can shadow it yourself before you add it. + // placement.copy_graphic_to(shadow_node, shadow_state, shadow); + any_shadow = true; + } + if (_dynamic_merge) { if (placement._glyph->has_quad()) { - placement.assign_quad_to(quad_shadow_map, shadow_state, shadow); + placement.assign_quad_to(quad_map, text_state); } else { - placement.assign_append_to(geom_shadow_collector_map, shadow_state, shadow); + placement.assign_append_to(geom_collector_map, text_state); } } else { - placement.assign_to(shadow_geom_node, shadow_state, shadow); + placement.assign_to(text_geom_node, text_state); } - - // Don't shadow the graphics. That can result in duplication of button - // objects, plus it looks weird. If you want a shadowed graphic, you - // can shadow it yourself before you add it. - // placement.copy_graphic_to(shadow_node, shadow_state, shadow); - any_shadow = true; - } - - if (_dynamic_merge) { - if (placement._glyph->has_quad()) { - placement.assign_quad_to(quad_map, text_state); - } else { - placement.assign_append_to(geom_collector_map, text_state); - } - } else { - placement.assign_to(text_geom_node, text_state); } placement.copy_graphic_to(text_node, text_state); } From 1b33fec978047c483659686e2bd2cd02b93bc08c Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 28 Jun 2016 21:35:09 +0200 Subject: [PATCH 3/5] Remove assertion when reregistering the same AudioManager constructor --- panda/src/audio/audioManager.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/audio/audioManager.cxx b/panda/src/audio/audioManager.cxx index d7eb0846fe..8dd52a8786 100644 --- a/panda/src/audio/audioManager.cxx +++ b/panda/src/audio/audioManager.cxx @@ -40,7 +40,7 @@ Create_AudioManager_proc *AudioManager::_create_AudioManager = NULL; void AudioManager:: register_AudioManager_creator(Create_AudioManager_proc* proc) { - nassertv(_create_AudioManager == NULL); + nassertv(_create_AudioManager == NULL || _create_AudioManager == proc); _create_AudioManager = proc; } From a906f34eee6fa573017efa15d6f9c21937bb25cc Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 28 Jun 2016 22:13:33 +0200 Subject: [PATCH 4/5] M_alpha now no longer squares the alpha component it writes to the framebuffer. To re-enable the old behaviour, set old-alpha-blend in Config.prc. --- panda/src/display/config_display.cxx | 9 +++++++++ panda/src/display/config_display.h | 1 + panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx | 9 ++++++++- panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 13 +++++++++++-- panda/src/tinydisplay/zbuffer.h | 15 +++++++++------ 5 files changed, 38 insertions(+), 9 deletions(-) diff --git a/panda/src/display/config_display.cxx b/panda/src/display/config_display.cxx index 0b46da0252..391a7e8676 100644 --- a/panda/src/display/config_display.cxx +++ b/panda/src/display/config_display.cxx @@ -298,6 +298,15 @@ ConfigVariableBool allow_incomplete_render "geometry is always paged in immediately when needed, holding up " "the frame render if necessary.")); +ConfigVariableBool old_alpha_blend +("old-alpha-blend", false, + PRC_DESC("Set this to true to enable the old alpha blending behavior from " + "Panda 1.9 in which the alpha value written out to the framebuffer " + "is squared. The new behavior is more intuitive when compositing " + "an semitransparent image produced using render-to-texture. You " + "should generally leave this false unless you have an effect that " + "relies on the old behavior, or you suspect an implementation bug.")); + ConfigVariableInt win_size ("win-size", "800 600", PRC_DESC("This is the default size at which to open a new window. This " diff --git a/panda/src/display/config_display.h b/panda/src/display/config_display.h index 1196389f5a..0b76e06472 100644 --- a/panda/src/display/config_display.h +++ b/panda/src/display/config_display.h @@ -68,6 +68,7 @@ extern EXPCL_PANDA_DISPLAY ConfigVariableBool default_stereo_camera; extern EXPCL_PANDA_DISPLAY ConfigVariableBool color_scale_via_lighting; extern EXPCL_PANDA_DISPLAY ConfigVariableBool alpha_scale_via_texture; extern EXPCL_PANDA_DISPLAY ConfigVariableBool allow_incomplete_render; +extern EXPCL_PANDA_DISPLAY ConfigVariableBool old_alpha_blend; extern EXPCL_PANDA_DISPLAY ConfigVariableInt win_size; extern EXPCL_PANDA_DISPLAY ConfigVariableInt win_origin; diff --git a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx index 43bf6d3311..03b5e8b6cb 100644 --- a/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx +++ b/panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx @@ -3798,7 +3798,14 @@ do_issue_blending() { case TransparencyAttrib::M_multisample_mask: case TransparencyAttrib::M_dual: set_render_state(D3DRS_ALPHABLENDENABLE, TRUE); - set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); + if (old_alpha_blend) { + set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, FALSE); + } else { + set_render_state(D3DRS_SEPARATEALPHABLENDENABLE, TRUE); + set_render_state(D3DRS_BLENDOPALPHA, D3DBLENDOP_ADD); + set_render_state(D3DRS_SRCBLENDALPHA, D3DBLEND_ONE); + set_render_state(D3DRS_DESTBLENDALPHA, D3DBLEND_INVSRCALPHA); + } set_render_state(D3DRS_BLENDOP, D3DBLENDOP_ADD); set_render_state(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); set_render_state(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index f078ce0d8b..bba123ea92 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7120,11 +7120,20 @@ do_issue_blending() { enable_multisample_alpha_mask(false); enable_blend(true); _glBlendEquation(GL_FUNC_ADD); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + if (old_alpha_blend) { + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } else { + _glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + } if (GLCAT.is_spam()) { GLCAT.spam() << "glBlendEquation(GL_FUNC_ADD)\n"; - GLCAT.spam() << "glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)\n"; + if (_supports_blend_equation_separate && !old_alpha_blend) { + GLCAT.spam() << "glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)\n"; + } else { + GLCAT.spam() << "glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)\n"; + } } return; diff --git a/panda/src/tinydisplay/zbuffer.h b/panda/src/tinydisplay/zbuffer.h index 46190ef4e6..ced08b5e31 100644 --- a/panda/src/tinydisplay/zbuffer.h +++ b/panda/src/tinydisplay/zbuffer.h @@ -107,23 +107,26 @@ typedef unsigned int PIXEL; #define PCOMPONENT_BLEND(c1, c2, a2) \ ((((unsigned int)(c1) * ((unsigned int)0xffff - (unsigned int)(a2)) + (unsigned int)(c2) * (unsigned int)(a2))) >> 16) -#define _BLEND_RGB(r1, g1, b1, r2, g2, b2, a2) \ +#define PALPHA_BLEND(a1, a2) \ + ((((unsigned int)(a1) * ((unsigned int)0xffff - (unsigned int)(a2))) >> 16) + (unsigned int)(a2)) + +#define _BLEND_RGB(r1, g1, b1, a1, r2, g2, b2, a2) \ RGBA_TO_PIXEL(PCOMPONENT_BLEND(r1, r2, a2), \ PCOMPONENT_BLEND(g1, g2, a2), \ PCOMPONENT_BLEND(b1, b2, a2), \ - a2) + PALPHA_BLEND(a1, a2)) -#define _BLEND_SRGB(r1, g1, b1, r2, g2, b2, a2) \ +#define _BLEND_SRGB(r1, g1, b1, a1, r2, g2, b2, a2) \ SRGBA_TO_PIXEL(PCOMPONENT_BLEND(r1, r2, a2), \ PCOMPONENT_BLEND(g1, g2, a2), \ PCOMPONENT_BLEND(b1, b2, a2), \ - a2) + PALPHA_BLEND(a1, a2)) #define PIXEL_BLEND_RGB(rgb, r, g, b, a) \ - _BLEND_RGB(PIXEL_R(rgb), PIXEL_G(rgb), PIXEL_B(rgb), r, g, b, a) + _BLEND_RGB(PIXEL_R(rgb), PIXEL_G(rgb), PIXEL_B(rgb), PIXEL_A(rgb), r, g, b, a) #define PIXEL_BLEND_SRGB(rgb, r, g, b, a) \ - _BLEND_SRGB(PIXEL_SR(rgb), PIXEL_SG(rgb), PIXEL_SB(rgb), r, g, b, a) + _BLEND_SRGB(PIXEL_SR(rgb), PIXEL_SG(rgb), PIXEL_SB(rgb), PIXEL_A(rgb), r, g, b, a) typedef struct { From b3bb19180e4d96863f2ebd070b287f1b5507e178 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 29 Jun 2016 19:08:05 +0200 Subject: [PATCH 5/5] Fix LNK4217 linker warnings on Windows --- dtool/src/interrogatedb/extension.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dtool/src/interrogatedb/extension.h b/dtool/src/interrogatedb/extension.h index 878c997f86..dd995081c1 100644 --- a/dtool/src/interrogatedb/extension.h +++ b/dtool/src/interrogatedb/extension.h @@ -31,7 +31,7 @@ public: * extended should create a specialization of this class template. */ template -class EXPCL_INTERROGATEDB Extension : public ExtensionBase { +class Extension : public ExtensionBase { }; /**