mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 08:27:29 -04:00
entities: hit box: eye padding
This commit is contained in:
parent
3ecf1ef5bf
commit
119541a2b1
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user