Skip to content

Commit

Permalink
changed connection rendering to use baked models instead of TESR, sho…
Browse files Browse the repository at this point in the history
…uld improve FPS

fixed wires not outputting to RF-only outputs, closes #1081
fixed connections on HV relays
  • Loading branch information
malte0811 committed May 4, 2016
1 parent 4e54dd3 commit 93fc723
Show file tree
Hide file tree
Showing 34 changed files with 688 additions and 1,592 deletions.
Empty file modified gradlew
100644 → 100755
Empty file.
10 changes: 6 additions & 4 deletions src/main/java/blusunrize/immersiveengineering/api/ApiUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package blusunrize.immersiveengineering.api;

import static blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection.vertices;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
Expand Down Expand Up @@ -237,7 +239,7 @@ public static Vec3[] getConnectionCatenary(Connection connection, Vec3 start, Ve
boolean vertical = connection.end.getX()==connection.start.getX() && connection.end.getZ()==connection.start.getZ();

if(vertical)
return new Vec3[]{new Vec3(end.xCoord, end.yCoord, end.zCoord)};
return new Vec3[]{new Vec3(start.xCoord, start.yCoord, start.zCoord), new Vec3(end.xCoord, end.yCoord, end.zCoord)};

double dx = (end.xCoord)-(start.xCoord);
double dy = (end.yCoord)-(start.yCoord);
Expand All @@ -257,12 +259,12 @@ public static Vec3[] getConnectionCatenary(Connection connection, Vec3 start, Ve
double p = (0+dw-a*Math.log((k+dy)/(k-dy)))*0.5;
double q = (dy+0-k*Math.cosh(l)/Math.sinh(l))*0.5;

int vertices = 16;
Vec3[] vex = new Vec3[vertices];

for(int i=0; i<vertices; i++)
vex[0] = new Vec3(start.xCoord, start.yCoord, start.zCoord);
for(int i=1; i<vertices; i++)
{
float n1 = (i+1)/(float)vertices;
float n1 = i/(float)vertices;
double x1 = 0 + dx * n1;
double z1 = 0 + dz * n1;
double y1 = a * Math.cosh((( Math.sqrt(x1*x1+z1*z1) )-p)/a)+q;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.util.Collection;
import java.util.HashMap;
import java.util.Set;

import com.google.common.collect.ImmutableSet;

import blusunrize.immersiveengineering.api.energy.wires.WireType;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.properties.PropertyHelper;
Expand All @@ -20,6 +22,8 @@ public class IEProperties

public static final PropertyBoolInverted MULTIBLOCKSLAVE = PropertyBoolInverted.create("*multiblockslave");//Name starts with an asterisk to ensure priority when overriding models
public static final PropertyBoolInverted DYNAMICRENDER = PropertyBoolInverted.create("+dynamicrender");//Name starts with a plus to ensure priority over anything but the multiblockslave property
public static final PropertySet CONNECTIONS = new PropertySet("conns");

public static final PropertyEnum[] SIDECONFIG = {
PropertyEnum.create("sideconfig_down", IEEnums.SideConfig.class),
PropertyEnum.create("sideconfig_up", IEEnums.SideConfig.class),
Expand Down Expand Up @@ -47,6 +51,7 @@ public class IEProperties

public static final PropertyBoolInverted[] CONVEYORWALLS = {PropertyBoolInverted.create("conveyorwall_left"), PropertyBoolInverted.create("conveyorwall_right")};
public static final PropertyInteger CONVEYORUPDOWN = PropertyInteger.create("conveyorupdown", 0,2);
// public static final Property

public static final IUnlistedProperty<HashMap> OBJ_TEXTURE_REMAP = new IUnlistedProperty<HashMap>()
{
Expand Down Expand Up @@ -90,4 +95,32 @@ public String getName(Boolean value)
return value.toString();
}
}
@SuppressWarnings("rawtypes")
public static class PropertySet implements IUnlistedProperty<Set> {
String name;
public PropertySet(String n) {
name = n;
}
@Override
public String getName() {
return name;
}

@Override
public boolean isValid(Set value) {
if (value==null)
return false;
return true;
}

@Override
public Class<Set> getType() {
return Set.class;
}

@Override
public String valueToString(Set value) {
return value.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ public static class Connection implements Comparable<Connection>
public WireType cableType;
public int length;
public Vec3[] catenaryVertices;

public static final int vertices = 17;

public Connection(BlockPos start, BlockPos end, WireType cableType, int length)
{
this.start=start;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package blusunrize.immersiveengineering.api.energy.wires;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import com.google.common.collect.ImmutableSet;

import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.TargetingInfo;
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
Expand All @@ -16,6 +22,7 @@
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3;

public abstract class TileEntityImmersiveConnectable extends TileEntityIEBase implements IImmersiveConnectable
{
Expand Down Expand Up @@ -239,4 +246,35 @@ public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket)
IELogger.error("TileEntityImmersiveConenctable encountered MASSIVE error writing NBT. You shoudl probably report this.");
}
}
public Set<Connection> genConnBlockstate() {
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, pos);
if (conns==null)
return ImmutableSet.of();
Set<Connection> ret = new HashSet<Connection>() {
@Override
public boolean equals(Object o) {
if (o==this)
return true;
if (!(o instanceof HashSet))
return false;
HashSet<Connection> other = (HashSet<Connection>) o;
if (other.size()!=this.size())
return false;
for (Connection c:this)
if (!other.contains(c))
return false;
return true;
}
};
for (Connection c:conns)
{
//generate subvertices
if (c.end.compareTo(pos)>=0)
continue;
c.getSubVertices(worldObj);
ret.add(c);
}

return ret;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
Expand All @@ -19,6 +20,7 @@
import blusunrize.immersiveengineering.ImmersiveEngineering;
import blusunrize.immersiveengineering.api.ApiUtils;
import blusunrize.immersiveengineering.api.IEApi;
import blusunrize.immersiveengineering.api.IEProperties;
import blusunrize.immersiveengineering.api.Lib;
import blusunrize.immersiveengineering.api.ManualHelper;
import blusunrize.immersiveengineering.api.ManualPageMultiblock;
Expand All @@ -43,6 +45,7 @@
import blusunrize.immersiveengineering.client.gui.GuiToolbox;
import blusunrize.immersiveengineering.client.models.ModelShaderMinecart;
import blusunrize.immersiveengineering.client.models.obj.IEOBJLoader;
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
import blusunrize.immersiveengineering.client.render.EntityRenderChemthrowerShot;
import blusunrize.immersiveengineering.client.render.EntityRenderGrapplingHook;
import blusunrize.immersiveengineering.client.render.EntityRenderIEExplosive;
Expand Down Expand Up @@ -152,6 +155,7 @@
import net.minecraft.client.renderer.ItemMeshDefinition;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.client.renderer.entity.ArmorStandRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderBiped;
Expand Down Expand Up @@ -348,6 +352,7 @@ public Render createRenderFor(RenderManager manager){
public Render createRenderFor(RenderManager manager){
return new EntityRenderIEExplosive(manager);
}});
ModelLoaderRegistry.registerLoader(new ConnLoader());
}

@Override
Expand Down Expand Up @@ -376,7 +381,7 @@ public void init()
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalDevices2());
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalDecoration());
// RenderingRegistry.registerBlockHandler(new BlockRenderMetalMultiblocks());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityImmersiveConnectable.class, new TileRenderImmersiveConnectable());
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityImmersiveConnectable.class, new TileRenderImmersiveConnectable());
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnectorLV.class, new TileRenderConnectorLV());
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConnectorMV.class, new TileRenderConnectorMV());
// ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTransformer.class, new TileRenderTransformer());
Expand Down
Loading

0 comments on commit 93fc723

Please sign in to comment.