本文整理汇总了C++中Chunk::IsDirty方法的典型用法代码示例。如果您正苦于以下问题:C++ Chunk::IsDirty方法的具体用法?C++ Chunk::IsDirty怎么用?C++ Chunk::IsDirty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chunk
的用法示例。
在下文中一共展示了Chunk::IsDirty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawLandscapeForShadows
void DrawLandscapeForShadows(StageOneShader *shader) {
if (!Model::gPlayer.KnownPosition())
return;
ChunkCoord player_cc;
Model::gPlayer.GetChunkCoord(&player_cc);
// Draw all visible chunks. Chunks that are not loaded will trigger a reload from the server. The top chunks
// should be loaded first, as they affect the lighting on the chunks below.
for (auto it=sShadowChunks.begin() ; it != sShadowChunks.end(); it++ ) {
Chunk *cp = ChunkFind(&(*it), true);
if (!cp->IsDirty() && cp->fChunkObject && cp->fChunkObject->Empty()) {
// This chunk exists, is updated, but contains nothing.
continue;
}
int dx = cp->cc.x - player_cc.x;
int dy = cp->cc.y - player_cc.y;
int dz = cp->cc.z - player_cc.z;
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
shader->Model(modelMatrix);
cp->Draw(shader, 0, DL_NoTransparent);
cp->DrawObjects(shader, dx, dy, dz, true);
}
}
示例2: DrawLandscapeTopDown
void DrawLandscapeTopDown(StageOneShader *shader, int width, int height, bool forceload, DL_Type dlType) {
if (!Model::gPlayer.KnownPosition())
return;
ChunkCoord player_cc;
Model::gPlayer.GetChunkCoord(&player_cc);
int verticallimit = (height+CHUNK_SIZE-1)/CHUNK_SIZE/2;
int horisontallimit = (width+CHUNK_SIZE-1)/CHUNK_SIZE/2;
// Draw all visible chunks. Chunks that are not loaded will trigger a reload from the server. The top chunks
// should be loaded first, as they affect the lighting on the chunks below.
for (int dz = verticallimit; dz >= -verticallimit; dz--) for (int dx = -horisontallimit; dx <= horisontallimit; dx++) for (int dy = -horisontallimit; dy <= horisontallimit; dy++) {
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
ChunkCoord cc;
cc.x = player_cc.x + dx;
cc.y = player_cc.y + dy;
cc.z = player_cc.z + dz;
Chunk *cp = ChunkFind(&cc, forceload);
if (cp == 0)
continue;
shader->Model(modelMatrix);
// Draw the chunk
if (!cp->IsDirty() && cp->fChunkObject && cp->fChunkObject->Empty()) {
// This chunk exists, is updated, but contains nothing.
continue;
}
cp->Draw(shader, 0, dlType);
cp->DrawObjects(shader, dx, dy, dz, true);
}
}
示例3: Update
void Chunks::Update()
{
int updated = 0;
for (int i = 0; i < VIEW_DISTANCE / CHUNK_SIZE_X * 2; i++)
{
for (int j = 0; j < VIEW_DISTANCE / CHUNK_SIZE_Z * 2; ++j)
{
Chunk* c = Get(i,j);
if (c->IsReady()) {
if (c->IsDirty() && updated < 2) {
c->Update();
updated++;
}
}
}
}
}
示例4: DrawLandscape
// TODO: This function should be split into a separate function for picking mode.
void DrawLandscape(StageOneShader *shader, DL_Type dlType) {
if (!Model::gPlayer.KnownPosition())
return;
if (dlType == DL_NoTransparent) {
// The lits of chunks used for shadowing is computed below, when in non-transparent mode.
// Start the list empty.
sShadowChunks.clear();
}
FindAllNearChunks(sChunkDistances);
ChunkCoord player_cc;
Model::gPlayer.GetChunkCoord(&player_cc);
// Draw all visible chunks. Chunks that are not loaded will trigger a reload from the server. The top chunks
// should be loaded first, as they affect the lighting on the chunks below.
int chunkHor = (int)(maxRenderDistance / CHUNK_SIZE + 1);
// At 80m viewing distance, there are 895 chunks. Using various filters, the actual chunks that can be seen are
// much fewer. Save the filtered list, to speed up the drawing.
int listOfVisibleChunks[sMaxVolume];
int src, dst;
// Create list of visible chunks. This check is faster than using queries, so it is a good filter to
// start with.
for (src=0, dst=0; sChunkDistances[src].distance < chunkHor; src++) {
if (src > sMaxVolume)
break; // Just a safety precaution, should never happen
Chunk *cp = sListOfNearChunks[src];
if (cp) {
if (cp->fScheduledForLoading)
continue; // Chunk doesn't exist yet
// Do not ignore the chunk just because it doesn't have any data yet, as the data update is triggered
// by the drawing function.
if (!cp->IsDirty() && cp->fChunkObject && cp->fChunkObject->Empty()) {
// This chunk exists, is updated, but contains nothing.
continue;
}
}
int dx = sChunkDistances[src].dx;
int dy = sChunkDistances[src].dy;
int dz = sChunkDistances[src].dz;
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
if (Outside(dx, dy , dz, modelMatrix)) {
continue; // Go to next chunk
}
listOfVisibleChunks[dst++] = src;
}
int visibleChunklistLength = dst;
// printf("DrawLandscape: listOfVisibleChunks %d\n", visibleChunklistLength);
bool insideAnyTeleport = false;
// We need to know which TP is the nearest.
float distanceToNearTP2 = 1000.0f*1000.0f; // Distance^2 to the nearest TP, initialized to something big.
glm::vec3 TPPosition;
for (int i=0; i<visibleChunklistLength; i++) {
if (i%NUMQUERIES == 0 && dlType == DL_NoTransparent) {
// Request NUMQUERIES queries, every NUMQUERIES chunk.
// The chunks that are tested is not the same ones that will be drawn,
// to allow the reading of the query result to be with a delay.
// The first NUMQUERIES chunks are not tested. The occlusion test using queries is most effective
// for long viewing distances, where there is a high chance of chunks not being visible.
// TODO: The test could also be used for transparent objects, if it wasn't that QuerySetup() enables depth update again.
int from = i+NUMQUERIES;
int to = i+NUMQUERIES*2;
if (to > visibleChunklistLength)
to = visibleChunklistLength;
if (to > from)
QuerySetup(shader, from, to, listOfVisibleChunks); // Initiate the query for a group of chunks
}
int ind = listOfVisibleChunks[i];
if (dlType == DL_OnlyTransparent)
ind = listOfVisibleChunks[visibleChunklistLength-i-1]; // Read chunks in reverse order for transparent objects
if (i >= NUMQUERIES && dlType == DL_NoTransparent) { // There is no query initiated for the first NUMQUERIES chunks.
GLuint numSamples = 1;
glGetQueryObjectuiv(sQueryId[i%(NUMQUERIES*2)], GL_QUERY_RESULT, &numSamples);
if (numSamples == 0)
continue; // No pixels changed by this chunk, skip it!
}
int dx = sChunkDistances[ind].dx;
int dy = sChunkDistances[ind].dy;
int dz = sChunkDistances[ind].dz;
glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(dx*CHUNK_SIZE, dz*CHUNK_SIZE, -dy*CHUNK_SIZE));
// Don't allow picking outside of near chunks.
if (dlType == DL_Picking && (dx < -1 || dx > 1 || dy < -1 || dy > 1 || dz < -1 || dz > 1))
break;
ChunkCoord cc;
cc.x = player_cc.x + dx;
cc.y = player_cc.y + dy;
cc.z = player_cc.z + dz;
// If we have come this far, a null pointer is no longer accepted. The chunk is needed. Either we get
// the real chunk, or an empty one.
Chunk *cp = ChunkFind(&cc, true);
if (dlType == DL_Picking) {
// Picking mode. Throw away the previous triangles, and replace it with special triangles used
// for the picking mode. These contain colour information to allow identification of cubes.
cp->fChunkBlocks->TestJellyBlockTimeout(true);
cp->PushTriangles(ChunkObject::Make(cp, true, dx, dy, dz)); // Stash away the old triangles for quick restore
//.........这里部分代码省略.........