Merge ease

This commit is contained in:
Jozufozu 2022-08-22 13:57:53 -07:00
parent 57f6a48969
commit 04d291e01b
15 changed files with 64 additions and 47 deletions

View file

@ -14,7 +14,7 @@ import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine;
import com.jozufozu.flywheel.core.Components;
import com.jozufozu.flywheel.core.RenderContext;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.util.extension.ClientLevelExtension;
import com.jozufozu.flywheel.extension.ClientLevelExtension;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;

View file

@ -3,7 +3,7 @@ package com.jozufozu.flywheel.backend.instancing.batching;
import java.util.HashSet;
import java.util.Set;
import com.jozufozu.flywheel.util.extension.RenderTypeExtension;
import com.jozufozu.flywheel.extension.RenderTypeExtension;
import com.mojang.blaze3d.vertex.BufferBuilder;
import net.minecraft.client.renderer.RenderType;

View file

@ -2,7 +2,7 @@ package com.jozufozu.flywheel.core;
import org.jetbrains.annotations.NotNull;
import com.jozufozu.flywheel.util.extension.Matrix4fExtension;
import com.jozufozu.flywheel.extension.Matrix4fExtension;
import com.jozufozu.flywheel.util.joml.FrustumIntersection;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Matrix4f;
@ -11,7 +11,6 @@ import net.minecraft.client.Camera;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.renderer.LevelRenderer;
import net.minecraft.client.renderer.RenderBuffers;
import net.minecraft.world.phys.Vec3;
public record RenderContext(LevelRenderer renderer, ClientLevel level, PoseStack stack, Matrix4f viewProjection,
Matrix4f projection, RenderBuffers buffers, Camera camera, FrustumIntersection culler) {

View file

@ -3,7 +3,7 @@ package com.jozufozu.flywheel.core.structs.transformed;
import org.lwjgl.system.MemoryUtil;
import com.jozufozu.flywheel.api.struct.StorageBufferWriter;
import com.jozufozu.flywheel.util.extension.MatrixExtension;
import com.jozufozu.flywheel.extension.MatrixWrite;
public class TransformedStorageWriter implements StorageBufferWriter<TransformedPart> {
@ -14,8 +14,8 @@ public class TransformedStorageWriter implements StorageBufferWriter<Transformed
@Override
public void write(long ptr, TransformedPart instance) {
MatrixExtension.writeUnsafe(instance.model, ptr);
MatrixExtension.writeUnsafe(instance.normal, ptr + 64);
MatrixWrite.writeUnsafe(instance.model, ptr);
MatrixWrite.writeUnsafe(instance.normal, ptr + 64);
MemoryUtil.memPutByte(ptr + 100, instance.r);
MemoryUtil.memPutByte(ptr + 101, instance.g);
MemoryUtil.memPutByte(ptr + 102, instance.b);

View file

@ -1,7 +1,7 @@
package com.jozufozu.flywheel.core.structs.transformed;
import com.jozufozu.flywheel.core.structs.ColoredLitWriter;
import com.jozufozu.flywheel.util.extension.MatrixExtension;
import com.jozufozu.flywheel.extension.MatrixWrite;
public class TransformedWriter extends ColoredLitWriter<TransformedPart> {
public static final TransformedWriter INSTANCE = new TransformedWriter();
@ -11,7 +11,7 @@ public class TransformedWriter extends ColoredLitWriter<TransformedPart> {
super.write(ptr, d);
ptr += 6;
((MatrixExtension) (Object) d.model).flywheel$writeUnsafe(ptr);
((MatrixExtension) (Object) d.normal).flywheel$writeUnsafe(ptr + 4 * 16);
((MatrixWrite) (Object) d.model).flywheel$writeUnsafe(ptr);
((MatrixWrite) (Object) d.normal).flywheel$writeUnsafe(ptr + 4 * 16);
}
}

View file

@ -8,7 +8,7 @@ import com.jozufozu.flywheel.core.Components;
import com.jozufozu.flywheel.core.RenderContext;
import com.jozufozu.flywheel.core.source.FileResolution;
import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.util.extension.MatrixExtension;
import com.jozufozu.flywheel.extension.MatrixWrite;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.core.Vec3i;
@ -52,7 +52,7 @@ public class ViewProvider extends UniformProvider {
var vp = context.viewProjection().copy();
vp.multiplyWithTranslation(-camX, -camY, -camZ);
MatrixExtension.writeUnsafe(vp, ptr);
MatrixWrite.writeUnsafe(vp, ptr);
MemoryUtil.memPutFloat(ptr + 64, camX);
MemoryUtil.memPutFloat(ptr + 68, camY);
MemoryUtil.memPutFloat(ptr + 72, camZ);

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.util.extension;
package com.jozufozu.flywheel.extension;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.entity.Entity;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.util.extension;
package com.jozufozu.flywheel.extension;
import com.jozufozu.flywheel.util.joml.Matrix3f;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.util.extension;
package com.jozufozu.flywheel.extension;
import com.jozufozu.flywheel.util.joml.Matrix4f;

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.util.extension;
package com.jozufozu.flywheel.extension;
import java.nio.ByteBuffer;
@ -9,7 +9,7 @@ import com.mojang.math.Matrix4f;
* @see com.jozufozu.flywheel.mixin.matrix.Matrix3fMixin
* @see com.jozufozu.flywheel.mixin.matrix.Matrix4fMixin
*/
public interface MatrixExtension {
public interface MatrixWrite {
/**
* Write the contents of this object into sequential memory starting at the given address.
@ -19,14 +19,14 @@ public interface MatrixExtension {
void flywheel$write(ByteBuffer buf);
static void write(Matrix4f matrix, ByteBuffer buf) {
((MatrixExtension) (Object) matrix).flywheel$write(buf);
((MatrixWrite) (Object) matrix).flywheel$write(buf);
}
static void writeUnsafe(Matrix4f matrix, long ptr) {
((MatrixExtension) (Object) matrix).flywheel$writeUnsafe(ptr);
((MatrixWrite) (Object) matrix).flywheel$writeUnsafe(ptr);
}
static void writeUnsafe(Matrix3f matrix, long ptr) {
((MatrixExtension) (Object) matrix).flywheel$writeUnsafe(ptr);
((MatrixWrite) (Object) matrix).flywheel$writeUnsafe(ptr);
}
}

View file

@ -1,4 +1,4 @@
package com.jozufozu.flywheel.util.extension;
package com.jozufozu.flywheel.extension;
import com.jozufozu.flywheel.backend.instancing.batching.DrawBuffer;

View file

@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.Backend;
import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry;
import com.jozufozu.flywheel.util.extension.ClientLevelExtension;
import com.jozufozu.flywheel.extension.ClientLevelExtension;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.entity.Entity;

View file

@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import com.jozufozu.flywheel.backend.instancing.batching.DrawBuffer;
import com.jozufozu.flywheel.util.extension.RenderTypeExtension;
import com.jozufozu.flywheel.extension.RenderTypeExtension;
import net.minecraft.client.renderer.RenderType;

View file

@ -6,22 +6,31 @@ import org.lwjgl.system.MemoryUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.jozufozu.flywheel.util.extension.Matrix3fExtension;
import com.jozufozu.flywheel.util.extension.MatrixExtension;
import com.jozufozu.flywheel.extension.Matrix3fExtension;
import com.jozufozu.flywheel.extension.MatrixWrite;
import com.mojang.math.Matrix3f;
@Mixin(Matrix3f.class)
public abstract class Matrix3fMixin implements MatrixExtension, Matrix3fExtension {
public abstract class Matrix3fMixin implements MatrixWrite, Matrix3fExtension {
@Shadow protected float m00;
@Shadow protected float m01;
@Shadow protected float m02;
@Shadow protected float m10;
@Shadow protected float m11;
@Shadow protected float m12;
@Shadow protected float m20;
@Shadow protected float m21;
@Shadow protected float m22;
@Shadow
protected float m00;
@Shadow
protected float m01;
@Shadow
protected float m02;
@Shadow
protected float m10;
@Shadow
protected float m11;
@Shadow
protected float m12;
@Shadow
protected float m20;
@Shadow
protected float m21;
@Shadow
protected float m22;
@Override
public void flywheel$writeUnsafe(long ptr) {

View file

@ -6,22 +6,31 @@ import org.lwjgl.system.MemoryUtil;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import com.jozufozu.flywheel.util.extension.Matrix4fExtension;
import com.jozufozu.flywheel.util.extension.MatrixExtension;
import com.jozufozu.flywheel.extension.Matrix4fExtension;
import com.jozufozu.flywheel.extension.MatrixWrite;
import com.mojang.math.Matrix4f;
@Mixin(Matrix4f.class)
public abstract class Matrix4fMixin implements MatrixExtension, Matrix4fExtension {
public abstract class Matrix4fMixin implements MatrixWrite, Matrix4fExtension {
@Shadow protected float m00;
@Shadow protected float m01;
@Shadow protected float m02;
@Shadow protected float m03;
@Shadow protected float m10;
@Shadow protected float m11;
@Shadow protected float m12;
@Shadow protected float m13;
@Shadow protected float m20;
@Shadow
protected float m00;
@Shadow
protected float m01;
@Shadow
protected float m02;
@Shadow
protected float m03;
@Shadow
protected float m10;
@Shadow
protected float m11;
@Shadow
protected float m12;
@Shadow
protected float m13;
@Shadow
protected float m20;
@Shadow protected float m21;
@Shadow protected float m22;
@Shadow protected float m23;