Merge branch 'TESRculling'

This commit is contained in:
Christian committed 2013-02-04 11:13:29 -05:00
commit c5bb9fc78f
6 files changed
+188 -21

No files matched your search

@@ -413,4 +413,9 @@ public class ForgeHooksClient
}
}
}
public static void setRenderPass(int pass)
{
renderPass = pass;
}
}
@@ -12,7 +12,7 @@ public class ForgeVersion
//This number is incremented every minecraft release, never reset
public static final int minorVersion = 6;
//This number is incremented every time a interface changes or new major feature is added, and reset every Minecraft version
public static final int revisionVersion = 0;
public static final int revisionVersion = 1;
//This number is incremented every time Jenkins builds Forge, and never reset. Should always be 0 in the repo code.
public static final int buildVersion = 0;
@@ -56,7 +56,17 @@
GL11.glRotatef(var2.prevRotationYaw + (var2.rotationYaw - var2.prevRotationYaw) * par1 + 180.0F, 0.0F, -1.0F, 0.0F);
GL11.glRotatef(var2.prevRotationPitch + (var2.rotationPitch - var2.prevRotationPitch) * par1, -1.0F, 0.0F, 0.0F);
}
@@ -1139,8 +1143,11 @@
@@ -1124,7 +1128,9 @@
{
RenderHelper.enableStandardItemLighting();
this.mc.mcProfiler.endStartSection("entities");
+ ForgeHooksClient.setRenderPass(0);
var5.renderEntities(var4.getPosition(par1), var14, par1);
+ ForgeHooksClient.setRenderPass(-1);
this.enableLightmap((double)par1);
this.mc.mcProfiler.endStartSection("litParticles");
var6.renderLitParticles(var4, par1);
@@ -1139,8 +1145,11 @@
var17 = (EntityPlayer)var4;
GL11.glDisable(GL11.GL_ALPHA_TEST);
this.mc.mcProfiler.endStartSection("outline");
@@ -70,7 +80,21 @@
GL11.glEnable(GL11.GL_ALPHA_TEST);
}
}
@@ -1204,15 +1211,18 @@
@@ -1194,6 +1203,13 @@
this.mc.mcProfiler.endStartSection("water");
var5.sortAndRender(var4, 1, (double)par1);
}
+
+ RenderHelper.enableStandardItemLighting();
+ this.mc.mcProfiler.endStartSection("entities");
+ ForgeHooksClient.setRenderPass(1);
+ var5.renderEntities(var4.getPosition(par1), var14, par1);
+ ForgeHooksClient.setRenderPass(-1);
+ RenderHelper.disableStandardItemLighting();
GL11.glDepthMask(true);
GL11.glEnable(GL11.GL_CULL_FACE);
@@ -1204,15 +1220,18 @@
var17 = (EntityPlayer)var4;
GL11.glDisable(GL11.GL_ALPHA_TEST);
this.mc.mcProfiler.endStartSection("outline");
@@ -92,7 +116,7 @@
GL11.glDisable(GL11.GL_BLEND);
this.mc.mcProfiler.endStartSection("weather");
this.renderRainSnow(par1);
@@ -1222,6 +1232,9 @@
@@ -1222,6 +1241,9 @@
{
this.renderCloudsCheck(var5, par1);
}
@@ -1,15 +1,120 @@
--- ../src_base/minecraft/net/minecraft/client/renderer/RenderGlobal.java
+++ ../src_work/minecraft/net/minecraft/client/renderer/RenderGlobal.java
@@ -62,6 +62,8 @@
@@ -62,6 +62,9 @@
import org.lwjgl.opengl.ARBOcclusionQuery;
import org.lwjgl.opengl.GL11;
+import net.minecraftforge.client.IRenderHandler;
+import net.minecraftforge.client.MinecraftForgeClient;
+
@SideOnly(Side.CLIENT)
public class RenderGlobal implements IWorldAccess
{
@@ -929,6 +931,12 @@
@@ -439,62 +442,72 @@
*/
public void renderEntities(Vec3 par1Vec3, ICamera par2ICamera, float par3)
{
+ int pass = MinecraftForgeClient.getRenderPass();
if (this.renderEntitiesStartupCounter > 0)
{
+ if(pass > 0)
+ return;
+
--this.renderEntitiesStartupCounter;
}
else
{
- this.theWorld.theProfiler.startSection("prepare");
- TileEntityRenderer.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, par3);
- RenderManager.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, this.mc.gameSettings, par3);
- this.countEntitiesTotal = 0;
- this.countEntitiesRendered = 0;
- this.countEntitiesHidden = 0;
- EntityLiving var4 = this.mc.renderViewEntity;
- RenderManager.renderPosX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
- RenderManager.renderPosY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
- RenderManager.renderPosZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
- TileEntityRenderer.staticPlayerX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
- TileEntityRenderer.staticPlayerY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
- TileEntityRenderer.staticPlayerZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
+ List var5 = this.theWorld.getLoadedEntityList();
+ if(pass == 0)
+ {
+ this.theWorld.theProfiler.startSection("prepare");
+ TileEntityRenderer.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, par3);
+ RenderManager.instance.cacheActiveRenderInfo(this.theWorld, this.renderEngine, this.mc.fontRenderer, this.mc.renderViewEntity, this.mc.gameSettings, par3);
+ this.countEntitiesTotal = 0;
+ this.countEntitiesRendered = 0;
+ this.countEntitiesHidden = 0;
+ EntityLiving var4 = this.mc.renderViewEntity;
+ RenderManager.renderPosX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
+ RenderManager.renderPosY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
+ RenderManager.renderPosZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
+ TileEntityRenderer.staticPlayerX = var4.lastTickPosX + (var4.posX - var4.lastTickPosX) * (double)par3;
+ TileEntityRenderer.staticPlayerY = var4.lastTickPosY + (var4.posY - var4.lastTickPosY) * (double)par3;
+ TileEntityRenderer.staticPlayerZ = var4.lastTickPosZ + (var4.posZ - var4.lastTickPosZ) * (double)par3;
+ this.countEntitiesTotal = var5.size();
+ }
this.mc.entityRenderer.enableLightmap((double)par3);
this.theWorld.theProfiler.endStartSection("global");
- List var5 = this.theWorld.getLoadedEntityList();
- this.countEntitiesTotal = var5.size();
int var6;
Entity var7;
for (var6 = 0; var6 < this.theWorld.weatherEffects.size(); ++var6)
{
var7 = (Entity)this.theWorld.weatherEffects.get(var6);
- ++this.countEntitiesRendered;
-
- if (var7.isInRangeToRenderVec3D(par1Vec3))
- {
- RenderManager.instance.renderEntity(var7, par3);
- }
- }
-
- this.theWorld.theProfiler.endStartSection("entities");
-
- for (var6 = 0; var6 < var5.size(); ++var6)
- {
- var7 = (Entity)var5.get(var6);
-
- if (var7.isInRangeToRenderVec3D(par1Vec3) && (var7.ignoreFrustumCheck || par2ICamera.isBoundingBoxInFrustum(var7.boundingBox) || var7.riddenByEntity == this.mc.thePlayer) && (var7 != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(var7.posX), 0, MathHelper.floor_double(var7.posZ)))
+
+ if (var7.shouldRenderInPass(pass) && var7.isInRangeToRenderVec3D(par1Vec3))
{
++this.countEntitiesRendered;
RenderManager.instance.renderEntity(var7, par3);
}
}
+ this.theWorld.theProfiler.endStartSection("entities");
+
+ for (var6 = 0; var6 < var5.size(); ++var6)
+ {
+ var7 = (Entity)var5.get(var6);
+
+ if (var7.shouldRenderInPass(pass) && var7.isInRangeToRenderVec3D(par1Vec3) && (var7.ignoreFrustumCheck || par2ICamera.isBoundingBoxInFrustum(var7.boundingBox) || var7.riddenByEntity == this.mc.thePlayer) && (var7 != this.mc.renderViewEntity || this.mc.gameSettings.thirdPersonView != 0 || this.mc.renderViewEntity.isPlayerSleeping()) && this.theWorld.blockExists(MathHelper.floor_double(var7.posX), 0, MathHelper.floor_double(var7.posZ)))
+ {
+ ++this.countEntitiesRendered;
+ RenderManager.instance.renderEntity(var7, par3);
+ }
+ }
+
this.theWorld.theProfiler.endStartSection("tileentities");
RenderHelper.enableStandardItemLighting();
+ TileEntity te;
for (var6 = 0; var6 < this.tileEntities.size(); ++var6)
{
- TileEntityRenderer.instance.renderTileEntity((TileEntity)this.tileEntities.get(var6), par3);
+ te = (TileEntity)this.tileEntities.get(var6);
+ if(par2ICamera.isBoundingBoxInFrustum(te.getRenderBoundingBox()) && te.shouldRenderInPass(pass))
+ TileEntityRenderer.instance.renderTileEntity(te, par3);
}
this.mc.entityRenderer.disableLightmap((double)par3);
@@ -929,6 +942,12 @@
*/
public void renderSky(float par1)
{
@@ -22,7 +127,7 @@
if (this.mc.theWorld.provider.dimensionId == 1)
{
GL11.glDisable(GL11.GL_FOG);
@@ -1167,6 +1175,13 @@
@@ -1167,6 +1186,13 @@
public void renderClouds(float par1)
{
@@ -36,7 +141,7 @@
if (this.mc.theWorld.provider.isSurfaceWorld())
{
if (this.mc.gameSettings.fancyGraphics)
@@ -1596,6 +1611,11 @@
@@ -1596,6 +1622,11 @@
}
public void drawBlockDamageTexture(Tessellator par1Tessellator, EntityPlayer par2EntityPlayer, float par3)
@@ -48,7 +153,7 @@
{
double var4 = par2EntityPlayer.lastTickPosX + (par2EntityPlayer.posX - par2EntityPlayer.lastTickPosX) * (double)par3;
double var6 = par2EntityPlayer.lastTickPosY + (par2EntityPlayer.posY - par2EntityPlayer.lastTickPosY) * (double)par3;
@@ -1873,6 +1893,7 @@
@@ -1873,6 +1904,7 @@
double var17 = this.mc.renderViewEntity.posY - par4;
double var19 = this.mc.renderViewEntity.posZ - par6;
EntityFX var21 = null;
@@ -56,7 +161,7 @@
if (par1Str.equals("hugeexplosion"))
{
@@ -2009,6 +2030,7 @@
@@ -2009,6 +2041,7 @@
else if (par1Str.equals("snowballpoof"))
{
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.snowball);
@@ -64,7 +169,7 @@
}
else if (par1Str.equals("dripWater"))
{
@@ -2025,6 +2047,7 @@
@@ -2025,6 +2058,7 @@
else if (par1Str.equals("slime"))
{
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, Item.slimeBall);
@@ -72,7 +177,7 @@
}
else if (par1Str.equals("heart"))
{
@@ -2046,6 +2069,7 @@
@@ -2046,6 +2080,7 @@
{
int var27 = Integer.parseInt(par1Str.substring(par1Str.indexOf("_") + 1));
var21 = new EntityBreakingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Item.itemsList[var27]);
@@ -80,7 +185,7 @@
}
else if (par1Str.startsWith("tilecrack_"))
{
@@ -2053,11 +2077,12 @@
@@ -2053,11 +2088,12 @@
int var25 = Integer.parseInt(var28[1]);
int var26 = Integer.parseInt(var28[2]);
var21 = (new EntityDiggingFX(this.theWorld, par2, par4, par6, par8, par10, par12, Block.blocksList[var25], 0, var26)).applyRenderColor(var26);
@@ -138,7 +138,7 @@
}
public int func_82143_as()
@@ -2399,4 +2441,92 @@
@@ -2399,4 +2441,97 @@
{
return this.isBurning();
}
@@ -229,5 +229,10 @@
+ public final void resetEntityId()
+ {
+ this.entityId = nextEntityID++;
+ }
+
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass == 0;
+ }
}
@@ -1,20 +1,22 @@
--- ../src_base/minecraft/net/minecraft/tileentity/TileEntity.java
+++ ../src_work/minecraft/net/minecraft/tileentity/TileEntity.java
@@ -11,7 +11,9 @@
@@ -11,7 +11,10 @@
import net.minecraft.block.TileEntityRecordPlayer;
import net.minecraft.crash.CrashReportCategory;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
+import net.minecraft.network.packet.Packet132TileEntityData;
+import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class TileEntity
@@ -296,4 +298,52 @@
@@ -296,4 +299,79 @@
addMapping(TileEntityBeacon.class, "Beacon");
addMapping(TileEntitySkull.class, "Skull");
}
+
+ // -- BEGIN FORGE PATCHES --
+ /**
+ * Determines if this TileEntity requires update calls.
+ * @return True if you want updateEntity() to be called, false if not
@@ -27,10 +29,10 @@
+ /**
+ * Called when you receive a TileEntityData packet for the location this
+ * TileEntity is currently in. On the client, the NetworkManager will always
+ * be the remote server. On the server, it will be whomever is responsible for
+ * be the remote server. On the server, it will be whomever is responsible for
+ * sending the packet.
+ *
+ * @param net The NetworkManager the packet originated from
+ *
+ * @param net The NetworkManager the packet originated from
+ * @param pkt The data packet
+ */
+ public void onDataPacket(INetworkManager net, Packet132TileEntityData pkt)
@@ -47,12 +49,12 @@
+ /**
+ * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes.
+ * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly.
+ *
+ *
+ * @param oldID The old ID of the block
+ * @param newID The new ID of the block (May be the same)
+ * @param oldMeta The old metadata of the block
+ * @param newMeta The new metadata of the block (May be the same)
+ * @param world Current world
+ * @param world Current world
+ * @param x X Postion
+ * @param y Y Position
+ * @param z Z Position
@@ -61,5 +63,31 @@
+ public boolean shouldRefresh(int oldID, int newID, int oldMeta, int newMeta, World world, int x, int y, int z)
+ {
+ return true;
+ }
+
+ public boolean shouldRenderInPass(int pass)
+ {
+ return pass == 0;
+ }
+ /**
+ * Sometimes default render bounding box: infinite in scope. Used to control rendering on {@link TileEntitySpecialRenderer}.
+ */
+ public static final AxisAlignedBB INFINITE_EXTENT_AABB = AxisAlignedBB.getBoundingBox(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY);
+
+ /**
+ * Return an {@link AxisAlignedBB} that controls the visible scope of a {@link TileEntitySpecialRenderer} associated with this {@link TileEntity}
+ * Defaults to the collision bounding box {@link Block#getCollisionBoundingBoxFromPool(World, int, int, int)} associated with the block
+ * at this location.
+ *
+ * @return an appropriately size {@link AxisAlignedBB} for the {@link TileEntity}
+ */
+ @SideOnly(Side.CLIENT)
+ public AxisAlignedBB getRenderBoundingBox()
+ {
+ if (getBlockType()!=null)
+ {
+ return getBlockType().getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord);
+ }
+ return INFINITE_EXTENT_AABB;
+ }
}