Removes hacks for typed array initialization
This was SVN commit r9882.
This commit is contained in:
parent
b2be81c51f
commit
83f7639ac9
@ -20,9 +20,9 @@ function Map(size, baseHeight)
|
||||
|
||||
for (var i = 0; i < size; i++)
|
||||
{
|
||||
this.texture[i] = new Uint16Array(Math.floor(size)); // uint16 - texture IDs // HACK: typed arrays require integer arguments
|
||||
this.texture[i] = new Uint16Array(size); // uint16 - texture IDs
|
||||
this.terrainObjects[i] = new Array(size); // array of entities
|
||||
this.area[i] = new Uint16Array(Math.floor(size)); // uint16 - area IDs // HACK: typed arrays require integer arguments
|
||||
this.area[i] = new Uint16Array(size); // uint16 - area IDs
|
||||
|
||||
for (var j = 0; j < size; j++)
|
||||
{
|
||||
@ -35,7 +35,7 @@ function Map(size, baseHeight)
|
||||
this.height = new Array(mapSize);
|
||||
for (var i = 0; i < mapSize; i++)
|
||||
{
|
||||
this.height[i] = new Float32Array(Math.floor(mapSize)); // float32 // HACK: typed arrays require integer arguments
|
||||
this.height[i] = new Float32Array(mapSize); // float32
|
||||
|
||||
for (var j = 0; j < mapSize; j++)
|
||||
{ // Initialize height map to baseHeight
|
||||
@ -97,10 +97,10 @@ Map.prototype.validT = function(x, z)
|
||||
{
|
||||
if (g_MapSettings.CircularMap)
|
||||
{ // Within map circle
|
||||
var halfSize = 0.5*this.size;
|
||||
var halfSize = Math.floor(0.5*this.size);
|
||||
var dx = (x - halfSize);
|
||||
var dz = (z - halfSize);
|
||||
return Math.sqrt(dx*dx + dz*dz) < (halfSize - 1.5);
|
||||
return Math.round(Math.sqrt(dx*dx + dz*dz)) < halfSize;
|
||||
}
|
||||
else
|
||||
{ // Within map square
|
||||
@ -300,7 +300,7 @@ Map.prototype.getMapData = function()
|
||||
// Convert 2D heightmap array to flat array
|
||||
// Flat because it's easier to handle by the engine
|
||||
var mapSize = size+1;
|
||||
var height16 = new Uint16Array(Math.floor(mapSize*mapSize)); // uint16 // HACK: typed arrays require integer arguments
|
||||
var height16 = new Uint16Array(mapSize*mapSize); // uint16
|
||||
for (var x = 0; x < mapSize; x++)
|
||||
{
|
||||
for (var z = 0; z < mapSize; z++)
|
||||
@ -332,8 +332,8 @@ Map.prototype.getMapData = function()
|
||||
data["textureNames"] = textureNames;
|
||||
|
||||
// Convert 2D tile data to flat array
|
||||
var tileIndex = new Uint16Array(Math.floor(size*size)); // uint16 // HACK: typed arrays require integer arguments
|
||||
var tilePriority = new Uint16Array(Math.floor(size*size)); // uint16 // HACK: typed arrays require integer arguments
|
||||
var tileIndex = new Uint16Array(size*size); // uint16
|
||||
var tilePriority = new Uint16Array(size*size); // uint16
|
||||
for (var x = 0; x < size; x++)
|
||||
{
|
||||
for (var z = 0; z < size; z++)
|
||||
|
@ -69,8 +69,8 @@ LayeredPainter.prototype.paint = function(area)
|
||||
// init typed arrays
|
||||
for (var i = 0; i < size; ++i)
|
||||
{
|
||||
saw[i] = new Uint8Array(Math.floor(size)); // bool / uint8 // HACK: typed arrays require integer arguments
|
||||
dist[i] = new Uint16Array(Math.floor(size)); // uint16 // HACK: typed arrays require integer arguments
|
||||
saw[i] = new Uint8Array(size); // bool / uint8
|
||||
dist[i] = new Uint16Array(size); // uint16
|
||||
}
|
||||
|
||||
// Point queue (implemented with array)
|
||||
@ -221,10 +221,10 @@ SmoothElevationPainter.prototype.paint = function(area)
|
||||
// init typed arrays
|
||||
for (var i = 0; i < mapSize; ++i)
|
||||
{
|
||||
saw[i] = new Uint8Array(Math.floor(mapSize)); // bool / uint8 // HACK: typed arrays require integer arguments
|
||||
dist[i] = new Uint16Array(Math.floor(mapSize)); // uint16 // HACK: typed arrays require integer arguments
|
||||
gotHeightPt[i] = new Uint8Array(Math.floor(mapSize)); // bool / uint8 // HACK: typed arrays require integer arguments
|
||||
newHeight[i] = new Float32Array(Math.floor(mapSize)); // float32 // HACK: typed arrays require integer arguments
|
||||
saw[i] = new Uint8Array(mapSize); // bool / uint8
|
||||
dist[i] = new Uint16Array(mapSize); // uint16
|
||||
gotHeightPt[i] = new Uint8Array(mapSize); // bool / uint8
|
||||
newHeight[i] = new Float32Array(mapSize); // float32
|
||||
}
|
||||
|
||||
var length = pts.length;
|
||||
|
@ -35,7 +35,7 @@ ClumpPlacer.prototype.place = function(constraint)
|
||||
var gotRet = new Array(size);
|
||||
for (var i = 0; i < size; ++i)
|
||||
{
|
||||
gotRet[i] = new Uint8Array(Math.floor(size)); // bool / uint8 // HACK: typed arrays require integer arguments
|
||||
gotRet[i] = new Uint8Array(size); // bool / uint8
|
||||
}
|
||||
|
||||
var radius = sqrt(this.size / PI);
|
||||
@ -49,9 +49,9 @@ ClumpPlacer.prototype.place = function(constraint)
|
||||
ctrlPts = Math.floor(radius * 2 * PI) + 1;
|
||||
}
|
||||
|
||||
var noise = new Float32Array(Math.floor(intPerim)); //float32 // HACK: typed arrays require integer arguments
|
||||
var ctrlCoords = new Float32Array(Math.floor(ctrlPts+1)); //float32 // HACK: typed arrays require integer arguments
|
||||
var ctrlVals = new Float32Array(Math.floor(ctrlPts+1)); //float32 // HACK: typed arrays require integer arguments
|
||||
var noise = new Float32Array(intPerim); //float32
|
||||
var ctrlCoords = new Float32Array(ctrlPts+1); //float32
|
||||
var ctrlVals = new Float32Array(ctrlPts+1); //float32
|
||||
|
||||
// Generate some interpolated noise
|
||||
for (var i=0; i < ctrlPts; i++)
|
||||
|
@ -13,7 +13,7 @@ function RangeOp(size)
|
||||
this.nn *= 2;
|
||||
}
|
||||
|
||||
this.vals = new Int16Array(Math.floor(2*this.nn)); // int16 // HACK: typed arrays require integer arguments
|
||||
this.vals = new Int16Array(2*this.nn); // int16
|
||||
}
|
||||
|
||||
RangeOp.prototype.set = function(pos, amt)
|
||||
@ -78,7 +78,7 @@ function TileClass(size, id)
|
||||
|
||||
for (var i=0; i < size; ++i)
|
||||
{
|
||||
this.inclusionCount[i] = new Int16Array(Math.floor(size)); //int16 // HACK: typed arrays require integer arguments
|
||||
this.inclusionCount[i] = new Int16Array(size); //int16
|
||||
this.rangeCount[i] = new RangeOp(size);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user