mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
various memory patches
also small preparation for kutil 1.22
This commit is contained in:
parent
7aa7aa2996
commit
18f77e89c1
@ -179,21 +179,19 @@ class World(
|
||||
val origin = connection.player.physics.positionInfo.blockPosition
|
||||
val chunk = this.chunks[origin.chunkPosition] ?: return
|
||||
|
||||
val offset = Vec3i.EMPTY
|
||||
val position = Vec3i.EMPTY
|
||||
val chunkDelta = Vec2i.EMPTY
|
||||
|
||||
for (i in 0 until 667) {
|
||||
randomTick(16, origin, offset, chunkDelta, chunk)
|
||||
randomTick(32, origin, offset, chunkDelta, chunk)
|
||||
randomTick(16, origin, position, chunkDelta, chunk)
|
||||
randomTick(32, origin, position, chunkDelta, chunk)
|
||||
}
|
||||
}
|
||||
|
||||
private fun randomTick(radius: Int, origin: BlockPosition, offset: BlockPosition, chunkDelta: Vec2i, chunk: Chunk) {
|
||||
offset.x = random.nextInt(-radius, radius)
|
||||
offset.y = random.nextInt(-radius, radius)
|
||||
offset.z = random.nextInt(-radius, radius)
|
||||
|
||||
val position = origin + offset
|
||||
private fun randomTick(radius: Int, origin: BlockPosition, position: BlockPosition, chunkDelta: Vec2i, chunk: Chunk) {
|
||||
position.x = origin.x + random.nextInt(-radius, radius)
|
||||
position.y = origin.x + random.nextInt(-radius, radius)
|
||||
position.z = origin.x + random.nextInt(-radius, radius)
|
||||
|
||||
chunkDelta.x = (origin.x - position.x) shr 4
|
||||
chunkDelta.y = (origin.z - position.z) shr 4
|
||||
|
@ -26,7 +26,6 @@ import de.bixilon.minosoft.data.registries.shapes.aabb.AABB
|
||||
import de.bixilon.minosoft.data.world.World
|
||||
import de.bixilon.minosoft.data.world.chunk.chunk.Chunk
|
||||
import de.bixilon.minosoft.data.world.positions.ChunkPositionUtil.chunkPosition
|
||||
import de.bixilon.minosoft.data.world.positions.ChunkPositionUtil.inChunkPosition
|
||||
|
||||
class WorldIterator(
|
||||
private val iterator: Iterator<Vec3i>,
|
||||
@ -57,7 +56,7 @@ class WorldIterator(
|
||||
this.chunk = chunk
|
||||
}
|
||||
|
||||
val state = chunk[position.inChunkPosition] ?: continue
|
||||
val state = chunk[position.x and 0x0F, position.y, position.z and 0x0F] ?: continue
|
||||
this.next = BlockPair(position, state, chunk)
|
||||
return true
|
||||
}
|
||||
|
@ -70,10 +70,8 @@ class GUIMesh(
|
||||
}
|
||||
}
|
||||
|
||||
data.add(outPosition.x)
|
||||
data.add(outPosition.y)
|
||||
data.add(uv.x)
|
||||
data.add(uv.y)
|
||||
data.add(outPosition.array)
|
||||
data.add(uv.array)
|
||||
data.add(texture.shaderId.buffer())
|
||||
data.add(color.buffer())
|
||||
}
|
||||
|
@ -205,9 +205,13 @@ object VecUtil {
|
||||
|
||||
val <T : Number> Vec3t<T>.toVec3: Vec3
|
||||
get() = Vec3(this)
|
||||
val Vec3d.toVec3: Vec3
|
||||
get() = Vec3(this)
|
||||
|
||||
val <T : Number> Vec3t<T>.toVec3d: Vec3d
|
||||
get() = Vec3d(this)
|
||||
val Vec3.toVec3d: Vec3d
|
||||
get() = Vec3d(this)
|
||||
|
||||
|
||||
fun Vec3d.Companion.horizontal(xz: () -> Double, y: Double): Vec3d {
|
||||
|
@ -149,4 +149,11 @@ object Vec3dUtil {
|
||||
Axes.Z -> z = value
|
||||
}
|
||||
}
|
||||
|
||||
fun Vec3d.addY(y: Double): Vec3d {
|
||||
val res = Vec3d(this)
|
||||
res.y += y
|
||||
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
@ -57,8 +57,10 @@ open class EventMaster(vararg parents: AbstractEventMaster) : AbstractEventMaste
|
||||
|
||||
override fun fire(event: Event): Boolean {
|
||||
parentLock.acquire()
|
||||
for (parent in parents) {
|
||||
parent.fire(event)
|
||||
if (parents.isNotEmpty()) {
|
||||
for (parent in parents) {
|
||||
parent.fire(event)
|
||||
}
|
||||
}
|
||||
parentLock.release()
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
package de.bixilon.minosoft.physics
|
||||
|
||||
import de.bixilon.kotlinglm.vec3.Vec3d
|
||||
import de.bixilon.kotlinglm.vec3.Vec3i
|
||||
import de.bixilon.minosoft.data.registries.biomes.Biome
|
||||
import de.bixilon.minosoft.data.registries.blocks.state.BlockState
|
||||
@ -27,6 +26,7 @@ import de.bixilon.minosoft.data.world.positions.ChunkPositionUtil.sectionHeight
|
||||
import de.bixilon.minosoft.data.world.positions.InChunkPosition
|
||||
import de.bixilon.minosoft.data.world.positions.InChunkSectionPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec2.Vec2iUtil.EMPTY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3dUtil.addY
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3dUtil.blockPosition
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3iUtil.EMPTY
|
||||
import de.bixilon.minosoft.physics.entities.EntityPhysics
|
||||
@ -54,11 +54,11 @@ class EntityPositionInfo(
|
||||
val blockPosition = position.blockPosition
|
||||
val chunkPosition = blockPosition.chunkPosition
|
||||
val sectionHeight = blockPosition.sectionHeight
|
||||
val eyePosition = (position + Vec3d(0.0f, physics.entity.eyeHeight, 0.0f)).blockPosition
|
||||
val eyePosition = position.addY(physics.entity.eyeHeight.toDouble()).blockPosition
|
||||
val inChunkPosition = blockPosition.inChunkPosition
|
||||
val inSectionPosition = blockPosition.inChunkSectionPosition
|
||||
|
||||
val velocityPosition = Vec3i(blockPosition.x, position.y - 0.5000001, blockPosition.z)
|
||||
val velocityPosition = Vec3i(blockPosition.x, (position.y - 0.5000001).toInt(), blockPosition.z)
|
||||
|
||||
val chunks = physics.entity.connection.world.chunks
|
||||
val revision = chunks.revision
|
||||
|
Loading…
x
Reference in New Issue
Block a user