mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-07-03 08:30:45 +02:00
Added a flag to decoded block to check if it contains any transparent colors. Useful to establish a fast path in transparent rendering if it does not.
This commit is contained in:
@ -43,12 +43,13 @@ type (
|
||||
}
|
||||
|
||||
DecodedBlock struct {
|
||||
Version byte
|
||||
MapContent []byte
|
||||
AirId int32
|
||||
IgnoreId int32
|
||||
AirOnly bool
|
||||
IndexMap map[int32]int32
|
||||
Version byte
|
||||
MapContent []byte
|
||||
AirId int32
|
||||
IgnoreId int32
|
||||
AirOnly bool
|
||||
Transparent bool
|
||||
IndexMap map[int32]int32
|
||||
}
|
||||
)
|
||||
|
||||
@ -138,6 +139,7 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
||||
airId, ignoreId := int32(-1), int32(-1)
|
||||
indexMap := make(map[int32]int32)
|
||||
var airOnly bool
|
||||
var transparent bool
|
||||
if version >= 22 {
|
||||
offset++
|
||||
numMappings := int(binary.BigEndian.Uint16(data[offset:]))
|
||||
@ -157,6 +159,9 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
||||
default:
|
||||
if index, found := colors.NameIndex[name]; found {
|
||||
indexMap[nodeId] = index
|
||||
if colors.IsTransparent(index) {
|
||||
transparent = true
|
||||
}
|
||||
} else {
|
||||
log.Printf("Missing color entry for %s.", name)
|
||||
}
|
||||
@ -166,12 +171,13 @@ func NewDecodedBlock(data []byte, colors *Colors) (db *DecodedBlock, err error)
|
||||
}
|
||||
|
||||
db = &DecodedBlock{
|
||||
Version: version,
|
||||
MapContent: mapContent,
|
||||
AirId: airId,
|
||||
IgnoreId: ignoreId,
|
||||
AirOnly: airOnly,
|
||||
IndexMap: indexMap}
|
||||
Version: version,
|
||||
MapContent: mapContent,
|
||||
AirId: airId,
|
||||
IgnoreId: ignoreId,
|
||||
AirOnly: airOnly,
|
||||
Transparent: transparent,
|
||||
IndexMap: indexMap}
|
||||
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user