34 |
withHeigth: (int)height |
withHeigth: (int)height |
35 |
andMaxHeight: (int)maxHeight |
andMaxHeight: (int)maxHeight |
36 |
{ |
{ |
37 |
|
NSParameterAssert (far >= 0); |
38 |
NSParameterAssert (height <= 255); |
NSParameterAssert (height <= 255); |
39 |
NSParameterAssert (height <= maxHeight); |
NSParameterAssert (height <= maxHeight); |
40 |
NSParameterAssert (height >= 0); |
NSParameterAssert (height >= 0); |
65 |
{ |
{ |
66 |
int height = ([heightField heightAtPosition: pos1] |
int height = ([heightField heightAtPosition: pos1] |
67 |
+ [heightField heightAtPosition: pos2]) / 2.0; |
+ [heightField heightAtPosition: pos2]) / 2.0; |
68 |
return [self _hazardWithFar: far |
|
69 |
withHeigth: height |
if (far > 2) |
70 |
andMaxHeight: maxHeight]; |
return [self _hazardWithFar: far |
71 |
|
withHeigth: height |
72 |
|
andMaxHeight: maxHeight]; |
73 |
|
else |
74 |
|
return height; |
75 |
} |
} |
76 |
|
|
77 |
+ (void) _generateFractaleGroundWithUpLeft: (map_coord_t)pos1 |
+ (void) _generateFractaleGroundWithUpLeft: (map_coord_t)pos1 |
156 |
int height = (upMid + downMid + leftMid + rightMid) / 4; |
int height = (upMid + downMid + leftMid + rightMid) / 4; |
157 |
int far = (int)sqrt ((double)(SQUARE (xMid - pos1.x) |
int far = (int)sqrt ((double)(SQUARE (xMid - pos1.x) |
158 |
+ SQUARE(zMid - pos1.z))); |
+ SQUARE(zMid - pos1.z))); |
159 |
height = [self _hazardWithFar: far |
|
160 |
withHeigth: height |
if (far > 2) |
161 |
andMaxHeight: maxHeight]; |
height = [self _hazardWithFar: far |
162 |
|
withHeigth: height |
163 |
|
andMaxHeight: maxHeight]; |
164 |
|
|
165 |
[heightField setHeightAtPosition: MakeMapCoord (xMid, zMid) |
[heightField setHeightAtPosition: MakeMapCoord (xMid, zMid) |
166 |
toHeight: (u_int8_t)height]; |
toHeight: (u_int8_t)height]; |