ShowBase: Fixed crash when want-render2dp is False

- Fixed crash in ShowBase when want-render2dp setting
        is set to 0(False).

Signed-off-by: deflected <deflected@users.noreply.github.com>
This commit is contained in:
deflected 2017-11-29 10:38:26 +02:00 committed by rdb
parent 7a46b2ca60
commit bdd53d60fc

View File

@ -968,6 +968,8 @@ class ShowBase(DirectObject.DirectObject):
if isinstance(self.win, GraphicsWindow): if isinstance(self.win, GraphicsWindow):
self.setupMouse(self.win) self.setupMouse(self.win)
self.makeCamera2d(self.win) self.makeCamera2d(self.win)
if self.wantRender2dp:
self.makeCamera2dp(self.win) self.makeCamera2dp(self.win)
if oldLens != None: if oldLens != None:
@ -1559,9 +1561,11 @@ class ShowBase(DirectObject.DirectObject):
# Tell the gui system about our new mouse watcher. # Tell the gui system about our new mouse watcher.
self.aspect2d.node().setMouseWatcher(mw.node()) self.aspect2d.node().setMouseWatcher(mw.node())
self.aspect2dp.node().setMouseWatcher(mw.node())
self.pixel2d.node().setMouseWatcher(mw.node()) self.pixel2d.node().setMouseWatcher(mw.node())
if self.wantRender2dp:
self.aspect2dp.node().setMouseWatcher(mw.node())
self.pixel2dp.node().setMouseWatcher(mw.node()) self.pixel2dp.node().setMouseWatcher(mw.node())
mw.node().addRegion(PGMouseWatcherBackground()) mw.node().addRegion(PGMouseWatcherBackground())
return self.buttonThrowers[0] return self.buttonThrowers[0]
@ -2729,6 +2733,7 @@ class ShowBase(DirectObject.DirectObject):
xsize, ysize = self.getSize() xsize, ysize = self.getSize()
if xsize > 0 and ysize > 0: if xsize > 0 and ysize > 0:
self.pixel2d.setScale(2.0 / xsize, 1.0, 2.0 / ysize) self.pixel2d.setScale(2.0 / xsize, 1.0, 2.0 / ysize)
if self.wantRender2dp:
self.pixel2dp.setScale(2.0 / xsize, 1.0, 2.0 / ysize) self.pixel2dp.setScale(2.0 / xsize, 1.0, 2.0 / ysize)
def adjustWindowAspectRatio(self, aspectRatio): def adjustWindowAspectRatio(self, aspectRatio):
@ -2753,6 +2758,7 @@ class ShowBase(DirectObject.DirectObject):
self.a2dLeft = -1 self.a2dLeft = -1
self.a2dRight = 1.0 self.a2dRight = 1.0
# Don't forget 2dp # Don't forget 2dp
if self.wantRender2dp:
self.aspect2dp.setScale(1.0, aspectRatio, aspectRatio) self.aspect2dp.setScale(1.0, aspectRatio, aspectRatio)
self.a2dpTop = 1.0 / aspectRatio self.a2dpTop = 1.0 / aspectRatio
self.a2dpBottom = - 1.0 / aspectRatio self.a2dpBottom = - 1.0 / aspectRatio
@ -2767,6 +2773,7 @@ class ShowBase(DirectObject.DirectObject):
self.a2dLeft = -aspectRatio self.a2dLeft = -aspectRatio
self.a2dRight = aspectRatio self.a2dRight = aspectRatio
# Don't forget 2dp # Don't forget 2dp
if self.wantRender2dp:
self.aspect2dp.setScale(1.0 / aspectRatio, 1.0, 1.0) self.aspect2dp.setScale(1.0 / aspectRatio, 1.0, 1.0)
self.a2dpTop = 1.0 self.a2dpTop = 1.0
self.a2dpBottom = -1.0 self.a2dpBottom = -1.0
@ -2793,6 +2800,7 @@ class ShowBase(DirectObject.DirectObject):
self.a2dBottomRightNs.setPos(self.a2dRight, 0, self.a2dBottom) self.a2dBottomRightNs.setPos(self.a2dRight, 0, self.a2dBottom)
# Reposition the aspect2dp marker nodes # Reposition the aspect2dp marker nodes
if self.wantRender2dp:
self.a2dpTopCenter.setPos(0, 0, self.a2dpTop) self.a2dpTopCenter.setPos(0, 0, self.a2dpTop)
self.a2dpBottomCenter.setPos(0, 0, self.a2dpBottom) self.a2dpBottomCenter.setPos(0, 0, self.a2dpBottom)
self.a2dpLeftCenter.setPos(self.a2dpLeft, 0, 0) self.a2dpLeftCenter.setPos(self.a2dpLeft, 0, 0)