mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
avoid some divide-by-zero exceptions
This commit is contained in:
parent
9158d9b20c
commit
a1c70ce95e
@ -738,6 +738,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
flags = flags | GraphicsPipe.BFRequireCallbackWindow
|
flags = flags | GraphicsPipe.BFRequireCallbackWindow
|
||||||
|
|
||||||
if host:
|
if host:
|
||||||
|
assert host.isValid()
|
||||||
win = self.graphicsEngine.makeOutput(pipe, name, 0, fbprops,
|
win = self.graphicsEngine.makeOutput(pipe, name, 0, fbprops,
|
||||||
props, flags, host.getGsg(), host)
|
props, flags, host.getGsg(), host)
|
||||||
elif gsg:
|
elif gsg:
|
||||||
@ -1211,7 +1212,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
if win == None:
|
if win == None:
|
||||||
win = self.win
|
win = self.win
|
||||||
|
|
||||||
if win != None and win.hasSize():
|
if win != None and win.hasSize() and win.getSbsLeftYSize() != 0:
|
||||||
aspectRatio = float(win.getSbsLeftXSize()) / float(win.getSbsLeftYSize())
|
aspectRatio = float(win.getSbsLeftXSize()) / float(win.getSbsLeftYSize())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@ -1222,9 +1223,12 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
if not props.hasSize():
|
if not props.hasSize():
|
||||||
props = WindowProperties.getDefault()
|
props = WindowProperties.getDefault()
|
||||||
|
|
||||||
if props.hasSize():
|
if props.hasSize() and props.getYSize() != 0:
|
||||||
aspectRatio = float(props.getXSize()) / float(props.getYSize())
|
aspectRatio = float(props.getXSize()) / float(props.getYSize())
|
||||||
|
|
||||||
|
if aspectRatio == 0:
|
||||||
|
return 1
|
||||||
|
|
||||||
return aspectRatio
|
return aspectRatio
|
||||||
|
|
||||||
def getSize(self, win = None):
|
def getSize(self, win = None):
|
||||||
@ -2660,6 +2664,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
if aspectRatio != self.__oldAspectRatio:
|
if aspectRatio != self.__oldAspectRatio:
|
||||||
self.__oldAspectRatio = aspectRatio
|
self.__oldAspectRatio = aspectRatio
|
||||||
# Fix up some anything that depends on the aspectRatio
|
# Fix up some anything that depends on the aspectRatio
|
||||||
|
if self.camLens:
|
||||||
self.camLens.setAspectRatio(aspectRatio)
|
self.camLens.setAspectRatio(aspectRatio)
|
||||||
if aspectRatio < 1:
|
if aspectRatio < 1:
|
||||||
# If the window is TALL, lets expand the top and bottom
|
# If the window is TALL, lets expand the top and bottom
|
||||||
|
Loading…
x
Reference in New Issue
Block a user