mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2024-12-23 16:50:18 +01:00
Implement renderer reset cheaper ... and this time correctly.
This commit is contained in:
parent
eed91e7148
commit
d6411f3f6d
@ -137,7 +137,7 @@ func NewRenderer(width, height int, transparent bool) (renderer *Renderer) {
|
||||
tBuffer: tBuffer,
|
||||
spans: spans}
|
||||
|
||||
renderer.Reset()
|
||||
renderer.initBuffers()
|
||||
return
|
||||
}
|
||||
|
||||
@ -146,16 +146,7 @@ func (r *Renderer) SetPos(xOfs, zOfs int16) {
|
||||
r.zOfs = zOfs
|
||||
}
|
||||
|
||||
func (r *Renderer) Reset() {
|
||||
|
||||
/* TODO: Figure out why this early stop results
|
||||
in broken renderings.
|
||||
|
||||
if r.IsEmpty() {
|
||||
return
|
||||
}
|
||||
*/
|
||||
|
||||
func (r *Renderer) initBuffers() {
|
||||
yb := r.yBuffer
|
||||
yb = yb[:len(yb)]
|
||||
for i := range yb {
|
||||
@ -173,9 +164,20 @@ func (r *Renderer) Reset() {
|
||||
for i := range ym {
|
||||
ym[i] = math.MinInt32
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Renderer) Reset() {
|
||||
|
||||
r.RejectedBlocks = 0
|
||||
|
||||
if r.SolidBlocks > 0 || r.TransparentBlocks > 0 {
|
||||
r.SolidBlocks = 0
|
||||
r.initBuffers()
|
||||
}
|
||||
|
||||
if r.TransparentBlocks > 0 {
|
||||
r.TransparentBlocks = 0
|
||||
|
||||
tb := r.tBuffer
|
||||
for i, t := range tb {
|
||||
if t != nil {
|
||||
@ -184,8 +186,6 @@ func (r *Renderer) Reset() {
|
||||
}
|
||||
}
|
||||
}
|
||||
r.SolidBlocks = 0
|
||||
r.RejectedBlocks = 0
|
||||
}
|
||||
|
||||
func (r *Renderer) IsFilled() bool {
|
||||
|
Loading…
Reference in New Issue
Block a user