Done?
This commit is contained in:
@@ -38,7 +38,7 @@ BlockType World::BlockAt(const Vector3f& pos, BlockType defaultBlockType) const
|
||||
return BlockAt(pos.x, pos.y, pos.z, defaultBlockType);
|
||||
}
|
||||
|
||||
void World::TransposeWorld(Player& player) {
|
||||
void World::TransposeWorld(Player& player, Bullet* bullets[MAX_BULLETS]) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
@@ -85,6 +85,9 @@ void World::TransposeWorld(Player& player) {
|
||||
|
||||
m_center[0] += x; m_center[1] += y;
|
||||
player.Teleport(x, y);
|
||||
|
||||
for (int index = 0; index < MAX_BULLETS; ++index)
|
||||
if (bullets[index]) bullets[index]->Transpose(x, y);
|
||||
}
|
||||
|
||||
void World::CleanUpWorld(int& deleteframes, bool clear = false) {
|
||||
@@ -106,12 +109,12 @@ void World::GetScope(int& x, int& y) {
|
||||
y = m_center[1];
|
||||
}
|
||||
|
||||
void World::Update(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||
void World::Update(int& rendercount, Bullet* bullets[MAX_BULLETS], Player& player, Transformation& world, Shader& shader, TextureAtlas& atlas, Perlin& perlin, BlockInfo* blockinfo[BTYPE_LAST]) {
|
||||
glStencilFunc(GL_EQUAL, 1, 0x00);
|
||||
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
atlas.Bind();
|
||||
RenderWorld(rendercount, badhitcount, player, world, shader);
|
||||
TransposeWorld(player);
|
||||
RenderWorld(rendercount, player, world, shader);
|
||||
TransposeWorld(player, bullets);
|
||||
UpdateWorld(player, perlin, blockinfo);
|
||||
shader.Disable();
|
||||
glStencilFunc(GL_GREATER, 1, 0xFF);
|
||||
@@ -273,10 +276,19 @@ void World::ChangeBlockAtCursor(BlockType blockType, Player& player, bool& block
|
||||
}
|
||||
}
|
||||
|
||||
void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Transformation& world, Shader& shader) {
|
||||
|
||||
void World::ChangeBlockAtPosition(BlockType blockType, Vector3f pos) {
|
||||
int bx = (int)pos.x % CHUNK_SIZE_X;
|
||||
int by = (int)pos.y % CHUNK_SIZE_Y;
|
||||
int bz = (int)pos.z % CHUNK_SIZE_Z;
|
||||
|
||||
ChunkAt(pos)->SetBlock(bx, by, bz, blockType, this);
|
||||
ChunkAt(pos)->MakeModified();
|
||||
}
|
||||
|
||||
void World::RenderWorld(int& rendercount, Player& player, Transformation& world, Shader& shader) {
|
||||
shader.Use();
|
||||
rendercount = 0;
|
||||
badhitcount = 0;
|
||||
Vector3f angle;
|
||||
Vector3f cursor;
|
||||
Vector3f direct = player.GetDirection();
|
||||
@@ -341,10 +353,8 @@ void World::RenderWorld(int& rendercount, int& badhitcount, Player& player, Tran
|
||||
int chx, chy;
|
||||
ChunkAt(cursor)->GetPosition(chx, chy);
|
||||
for (int index = 0; index < rendercount; ++index) // Permet de v<>rifier seulement contre celles ajout<75>es dans la frame, et ne pas avoir <20> refaire l'array <20> chaque frame.
|
||||
if (renderManifest[index].x == chx && renderManifest[index].z == chy) {
|
||||
if (renderManifest[index].x == chx && renderManifest[index].z == chy)
|
||||
valide = false;
|
||||
++badhitcount;
|
||||
}
|
||||
|
||||
if (valide) renderManifest[rendercount++] = Vector3f(chx, (VIEW_DISTANCE - (pos - cursor).Length() * 2.f + 128) / (float)VIEW_DISTANCE, chy);
|
||||
}
|
||||
|
Reference in New Issue
Block a user