mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-06-10 22:58:56 +02:00
d4106d545b
- Outline buffering now uses Vector3f instead of Vec3 to avoid creating many objects and double to float casts - Remove OutlineParams.transformNormals since it was not used - Rename OutlineParams#disableNormals to disableLineNormals since only lines have normals disabled - Fix seats not having descriptions
49 lines
1.3 KiB
Java
49 lines
1.3 KiB
Java
package com.simibubi.create.foundation.utility.outliner;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.math.Vector4f;
|
|
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
|
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.phys.AABB;
|
|
|
|
public class ChasingAABBOutline extends AABBOutline {
|
|
|
|
AABB targetBB;
|
|
AABB prevBB;
|
|
|
|
public ChasingAABBOutline(AABB bb) {
|
|
super(bb);
|
|
prevBB = bb.inflate(0);
|
|
targetBB = bb.inflate(0);
|
|
}
|
|
|
|
public void target(AABB target) {
|
|
targetBB = target;
|
|
}
|
|
|
|
@Override
|
|
public void tick() {
|
|
prevBB = bb;
|
|
setBounds(interpolateBBs(bb, targetBB, .5f));
|
|
}
|
|
|
|
@Override
|
|
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
|
params.loadColor(colorTemp);
|
|
Vector4f color = colorTemp;
|
|
int lightmap = params.lightmap;
|
|
boolean disableLineNormals = params.disableLineNormals;
|
|
|
|
renderBox(ms, buffer, interpolateBBs(prevBB, bb, pt), color, lightmap, disableLineNormals);
|
|
}
|
|
|
|
private static AABB interpolateBBs(AABB current, AABB target, float pt) {
|
|
return new AABB(Mth.lerp(pt, current.minX, target.minX),
|
|
Mth.lerp(pt, current.minY, target.minY), Mth.lerp(pt, current.minZ, target.minZ),
|
|
Mth.lerp(pt, current.maxX, target.maxX), Mth.lerp(pt, current.maxY, target.maxY),
|
|
Mth.lerp(pt, current.maxZ, target.maxZ));
|
|
}
|
|
|
|
}
|