Fixed geometry leakage

This commit is contained in:
Sollace 2019-11-27 14:09:16 +02:00
parent 2cfe7e138a
commit 958da3a4b1
4 changed files with 94 additions and 116 deletions

View file

@ -644,7 +644,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(attributes.motionPitch)); stack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(attributes.motionPitch));
} }
PonyTransformation.forSize(getSize()).transform(this, part); PonyTransformation.forSize(getSize()).transform(this, part, stack);
} }
interface RenderStage { interface RenderStage {

View file

@ -7,7 +7,6 @@ import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.armour.IEquestrianArmour; import com.minelittlepony.model.armour.IEquestrianArmour;
import com.minelittlepony.mson.api.ModelContext; import com.minelittlepony.mson.api.ModelContext;
import com.minelittlepony.pony.IPony; import com.minelittlepony.pony.IPony;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.model.ModelPart; import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumer;
@ -126,14 +125,9 @@ public class ModelSeapony<T extends LivingEntity> extends ModelUnicorn<T> {
tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId); tail.renderPart(stack, vertices, overlayUv, lightUv, red, green, blue, alpha, attributes.interpolatorId);
GlStateManager.enableBlend();
leftFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha); leftFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
centerFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha); centerFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
rightFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha); rightFin.render(stack, vertices, overlayUv, lightUv, red, green, blue, alpha);
GlStateManager.disableBlend();
} }
@Override @Override

View file

@ -17,7 +17,6 @@ import net.minecraft.entity.EquipmentSlot;
import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.MathHelper;
import static com.minelittlepony.model.PonyModelConstants.PI; import static com.minelittlepony.model.PonyModelConstants.PI;
import static com.mojang.blaze3d.platform.GlStateManager.*;
public class LayerPonyCape<M extends ClientPonyModel<AbstractClientPlayerEntity>> extends AbstractPonyLayer<AbstractClientPlayerEntity, M> { public class LayerPonyCape<M extends ClientPonyModel<AbstractClientPlayerEntity>> extends AbstractPonyLayer<AbstractClientPlayerEntity, M> {
@ -33,7 +32,7 @@ public class LayerPonyCape<M extends ClientPonyModel<AbstractClientPlayerEntity>
&& player.isSkinOverlayVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null && player.isSkinOverlayVisible(PlayerModelPart.CAPE) && player.getCapeTexture() != null
&& player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) { && player.getEquippedStack(EquipmentSlot.CHEST).getItem() != Items.ELYTRA) {
pushMatrix(); stack.push();
model.transform(BodyPart.BODY, stack); model.transform(BodyPart.BODY, stack);
stack.translate(0, 0.24F, 0); stack.translate(0, 0.24F, 0);

View file

@ -1,12 +1,12 @@
package com.minelittlepony.client.transform; package com.minelittlepony.client.transform;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3d;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.minelittlepony.model.BodyPart; import com.minelittlepony.model.BodyPart;
import com.minelittlepony.model.IModel; import com.minelittlepony.model.IModel;
import com.minelittlepony.pony.meta.Size; import com.minelittlepony.pony.meta.Size;
import com.mojang.blaze3d.systems.RenderSystem;
import java.util.Map; import java.util.Map;
@ -14,22 +14,22 @@ public enum PonyTransformation {
NORMAL(Size.NORMAL, 0, 3F, 0.75F) { NORMAL(Size.NORMAL, 0, 3F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) translate(0, -0.3F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.3F, 0);
if (model.getAttributes().isCrouching) translate(0, -0.2F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.2F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.61F, 0.1F); if (model.getAttributes().isSleeping) stack.translate(0, -0.61F, 0.1F);
if (model.isRiding()) translate(0, -0.2F, -0.2F); if (model.isRiding()) stack.translate(0, -0.2F, -0.2F);
switch (part) { switch (part) {
case NECK: case NECK:
if (model.getAttributes().isCrouching) translate(-0.03F, 0.03F, 0.1F); if (model.getAttributes().isCrouching) stack.translate(-0.03F, 0.03F, 0.1F);
break; break;
case HEAD: case HEAD:
if (model.getAttributes().isCrouching) translate(0, 0.1F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.1F, 0);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.37F, 0.45F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.37F, 0.45F);
break; break;
case BACK: case BACK:
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
default: default:
} }
@ -37,103 +37,103 @@ public enum PonyTransformation {
}, },
LANKY(Size.LANKY, 0, 2.6F, 0.75F) { LANKY(Size.LANKY, 0, 2.6F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) translate(0, -0.2F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.2F, 0);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.6F, 0.15F); if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.15F);
if (model.isRiding()) translate(0, 0, -0.2F); if (model.isRiding()) stack.translate(0, 0, -0.2F);
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.15F, -0.07F); stack.translate(0, -0.15F, -0.07F);
if (model.getAttributes().isCrouching) translate(-0.03F, 0.16F, 0.07F); if (model.getAttributes().isCrouching) stack.translate(-0.03F, 0.16F, 0.07F);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.5F, 0.25F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.5F, 0.25F);
break; break;
case HEAD: case HEAD:
translate(0, -0.17F, -0.04F); stack.translate(0, -0.17F, -0.04F);
if (model.getAttributes().isSleeping) translate(0, 0, -0.1F); if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) translate(0, 0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.45F, 0.45F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.45F, 0.45F);
break; break;
case BODY: case BODY:
translate(0, -0.2F, -0.04F); stack.translate(0, -0.2F, -0.04F);
scale(0.9F, 1.2F, 0.9F); stack.scale(0.9F, 1.2F, 0.9F);
break; break;
case TAIL: case TAIL:
translate(0, -0.2F, 0.08F); stack.translate(0, -0.2F, 0.08F);
break; break;
case LEGS: case LEGS:
translate(0, -0.18F, 0); stack.translate(0, -0.18F, 0);
scale(0.9F, 1.12F, 0.9F); stack.scale(0.9F, 1.12F, 0.9F);
break; break;
case BACK: case BACK:
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
} }
} }
}, },
BULKY(Size.BULKY, 0, 2.3F, 0.75F) { BULKY(Size.BULKY, 0, 2.3F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.6F, 0.25F); if (model.getAttributes().isSleeping) stack.translate(0, -0.6F, 0.25F);
if (model.isRiding()) translate(0, 0, -0.2F); if (model.isRiding()) stack.translate(0, 0, -0.2F);
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.15F, -0.07F); stack.translate(0, -0.15F, -0.07F);
if (model.getAttributes().isCrouching) translate(-0.03F, 0.16F, 0.07F); if (model.getAttributes().isCrouching) stack.translate(-0.03F, 0.16F, 0.07F);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.5F, 0.25F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.5F, 0.25F);
break; break;
case HEAD: case HEAD:
translate(0, -0.17F, -0.04F); stack.translate(0, -0.17F, -0.04F);
if (model.getAttributes().isSleeping) translate(0, 0, -0.1F); if (model.getAttributes().isSleeping) stack.translate(0, 0, -0.1F);
if (model.getAttributes().isCrouching) translate(0, 0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.15F, 0);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.15F, 0.25F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.15F, 0.25F);
break; break;
case BODY: case BODY:
translate(0, -0.2F, -0.04F); stack.translate(0, -0.2F, -0.04F);
scale(1.15F, 1.2F, 1.2F); stack.scale(1.15F, 1.2F, 1.2F);
break; break;
case TAIL: case TAIL:
translate(0, -0.2F, 0.08F); stack.translate(0, -0.2F, 0.08F);
break; break;
case LEGS: case LEGS:
translate(0, -0.18F, 0); stack.translate(0, -0.18F, 0);
scale(1.15F, 1.12F, 1.15F); stack.scale(1.15F, 1.12F, 1.15F);
break; break;
case BACK: case BACK:
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
} }
} }
}, },
FOAL(Size.FOAL, 0, 3.8F, 0.75F) { FOAL(Size.FOAL, 0, 3.8F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) translate(0, -0.9F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.9F, 0);
if (model.getAttributes().isCrouching) translate(0, -0.3F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.3F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.65F, -0.3F); if (model.getAttributes().isSleeping) stack.translate(0, -0.65F, -0.3F);
if (model.isRiding()) translate(0, -0.6F, -0.2F); if (model.isRiding()) stack.translate(0, -0.6F, -0.2F);
translate(0, 0.2F, 0); stack.translate(0, 0.2F, 0);
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, 0, 0.04F); stack.translate(0, 0, 0.04F);
scale(1.3F, 1.3F, 1.3F); stack.scale(1.3F, 1.3F, 1.3F);
if (model.getAttributes().isCrouching) translate(0, -0.01F, 0.15F); if (model.getAttributes().isCrouching) stack.translate(0, -0.01F, 0.15F);
break; break;
case HEAD: case HEAD:
if (model.getAttributes().isSwimmingRotated) translate(0, 0.9F, 0.9F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.9F, 0.9F);
scale(1.3F, 1.3F, 1.3F); stack.scale(1.3F, 1.3F, 1.3F);
break; break;
case LEGS: case LEGS:
translate(0, 0.09F, 0); stack.translate(0, 0.09F, 0);
scale(1, 0.81F, 1); stack.scale(1, 0.81F, 1);
break; break;
case BACK: case BACK:
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
default: default:
} }
@ -141,69 +141,69 @@ public enum PonyTransformation {
}, },
TALL(Size.TALL, 0, 2.2F, 0.75F) { TALL(Size.TALL, 0, 2.2F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.5F, 0.35F); if (model.getAttributes().isSleeping) stack.translate(0, -0.5F, 0.35F);
if (model.isRiding()) translate(0, 0.1F, -0.2F); if (model.isRiding()) stack.translate(0, 0.1F, -0.2F);
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.09F, 0); stack.translate(0, -0.09F, 0);
scale(1, 1.1F, 1); stack.scale(1, 1.1F, 1);
if (model.getAttributes().isCrouching) translate(-0.02F, -0.02F, 0.1F); if (model.getAttributes().isCrouching) stack.translate(-0.02F, -0.02F, 0.1F);
break; break;
case HEAD: case HEAD:
translate(0.01F, -0.15F, 0); stack.translate(0.01F, -0.15F, 0);
if (model.getAttributes().isCrouching) translate(0, 0.04F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.04F, 0);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.17F, 0.25F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.17F, 0.25F);
break; break;
case BODY: case BODY:
case TAIL: case TAIL:
translate(0, -0.1F, 0); stack.translate(0, -0.1F, 0);
break; break;
case LEGS: case LEGS:
translate(0, -0.27F, 0.03F); stack.translate(0, -0.27F, 0.03F);
scale(1, 1.18F, 1); stack.scale(1, 1.18F, 1);
if (model.getAttributes().isGoingFast) translate(0, 0.05F, 0); if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
break; break;
case BACK: case BACK:
riderOffset = new Vec3d(0, 2.2F, 0.75F); riderOffset = new Vec3d(0, 2.2F, 0.75F);
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
} }
} }
}, },
YEARLING(Size.YEARLING, 0, 3.8F, 0.75F) { YEARLING(Size.YEARLING, 0, 3.8F, 0.75F) {
@Override @Override
public void transform(IModel model, BodyPart part) { public void transform(IModel model, BodyPart part, MatrixStack stack) {
if (model.getAttributes().isSwimming) translate(0, -0.6F, 0); if (model.getAttributes().isSwimming) stack.translate(0, -0.6F, 0);
if (model.getAttributes().isCrouching) translate(0, -0.15F, 0); if (model.getAttributes().isCrouching) stack.translate(0, -0.15F, 0);
if (model.getAttributes().isSleeping) translate(0, -0.4F, -0.3F); if (model.getAttributes().isSleeping) stack.translate(0, -0.4F, -0.3F);
if (model.isRiding()) translate(0, -0.4F, -0.2F); if (model.isRiding()) stack.translate(0, -0.4F, -0.2F);
switch (part) { switch (part) {
case NECK: case NECK:
translate(0, -0.09F, -0.01F); stack.translate(0, -0.09F, -0.01F);
scale(1, 1.1F, 1); stack.scale(1, 1.1F, 1);
if (model.getAttributes().isCrouching) translate(-0.02F, -0.02F, 0.1F); if (model.getAttributes().isCrouching) stack.translate(-0.02F, -0.02F, 0.1F);
break; break;
case HEAD: case HEAD:
translate(0, -0.15F, 0.01F); stack.translate(0, -0.15F, 0.01F);
if (model.getAttributes().isCrouching) translate(0, 0.04F, 0); if (model.getAttributes().isCrouching) stack.translate(0, 0.04F, 0);
if (model.getAttributes().isSwimmingRotated) translate(0, 0.8F, 0.85F); if (model.getAttributes().isSwimmingRotated) stack.translate(0, 0.8F, 0.85F);
scale(1.15F, 1.15F, 1.15F); stack.scale(1.15F, 1.15F, 1.15F);
break; break;
case BODY: case BODY:
case TAIL: case TAIL:
translate(0, -0.1F, 0); stack.translate(0, -0.1F, 0);
break; break;
case LEGS: case LEGS:
translate(0, -0.265F, 0.03F); stack.translate(0, -0.265F, 0.03F);
scale(1, 1.18F, 1); stack.scale(1, 1.18F, 1);
if (model.getAttributes().isGoingFast) translate(0, 0.05F, 0); if (model.getAttributes().isGoingFast) stack.translate(0, 0.05F, 0);
break; break;
case BACK: case BACK:
translateVec(riderOffset); stack.translate(riderOffset.x, riderOffset.y, riderOffset.z);
break; break;
} }
} }
@ -226,26 +226,11 @@ public enum PonyTransformation {
riderOffset = new Vec3d(rX, rY, rZ); riderOffset = new Vec3d(rX, rY, rZ);
} }
public static void translateVec(Vec3d offset) {
RenderSystem.translated(offset.x, offset.y, offset.z);
}
protected void scale(float x, float y, float z) {
RenderSystem.scalef(x, y, z);
}
protected void translate(float x, float y, float z) {
RenderSystem.translatef(x, y, z);
}
public Vec3d getRiderOffset() { public Vec3d getRiderOffset() {
return riderOffset; return riderOffset;
} }
public abstract void transform(IModel model, BodyPart part); public abstract void transform(IModel model, BodyPart part, MatrixStack stack);
public static PonyTransformation forSize(Size size) { public static PonyTransformation forSize(Size size) {
return sizeToTransform.getOrDefault(size, NORMAL); return sizeToTransform.getOrDefault(size, NORMAL);