Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Light Bug #1

Open
BertilBraun opened this issue Sep 30, 2018 · 0 comments
Open

Light Bug #1

BertilBraun opened this issue Sep 30, 2018 · 0 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@BertilBraun
Copy link
Owner

Light updates are disabled, because I can not find the bug, thats causing the assert.

In the queue of lightupdates sometimes NULL objects get pushed back (maybe the reason).

void FinishLights() {

	while (!sunRemovalQueue.empty()) {
		
		if (&sunRemovalQueue.front() == nullptr)
			continue;

		glm::vec3	pos = sunRemovalQueue.front().first;
		short		val = sunRemovalQueue.front().second;

		Vector2 c = chunkCoord(pos.x, pos.z);
		Vector2 b = blockCoord(pos.x, pos.z);

		sunRemovalQueue.pop();

		auto TrySetLightValue = [&](float ox, float oy, float oz) {

			int neighborLevel = getSunlight(b.x   ox, pos.y   oy, b.z   oz);

			if (neighborLevel != 0 && neighborLevel < val) 
				resetSunlight(pos.x   ox, pos.y   oy, pos.z   oz);

			else if (neighborLevel >= val) 
				sunLightQueue.emplace(pos.x   ox, pos.y   oy, pos.z   oz);
		};

		TrySetLightValue(-1,  0,  0);
		TrySetLightValue( 1,  0,  0);
		TrySetLightValue( 0, -1,  0);
		TrySetLightValue( 0,  1,  0);
		TrySetLightValue( 0,  0, -1);
		TrySetLightValue( 0,  0,  1);
	}
}
void resetSunlight(int x, int y, int z){ 

	sunRemovalQueue.emplace(glm::vec3(x, y, z), getSunlight(x, y, z));
	setSunlight(x, y % CHUNK_SIZE, z, 0);
}
@BertilBraun BertilBraun added help wanted Extra attention is needed bug Something isn't working labels Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant