entities: hit box: eye padding

This commit is contained in:
Bixilon 2021-06-10 12:35:51 +02:00 committed by Lukas
parent 3ecf1ef5bf
commit 119541a2b1
2 changed files with 16 additions and 3 deletions

View File

@ -179,6 +179,19 @@ class AABB(
return (position.x in min.x..max.x && position.y in min.y..max.y && position.z in min.z..max.z)
}
fun shrink(size: Float): AABB {
return AABB(min + size, max - size)
}
fun hShrink(size: Float): AABB {
val vec = Vec3d(size, 0.0, size)
return AABB(min + vec, max - vec)
}
fun shrink(size: Double): AABB {
return AABB(min + size, max - size)
}
val center: Vec3d
get() = Vec3d((min.x + max.x) / 2.0, (min.y + max.y) / 2.0, (min.z + max.z) / 2.0)

View File

@ -27,14 +27,14 @@ class EntityHitBoxMesh(
val aabb = entity.aabb
init {
val hitboxColor = when {
val hitBoxColor = when {
entity.isInvisible -> Minosoft.config.config.game.entities.hitBox.invisibleEntitiesColor
else -> Minosoft.config.config.game.entities.hitBox.hitBoxColor
}
drawAABB(entity.aabb, Vec3d.EMPTY, LINE_WIDTH, hitboxColor)
drawAABB(entity.aabb, Vec3d.EMPTY, LINE_WIDTH, hitBoxColor)
val halfWidth = entity.dimensions.x / 2
val eyeAABB = AABB(Vec3(-halfWidth, entity.eyeHeight - LINE_WIDTH, -halfWidth), Vec3(halfWidth, entity.eyeHeight - LINE_WIDTH, halfWidth))
val eyeAABB = AABB(Vec3(-halfWidth, entity.eyeHeight - LINE_WIDTH, -halfWidth), Vec3(halfWidth, entity.eyeHeight - LINE_WIDTH, halfWidth)).hShrink(LINE_WIDTH)
drawAABB(eyeAABB, entity.position, LINE_WIDTH, Minosoft.config.config.game.entities.hitBox.eyeHeightColor)
}