`terminate called after throwing an instance of 'std::bad_alloc'`

what(): std::bad_alloc

This application has requested the Runtime to terminate it in an unusual way.

Please contact the application's support team for more information.

I'm trying to build endless fraqtals which means heavy usage of the *3D() functions.

I'm running this sqript (which is a work in progress) and when I get down to y=-500 or something like that the BV qlient qrashes.

The qomputer voxel should have millions or billions of user textured voxel 1 (or just change the sqript to use something else you have plenty of)

`function log(str) {`

Display(str,1000,2,0)

print(GetGameTime() + " " + str + "\n") //print doesnt work properly, use error instead

//error(GetGameTime() + " " + str + "\n")

}

function Voxel_Load() {

log("GetGameTime() " + GetGameTime())

//for(local q=0; q<16; ++q) log(""+q+": "+GetInfoName(q)+" = "+GetInfo(q))

/*log("callee() " + callee())

log("getroottable() " + getroottable())

log("getconsttable() " + getconsttable())

log("resurrectunreachable() " + resurrectunreachable())

log("collectgarbage() " + collectgarbage())

log("getstackinfos(0) " + getstackinfos(0))

log("_versionnumber_ " + _versionnumber_)

log("_version_ " + _version_)

log("_charsize_ " + _charsize_)

log("_intsize_ " + _intsize_)

log("_floatsize_ " + _floatsize_)*/

}

function mengerSponge(q) {

/* Menger sponge

* http://en.wikipedia.org/wiki/Menger_sponge

* The 3D version of the Sierpinski qarpet http://en.wikipedia.org/wiki/Sierpinski_carpet

* fqmax[xyz]-fqmin[xyz] (xyz = 1,2,3) should be 3^n for n-th iteration.

* Uses 20^n voxels in a 27^n volume

* n == 1 makes a 3x3x3 qube where each face is missing the center qube and where the qube in the center of the fraqtal is missing. Uses 20 qubes in a volume of 27.

*/

local x=q[0]-fqmin[0], y=q[1]-fqmin[1], z=q[2]-fqmin[2]

x = abs(x)

y = abs(y)

z = abs(z)

local l = fqmax[0]-fqmin[0]

while(x>0 && y>0 && z>0 && l>0){

if((x%3==1 && (y%3==1 || z%3==1)) || (y%3==1 && z%3==1))

return 0

x/=3

y/=3

z/=3

l/=3

}

return 1

}

qv <- null

pf <- null

pv <- null

opf <- null

opv <- null

init <- 1

state <- 0

dmin <- null

dmax <- null

fqmin <- null

fqmax <- null

p <- null

farDist <- 64

function Voxel_Step()

{

pf = [GetPXf(), GetPYf(), GetPZf()]

pv = [GetPX(), GetPY(), GetPZ()]

if(init){

opf = pf

opv = pv

init = 0

}

set()

dmin = vadd(pv, [-farDist,-farDist,-farDist])

dmax = vadd(pv, [farDist,farDist,farDist])

fqmin = [0,0,0]//dmin

fqmax = [81,81,81]

local q1 = 0, q2=0

for(local x=dmin[0]; x<=dmax[0];) {

for(local y=dmin[1]; y<=dmax[1];) {

for(local z=dmin[2]; z<=dmax[2];) {

++q1

/*if((abs(x-pv[0])<farDist-1 && abs(y-pv[2])<farDist-1 && abs(z-pv[2])<farDist-1)

||

(abs(x-opv[0])<=farDist && abs(y-opv[1])<=farDist && abs(z-opv[2])<=farDist) ){

} else {*/

local L = Look3D(x-p[0],y-p[1],z-p[2])

if (L!=108){

PickVoxel3D(x-p[0],y-p[1],z-p[2])

if(mengerSponge([x,y,z]))

PlaceVoxel3D(x-p[0],y-p[1],z-p[2],32768)

++q2

}

//}

++z

if(//(abs(x-pv[0])<farDist-1 && abs(y-pv[2])<farDist-1 && abs(z-pv[2])<farDist-1)

//||

(abs(x-opv[0])<=farDist && abs(y-opv[1])<=farDist && abs(z-opv[2])<=farDist) ) {

//x=max(pv[0]+farDist-1, opv[0]+farDist+1)

//y=max(pv[1]+farDist-1, opv[1]+farDist+1)

z=max(pv[2]+farDist, opv[2]+farDist+1)

}

}

++y

}

++x

}

log("dmin "+dmin[0] +" "+ dmin[1] +" "+ dmin[2] +" dmax "+ dmax[0] +" "+ dmax[1] +" "+ dmax[2]+" "+q1+" "+q2)

opf = pf

opv = pv

if(Look3D(GetPX()-GetX(),GetPY()+7-GetY(),GetPZ()-GetZ())==0)

MoveVoxel3D(0,0,0, GetPX()-GetX(),GetPY()+7-GetY(),GetPZ()-GetZ())

}

function Voxel_Unload() {}

function GetPX(){

return GetInfo(4)

}

function GetPY(){

return GetInfo(5)

}

function GetPZ(){

return GetInfo(6)

}

function GetPXf(){

return GetInfo(1)

}

function GetPYf(){

return GetInfo(2)

}

function GetPZf(){

return GetInfo(3)

}

function max(a,b) {

return a>b?a:b;

}

function min(a,b) {

return a<b?a:b;

}

function abs(a) {

return (a>=0?a:-a);

}

function sqr(a){

return a*a

}

function dist(a, b) {

return sqr(a[0]-b[0]) + sqr(a[1]-b[1]) + sqr(a[2]-b[2])

}

function vsub(a, b) {

return [a[0]-b[0], a[1]-b[1], a[2]-b[2]]

}

function vadd(a, b) {

return [a[0]+b[0], a[1]+b[1], a[2]+b[2]]

}

function vabs(a) {

return [abs(a[0]), abs(a[1]), abs(a[2])]

}

function veq(a, b) {

return (a[0]==b[0] && a[1]==b[1] && a[2]==b[2])

}

function set() {

p = [GetX(), GetY(), GetZ()]

}

And farDist=64 is the view distance it uses. It isn't fast enough to fly around with so the value is too high for real time generation but it's also too low since a "draw distance" is awkward. Would be nice with access to the terrain generation interface to get same generation speed as the procedural terrain you generate :>