mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
New batch of Model/rendering fixes:
- PerspectiveMapWrapper did not pass IModelData through to the wrapped model. - CompositeModel did not store the returned textures from getTextureDependencies. - VertexFormat used COLOR instead of UV to detect UV presence. - QuadTransformer would crash due to index out of bounds. - Small cleanup of TransformationHelper
This commit is contained in:
1 parent
ac61018806
commit
e8ce61d4cd
8 files changed
+43
-27
No files matched your search
@@ -33,6 +33,7 @@ import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.model.TransformationHelper;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@@ -130,7 +131,10 @@ public class PerspectiveMapWrapper implements IBakedModel
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override public ItemCameraTransforms getItemCameraTransforms() { return parent.getItemCameraTransforms(); }
|
||||
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) { return parent.getQuads(state, side, rand); }
|
||||
|
||||
@Override public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData extraData)
|
||||
{
|
||||
return parent.getQuads(state, side, rand, extraData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemOverrideList getOverrides()
|
||||
|
||||
@@ -48,9 +48,9 @@ public class QuadTransformer
|
||||
|
||||
private void processVertices(int[] inData, int[] outData)
|
||||
{
|
||||
// TODO: Extract rotation matrix and fix NORMALs if present.
|
||||
int stride = format.getIntegerSize();
|
||||
for (int i=0;i<4;i++)
|
||||
int count = inData.length / stride;
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
int offset = positionOffset + i * stride;
|
||||
float x = Float.intBitsToFloat(inData[offset ]);
|
||||
@@ -68,7 +68,7 @@ public class QuadTransformer
|
||||
|
||||
if (normalOffset >= 0)
|
||||
{
|
||||
for (int i=0;i<4;i++)
|
||||
for (int i=0;i<count;i++)
|
||||
{
|
||||
int offset = normalOffset + i * stride;
|
||||
int normalIn = inData[offset];
|
||||
|
||||
@@ -27,7 +27,6 @@ import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.renderer.model.*;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.vertex.VertexFormat;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -84,7 +83,7 @@ public class CompositeModel implements IBakedModel
|
||||
{
|
||||
quads.addAll(part.getQuads(state, side, rand, EmptyModelData.INSTANCE));
|
||||
}
|
||||
return null;
|
||||
return quads;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,7 +227,7 @@ public class CompositeModel implements IBakedModel
|
||||
Set<Material> textures = new HashSet<>();
|
||||
for(Submodel part : parts.values())
|
||||
{
|
||||
part.getTextureDependencies(owner, modelGetter, missingTextureErrors);
|
||||
textures.addAll(part.getTextureDependencies(owner, modelGetter, missingTextureErrors));
|
||||
}
|
||||
return textures;
|
||||
}
|
||||
|
||||
@@ -50,6 +50,16 @@ public final class TransformationHelper
|
||||
return new Quaternion(xyz.getX(), xyz.getY(), xyz.getZ(), degrees);
|
||||
}
|
||||
|
||||
public static Quaternion quatFromXYZ(float[] xyz, boolean degrees)
|
||||
{
|
||||
return new Quaternion(xyz[0], xyz[1], xyz[2], degrees);
|
||||
}
|
||||
|
||||
public static Quaternion makeQuaternion(float[] values)
|
||||
{
|
||||
return new Quaternion(values[0], values[1], values[2], values[3]);
|
||||
}
|
||||
|
||||
public static Vector3f lerp(Vector3f from, Vector3f to, float progress)
|
||||
{
|
||||
Vector3f res = from.func_229195_e_();
|
||||
@@ -120,11 +130,6 @@ public final class TransformationHelper
|
||||
MathHelper.abs(v1.getW()-v2.getW()) < epsilon;
|
||||
}
|
||||
|
||||
public static Quaternion makeQuaternion(float[] values)
|
||||
{
|
||||
return new Quaternion(values[0], values[1], values[2], values[3]);
|
||||
}
|
||||
|
||||
public static class Deserializer implements JsonDeserializer<TransformationMatrix>
|
||||
{
|
||||
@Override
|
||||
@@ -261,15 +266,15 @@ public final class TransformationHelper
|
||||
{
|
||||
if (entry.getKey().equals("x"))
|
||||
{
|
||||
ret = new Quaternion(new Vector3f(1, 0, 0), entry.getValue().getAsNumber().floatValue(), true);
|
||||
ret = Vector3f.field_229179_b_.func_229187_a_(entry.getValue().getAsNumber().floatValue());
|
||||
}
|
||||
else if (entry.getKey().equals("y"))
|
||||
{
|
||||
ret = new Quaternion(new Vector3f(0, 1, 0), entry.getValue().getAsNumber().floatValue(), true);
|
||||
ret = Vector3f.field_229181_d_.func_229187_a_(entry.getValue().getAsNumber().floatValue());
|
||||
}
|
||||
else if (entry.getKey().equals("z"))
|
||||
{
|
||||
ret = new Quaternion(new Vector3f(0, 0, 1), entry.getValue().getAsNumber().floatValue(), true);
|
||||
ret = Vector3f.field_229183_f_.func_229187_a_(entry.getValue().getAsNumber().floatValue());
|
||||
}
|
||||
else throw new JsonParseException("Axis rotation: expected single axis key, got: " + entry.getKey());
|
||||
}
|
||||
@@ -286,7 +291,7 @@ public final class TransformationHelper
|
||||
{
|
||||
if (e.getAsJsonArray().get(0).isJsonObject())
|
||||
{
|
||||
Quaternion ret = new Quaternion(0, 0, 0, 1);
|
||||
Quaternion ret = Quaternion.field_227060_a_.func_227068_g_();
|
||||
for (JsonElement a : e.getAsJsonArray())
|
||||
{
|
||||
ret.multiply(parseAxisRotation(a));
|
||||
@@ -297,7 +302,7 @@ public final class TransformationHelper
|
||||
{
|
||||
JsonArray array = e.getAsJsonArray();
|
||||
if (array.size() == 3) //Vanilla rotation
|
||||
return quatFromXYZ(new Vector3f(parseFloatArray(e, 3, "Rotation")), true);
|
||||
return quatFromXYZ(parseFloatArray(e, 3, "Rotation"), true);
|
||||
else // quaternion
|
||||
return makeQuaternion(parseFloatArray(e, 4, "Rotation"));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user