if (id >= 0 && id < 10000) {
for (int i = 0; i < subdivision; i++) {
for (int j = 0; j < subdivision; j++) {
- if (patchobjectnum[i][j] < 300 - 1) {
+ if (patchobjects[i][j].size() < 300 - 1) {
points[0].x = (size / subdivision) * i;
points[0].z = (size / subdivision) * j;
points[0].y = heightmap[(int)points[0].x][(int)points[0].z];
points[0] *= scale;
points[1] *= scale;
if (where.x + radius > points[0].x && where.x - radius < points[1].x && where.z + radius > points[0].z && where.z - radius < points[1].z) {
- patchobjects[i][j][patchobjectnum[i][j]] = id;
- patchobjectnum[i][j]++;
+ patchobjects[i][j].push_back(id);
}
}
}
void Terrain::DoShadows()
{
- static int i, j, k, l, todivide;
- static float brightness, total;
static XYZ testpoint, testpoint2, terrainpoint, lightloc, col;
lightloc = light.location;
if (!skyboxtexture) {
float shadowed;
Normalise(&lightloc);
//Calculate shadows
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
+ for (short int i = 0; i < size; i++) {
+ for (short int j = 0; j < size; j++) {
terrainpoint.x = (float)(i) * scale;
terrainpoint.z = (float)(j) * scale;
terrainpoint.y = heightmap[i][j] * scale;
shadowed = 0;
patchx = (float)(i) * subdivision / size;
patchz = (float)(j) * subdivision / size;
- if (patchobjectnum[patchx][patchz]) {
- for (k = 0; k < patchobjectnum[patchx][patchz]; k++) {
- l = patchobjects[patchx][patchz][k];
+ if (patchobjects[patchx][patchz].size()) {
+ for (unsigned int k = 0; k < patchobjects[patchx][patchz].size(); k++) {
+ unsigned int l = patchobjects[patchx][patchz][k];
if (Object::objects[l]->type != treetrunktype) {
testpoint = terrainpoint;
testpoint2 = terrainpoint + lightloc * 50 * (1 - shadowed);
}
Game::LoadingScreen();
}
- brightness = dotproduct(&lightloc, &normals[i][j]);
+ float brightness = dotproduct(&lightloc, &normals[i][j]);
if (shadowed)
brightness *= 1 - shadowed;
Game::LoadingScreen();
//Smooth shadows
- for (i = 0; i < size; i++) {
- for (j = 0; j < size; j++) {
- for (k = 0; k < 3; k++) {
- total = 0;
- todivide = 0;
+ for (short int i = 0; i < size; i++) {
+ for (short int j = 0; j < size; j++) {
+ for (short int k = 0; k < 3; k++) {
+ float total = 0;
+ unsigned int todivide = 0;
if (i != 0) {
total += colors[j][i - 1][k];
todivide++;
}
}
- for (i = 0; i < subdivision; i++) {
- for (j = 0; j < subdivision; j++) {
+ for (unsigned int i = 0; i < subdivision; i++) {
+ for (unsigned int j = 0; j < subdivision; j++) {
UpdateVertexArray(i, j);
}
}
{
size = 0;
- memset(patchobjectnum, 0, sizeof(patchobjectnum));
- memset(patchobjects, 0, sizeof(patchobjects));
-
scale = 1.0f;
type = 0;
memset(heightmap, 0, sizeof(heightmap));