mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
fix a few bugs
This commit is contained in:
parent
a21091c9dc
commit
07aa73df98
@ -164,7 +164,6 @@ class TexMemWatcher(DirectObject):
|
|||||||
# Now start handling up the actual stuff in the scene.
|
# Now start handling up the actual stuff in the scene.
|
||||||
|
|
||||||
self.background = None
|
self.background = None
|
||||||
self.overflowing = False
|
|
||||||
self.nextTexRecordKey = 0
|
self.nextTexRecordKey = 0
|
||||||
self.rollover = None
|
self.rollover = None
|
||||||
self.isolate = None
|
self.isolate = None
|
||||||
@ -632,7 +631,6 @@ class TexMemWatcher(DirectObject):
|
|||||||
# packing effectiveness.
|
# packing effectiveness.
|
||||||
texRecords.sort(key = lambda tr: (tr.tw, tr.th), reverse = True)
|
texRecords.sort(key = lambda tr: (tr.tw, tr.th), reverse = True)
|
||||||
|
|
||||||
self.overflowing = False
|
|
||||||
for tr in texRecords:
|
for tr in texRecords:
|
||||||
self.placeTexture(tr)
|
self.placeTexture(tr)
|
||||||
self.texRecordsByTex[tr.tex] = tr
|
self.texRecordsByTex[tr.tex] = tr
|
||||||
@ -726,7 +724,6 @@ class TexMemWatcher(DirectObject):
|
|||||||
texRecords = self.texRecordsByTex.values()
|
texRecords = self.texRecordsByTex.values()
|
||||||
texRecords.sort(key = lambda tr: (tr.tw, tr.th), reverse = True)
|
texRecords.sort(key = lambda tr: (tr.tw, tr.th), reverse = True)
|
||||||
|
|
||||||
self.overflowing = False
|
|
||||||
for tr in texRecords:
|
for tr in texRecords:
|
||||||
self.placeTexture(tr)
|
self.placeTexture(tr)
|
||||||
|
|
||||||
@ -745,21 +742,26 @@ class TexMemWatcher(DirectObject):
|
|||||||
|
|
||||||
def unplaceTexture(self, tr):
|
def unplaceTexture(self, tr):
|
||||||
""" Removes the texture from its place on the canvas. """
|
""" Removes the texture from its place on the canvas. """
|
||||||
for tp in tr.placements:
|
if tr.placements:
|
||||||
tp.clearBitmasks(self.bitmasks)
|
for tp in tr.placements:
|
||||||
if not tp.overflowed:
|
tp.clearBitmasks(self.bitmasks)
|
||||||
self.placedQSize -= tp.area
|
if not tp.overflowed:
|
||||||
del self.texPlacements[tp]
|
self.placedQSize -= tp.area
|
||||||
tr.placements = []
|
assert self.placedQSize >= 0
|
||||||
tr.clearCard(self)
|
del self.texPlacements[tp]
|
||||||
if not tp.overflowed:
|
tr.placements = []
|
||||||
self.placedSize -= tr.size
|
tr.clearCard(self)
|
||||||
|
if not tr.overflowed:
|
||||||
|
self.placedSize -= tr.size
|
||||||
|
assert self.placedSize >= 0
|
||||||
|
tr.overflowed = 0
|
||||||
|
|
||||||
def placeTexture(self, tr):
|
def placeTexture(self, tr):
|
||||||
""" Places the texture somewhere on the canvas where it will
|
""" Places the texture somewhere on the canvas where it will
|
||||||
fit. """
|
fit. """
|
||||||
|
|
||||||
tr.computePlacementSize(self)
|
tr.computePlacementSize(self)
|
||||||
|
tr.overflowed = 0
|
||||||
|
|
||||||
shouldFit = False
|
shouldFit = False
|
||||||
availableSize = self.limit - self.placedSize
|
availableSize = self.limit - self.placedSize
|
||||||
@ -807,25 +809,17 @@ class TexMemWatcher(DirectObject):
|
|||||||
return
|
return
|
||||||
|
|
||||||
# Just let it overflow.
|
# Just let it overflow.
|
||||||
self.overflowing = True
|
tr.overflowed = 1
|
||||||
tp = self.findOverflowHole(tr.area, tr.w, tr.h)
|
tp = self.findOverflowHole(tr.area, tr.w, tr.h)
|
||||||
if tp:
|
tp.overflowed = 1
|
||||||
if tp.p[1] > self.w or tp.p[3] > self.h:
|
while len(self.bitmasks) <= tp.p[3]:
|
||||||
tp.overflowed = 1
|
self.bitmasks.append(BitArray())
|
||||||
while len(self.bitmasks) <= tp.p[3]:
|
|
||||||
self.bitmasks.append(BitArray())
|
tr.placements = [tp]
|
||||||
|
tr.makeCard(self)
|
||||||
tr.placements = [tp]
|
tp.setBitmasks(self.bitmasks)
|
||||||
tr.makeCard(self)
|
self.texPlacements[tp] = tr
|
||||||
tp.setBitmasks(self.bitmasks)
|
|
||||||
if not tp.overflowed:
|
|
||||||
self.placedQSize += tp.area
|
|
||||||
self.placedSize += tr.size
|
|
||||||
self.texPlacements[tp] = tr
|
|
||||||
return
|
|
||||||
|
|
||||||
# Something went wrong.
|
|
||||||
assert False
|
|
||||||
|
|
||||||
def findHole(self, area, w, h):
|
def findHole(self, area, w, h):
|
||||||
""" Searches for a rectangular hole that is at least area
|
""" Searches for a rectangular hole that is at least area
|
||||||
@ -1044,7 +1038,7 @@ class TexMemWatcher(DirectObject):
|
|||||||
|
|
||||||
t = b + 1
|
t = b + 1
|
||||||
while t < b + h and \
|
while t < b + h and \
|
||||||
(t > len(self.bitmasks) or (self.bitmasks[t] & mask).isZero()):
|
(t >= len(self.bitmasks) or (self.bitmasks[t] & mask).isZero()):
|
||||||
t += 1
|
t += 1
|
||||||
|
|
||||||
if t < b + h:
|
if t < b + h:
|
||||||
@ -1089,6 +1083,7 @@ class TexRecord:
|
|||||||
self.root = None
|
self.root = None
|
||||||
self.regions = []
|
self.regions = []
|
||||||
self.placements = []
|
self.placements = []
|
||||||
|
self.overflowed = 0
|
||||||
|
|
||||||
self.setSize(size)
|
self.setSize(size)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user