sortedarraylist update; physball breaks the actor render dunno why

This commit is contained in:
minjaesong
2019-04-30 02:52:09 +09:00
parent 5a95f1c21a
commit 7d216acd52
12 changed files with 130 additions and 52 deletions

View File

@@ -11,9 +11,11 @@ object Wire {
const val BIT_UTILITY_PROTOTYPE = 2
const val BIT_POWER_LOW = 4
const val BIT_POWER_HIGHT = 8
const val BIT_ETHERNET = 16
const val BIT_PARALLEL_8B = 16 // uses bit-to-mantissa encoding
const val BIT_PARALLEL_16B = 32 // uses bit-to-mantissa encoding
const val BIT_ETHERNET = 64 // the actual datagramme should be represented by another means than the ConduitFills
/* A mapping for World's conduitFills[] index */
/* A mapping for World's WiringNode.fills[] index */
const val FILL_ID_SIGNAL_RED = 0
const val FILL_ID_UTILITY_PROTOTYPE = 1
@@ -23,4 +25,22 @@ object Wire {
else -> null
}
/**
* Encodes a byte to Float's mantissa. Normal value range is 1.0..1.99609375. When decoding, the sign and exponent bits
* must be ignored. (e.g. the encoded float might have non-one-point-something value after "bitwise" add/subtraction.
*
* MSB of the byte is also the highest bit in the mantissa. Therefore ```0x80``` will be encoded as ```1.5```
*/
fun Byte.toFloatMantissa(): Float = Float.fromBits(0x3F800000 or (this.toInt().and(0xFF) shl 15))
fun Short.toFloatMantissa(): Float = Float.fromBits(0x3F800000 or (this.toInt().and(0xFFFF) shl 7))
/**
* This function does the reversal calculation.
*
* @see net.torvald.terrarum.blockproperties.Wire.toFloatMantissa
*/
fun Float.fromMantissaToByte(): Byte = this.toRawBits().ushr(15).and(0xFF).toByte()
fun Float.fromMantissaToShort(): Short = this.toRawBits().ushr(7).and(0xFFFF).toShort()
}