Rendering bug fixed (kinda)
This commit is contained in:
parent
3d20bcd33d
commit
c42ff423b8
lwjgl-rundir
src/main/java/net/minecraft/src
Binary file not shown.
Binary file not shown.
|
@ -56,11 +56,11 @@ public class TextureManager {
|
|||
int var10 = var9.w;
|
||||
int var11 = var9.h;
|
||||
String var12 = this.getBasename(par1Str);
|
||||
|
||||
|
||||
if (this.hasAnimationTxt(par1Str, var3)) {
|
||||
int var13 = var10;
|
||||
int var15 = var11 / var10;
|
||||
|
||||
|
||||
for (int var16 = 0; var16 < var15; ++var16) {
|
||||
Texture var17 = this.makeTexture(var12, 2, var13, var13, EaglerAdapter.GL_CLAMP, EaglerAdapter.GL_RGBA, EaglerAdapter.GL_NEAREST, EaglerAdapter.GL_NEAREST, false, var9.getSubImage(0, var13 * var16, var13, var13));
|
||||
var2.add(var17);
|
||||
|
|
|
@ -4,20 +4,24 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||
import net.lax1dude.eaglercraft.EaglerAdapter;
|
||||
import net.lax1dude.eaglercraft.adapter.Tessellator;
|
||||
|
||||
public class WorldRenderer
|
||||
{
|
||||
public class WorldRenderer {
|
||||
/** Reference to the World object. */
|
||||
public World worldObj;
|
||||
private int glRenderList = -1;
|
||||
private static Tessellator tessellator = Tessellator.instance;
|
||||
public static int chunksUpdated;
|
||||
public static int chunksUpdated = 0;
|
||||
public static int chunksGeometryUpdated = 0;
|
||||
public int posX;
|
||||
public int posY;
|
||||
public int posZ;
|
||||
|
||||
public int chunkX;
|
||||
public int chunkY;
|
||||
public int chunkZ;
|
||||
|
||||
/** Pos X minus */
|
||||
public int posXMinus;
|
||||
|
||||
|
@ -35,7 +39,7 @@ public class WorldRenderer
|
|||
|
||||
/** Pos Z clipped */
|
||||
public int posZClip;
|
||||
public boolean isInFrustum;
|
||||
public boolean isInFrustum = false;
|
||||
|
||||
/** Should this renderer skip this render pass */
|
||||
public boolean[] skipRenderPass = new boolean[2];
|
||||
|
@ -64,12 +68,9 @@ public class WorldRenderer
|
|||
/** Is this renderer waiting on the result of the occlusion query */
|
||||
public boolean isWaitingOnOcclusionQuery;
|
||||
|
||||
/** OpenGL occlusion query */
|
||||
public int glOcclusionQuery;
|
||||
|
||||
/** Is the chunk lit */
|
||||
public boolean isChunkLit;
|
||||
private boolean isInitialized;
|
||||
private boolean isInitialized = false;
|
||||
|
||||
/** All the tile entities that have special rendering code for this chunk */
|
||||
public List tileEntityRenderers = new ArrayList();
|
||||
|
@ -78,8 +79,7 @@ public class WorldRenderer
|
|||
/** Bytes sent to the GPU */
|
||||
private int bytesDrawn;
|
||||
|
||||
public WorldRenderer(World par1World, List par2List, int par3, int par4, int par5, int par6)
|
||||
{
|
||||
public WorldRenderer(World par1World, List par2List, int par3, int par4, int par5, int par6) {
|
||||
this.worldObj = par1World;
|
||||
this.tileEntities = par2List;
|
||||
this.glRenderList = par6;
|
||||
|
@ -89,16 +89,18 @@ public class WorldRenderer
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets a new position for the renderer and setting it up so it can be reloaded with the new data for that position
|
||||
* Sets a new position for the renderer and setting it up so it can be reloaded
|
||||
* with the new data for that position
|
||||
*/
|
||||
public void setPosition(int par1, int par2, int par3)
|
||||
{
|
||||
if (par1 != this.posX || par2 != this.posY || par3 != this.posZ)
|
||||
{
|
||||
public void setPosition(int par1, int par2, int par3) {
|
||||
if (par1 != this.posX || par2 != this.posY || par3 != this.posZ) {
|
||||
this.setDontDraw();
|
||||
this.posX = par1;
|
||||
this.posY = par2;
|
||||
this.posZ = par3;
|
||||
this.chunkX = par1 >> 4;
|
||||
this.chunkY = par2 >> 4;
|
||||
this.chunkZ = par3 >> 4;
|
||||
this.posXPlus = par1 + 8;
|
||||
this.posYPlus = par2 + 8;
|
||||
this.posZPlus = par3 + 8;
|
||||
|
@ -108,27 +110,26 @@ public class WorldRenderer
|
|||
this.posXMinus = par1 - this.posXClip;
|
||||
this.posYMinus = par2 - this.posYClip;
|
||||
this.posZMinus = par3 - this.posZClip;
|
||||
float var4 = 6.0F;
|
||||
this.rendererBoundingBox = AxisAlignedBB.getBoundingBox((double)((float)par1 - var4), (double)((float)par2 - var4), (double)((float)par3 - var4), (double)((float)(par1 + 16) + var4), (double)((float)(par2 + 16) + var4), (double)((float)(par3 + 16) + var4));
|
||||
float var4 = 0.0F;
|
||||
this.rendererBoundingBox = AxisAlignedBB.getBoundingBox((double) ((float) par1 - var4), (double) ((float) par2 - var4), (double) ((float) par3 - var4), (double) ((float) (par1 + 16) + var4),
|
||||
(double) ((float) (par2 + 16) + var4), (double) ((float) (par3 + 16) + var4));
|
||||
//EaglerAdapter.glNewList(this.glRenderList + 2, EaglerAdapter.GL_COMPILE);
|
||||
//RenderItem.renderAABB(AxisAlignedBB.getAABBPool().getAABB((double)((float)this.posXClip - var4), (double)((float)this.posYClip - var4), (double)((float)this.posZClip - var4), (double)((float)(this.posXClip + 16) + var4), (double)((float)(this.posYClip + 16) + var4), (double)((float)(this.posZClip + 16) + var4)));
|
||||
//RenderItem.renderAABB(AxisAlignedBB.getAABBPool().getAABB((double) ((float) this.posXClip - var4), (double) ((float) this.posYClip - var4), (double) ((float) this.posZClip - var4), (double) ((float) (this.posXClip + 16) + var4),
|
||||
// (double) ((float) (this.posYClip + 16) + var4), (double) ((float) (this.posZClip + 16) + var4)));
|
||||
//EaglerAdapter.glEndList();
|
||||
this.markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupGLTranslation()
|
||||
{
|
||||
EaglerAdapter.glTranslatef((float)this.posXClip, (float)this.posYClip, (float)this.posZClip);
|
||||
private void setupGLTranslation() {
|
||||
EaglerAdapter.glTranslatef((float) this.posXClip, (float) this.posYClip, (float) this.posZClip);
|
||||
}
|
||||
|
||||
/**
|
||||
* Will update this chunk renderer
|
||||
*/
|
||||
public void updateRenderer()
|
||||
{
|
||||
if (this.needsUpdate)
|
||||
{
|
||||
public void updateRenderer() {
|
||||
if (this.needsUpdate) {
|
||||
this.needsUpdate = false;
|
||||
int var1 = this.posX;
|
||||
int var2 = this.posY;
|
||||
|
@ -137,8 +138,7 @@ public class WorldRenderer
|
|||
int var5 = this.posY + 16;
|
||||
int var6 = this.posZ + 16;
|
||||
|
||||
for (int var7 = 0; var7 < 2; ++var7)
|
||||
{
|
||||
for (int var7 = 0; var7 < 2; ++var7) {
|
||||
this.skipRenderPass[var7] = true;
|
||||
}
|
||||
|
||||
|
@ -148,65 +148,52 @@ public class WorldRenderer
|
|||
this.tileEntityRenderers.clear();
|
||||
byte var8 = 1;
|
||||
ChunkCache var9 = new ChunkCache(this.worldObj, var1 - var8, var2 - var8, var3 - var8, var4 + var8, var5 + var8, var6 + var8, var8);
|
||||
|
||||
if (!var9.extendedLevelsInChunkCache())
|
||||
{
|
||||
if (!var9.extendedLevelsInChunkCache()) {
|
||||
EaglerAdapter.hintAnisotropicFix(true);
|
||||
++chunksUpdated;
|
||||
RenderBlocks var10 = new RenderBlocks(var9);
|
||||
this.bytesDrawn = 0;
|
||||
|
||||
for (int var11 = 0; var11 < 2; ++var11)
|
||||
{
|
||||
for (int var11 = 0; var11 < 2; ++var11) {
|
||||
boolean var12 = false;
|
||||
boolean var13 = false;
|
||||
boolean var14 = false;
|
||||
|
||||
for (int var15 = var2; var15 < var5; ++var15)
|
||||
{
|
||||
for (int var16 = var3; var16 < var6; ++var16)
|
||||
{
|
||||
for (int var17 = var1; var17 < var4; ++var17)
|
||||
{
|
||||
for (int var15 = var2; var15 < var5; ++var15) {
|
||||
for (int var16 = var3; var16 < var6; ++var16) {
|
||||
for (int var17 = var1; var17 < var4; ++var17) {
|
||||
int var18 = var9.getBlockId(var17, var15, var16);
|
||||
|
||||
if (var18 > 0)
|
||||
{
|
||||
if (!var14)
|
||||
{
|
||||
if (var18 > 0) {
|
||||
if (!var14) {
|
||||
var14 = true;
|
||||
EaglerAdapter.glNewList(this.glRenderList + var11, EaglerAdapter.GL_COMPILE);
|
||||
/*EaglerAdapter.glPushMatrix();
|
||||
this.setupGLTranslation();
|
||||
float var19 = 1.000001F;
|
||||
EaglerAdapter.glTranslatef(-8.0F, -8.0F, -8.0F);
|
||||
EaglerAdapter.glScalef(var19, var19, var19);
|
||||
EaglerAdapter.glTranslatef(8.0F, 8.0F, 8.0F);*/
|
||||
//EaglerAdapter.glPushMatrix();
|
||||
//this.setupGLTranslation();
|
||||
//float var19 = 1.000001F;
|
||||
//EaglerAdapter.glTranslatef(-8.0F, -8.0F, -8.0F);
|
||||
//EaglerAdapter.glScalef(var19, var19, var19);
|
||||
//EaglerAdapter.glTranslatef(8.0F, 8.0F, 8.0F);
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setTranslation((double)(-this.posX), (double)(-this.posY), (double)(-this.posZ));
|
||||
tessellator.setTranslation((double) (this.posXClip-this.posX), (double) (this.posYClip-this.posY), (double) (this.posZClip-this.posZ));
|
||||
}
|
||||
|
||||
Block var23 = Block.blocksList[var18];
|
||||
|
||||
if (var23 != null)
|
||||
{
|
||||
if (var11 == 0 && var23.hasTileEntity())
|
||||
{
|
||||
if (var23 != null) {
|
||||
if (var11 == 0 && var23.hasTileEntity()) {
|
||||
TileEntity var20 = var9.getBlockTileEntity(var17, var15, var16);
|
||||
|
||||
if (TileEntityRenderer.instance.hasSpecialRenderer(var20))
|
||||
{
|
||||
if (TileEntityRenderer.instance.hasSpecialRenderer(var20)) {
|
||||
this.tileEntityRenderers.add(var20);
|
||||
}
|
||||
}
|
||||
|
||||
int var24 = var23.getRenderBlockPass();
|
||||
|
||||
if (var24 != var11)
|
||||
{
|
||||
if (var24 != var11) {
|
||||
var12 = true;
|
||||
}
|
||||
else if (var24 == var11)
|
||||
{
|
||||
} else if (var24 == var11) {
|
||||
var13 |= var10.renderBlockByRenderType(var23, var17, var15, var16);
|
||||
}
|
||||
}
|
||||
|
@ -215,28 +202,29 @@ public class WorldRenderer
|
|||
}
|
||||
}
|
||||
|
||||
if (var14)
|
||||
{
|
||||
if (var14) {
|
||||
this.bytesDrawn += tessellator.draw();
|
||||
//EaglerAdapter.glPopMatrix();
|
||||
EaglerAdapter.glEndList();
|
||||
tessellator.setTranslation(0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
var13 = false;
|
||||
}
|
||||
|
||||
if (var13)
|
||||
{
|
||||
if (var13) {
|
||||
this.skipRenderPass[var11] = false;
|
||||
}
|
||||
|
||||
if (!var12)
|
||||
{
|
||||
if (!var12) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!(skipRenderPass[0] && skipRenderPass[1])) {
|
||||
++chunksGeometryUpdated;
|
||||
}
|
||||
|
||||
EaglerAdapter.hintAnisotropicFix(false);
|
||||
}
|
||||
|
||||
HashSet var22 = new HashSet();
|
||||
|
@ -247,37 +235,42 @@ public class WorldRenderer
|
|||
this.tileEntities.removeAll(var21);
|
||||
this.isChunkLit = Chunk.isLit;
|
||||
this.isInitialized = true;
|
||||
|
||||
if(skipRenderPass[0]) {
|
||||
EaglerAdapter.flushDisplayList(glRenderList);
|
||||
}
|
||||
if(skipRenderPass[1]) {
|
||||
EaglerAdapter.flushDisplayList(glRenderList + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance of this chunk renderer to the entity without performing the final normalizing square root,
|
||||
* for performance reasons.
|
||||
* Returns the distance of this chunk renderer to the entity without performing
|
||||
* the final normalizing square root, for performance reasons.
|
||||
*/
|
||||
public float distanceToEntitySquared(Entity par1Entity)
|
||||
{
|
||||
float var2 = (float)(par1Entity.posX - (double)this.posXPlus);
|
||||
float var3 = (float)(par1Entity.posY - (double)this.posYPlus);
|
||||
float var4 = (float)(par1Entity.posZ - (double)this.posZPlus);
|
||||
public float distanceToEntitySquared(Entity par1Entity) {
|
||||
float var2 = (float) (par1Entity.posX - (double) this.posXPlus);
|
||||
float var3 = (float) (par1Entity.posY - (double) this.posYPlus);
|
||||
float var4 = (float) (par1Entity.posZ - (double) this.posZPlus);
|
||||
return var2 * var2 + var3 * var3 + var4 * var4;
|
||||
}
|
||||
|
||||
/**
|
||||
* When called this renderer won't draw anymore until its gets initialized again
|
||||
*/
|
||||
public void setDontDraw()
|
||||
{
|
||||
for (int var1 = 0; var1 < 2; ++var1)
|
||||
{
|
||||
public void setDontDraw() {
|
||||
for (int var1 = 0; var1 < 2; ++var1) {
|
||||
this.skipRenderPass[var1] = true;
|
||||
EaglerAdapter.flushDisplayList(glRenderList);
|
||||
EaglerAdapter.flushDisplayList(glRenderList + 1);
|
||||
}
|
||||
|
||||
this.isInFrustum = false;
|
||||
this.isInitialized = false;
|
||||
}
|
||||
|
||||
public void stopRendering()
|
||||
{
|
||||
public void stopRendering() {
|
||||
this.setDontDraw();
|
||||
this.worldObj = null;
|
||||
}
|
||||
|
@ -285,37 +278,37 @@ public class WorldRenderer
|
|||
/**
|
||||
* Takes in the pass the call list is being requested for. Args: renderPass
|
||||
*/
|
||||
public int getGLCallListForPass(int par1)
|
||||
{
|
||||
public int getGLCallListForPass(int par1) {
|
||||
return !this.isInFrustum ? -1 : (!this.skipRenderPass[par1] ? this.glRenderList + par1 : -1);
|
||||
}
|
||||
|
||||
public void updateInFrustum(ICamera par1ICamera)
|
||||
{
|
||||
public void updateInFrustum(ICamera par1ICamera) {
|
||||
this.isInFrustum = par1ICamera.isBoundingBoxInFrustum(this.rendererBoundingBox);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the occlusion query GL List
|
||||
*/
|
||||
public void callOcclusionQueryList()
|
||||
{
|
||||
public void callOcclusionQueryList() {
|
||||
EaglerAdapter.glCallList(this.glRenderList + 2);
|
||||
}
|
||||
|
||||
public boolean shouldTryOcclusionQuery() {
|
||||
return !this.isInitialized ? true : !this.skipRenderPass[0] || !this.skipRenderPass[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all render passes are to be skipped. Returns false if the renderer is not initialized
|
||||
* Checks if all render passes are to be skipped. Returns false if the renderer
|
||||
* is not initialized
|
||||
*/
|
||||
public boolean skipAllRenderPasses()
|
||||
{
|
||||
public boolean skipAllRenderPasses() {
|
||||
return !this.isInitialized ? false : this.skipRenderPass[0] && this.skipRenderPass[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the current renderer data as dirty and needing to be updated.
|
||||
*/
|
||||
public void markDirty()
|
||||
{
|
||||
public void markDirty() {
|
||||
this.needsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue