Scaling fix (#53)

* Actually USE show scaling when rendering Fixes #51
* Center models on the entity being rendered (initial) Fixes #52
This commit is contained in:
Sollace 2018-05-26 03:39:30 +02:00 committed by Matthew Messinger
parent 5b3836c2df
commit 9a98ac4b22
7 changed files with 36 additions and 19 deletions

View file

@ -16,4 +16,9 @@ public interface IRenderPony {
* Gets the current shadow size for rendering. * Gets the current shadow size for rendering.
*/ */
float getShadowScale(); float getShadowScale();
/**
* Gets the scaling factor used when rendering this pony.
*/
float getScaleFactor();
} }

View file

@ -727,7 +727,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
pushMatrix(); pushMatrix();
transform(BodyPart.HEAD); transform(BodyPart.HEAD);
renderHead(entityIn, move, swing, ticks, headYaw, headPitch, scale); renderHead(entityIn, move, swing, ticks, headYaw, headPitch, this.scale);
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();
@ -737,7 +737,7 @@ public abstract class AbstractPonyModel extends ModelPlayer implements IModel {
pushMatrix(); pushMatrix();
transform(BodyPart.BODY); transform(BodyPart.BODY);
renderBody(entityIn, move, swing, ticks, headYaw, headPitch, scale); renderBody(entityIn, move, swing, ticks, headYaw, headPitch, this.scale);
popMatrix(); popMatrix();
pushMatrix(); pushMatrix();

View file

@ -1,5 +1,7 @@
package com.minelittlepony.pony.data; package com.minelittlepony.pony.data;
import com.minelittlepony.MineLittlePony;
public enum PonySize implements ITriggerPixelMapped<PonySize> { public enum PonySize implements ITriggerPixelMapped<PonySize> {
NORMAL(0, 0.4f, 1f), NORMAL(0, 0.4f, 1f),
LARGE(0xce3254, 0.5f, 0.8f), LARGE(0xce3254, 0.5f, 0.8f),
@ -18,10 +20,16 @@ public enum PonySize implements ITriggerPixelMapped<PonySize> {
} }
public float getShadowSize() { public float getShadowSize() {
if (MineLittlePony.getConfig().showscale) {
return shadowSize * 0.9F;
}
return shadowSize; return shadowSize;
} }
public float getScaleFactor() { public float getScaleFactor() {
if (MineLittlePony.getConfig().showscale) {
return scale * 0.9F;
}
return scale; return scale;
} }

View file

@ -11,7 +11,7 @@ public enum TriggerPixels {
RACE(PonyRace.HUMAN, 0, 0), RACE(PonyRace.HUMAN, 0, 0),
TAIL(TailLengths.FULL, 1, 0), TAIL(TailLengths.FULL, 1, 0),
GENDER(PonyGender.MARE, 2, 0), GENDER(PonyGender.MARE, 2, 0),
SIZE(PonySize.NORMAL, 3, 0), SIZE(PonySize.LARGE, 3, 0),
GLOW(null, 0, 1); GLOW(null, 0, 1);
private int x; private int x;

View file

@ -9,6 +9,8 @@ import com.minelittlepony.render.layer.LayerPonyArmor;
import com.minelittlepony.render.layer.LayerPonyCustomHead; import com.minelittlepony.render.layer.LayerPonyCustomHead;
import com.minelittlepony.render.layer.LayerPonyElytra; import com.minelittlepony.render.layer.LayerPonyElytra;
import com.voxelmodpack.hdskins.HDSkinManager; import com.voxelmodpack.hdskins.HDSkinManager;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.layers.LayerArrow; import net.minecraft.client.renderer.entity.layers.LayerArrow;
@ -16,7 +18,6 @@ import net.minecraft.entity.EntityLiving;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.OverridingMethodsMustInvokeSuper;
public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony { public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving<T> implements IRenderPony {
@ -50,7 +51,6 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
} }
@Override @Override
@OverridingMethodsMustInvokeSuper
protected void preRenderCallback(T entity, float ticks) { protected void preRenderCallback(T entity, float ticks) {
playerModel.getModel().isSneak = entity.isSneaking(); playerModel.getModel().isSneak = entity.isSneaking();
playerModel.getModel().isFlying = !entity.onGround; playerModel.getModel().isFlying = !entity.onGround;
@ -60,6 +60,11 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata()); playerModel.apply(MineLittlePony.getInstance().getManager().getPony(loc, false).getMetadata());
shadowSize = getShadowScale(); shadowSize = getShadowScale();
float s = getScaleFactor();
GlStateManager.scale(s, s, s);
GlStateManager.translate(0, 0, -entity.width / 2); // move us to the center of the shadow
} }
@Override @Override
@ -72,6 +77,12 @@ public abstract class RenderPonyMob<T extends EntityLiving> extends RenderLiving
return 0.5F; return 0.5F;
} }
@Override
public float getScaleFactor() {
if (MineLittlePony.getConfig().showscale) return 0.9F;
return 1;
}
@Override @Override
public ModelWrapper getPlayerModel() { public ModelWrapper getPlayerModel() {
return playerModel; return playerModel;

View file

@ -47,23 +47,20 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
} }
@Override @Override
protected void renderLivingAt(AbstractClientPlayer player, double x, double y, double z) { protected void preRenderCallback(AbstractClientPlayer player, float ticks) {
float s = getScaleFactor();
GlStateManager.scale(s, s, s);
super.renderLivingAt(player, x, y, z);
}
@Override
public void doRender(AbstractClientPlayer player, double x, double y, double z, float entityYaw, float ticks) {
updateModel(player); updateModel(player);
ponyModel.isSneak = player.isSneaking(); ponyModel.isSneak = player.isSneaking();
ponyModel.isSleeping = player.isPlayerSleeping(); ponyModel.isSleeping = player.isPlayerSleeping();
ponyModel.isFlying = pony.isPegasusFlying(player); ponyModel.isFlying = pony.isPegasusFlying(player);
super.preRenderCallback(player, ticks);
shadowSize = getShadowScale(); shadowSize = getShadowScale();
super.doRender(player, x, y, z, entityYaw, ticks); float s = getScaleFactor();
GlStateManager.scale(s, s, s);
GlStateManager.translate(0, 0, -player.width / 2); // move us to the center of the shadow
} }
@Override @Override
@ -135,8 +132,6 @@ public abstract class RenderPonyBase extends RenderPlayer implements IRenderPony
return pony; return pony;
} }
protected abstract float getScaleFactor();
protected abstract void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks); protected abstract void transformElytraFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float ticks);
protected abstract void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks); protected abstract void transformPegasusFlight(AbstractClientPlayer player, double motionX, double motionY, double motionZ, float yaw, float pitch, float ticks);

View file

@ -1,6 +1,5 @@
package com.minelittlepony.render.player; package com.minelittlepony.render.player;
import com.minelittlepony.MineLittlePony;
import com.minelittlepony.model.ModelWrapper; import com.minelittlepony.model.ModelWrapper;
import com.minelittlepony.util.math.MathUtil; import com.minelittlepony.util.math.MathUtil;
@ -17,12 +16,11 @@ public class RenderPonyPlayer extends RenderPonyBase {
@Override @Override
public float getShadowScale() { public float getShadowScale() {
if (!MineLittlePony.getConfig().showscale) return .5f;
return getPony().getMetadata().getSize().getShadowSize(); return getPony().getMetadata().getSize().getShadowSize();
} }
@Override @Override
protected float getScaleFactor() { public float getScaleFactor() {
return getPony().getMetadata().getSize().getScaleFactor(); return getPony().getMetadata().getSize().getScaleFactor();
} }