//FIXME: a lot less map requests (therefore a lot higher map rendering speed) can be made //if you draw volumes of cells separately. transparency may break void Map_Render_Debug::drawPlane(int bx1, int by1, int bx2, int by2, int bz) { int tx = (int)floor(bx1 / 64.0f); int ty = (int)floor(by1 / 64.0f); rmp_cityscape* cityscape = Map.cellCityscape(tx,ty); //cityscape to gather data from for (int x = bx1; x <= bx2; x++) for (int y = by1; y <= by2; y++) { int cx = (int)floor(x / 64.0f); //current cityscape int cy = (int)floor(y / 64.0f); if ((tx != cx) || (ty != cy)) { tx = cx; ty = cy; //precache new one cityscape = Map.cellCityscape(tx,ty); } int kx = x - 64*(x / 64);//abs(x % 64);//x-abs(cx*64); int ky = y - 64*(y / 64);//abs(y % 64);//y-abs(cy*64); //int texID = if ((cityscape->rmp_city_scape) && (bz < cityscape->maxHeight)) { Vertex_Buffer* vBuffer = 0; TexID texBase = 0; for (uint i = 0; i < VBOEntry.Count; i++) { if (strcmp(VBOEntry[i]->GraphicsName,cityscape->GraphicsName[0]) == 0) { vBuffer = &VBOEntry[i]->VBO; texBase = VBOEntry[i]->SpriteBase; break; } } if (vBuffer == 0) { //debugrender_vboentry* vboEntry = VBOEntry.Add(); VBOEntry.Count++; //Add(); if (VBOEntry.Count >= VBOEntry.AllocCount) { logWrite("BAD ERROR: attempting to draw more different VBO's than allocated entries"); return; } VBOEntry[VBOEntry.Count-1]->GraphicsName = cityscape->GraphicsName[0]; VBOEntry[VBOEntry.Count-1]->VBO.Clear(); vBuffer = &VBOEntry[VBOEntry.Count-1]->VBO; //Get sprite base TexID to use later to bind texture atlas (also this is offset for blockgeometry) char texName[256]; snprintf(texName,256,"%s_0",VBOEntry[VBOEntry.Count-1]->GraphicsName); VBOEntry[VBOEntry.Count-1]->SpriteBase = Graphics.GetTextureID(texName); texBase = VBOEntry[VBOEntry.Count-1]->SpriteBase; } //Block fetched from map: rmp_block_info* block = &cityscape->rmp_city_scape[bz*64*64+ky*64+kx]; //Block with (possibly) animated textures: rmp_block_info _block; memcpy(&_block,block,sizeof(rmp_block_info)); TexID tex_left = texBase+block->tex_left; TexID tex_right = texBase+block->tex_right; TexID tex_top = texBase+block->tex_top; TexID tex_bottom = texBase+block->tex_bottom; TexID tex_lid = texBase+block->tex_lid; AnimSeqID anim_left = Animations.GetAnimationSeq(tex_left); AnimSeqID anim_right = Animations.GetAnimationSeq(tex_right); AnimSeqID anim_top = Animations.GetAnimationSeq(tex_top); AnimSeqID anim_bottom = Animations.GetAnimationSeq(tex_bottom); AnimSeqID anim_lid = Animations.GetAnimationSeq(tex_lid); //Animate faces float tgtAnimationTime = 0.0f; if (anim_left != BAD_ID) { //HAX Animation anim = Animations.GetAnimation(anim_left); anim.startTime = 0.0f; _block.tex_left = anim.GetTexID()-texBase; tgtAnimationTime = Timer.Time() + anim.RemainingTime(); } if (anim_right != BAD_ID) { Animation anim = Animations.GetAnimation(anim_right); anim.startTime = 0.0f; _block.tex_right = anim.GetTexID()-texBase; tgtAnimationTime = Timer.Time() + anim.RemainingTime(); } if (anim_top != BAD_ID) { Animation anim = Animations.GetAnimation(anim_top); anim.startTime = 0.0f; _block.tex_top = anim.GetTexID()-texBase; tgtAnimationTime = Timer.Time() + anim.RemainingTime(); } if (anim_bottom != BAD_ID) { Animation anim = Animations.GetAnimation(anim_bottom); anim.startTime = 0.0f; _block.tex_bottom = anim.GetTexID()-texBase; tgtAnimationTime = Timer.Time() + anim.RemainingTime(); } if (anim_lid != BAD_ID) { Animation anim = Animations.GetAnimation(anim_lid); anim.startTime = 0.0f; _block.tex_lid = anim.GetTexID()-texBase; tgtAnimationTime = Timer.Time() + anim.RemainingTime(); } if (tgtAnimationTime > 0.0f) { if (nextAnimationTime > 0.0f) { nextAnimationTime = min(tgtAnimationTime,nextAnimationTime); } else { nextAnimationTime = tgtAnimationTime; } } //if ((block->block_type & 0xF) > 0) Map_Vertex_Geometry.blockGeometry(vBuffer, &_block, texBase, Vector3f(x*1.0f,y*1.0f,bz*1.0f-1.0f)); } } }