mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-14 08:16:13 +01:00
Literally unusable
- Trim out dead light code from *EmbeddedEnvironment - Fix indirect never deleting empty culling groups - Fix embedded transforms not being applied
This commit is contained in:
parent
b7c8604898
commit
ef2bb09fcd
7 changed files with 19 additions and 21 deletions
|
@ -57,8 +57,6 @@ public abstract class AbstractEmbeddedEnvironment implements Environment, Visual
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setupDraw(GlProgram program) {
|
public void setupDraw(GlProgram program) {
|
||||||
setupLight(program);
|
|
||||||
|
|
||||||
program.setMat4(EmbeddingUniforms.MODEL_MATRIX, poseComposed);
|
program.setMat4(EmbeddingUniforms.MODEL_MATRIX, poseComposed);
|
||||||
program.setMat3(EmbeddingUniforms.NORMAL_MATRIX, normalComposed);
|
program.setMat3(EmbeddingUniforms.NORMAL_MATRIX, normalComposed);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +107,5 @@ public abstract class AbstractEmbeddedEnvironment implements Environment, Visual
|
||||||
deleted = true;
|
deleted = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void setupLight(GlProgram program);
|
|
||||||
|
|
||||||
public abstract void composeMatrices(Matrix4f pose, Matrix3f normal);
|
public abstract void composeMatrices(Matrix4f pose, Matrix3f normal);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.joml.Matrix4f;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.event.RenderStage;
|
import dev.engine_room.flywheel.api.event.RenderStage;
|
||||||
import dev.engine_room.flywheel.backend.engine.EngineImpl;
|
import dev.engine_room.flywheel.backend.engine.EngineImpl;
|
||||||
import dev.engine_room.flywheel.backend.gl.shader.GlProgram;
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
|
|
||||||
public class NestedEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
public class NestedEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
||||||
|
@ -21,11 +20,6 @@ public class NestedEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupLight(GlProgram program) {
|
|
||||||
parent.setupLight(program);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
|
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
|
||||||
parent.composeMatrices(pose, normal);
|
parent.composeMatrices(pose, normal);
|
||||||
|
|
|
@ -5,7 +5,6 @@ import org.joml.Matrix4f;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.api.event.RenderStage;
|
import dev.engine_room.flywheel.api.event.RenderStage;
|
||||||
import dev.engine_room.flywheel.backend.engine.EngineImpl;
|
import dev.engine_room.flywheel.backend.engine.EngineImpl;
|
||||||
import dev.engine_room.flywheel.backend.gl.shader.GlProgram;
|
|
||||||
import it.unimi.dsi.fastutil.longs.LongArraySet;
|
import it.unimi.dsi.fastutil.longs.LongArraySet;
|
||||||
import it.unimi.dsi.fastutil.longs.LongSet;
|
import it.unimi.dsi.fastutil.longs.LongSet;
|
||||||
|
|
||||||
|
@ -27,11 +26,6 @@ public class TopLevelEmbeddedEnvironment extends AbstractEmbeddedEnvironment {
|
||||||
out.addAll(lightSections);
|
out.addAll(lightSections);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setupLight(GlProgram program) {
|
|
||||||
program.setBool(EmbeddingUniforms.USE_LIGHT_VOLUME, !lightSections.isEmpty());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
|
public void composeMatrices(Matrix4f pose, Matrix3f normal) {
|
||||||
pose.set(this.pose);
|
pose.set(this.pose);
|
||||||
|
|
|
@ -277,6 +277,16 @@ public class IndirectCullingGroup<I extends Instance> {
|
||||||
buffers.delete();
|
buffers.delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean checkEmptyAndDelete() {
|
||||||
|
var out = indirectDraws.isEmpty();
|
||||||
|
|
||||||
|
if (out) {
|
||||||
|
delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
private record MultiDraw(Material material, int start, int end) {
|
private record MultiDraw(Material material, int start, int end) {
|
||||||
private void submit() {
|
private void submit() {
|
||||||
GlCompat.safeMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, this.start * IndirectBuffers.DRAW_COMMAND_STRIDE, this.end - this.start, (int) IndirectBuffers.DRAW_COMMAND_STRIDE);
|
GlCompat.safeMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, this.start * IndirectBuffers.DRAW_COMMAND_STRIDE, this.end - this.start, (int) IndirectBuffers.DRAW_COMMAND_STRIDE);
|
||||||
|
|
|
@ -107,7 +107,11 @@ public class IndirectDrawManager extends DrawManager<IndirectInstancer<?>> {
|
||||||
group.flushInstancers();
|
group.flushInstancers();
|
||||||
}
|
}
|
||||||
|
|
||||||
instancers.values().removeIf(instancer -> instancer.instanceCount() == 0);
|
cullingGroups.values()
|
||||||
|
.removeIf(IndirectCullingGroup::checkEmptyAndDelete);
|
||||||
|
|
||||||
|
instancers.values()
|
||||||
|
.removeIf(instancer -> instancer.instanceCount() == 0);
|
||||||
|
|
||||||
meshPool.flush();
|
meshPool.flush();
|
||||||
|
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class InstancedDrawManager extends DrawManager<InstancedInstancer<?>> {
|
||||||
public void flush(LightStorage lightStorage) {
|
public void flush(LightStorage lightStorage) {
|
||||||
super.flush(lightStorage);
|
super.flush(lightStorage);
|
||||||
|
|
||||||
var instancers = this.instancers.values();
|
this.instancers.values()
|
||||||
instancers.removeIf(instancer -> {
|
.removeIf(instancer -> {
|
||||||
// Update the instancers and remove any that are empty.
|
// Update the instancers and remove any that are empty.
|
||||||
instancer.update();
|
instancer.update();
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ vec2 getCrumblingTexCoord() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _FLW_EMBEDDED
|
#ifdef FLW_EMBEDDED
|
||||||
uniform mat4 _flw_modelMatrix;
|
uniform mat4 _flw_modelMatrix;
|
||||||
uniform mat3 _flw_normalMatrix;
|
uniform mat3 _flw_normalMatrix;
|
||||||
#endif
|
#endif
|
||||||
|
@ -82,7 +82,7 @@ void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
|
||||||
_flw_crumblingTexCoord = getCrumblingTexCoord();
|
_flw_crumblingTexCoord = getCrumblingTexCoord();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _FLW_EMBEDDED
|
#ifdef FLW_EMBEDDED
|
||||||
flw_vertexPos = _flw_modelMatrix * flw_vertexPos;
|
flw_vertexPos = _flw_modelMatrix * flw_vertexPos;
|
||||||
flw_vertexNormal = _flw_normalMatrix * flw_vertexNormal;
|
flw_vertexNormal = _flw_normalMatrix * flw_vertexNormal;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue