Instancer interface

- Entire material/model system finally cleaned up
This commit is contained in:
Jozufozu 2021-09-12 09:40:37 -07:00
parent 6fcc960189
commit 2eef57204c
15 changed files with 30 additions and 29 deletions

View File

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.foundation.render.AllMaterialSpecs; import com.simibubi.create.foundation.render.AllMaterialSpecs;
@ -9,7 +9,7 @@ public class CutoutRotatingInstance extends SingleRotatingInstance {
super(modelManager, tile); super(modelManager, tile);
} }
protected InstanceMaterial<RotatingData> getRotatingMaterial() { protected Material<RotatingData> getRotatingMaterial() {
return materialManager.defaultCutout() return materialManager.defaultCutout()
.material(AllMaterialSpecs.ROTATING); .material(AllMaterialSpecs.ROTATING);
} }

View File

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.simibubi.create.AllBlocks; import com.simibubi.create.AllBlocks;
@ -84,7 +84,7 @@ public abstract class KineticTileInstance<T extends KineticTileEntity> extends T
return shaft(getRotationAxis()); return shaft(getRotationAxis());
} }
protected InstanceMaterial<RotatingData> getRotatingMaterial() { protected Material<RotatingData> getRotatingMaterial() {
return materialManager.defaultSolid() return materialManager.defaultSolid()
.material(AllMaterialSpecs.ROTATING); .material(AllMaterialSpecs.ROTATING);
} }

View File

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.base; package com.simibubi.create.content.contraptions.base;
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import net.minecraft.util.Direction; import net.minecraft.util.Direction;
@ -17,13 +18,11 @@ public class RotatingData extends KineticData {
public RotatingData setRotationAxis(Direction.Axis axis) { public RotatingData setRotationAxis(Direction.Axis axis) {
Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis); Direction orientation = Direction.get(Direction.AxisDirection.POSITIVE, axis);
setRotationAxis(orientation.step()); return setRotationAxis(orientation.step());
return this;
} }
public RotatingData setRotationAxis(Vector3f axis) { public RotatingData setRotationAxis(Vector3f axis) {
setRotationAxis(axis.x(), axis.y(), axis.z()); return setRotationAxis(axis.x(), axis.y(), axis.z());
return this;
} }
public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) { public RotatingData setRotationAxis(float rotationAxisX, float rotationAxisY, float rotationAxisZ) {

View File

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;

View File

@ -1,6 +1,6 @@
package com.simibubi.create.content.contraptions.components.actors; package com.simibubi.create.content.contraptions.components.actors;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext; import com.simibubi.create.content.contraptions.components.structureMovement.MovementContext;
@ -22,7 +22,7 @@ public class DrillActorInstance extends ActorInstance {
public DrillActorInstance(MaterialManager materialManager, PlacementSimulationWorld contraption, MovementContext context) { public DrillActorInstance(MaterialManager materialManager, PlacementSimulationWorld contraption, MovementContext context) {
super(materialManager, contraption, context); super(materialManager, contraption, context);
InstanceMaterial<ActorData> instanceMaterial = materialManager.defaultSolid() Material<ActorData> material = materialManager.defaultSolid()
.material(AllMaterialSpecs.ACTORS); .material(AllMaterialSpecs.ACTORS);
BlockState state = context.state; BlockState state = context.state;
@ -38,7 +38,7 @@ public class DrillActorInstance extends ActorInstance {
else else
eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0); eulerY = facing.toYRot() + ((axis == Direction.Axis.X) ? 180 : 0);
drillHead = instanceMaterial.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance(); drillHead = material.getModel(AllBlockPartials.DRILL_HEAD, state).createInstance();
drillHead.setPosition(context.localPos) drillHead.setPosition(context.localPos)
.setBlockLight(localBlockLight()) .setBlockLight(localBlockLight())

View File

@ -2,7 +2,7 @@ package com.simibubi.create.content.contraptions.components.actors;
import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING; import static net.minecraft.state.properties.BlockStateProperties.HORIZONTAL_FACING;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.materials.ModelData; import com.jozufozu.flywheel.core.materials.ModelData;
@ -37,14 +37,14 @@ public class HarvesterActorInstance extends ActorInstance {
public HarvesterActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) { public HarvesterActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
super(materialManager, simulationWorld, context); super(materialManager, simulationWorld, context);
InstanceMaterial<ModelData> instanceMaterial = materialManager.defaultCutout() Material<ModelData> material = materialManager.defaultCutout()
.material(Materials.TRANSFORMED); .material(Materials.TRANSFORMED);
BlockState state = context.state; BlockState state = context.state;
facing = state.getValue(HORIZONTAL_FACING); facing = state.getValue(HORIZONTAL_FACING);
harvester = instanceMaterial.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance(); harvester = material.getModel(AllBlockPartials.HARVESTER_BLADE, state).createInstance();
horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0); horizontalAngle = facing.toYRot() + ((facing.getAxis() == Direction.Axis.X) ? 180 : 0);

View File

@ -3,7 +3,7 @@ package com.simibubi.create.content.contraptions.components.deployer;
import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE; import static com.simibubi.create.content.contraptions.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING; import static com.simibubi.create.content.contraptions.base.DirectionalKineticBlock.FACING;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.Materials; import com.jozufozu.flywheel.core.Materials;
import com.jozufozu.flywheel.core.PartialModel; import com.jozufozu.flywheel.core.PartialModel;
@ -45,7 +45,7 @@ public class DeployerActorInstance extends ActorInstance {
public DeployerActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) { public DeployerActorInstance(MaterialManager materialManager, PlacementSimulationWorld simulationWorld, MovementContext context) {
super(materialManager, simulationWorld, context); super(materialManager, simulationWorld, context);
InstanceMaterial<ModelData> mat = materialManager.defaultSolid() Material<ModelData> mat = materialManager.defaultSolid()
.material(Materials.TRANSFORMED); .material(Materials.TRANSFORMED);
BlockState state = context.state; BlockState state = context.state;

View File

@ -9,7 +9,7 @@ import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData; import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
@ -63,7 +63,7 @@ public class FlyWheelInstance extends KineticTileInstance<FlywheelTileEntity> im
connectorAngleMult = flipAngle ? -1 : 1; connectorAngleMult = flipAngle ? -1 : 1;
InstanceMaterial<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance(); upperRotating = mat.getModel(AllBlockPartials.FLYWHEEL_UPPER_ROTATING, blockState).createInstance();
lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance(); lowerRotating = mat.getModel(AllBlockPartials.FLYWHEEL_LOWER_ROTATING, blockState).createInstance();

View File

@ -1,6 +1,7 @@
package com.simibubi.create.content.contraptions.relays.belt; package com.simibubi.create.content.contraptions.relays.belt;
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.simibubi.create.content.contraptions.base.KineticData; import com.simibubi.create.content.contraptions.base.KineticData;
import com.simibubi.create.foundation.block.render.SpriteShiftEntry; import com.simibubi.create.foundation.block.render.SpriteShiftEntry;

View File

@ -4,7 +4,7 @@ import java.util.ArrayList;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.IRotate; import com.simibubi.create.content.contraptions.base.IRotate;
@ -26,7 +26,7 @@ public class SplitShaftInstance extends KineticTileInstance<SplitShaftTileEntity
float speed = tile.getSpeed(); float speed = tile.getSpeed();
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial(); Material<RotatingData> rotatingMaterial = getRotatingMaterial();
for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) { for (Direction dir : Iterate.directionsInAxis(getRotationAxis())) {

View File

@ -5,7 +5,7 @@ import java.util.Map;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.simibubi.create.AllBlockPartials; import com.simibubi.create.AllBlockPartials;
import com.simibubi.create.content.contraptions.base.KineticTileInstance; import com.simibubi.create.content.contraptions.base.KineticTileInstance;
@ -33,7 +33,7 @@ public class GearboxInstance extends KineticTileInstance<GearboxTileEntity> {
int skyLight = world.getBrightness(LightType.SKY, pos); int skyLight = world.getBrightness(LightType.SKY, pos);
updateSourceFacing(); updateSourceFacing();
InstanceMaterial<RotatingData> rotatingMaterial = getRotatingMaterial(); Material<RotatingData> rotatingMaterial = getRotatingMaterial();
for (Direction direction : Iterate.directions) { for (Direction direction : Iterate.directions) {
final Direction.Axis axis = direction.getAxis(); final Direction.Axis axis = direction.getAxis();

View File

@ -1,13 +1,13 @@
package com.simibubi.create.content.logistics.block; package com.simibubi.create.content.logistics.block;
import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer; import com.jozufozu.flywheel.backend.gl.buffer.MappedBuffer;
import com.jozufozu.flywheel.backend.instancing.GPUInstancer;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.core.materials.IFlatLight; import com.jozufozu.flywheel.core.materials.IFlatLight;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.vector.Vector3f; import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.util.math.vector.Vector3i;
public class FlapData extends InstanceData implements IFlatLight<FlapData> { public class FlapData extends InstanceData implements IFlatLight<FlapData> {

View File

@ -6,7 +6,7 @@ import com.google.common.collect.Lists;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.InstanceData; import com.jozufozu.flywheel.backend.instancing.InstanceData;
import com.jozufozu.flywheel.backend.instancing.Instancer; import com.jozufozu.flywheel.backend.instancing.Instancer;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData; import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
@ -47,7 +47,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
public ArmInstance(MaterialManager modelManager, ArmTileEntity tile) { public ArmInstance(MaterialManager modelManager, ArmTileEntity tile) {
super(modelManager, tile); super(modelManager, tile);
InstanceMaterial<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance(); base = mat.getModel(AllBlockPartials.ARM_BASE, blockState).createInstance();
lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance(); lowerBody = mat.getModel(AllBlockPartials.ARM_LOWER_BODY, blockState).createInstance();

View File

@ -2,7 +2,7 @@ package com.simibubi.create.content.logistics.block.redstone;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.core.materials.ModelData; import com.jozufozu.flywheel.core.materials.ModelData;
import com.jozufozu.flywheel.util.transform.MatrixTransformStack; import com.jozufozu.flywheel.util.transform.MatrixTransformStack;
@ -26,7 +26,7 @@ public class AnalogLeverInstance extends TileEntityInstance<AnalogLeverTileEntit
public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) { public AnalogLeverInstance(MaterialManager modelManager, AnalogLeverTileEntity tile) {
super(modelManager, tile); super(modelManager, tile);
InstanceMaterial<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance(); handle = mat.getModel(AllBlockPartials.ANALOG_LEVER_HANDLE, blockState).createInstance();
indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance(); indicator = mat.getModel(AllBlockPartials.ANALOG_LEVER_INDICATOR, blockState).createInstance();

View File

@ -1,7 +1,7 @@
package com.simibubi.create.content.schematics.block; package com.simibubi.create.content.schematics.block;
import com.jozufozu.flywheel.backend.instancing.IDynamicInstance; import com.jozufozu.flywheel.backend.instancing.IDynamicInstance;
import com.jozufozu.flywheel.backend.material.InstanceMaterial; import com.jozufozu.flywheel.backend.material.Material;
import com.jozufozu.flywheel.backend.material.MaterialManager; import com.jozufozu.flywheel.backend.material.MaterialManager;
import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance;
import com.jozufozu.flywheel.core.materials.ModelData; import com.jozufozu.flywheel.core.materials.ModelData;
@ -20,7 +20,7 @@ public class SchematicannonInstance extends TileEntityInstance<SchematicannonTil
public SchematicannonInstance(MaterialManager modelManager, SchematicannonTileEntity tile) { public SchematicannonInstance(MaterialManager modelManager, SchematicannonTileEntity tile) {
super(modelManager, tile); super(modelManager, tile);
InstanceMaterial<ModelData> mat = getTransformMaterial(); Material<ModelData> mat = getTransformMaterial();
connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance(); connector = mat.getModel(AllBlockPartials.SCHEMATICANNON_CONNECTOR, blockState).createInstance();
pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance(); pipe = mat.getModel(AllBlockPartials.SCHEMATICANNON_PIPE, blockState).createInstance();