Skip to content

Commit 0f8e2e4

Browse files
committed
RenderPipeline(raw)
1 parent 4d1823d commit 0f8e2e4

File tree

12 files changed

+134
-90
lines changed

12 files changed

+134
-90
lines changed

common/src/main/kotlin/com/lambda/event/events/RenderEvent.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ import com.lambda.Lambda.mc
2121
import com.lambda.event.Event
2222
import com.lambda.event.callback.Cancellable
2323
import com.lambda.event.callback.ICancellable
24-
import com.lambda.graphics.renderer.esp.global.DynamicESP
24+
import com.lambda.graphics.RenderPipeline
2525
import com.lambda.graphics.renderer.esp.global.StaticESP
2626
import com.lambda.util.math.Vec2d
2727

2828
sealed class RenderEvent {
2929
class World : Event
3030

3131
class StaticESP : Event {
32-
val renderer = StaticESP
32+
val renderer = RenderPipeline.STATIC_ESP
3333
}
3434

3535
class DynamicESP : Event {
36-
val renderer = DynamicESP
36+
val renderer = RenderPipeline.DYNAMIC_ESP
3737
}
3838

3939
sealed class GUI(val scale: Double) : Event {

common/src/main/kotlin/com/lambda/graphics/RenderMain.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import com.lambda.graphics.buffer.FrameBuffer
2828
import com.lambda.graphics.gl.GlStateUtils.setupGL
2929
import com.lambda.graphics.gl.Matrices
3030
import com.lambda.graphics.gl.Matrices.resetMatrices
31-
import com.lambda.graphics.renderer.esp.global.StaticESP
32-
import com.lambda.graphics.renderer.esp.global.DynamicESP
3331
import com.lambda.graphics.shader.Shader
3432
import com.lambda.gui.impl.hudgui.LambdaHudGui
3533
import com.lambda.module.modules.client.ClickGui
@@ -80,8 +78,6 @@ object RenderMain {
8078

8179
setupGL {
8280
RenderEvent.World().post()
83-
StaticESP.render()
84-
DynamicESP.render()
8581
}
8682
}
8783

common/src/main/kotlin/com/lambda/graphics/renderer/esp/global/DynamicESP.kt renamed to common/src/main/kotlin/com/lambda/graphics/RenderPipeline.kt

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,39 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
package com.lambda.graphics.renderer.esp.global
18+
package com.lambda.graphics
1919

20+
import com.lambda.core.Loadable
2021
import com.lambda.event.EventFlow.post
2122
import com.lambda.event.events.RenderEvent
2223
import com.lambda.event.events.TickEvent
2324
import com.lambda.event.listener.SafeListener.Companion.listener
2425
import com.lambda.graphics.renderer.esp.impl.DynamicESPRenderer
26+
import com.lambda.graphics.renderer.esp.impl.StaticESPRenderer
27+
28+
object RenderPipeline : Loadable {
29+
// Updates once a tick, stays fixed, uses less memory
30+
val STATIC_ESP = StaticESPRenderer()
31+
32+
// Updates once a tick, interpolates within frames
33+
val DYNAMIC_ESP = DynamicESPRenderer()
2534

26-
object DynamicESP : DynamicESPRenderer() {
2735
init {
36+
// Ticked 3d renderers update
2837
listener<TickEvent.Post> {
29-
clear()
38+
STATIC_ESP.clear()
39+
RenderEvent.StaticESP().post()
40+
STATIC_ESP.upload()
41+
42+
DYNAMIC_ESP.clear()
3043
RenderEvent.DynamicESP().post()
31-
upload()
44+
DYNAMIC_ESP.upload()
45+
}
46+
47+
// 3d renderers drawcall
48+
listener<RenderEvent.World> {
49+
STATIC_ESP.render()
50+
DYNAMIC_ESP.render()
3251
}
3352
}
34-
}
53+
}

common/src/main/kotlin/com/lambda/graphics/renderer/esp/global/StaticESP.kt

Lines changed: 0 additions & 34 deletions
This file was deleted.

common/src/main/kotlin/com/lambda/interaction/construction/result/Drawable.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
package com.lambda.interaction.construction.result
1919

2020
import com.lambda.context.SafeContext
21+
import com.lambda.graphics.RenderPipeline
2122
import com.lambda.graphics.renderer.esp.DirectionMask
2223
import com.lambda.graphics.renderer.esp.DirectionMask.include
23-
import com.lambda.graphics.renderer.esp.global.StaticESP
2424
import com.lambda.graphics.renderer.esp.builders.buildFilled
2525
import com.lambda.util.BlockUtils.blockState
2626
import net.minecraft.block.BlockState
@@ -34,7 +34,7 @@ interface Drawable {
3434
fun SafeContext.buildRenderer()
3535

3636
fun SafeContext.withBox(box: Box, color: Color, mask: Int = DirectionMask.ALL) {
37-
StaticESP.buildFilled(box, color, mask)
37+
RenderPipeline.STATIC_ESP.buildFilled(box, color, mask)
3838
//StaticESP.buildOutline(box, color, mask)
3939
}
4040

common/src/main/kotlin/com/lambda/module/modules/player/FastBreak.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ package com.lambda.module.modules.player
2020
import com.lambda.context.SafeContext
2121
import com.lambda.event.events.*
2222
import com.lambda.event.listener.SafeListener.Companion.listener
23+
import com.lambda.graphics.RenderPipeline
2324
import com.lambda.graphics.renderer.esp.DynamicAABB
2425
import com.lambda.graphics.renderer.esp.builders.buildFilled
2526
import com.lambda.graphics.renderer.esp.builders.buildOutline
26-
import com.lambda.graphics.renderer.esp.global.DynamicESP
2727
import com.lambda.module.Module
2828
import com.lambda.module.tag.ModuleTag
2929
import com.lambda.util.math.lerp
@@ -59,8 +59,7 @@ object FastBreak : Module(
5959
private val endOutlineColour by setting("End Outline Colour", Color(0f, 1f, 0f, 0.3f), "The colour used to render the end outline of the box", visibility = { page == Page.Render && renderMode.isEnabled() && renderSetting != RenderSetting.Fill && outlineColourMode == ColourMode.Dynamic })
6060
private val outlineWidth by setting("Outline Width", 1f, 0f..3f, 0.1f, "the thickness of the outline", visibility = { page == Page.Render && renderMode.isEnabled() && renderSetting != RenderSetting.Fill })
6161

62-
63-
private val renderer = DynamicESP
62+
private val renderer = RenderPipeline.DYNAMIC_ESP
6463
private var boxSet = emptySet<Box>()
6564

6665
private enum class Page {

common/src/main/kotlin/com/lambda/module/modules/player/PacketMine.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ import com.lambda.Lambda.mc
2121
import com.lambda.context.SafeContext
2222
import com.lambda.event.events.*
2323
import com.lambda.event.listener.SafeListener.Companion.listener
24+
import com.lambda.graphics.RenderPipeline
2425
import com.lambda.graphics.renderer.esp.DynamicAABB
2526
import com.lambda.graphics.renderer.esp.builders.buildFilled
2627
import com.lambda.graphics.renderer.esp.builders.buildOutline
27-
import com.lambda.graphics.renderer.esp.global.DynamicESP
2828
import com.lambda.interaction.RotationManager
2929
import com.lambda.interaction.rotation.RotationContext
3030
import com.lambda.interaction.visibilty.VisibilityChecker.findRotation
@@ -246,7 +246,7 @@ object PacketMine : Module(
246246
this == Primary
247247
}
248248

249-
val renderer = DynamicESP
249+
val renderer = RenderPipeline.DYNAMIC_ESP
250250
private var currentMiningBlock = Array<BreakingContext?>(2) { null }
251251
private var lastNonEmptyState: BlockState? = null
252252
private val blockQueue = ArrayDeque<BlockPos>()

common/src/main/kotlin/com/lambda/newgui/component/window/TitleBar.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package com.lambda.newgui.component.window
1919

2020
import com.lambda.module.modules.client.NewCGui
2121
import com.lambda.newgui.component.HAlign
22-
import com.lambda.newgui.component.VAlign
2322
import com.lambda.newgui.component.core.TextField.Companion.textField
2423
import com.lambda.newgui.component.core.UIBuilder
2524
import com.lambda.newgui.component.layout.Layout

common/src/main/kotlin/com/lambda/newgui/component/window/WindowContent.kt

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,43 @@ class WindowContent(
3434
private var scrollOffset = 0.0
3535
private var rubberbandDelta = 0.0
3636

37-
private var renderScrollOffset by animation.exp({ scrollOffset + rubberbandDelta }, 0.7)
38-
private val scaleAnimation by animation.exp(1.0, 0.9, 0.7, ::scrolling)
37+
var renderScrollOffset by animation.exp({ scrollOffset + rubberbandDelta }, 0.7)
3938
private var scrolling = false
4039

40+
private var contentHeight = {
41+
NewCGui.padding * 2 +
42+
children.sumOf(Layout::renderHeight) +
43+
NewCGui.listStep * (children.size - 1).coerceAtLeast(0)
44+
}
45+
46+
private var reorder = block@ {
47+
children.forEachIndexed { i, child ->
48+
val prev by lazy { children[i - 1] }
49+
50+
child.overrideY {
51+
if (i == 0) {
52+
renderPositionY + renderScrollOffset + NewCGui.padding
53+
} else {
54+
prev.renderPositionY + prev.renderHeight + NewCGui.listStep
55+
}
56+
}
57+
}
58+
}
59+
60+
/**
61+
* Overrides the summary height of the content
62+
*/
63+
fun overrideContentHeight(block: () -> Double) {
64+
contentHeight = block
65+
}
66+
67+
/**
68+
* Overrides the action performed on ordering update
69+
*/
70+
fun reorderChildren(block: () -> Unit) {
71+
reorder = block
72+
}
73+
4174
init {
4275
overrideX { owner.titleBar.renderPositionX }
4376
overrideY { owner.titleBar.let { it.renderPositionY + it.renderHeight } }
@@ -50,7 +83,7 @@ class WindowContent(
5083
rubberbandDelta = 0.0
5184
renderScrollOffset = 0.0
5285

53-
reorderChildren()
86+
if (scrollable) reorder()
5487
}
5588

5689
onTick {
@@ -70,8 +103,6 @@ class WindowContent(
70103
if (abs(rubberbandDelta) < 0.05) rubberbandDelta = 0.0
71104

72105
animation.tick()
73-
74-
reorderChildren()
75106
}
76107

77108
onMouseScroll { delta ->
@@ -80,29 +111,12 @@ class WindowContent(
80111
}
81112
}
82113

83-
private fun reorderChildren() {
84-
if (!scrollable) return
85-
86-
children.forEachIndexed { i, child ->
87-
val prev by lazy { children[i - 1] }
88-
89-
child.overrideY {
90-
if (i == 0) {
91-
renderPositionY + renderScrollOffset + NewCGui.padding
92-
} else {
93-
prev.renderPositionY + prev.renderHeight + NewCGui.listStep
94-
}
95-
}
96-
}
114+
override fun render(e: GuiEvent) {
115+
if (scrollable) reorder()
116+
super.render(e)
97117
}
98118

99-
fun getContentHeight(): Double {
100-
val components = children.sumOf(Layout::renderHeight)
101-
val step = NewCGui.listStep * (children.size - 1).coerceAtLeast(0)
102-
val padding = NewCGui.padding * 2
103-
104-
return components + step + padding
105-
}
119+
fun getContentHeight() = contentHeight()
106120

107121
companion object {
108122
/**

common/src/main/kotlin/com/lambda/newgui/impl/clickgui/ModuleLayout.kt

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,37 @@ class ModuleLayout(
7777
}
7878
}
7979

80+
content.overrideContentHeight {
81+
val settings = content.children
82+
.filterIsInstance<SettingLayout<*, *>>()
83+
84+
val components = settings.sumOf {
85+
(it.renderHeight + NewCGui.listStep) * it.visibilityAnimation
86+
} - NewCGui.listStep
87+
88+
val padding = NewCGui.padding * 2
89+
components + if (settings.isNotEmpty()) padding else 0.0
90+
}
91+
92+
content.reorderChildren {
93+
val settings = content.children
94+
.filterIsInstance<SettingLayout<*, *>>()
95+
96+
var y = 0.0
97+
98+
settings.forEach {
99+
if (it.visible) {
100+
it.heightOffset = y
101+
}
102+
103+
y += (it.renderHeight + NewCGui.listStep) * it.visibilityAnimation
104+
105+
it.overrideY {
106+
content.renderPositionY + content.renderScrollOffset + NewCGui.padding + it.heightOffset
107+
}
108+
}
109+
}
110+
80111
rect { // Separator
81112
onUpdate {
82113
val vec = Vec2d(
@@ -94,10 +125,6 @@ class ModuleLayout(
94125
}
95126
}
96127

97-
onShow {
98-
enableAnimation = 0.0
99-
}
100-
101128
titleBarRect.onUpdate {
102129
setColor(lerp(enableAnimation, NewCGui.moduleDisabledColor, NewCGui.moduleEnabledColor))
103130
correctRadius()
@@ -110,18 +137,22 @@ class ModuleLayout(
110137

111138
children.remove(outlineRect)
112139

140+
onShow {
141+
enableAnimation = 0.0
142+
}
143+
113144
onTick {
114145
val cursor = if (titleBar.isHovered) Mouse.Cursor.Pointer else Mouse.Cursor.Arrow
115146
cursorController.setCursor(cursor)
116147
}
117148

118-
content.apply {
119-
module.settings.forEach { setting -> layoutOf(setting) }
149+
module.settings.forEach { setting ->
150+
content.layoutOf(setting)
120151
}
121152
}
122153

123154
private fun FilledRect.correctRadius() {
124-
if (!isLast) {
155+
if (!isLast || !NewCGui.autoResize) {
125156
setRadius(0.0)
126157
return
127158
}

0 commit comments

Comments
 (0)