-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79be4af
commit d598173
Showing
11 changed files
with
146 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
mmdrenderer/src/main/java/com/primogemstudio/advancedfmk/interfaces/BufferBuilderExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
package com.primogemstudio.advancedfmk.interfaces | ||
|
||
import com.primogemstudio.advancedfmk.mmd.PMXModel | ||
|
||
interface BufferBuilderExt { | ||
fun fullFormat(): Boolean | ||
fun bumpNxt(d: Int) | ||
fun submit() | ||
fun resize() | ||
fun padding(): Int | ||
fun setPtr(ptr: Int) | ||
fun getPMXModel(): PMXModel? | ||
fun setPMXModel(model: PMXModel?) | ||
} | ||
|
||
interface RenderedBufferExt { | ||
fun getPMXModel(): PMXModel? | ||
fun setPMXModel(model: PMXModel?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
mmdrenderer/src/main/java/com/primogemstudio/advancedfmk/mixin/VertexBufferMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.primogemstudio.advancedfmk.mixin; | ||
|
||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import com.mojang.blaze3d.vertex.BufferBuilder; | ||
import com.mojang.blaze3d.vertex.VertexBuffer; | ||
import com.mojang.blaze3d.vertex.VertexFormat; | ||
import com.primogemstudio.advancedfmk.interfaces.RenderedBufferExt; | ||
import com.primogemstudio.advancedfmk.mmd.PMXModel; | ||
import org.jetbrains.annotations.Nullable; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
@Mixin(VertexBuffer.class) | ||
public abstract class VertexBufferMixin { | ||
@Shadow | ||
@Nullable | ||
protected abstract RenderSystem.AutoStorageIndexBuffer uploadIndexBuffer(BufferBuilder.DrawState drawState, @Nullable ByteBuffer buffer); | ||
|
||
@Unique | ||
private PMXModel getModel(BufferBuilder.RenderedBuffer buffer) { | ||
return ((RenderedBufferExt) buffer).getPMXModel(); | ||
} | ||
|
||
@Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/BufferBuilder$DrawState;indexCount()I")) | ||
private int indexCount(BufferBuilder.DrawState instance, BufferBuilder.RenderedBuffer buffer) { | ||
var model = getModel(buffer); | ||
return model != null ? model.indexCount : instance.indexCount(); | ||
} | ||
|
||
@Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/BufferBuilder$DrawState;indexType()Lcom/mojang/blaze3d/vertex/VertexFormat$IndexType;")) | ||
private VertexFormat.IndexType indexType(BufferBuilder.DrawState instance, BufferBuilder.RenderedBuffer buffer) { | ||
var model = getModel(buffer); | ||
return model != null ? VertexFormat.IndexType.INT : instance.indexType(); | ||
} | ||
|
||
@Redirect(method = "upload", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/VertexBuffer;uploadIndexBuffer(Lcom/mojang/blaze3d/vertex/BufferBuilder$DrawState;Ljava/nio/ByteBuffer;)Lcom/mojang/blaze3d/systems/RenderSystem$AutoStorageIndexBuffer;")) | ||
private RenderSystem.AutoStorageIndexBuffer uploadIndexBuffer(VertexBuffer instance, BufferBuilder.DrawState drawState, ByteBuffer buffer, BufferBuilder.RenderedBuffer buff) { | ||
var model = getModel(buff); | ||
if (model != null) { | ||
model.bindIndices(); | ||
return null; | ||
} | ||
return uploadIndexBuffer(drawState, buffer); | ||
} | ||
} |
28 changes: 25 additions & 3 deletions
28
mmdrenderer/src/main/java/com/primogemstudio/advancedfmk/mmd/PMXModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule natives
updated
6 files
+ − | arm/libsaba-native.dylib | |
+ − | arm/libsaba-native.so | |
+ − | arm/saba-native.dll | |
+ − | libsaba-native.dylib | |
+ − | libsaba-native.so | |
+ − | saba-native.dll |