mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-25 22:46:26 +01:00
Cool Command Captures/Pauses
- Add frustum debug utility - Fix scaling for transformed bounding spheres
This commit is contained in:
parent
564b0996f9
commit
8833181cfe
4 changed files with 30 additions and 4 deletions
|
@ -5,6 +5,7 @@ import java.util.function.BiConsumer;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import com.jozufozu.flywheel.backend.Backend;
|
||||
import com.jozufozu.flywheel.core.uniform.FrustumProvider;
|
||||
import com.mojang.brigadier.Command;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||
|
@ -109,6 +110,23 @@ public class FlwCommands {
|
|||
return 1;
|
||||
}))));
|
||||
|
||||
commandBuilder.command.then(Commands.literal("debugFrustum")
|
||||
.then(Commands.literal("pause")
|
||||
.executes(context -> {
|
||||
FrustumProvider.PAUSED = true;
|
||||
return 1;
|
||||
}))
|
||||
.then(Commands.literal("unpause")
|
||||
.executes(context -> {
|
||||
FrustumProvider.PAUSED = false;
|
||||
return 1;
|
||||
}))
|
||||
.then(Commands.literal("capture")
|
||||
.executes(context -> {
|
||||
FrustumProvider.CAPTURE = true;
|
||||
return 1;
|
||||
})));
|
||||
|
||||
commandBuilder.build(event.getDispatcher());
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,9 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
|
||||
public class FrustumProvider extends UniformProvider {
|
||||
|
||||
public static boolean PAUSED = false;
|
||||
public static boolean CAPTURE = false;
|
||||
|
||||
public FrustumProvider() {
|
||||
MinecraftForge.EVENT_BUS.addListener(this::beginFrame);
|
||||
}
|
||||
|
@ -34,7 +37,7 @@ public class FrustumProvider extends UniformProvider {
|
|||
}
|
||||
|
||||
public void update(RenderContext context) {
|
||||
if (ptr == MemoryUtil.NULL) {
|
||||
if (ptr == MemoryUtil.NULL || (PAUSED && !CAPTURE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -51,5 +54,6 @@ public class FrustumProvider extends UniformProvider {
|
|||
shiftedCuller.getJozuPackedPlanes(ptr);
|
||||
|
||||
notifier.signalChanged();
|
||||
CAPTURE = false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ void flw_transformBoundingSphere(in Instance i, inout vec3 center, inout float r
|
|||
center = rotateVertexByQuat(center - pivot, rotation) + pivot + pos;
|
||||
}
|
||||
|
||||
#ifdef VERTEX_SHADER
|
||||
#ifdef VERTEX_SHADER
|
||||
void flw_instanceVertex(Instance i) {
|
||||
vec4 rotation = unpackVec4F(i.rotation);
|
||||
vec3 pivot = unpackVec3F(i.pivot);
|
||||
|
|
|
@ -10,10 +10,14 @@ struct Instance {
|
|||
};
|
||||
|
||||
void flw_transformBoundingSphere(in Instance i, inout vec3 center, inout float radius) {
|
||||
center = (unpackMat4F(i.pose) * vec4(center, 1.0)).xyz;
|
||||
mat4 pose = unpackMat4F(i.pose);
|
||||
center = (pose * vec4(center, 1.0)).xyz;
|
||||
|
||||
float scale = max(length(pose[0].xyz), max(length(pose[1].xyz), length(pose[2].xyz)));
|
||||
radius *= scale;
|
||||
}
|
||||
|
||||
#ifdef VERTEX_SHADER
|
||||
#ifdef VERTEX_SHADER
|
||||
void flw_instanceVertex(Instance i) {
|
||||
flw_vertexPos = unpackMat4F(i.pose) * flw_vertexPos;
|
||||
flw_vertexNormal = unpackMat3F(i.normal) * flw_vertexNormal;
|
||||
|
|
Loading…
Reference in a new issue