Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions common/src/main/kotlin/com/lambda/event/events/RenderEvent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ import com.lambda.Lambda.mc
import com.lambda.event.Event
import com.lambda.event.callback.Cancellable
import com.lambda.event.callback.ICancellable
import com.lambda.graphics.renderer.esp.global.BlockESPRenderer
import com.lambda.graphics.renderer.esp.global.EntityESPRenderer
import com.lambda.graphics.renderer.esp.global.StaticESP
import com.lambda.graphics.renderer.esp.global.DynamicESP
import com.lambda.util.math.Vec2d

abstract class RenderEvent : Event {
class World : RenderEvent()

class BlockESP : RenderEvent() {
val renderer = BlockESPRenderer
class StaticESP : RenderEvent() {
val renderer = StaticESP
}

class EntityESP : RenderEvent() {
val renderer = EntityESPRenderer
class DynamicESP : RenderEvent() {
val renderer = DynamicESP
}

abstract class GUI(val scale: Double) : RenderEvent() {
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/kotlin/com/lambda/graphics/RenderMain.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import com.lambda.graphics.gl.GlStateUtils.setupGL
import com.lambda.graphics.gl.Matrices
import com.lambda.graphics.gl.Matrices.resetMatrix
import com.lambda.graphics.gl.Matrices.translate
import com.lambda.graphics.renderer.esp.global.BlockESPRenderer
import com.lambda.graphics.renderer.esp.global.EntityESPRenderer
import com.lambda.graphics.renderer.esp.global.StaticESP
import com.lambda.graphics.renderer.esp.global.DynamicESP
import com.lambda.module.modules.client.GuiSettings
import com.lambda.util.math.Vec2d
import com.mojang.blaze3d.systems.RenderSystem.getProjectionMatrix
Expand Down Expand Up @@ -42,8 +42,8 @@ object RenderMain {

setupGL {
RenderEvent.World().post()
BlockESPRenderer.render()
EntityESPRenderer.render()
StaticESP.render()
DynamicESP.render()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.lambda.event.events.WorldEvent
import com.lambda.event.listener.SafeListener.Companion.concurrentListener
import com.lambda.event.listener.SafeListener.Companion.listener
import com.lambda.graphics.buffer.vao.vertex.BufferUsage
import com.lambda.graphics.renderer.esp.impl.ESPRenderer
import com.lambda.graphics.renderer.esp.impl.StaticESPRenderer
import com.lambda.module.modules.client.RenderSettings
import com.lambda.threading.awaitMainThread
import net.minecraft.util.math.ChunkPos
Expand All @@ -16,7 +18,7 @@ import java.util.concurrent.ConcurrentLinkedDeque

class ChunkedESP private constructor(
owner: Any,
private val update: ESPRenderer.(WorldView, Int, Int, Int) -> Unit
private val update: StaticESPRenderer.(WorldView, Int, Int, Int) -> Unit
) {
private val rendererMap = ConcurrentHashMap<Long, EspChunk>()
private val WorldChunk.renderer get() = rendererMap.getOrPut(pos.toLong()) {
Expand Down Expand Up @@ -76,7 +78,7 @@ class ChunkedESP private constructor(

companion object {
fun Any.newChunkedESP(
update: ESPRenderer.(WorldView, Int, Int, Int) -> Unit
update: StaticESPRenderer.(WorldView, Int, Int, Int) -> Unit
) = ChunkedESP(this, update)
}

Expand All @@ -101,7 +103,7 @@ class ChunkedESP private constructor(

suspend fun rebuild() {
val newRenderer = awaitMainThread {
ESPRenderer(BufferUsage.STATIC)
StaticESPRenderer(BufferUsage.STATIC)
}

iterateChunk { x, y, z ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.lambda.graphics.renderer.esp

import com.lambda.util.math.VecUtils.minus
import com.lambda.util.math.VecUtils.plus
import com.lambda.util.primitives.extension.max
import com.lambda.util.primitives.extension.min
import com.lambda.util.primitives.extension.prevPos
import net.minecraft.entity.Entity
import net.minecraft.util.math.Box

class DynamicAABB {
private var prev: Box? = null
private var curr: Box? = null

fun update(box: Box) {
prev = curr
curr = box

if (prev == null) {
prev = box
}
}

fun reset() {
prev = null
curr = null
}

fun getBoxPair(): Pair<Box, Box>? {
prev?.let { previous ->
curr?.let { current ->
return previous to current
}
}

return null
}

companion object {
val Entity.dynamicBox get() = DynamicAABB().apply {
val box = boundingBox

val delta = prevPos - pos
val prevBox = Box(box.min + delta, box.max + delta)

update(prevBox)
update(box)
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package com.lambda.graphics.renderer.esp.builders

import com.lambda.graphics.renderer.esp.DirectionMask
import com.lambda.graphics.renderer.esp.DirectionMask.hasDirection
import com.lambda.graphics.renderer.esp.DynamicAABB
import com.lambda.graphics.renderer.esp.impl.DynamicESPRenderer
import com.lambda.util.primitives.extension.max
import com.lambda.util.primitives.extension.min
import java.awt.Color

fun DynamicESPRenderer.build(
box: DynamicAABB,
filledColor: Color,
outlineColor: Color,
sides: Int = DirectionMask.ALL,
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
) {
buildFilled(box, filledColor, sides)
buildOutline(box, outlineColor, sides, outlineMode)
}

fun DynamicESPRenderer.buildFilled(
box: DynamicAABB,
color: Color,
sides: Int = DirectionMask.ALL
) = faces.use {
val boxes = box.getBoxPair() ?: return@use

val pos11 = boxes.first.min
val pos12 = boxes.first.max
val pos21 = boxes.second.min
val pos22 = boxes.second.max

grow(8)

val blb by lazy { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color).end() }
val blf by lazy { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color).end() }
val brb by lazy { vec3(pos12.x, pos11.y, pos11.z).vec3(pos22.x, pos21.y, pos21.z).color(color).end() }
val brf by lazy { vec3(pos12.x, pos11.y, pos12.z).vec3(pos22.x, pos21.y, pos22.z).color(color).end() }
val tlb by lazy { vec3(pos11.x, pos12.y, pos11.z).vec3(pos21.x, pos22.y, pos21.z).color(color).end() }
val tlf by lazy { vec3(pos11.x, pos12.y, pos12.z).vec3(pos21.x, pos22.y, pos22.z).color(color).end() }
val trb by lazy { vec3(pos12.x, pos12.y, pos11.z).vec3(pos22.x, pos22.y, pos21.z).color(color).end() }
val trf by lazy { vec3(pos12.x, pos12.y, pos12.z).vec3(pos22.x, pos22.y, pos22.z).color(color).end() }

if (sides.hasDirection(DirectionMask.EAST)) putQuad(brb, trb, trf, brf)
if (sides.hasDirection(DirectionMask.WEST)) putQuad(blb, blf, tlf, tlb)
if (sides.hasDirection(DirectionMask.UP)) putQuad(tlb, tlf, trf, trb)
if (sides.hasDirection(DirectionMask.DOWN)) putQuad(blb, brb, brf, blf)
if (sides.hasDirection(DirectionMask.SOUTH)) putQuad(blf, brf, trf, tlf)
if (sides.hasDirection(DirectionMask.NORTH)) putQuad(blb, tlb, trb, brb)
}

fun DynamicESPRenderer.buildOutline(
box: DynamicAABB,
color: Color,
sides: Int = DirectionMask.ALL,
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
) = outlines.use {
val boxes = box.getBoxPair() ?: return@use

val pos11 = boxes.first.min
val pos12 = boxes.first.max
val pos21 = boxes.second.min
val pos22 = boxes.second.max

grow(8)

val blb by lazy { vec3(pos11.x, pos11.y, pos11.z).vec3(pos21.x, pos21.y, pos21.z).color(color).end() }
val blf by lazy { vec3(pos11.x, pos11.y, pos12.z).vec3(pos21.x, pos21.y, pos22.z).color(color).end() }
val brb by lazy { vec3(pos12.x, pos11.y, pos11.z).vec3(pos22.x, pos21.y, pos21.z).color(color).end() }
val brf by lazy { vec3(pos12.x, pos11.y, pos12.z).vec3(pos22.x, pos21.y, pos22.z).color(color).end() }
val tlb by lazy { vec3(pos11.x, pos12.y, pos11.z).vec3(pos21.x, pos22.y, pos21.z).color(color).end() }
val tlf by lazy { vec3(pos11.x, pos12.y, pos12.z).vec3(pos21.x, pos22.y, pos22.z).color(color).end() }
val trb by lazy { vec3(pos12.x, pos12.y, pos11.z).vec3(pos22.x, pos22.y, pos21.z).color(color).end() }
val trf by lazy { vec3(pos12.x, pos12.y, pos12.z).vec3(pos22.x, pos22.y, pos22.z).color(color).end() }

val hasEast = sides.hasDirection(DirectionMask.EAST)
val hasWest = sides.hasDirection(DirectionMask.WEST)
val hasUp = sides.hasDirection(DirectionMask.UP)
val hasDown = sides.hasDirection(DirectionMask.DOWN)
val hasSouth = sides.hasDirection(DirectionMask.SOUTH)
val hasNorth = sides.hasDirection(DirectionMask.NORTH)

if (outlineMode.check(hasUp, hasNorth)) putLine(tlb, trb)
if (outlineMode.check(hasUp, hasSouth)) putLine(tlf, trf)
if (outlineMode.check(hasUp, hasWest)) putLine(tlb, tlf)
if (outlineMode.check(hasUp, hasEast)) putLine(trf, trb)

if (outlineMode.check(hasDown, hasNorth)) putLine(blb, brb)
if (outlineMode.check(hasDown, hasSouth)) putLine(blf, brf)
if (outlineMode.check(hasDown, hasWest)) putLine(blb, blf)
if (outlineMode.check(hasDown, hasEast)) putLine(brb, brf)

if (outlineMode.check(hasWest, hasNorth)) putLine(tlb, blb)
if (outlineMode.check(hasNorth, hasEast)) putLine(trb, brb)
if (outlineMode.check(hasEast, hasSouth)) putLine(trf, brf)
if (outlineMode.check(hasSouth, hasWest)) putLine(tlf, blf)
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package com.lambda.graphics.renderer.esp.global
package com.lambda.graphics.renderer.esp.builders

import com.lambda.graphics.renderer.esp.DirectionMask
import com.lambda.graphics.renderer.esp.DirectionMask.hasDirection
import com.lambda.graphics.renderer.esp.ESPRenderer
import com.lambda.graphics.renderer.esp.impl.ESPRenderer
import com.lambda.graphics.renderer.esp.impl.StaticESPRenderer
import com.lambda.util.primitives.extension.max
import com.lambda.util.primitives.extension.min
import net.minecraft.util.math.Box
import java.awt.Color

fun ESPRenderer.build(
fun StaticESPRenderer.build(
box: Box,
filledColor: Color,
outlineColor: Color,
Expand All @@ -19,20 +20,20 @@ fun ESPRenderer.build(
buildOutline(box, outlineColor, sides, outlineMode)
}

fun ESPRenderer.buildFilled(
fun StaticESPRenderer.buildFilled(
box: Box,
color: Color,
sides: Int = DirectionMask.ALL
) = buildFilled(box, color, color, sides)

fun ESPRenderer.buildOutline(
fun StaticESPRenderer.buildOutline(
box: Box,
color: Color,
sides: Int = DirectionMask.ALL,
outlineMode: DirectionMask.OutlineMode = DirectionMask.OutlineMode.OR
) = buildOutline(box, color, color, sides, outlineMode)

fun ESPRenderer.buildFilled(
fun StaticESPRenderer.buildFilled(
box: Box,
colorBottom: Color,
colorTop: Color = colorBottom,
Expand All @@ -42,7 +43,6 @@ fun ESPRenderer.buildFilled(
val pos2 = box.max

grow(8)
updateFaces = true

val blb by vertex(faceVertices, pos1.x, pos1.y, pos1.z, colorBottom)
val blf by vertex(faceVertices, pos1.x, pos1.y, pos2.z, colorBottom)
Expand All @@ -59,9 +59,11 @@ fun ESPRenderer.buildFilled(
if (sides.hasDirection(DirectionMask.DOWN)) putQuad(blb, brb, brf, blf)
if (sides.hasDirection(DirectionMask.SOUTH)) putQuad(blf, brf, trf, tlf)
if (sides.hasDirection(DirectionMask.NORTH)) putQuad(blb, tlb, trb, brb)

updateFaces = true
}

fun ESPRenderer.buildOutline(
fun StaticESPRenderer.buildOutline(
box: Box,
colorBottom: Color,
colorTop: Color = colorBottom,
Expand All @@ -72,7 +74,6 @@ fun ESPRenderer.buildOutline(
val pos2 = box.max

grow(8)
updateOutlines = true

val blb by vertex(outlineVertices, pos1.x, pos1.y, pos1.z, colorBottom)
val blf by vertex(outlineVertices, pos1.x, pos1.y, pos2.z, colorBottom)
Expand Down Expand Up @@ -104,4 +105,6 @@ fun ESPRenderer.buildOutline(
if (outlineMode.check(hasNorth, hasEast)) putLine(trb, brb)
if (outlineMode.check(hasEast, hasSouth)) putLine(trf, brf)
if (outlineMode.check(hasSouth, hasWest)) putLine(tlf, blf)

updateOutlines = true
}
Loading