- [3D Terrain] Add smooth shading and improve performance.

This commit is contained in:
Tanasart 2024-06-15 10:54:16 +07:00
parent 153863a904
commit 63bbf10ba2
2 changed files with 389 additions and 84 deletions

View file

@ -2,55 +2,179 @@ function __3dTerrain() : __3dObject() constructor {
VB = [ noone ];
VF = global.VF_POS_NORM_TEX_COL;
render_type = pr_trianglelist;
smooth = false;
self.subdivision = 4;
heights = array_create((subdivision + 1) * (subdivision + 1));
static initModel = function() {
print("Init")
var _hs = 1 / 2;
var _vt = array_create(3 * 2 * subdivision * subdivision);
var _in = 0;
var amo_ch = (subdivision + 1) * (subdivision + 1);
var hs = array_length(heights) == amo_ch;
var st = 1 / subdivision;
var st2 = st * 2;
if(!hs) {
for( var i = 0; i < subdivision; i++ )
for( var j = 0; j < subdivision; j++ ) {
var u0 = i * st;
var u1 = u0 + st;
var v0 = j * st;
var v1 = v0 + st;
var x0 = u0 - 0.5;
var x1 = u1 - 0.5;
var y0 = v0 - 0.5;
var y1 = v1 - 0.5;
_vt[_in + 0] = new __vertex(x0, y0, 0).setNormal(0., 0., 1.).setUV(u0, v0);
_vt[_in + 1] = new __vertex(x1, y1, 0).setNormal(0., 0., 1.).setUV(u1, v1);
_vt[_in + 2] = new __vertex(x1, y0, 0).setNormal(0., 0., 1.).setUV(u1, v0);
_vt[_in + 3] = new __vertex(x0, y0, 0).setNormal(0., 0., 1.).setUV(u0, v0);
_vt[_in + 4] = new __vertex(x0, y1, 0).setNormal(0., 0., 1.).setUV(u0, v1);
_vt[_in + 5] = new __vertex(x1, y1, 0).setNormal(0., 0., 1.).setUV(u1, v1);
_in += 6;
}
} else {
for( var i = 0; i < subdivision; i++ )
for( var j = 0; j < subdivision; j++ ) {
var u0 = (i + 0) / subdivision;
var u1 = (i + 1) / subdivision;
var v0 = (j + 0) / subdivision;
var v1 = (j + 1) / subdivision;
var u0 = i * st;
var u1 = u0 + st;
var v0 = j * st;
var v1 = v0 + st;
var x0 = -0.5 + u0;
var x1 = -0.5 + u1;
var y0 = -0.5 + v0;
var y1 = -0.5 + v1;
var x0 = u0 - 0.5;
var x1 = u1 - 0.5;
var y0 = v0 - 0.5;
var y1 = v1 - 0.5;
var _i0 = j * (subdivision + 1) + i;
var _i1 = j * (subdivision + 1) + i + 1;
var _i2 = (j + 1) * (subdivision + 1) + i;
var _i3 = (j + 1) * (subdivision + 1) + i + 1;
var _h0 = heights[ j * (subdivision + 1) + i ];
var _h1 = heights[ j * (subdivision + 1) + i + 1];
var _h2 = heights[(j + 1) * (subdivision + 1) + i ];
var _h3 = heights[(j + 1) * (subdivision + 1) + i + 1];
var _h0 = hs? heights[_i0] : 0;
var _h1 = hs? heights[_i1] : 0;
var _h2 = hs? heights[_i2] : 0;
var _h3 = hs? heights[_i3] : 0;
if(smooth) {
var _n = new __vec3(x1 - x0, y0 - y0, _h1 - _h0)
.cross(new __vec3(x0 - x0, y1 - y0, _h2 - _h0))
.normalize();
var _h4 = heights[clamp(j , 0, subdivision) * (subdivision + 1) + clamp(i - 1, 0, subdivision)];
var _h5 = heights[clamp(j - 1, 0, subdivision) * (subdivision + 1) + clamp(i , 0, subdivision)];
var _h6 = heights[clamp(j - 1, 0, subdivision) * (subdivision + 1) + clamp(i + 1, 0, subdivision)];
var _h7 = heights[clamp(j , 0, subdivision) * (subdivision + 1) + clamp(i + 2, 0, subdivision)];
var _h8 = heights[clamp(j + 1, 0, subdivision) * (subdivision + 1) + clamp(i + 2, 0, subdivision)];
var _h9 = heights[clamp(j + 2, 0, subdivision) * (subdivision + 1) + clamp(i + 1, 0, subdivision)];
var _h10 = heights[clamp(j + 2, 0, subdivision) * (subdivision + 1) + clamp(i , 0, subdivision)];
var _h11 = heights[clamp(j + 1, 0, subdivision) * (subdivision + 1) + clamp(i - 1, 0, subdivision)];
_vt[_in + 0] = new __vertex(x0, y0, _h0).setNormal(_n.x, _n.y, _n.z).setUV(u0, v0);
_vt[_in + 1] = new __vertex(x1, y1, _h3).setNormal(_n.x, _n.y, _n.z).setUV(u1, v1);
_vt[_in + 2] = new __vertex(x1, y0, _h1).setNormal(_n.x, _n.y, _n.z).setUV(u1, v0);
////////////////////////////////////////////////////////////////////////////////
_vt[_in + 3] = new __vertex(x0, y0, _h0).setNormal(_n.x, _n.y, _n.z).setUV(u0, v0);
_vt[_in + 4] = new __vertex(x0, y1, _h2).setNormal(_n.x, _n.y, _n.z).setUV(u0, v1);
_vt[_in + 5] = new __vertex(x1, y1, _h3).setNormal(_n.x, _n.y, _n.z).setUV(u1, v1);
var _nx0 = st2, _ny0 = 0, _nz0 = _h1 - _h4;
var _nx1 = 0, _ny1 = st2, _nz1 = _h2 - _h5;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n0x = _cx / len;
var _n0y = _cy / len;
var _n0z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h7 - _h0;
var _nx1 = 0, _ny1 = st2, _nz1 = _h3 - _h6;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n1x = _cx / len;
var _n1y = _cy / len;
var _n1z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h3 - _h11;
var _nx1 = 0, _ny1 = st2, _nz1 = _h10 - _h0;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n2x = _cx / len;
var _n2y = _cy / len;
var _n2z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h8 - _h2;
var _nx1 = 0, _ny1 = st2, _nz1 = _h9 - _h1;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n3x = _cx / len;
var _n3y = _cy / len;
var _n3z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
_vt[_in + 0] = new __vertex(x0, y0, _h0).setNormal(_n0x, _n0y, _n0z).setUV(u0, v0);
_vt[_in + 1] = new __vertex(x1, y1, _h3).setNormal(_n3x, _n3y, _n3z).setUV(u1, v1);
_vt[_in + 2] = new __vertex(x1, y0, _h1).setNormal(_n1x, _n1y, _n1z).setUV(u1, v0);
_vt[_in + 3] = new __vertex(x0, y0, _h0).setNormal(_n0x, _n0y, _n0z).setUV(u0, v0);
_vt[_in + 4] = new __vertex(x0, y1, _h2).setNormal(_n2x, _n2y, _n2z).setUV(u0, v1);
_vt[_in + 5] = new __vertex(x1, y1, _h3).setNormal(_n3x, _n3y, _n3z).setUV(u1, v1);
} else {
var _nx0 = st;
var _ny0 = 0;
var _nz0 = _h1 - _h0;
var _nx1 = 0;
var _ny1 = st;
var _nz1 = _h2 - _h0;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _nx = _cx / len;
var _ny = _cy / len;
var _nz = _cz / len;
_vt[_in + 0] = new __vertex(x0, y0, _h0).setNormal(_nx, _ny, _nz).setUV(u0, v0);
_vt[_in + 1] = new __vertex(x1, y1, _h3).setNormal(_nx, _ny, _nz).setUV(u1, v1);
_vt[_in + 2] = new __vertex(x1, y0, _h1).setNormal(_nx, _ny, _nz).setUV(u1, v0);
_vt[_in + 3] = new __vertex(x0, y0, _h0).setNormal(_nx, _ny, _nz).setUV(u0, v0);
_vt[_in + 4] = new __vertex(x0, y1, _h2).setNormal(_nx, _ny, _nz).setUV(u0, v1);
_vt[_in + 5] = new __vertex(x1, y1, _h3).setNormal(_nx, _ny, _nz).setUV(u1, v1);
}
_in += 6;
}
}
vertex = [ _vt ];
VB = build();
@ -61,55 +185,227 @@ function __3dTerrain() : __3dObject() constructor {
var _in = 0;
var _vt = vertex[0];
var sub = subdivision;
var sub1 = sub + 1;
var st = 1 / subdivision;
var st2 = st * 2;
if(VB[0]) vertex_delete_buffer(VB[0]);
VB[0] = vertex_create_buffer();
vertex_begin(VB[0], VF);
for( var i = 0; i < subdivision; i++ )
for( var j = 0; j < subdivision; j++ ) {
var u0 = (i + 0) / subdivision;
var u1 = (i + 1) / subdivision;
var v0 = (j + 0) / subdivision;
var v1 = (j + 1) / subdivision;
var vb = VB[0];
var n = 0, i = 0, j = 0;
var x0 = -0.5 + u0;
var x1 = -0.5 + u1;
var y0 = -0.5 + v0;
var y1 = -0.5 + v1;
if(smooth) {
repeat( sub * sub ) {
var _i0 = j * (subdivision + 1) + i;
var _i1 = j * (subdivision + 1) + i + 1;
var _i2 = (j + 1) * (subdivision + 1) + i;
var _i3 = (j + 1) * (subdivision + 1) + i + 1;
var _h0 = _h[ j * sub1 + i ];
var _h1 = _h[ j * sub1 + i + 1];
var _h2 = _h[(j + 1) * sub1 + i ];
var _h3 = _h[(j + 1) * sub1 + i + 1];
var _h0 = heights[_i0];
var _h1 = heights[_i1];
var _h2 = heights[_i2];
var _h3 = heights[_i3];
var _v0 = _vt[_in + 0];
var _v1 = _vt[_in + 1];
var _v2 = _vt[_in + 2];
var _v3 = _vt[_in + 3];
var _v4 = _vt[_in + 4];
var _v5 = _vt[_in + 5];
var _n = new __vec3(x1 - x0, y0 - y0, _h1 - _h0)
.cross(new __vec3(x0 - x0, y1 - y0, _h2 - _h0))
.normalize();
var _h4 = _h[ j * sub1 + max(i - 1, 0) ];
var _h5 = _h[ max(j - 1, 0) * sub1 + i ];
var _h6 = _h[ max(j - 1, 0) * sub1 + min(i + 1, sub) ];
var _h7 = _h[ j * sub1 + min(i + 2, sub) ];
var _h8 = _h[ min(j + 1, sub) * sub1 + min(i + 2, sub) ];
var _h9 = _h[ min(j + 2, sub) * sub1 + min(i + 1, sub) ];
var _h10 = _h[ min(j + 2, sub) * sub1 + i ];
var _h11 = _h[ min(j + 1, sub) * sub1 + max(i - 1, 0) ];
_vt[_in + 0].z = _h0; _vt[_in + 0].nx = _n.x; _vt[_in + 0].ny = _n.y; _vt[_in + 0].nz = _n.z;
_vt[_in + 1].z = _h3; _vt[_in + 1].nx = _n.x; _vt[_in + 1].ny = _n.y; _vt[_in + 1].nz = _n.z;
_vt[_in + 2].z = _h1; _vt[_in + 2].nx = _n.x; _vt[_in + 2].ny = _n.y; _vt[_in + 2].nz = _n.z;
////////////////////////////////////////////////////////////////////////////////
_vt[_in + 3].z = _h0; _vt[_in + 3].nx = _n.x; _vt[_in + 3].ny = _n.y; _vt[_in + 3].nz = _n.z;
_vt[_in + 4].z = _h2; _vt[_in + 4].nx = _n.x; _vt[_in + 4].ny = _n.y; _vt[_in + 4].nz = _n.z;
_vt[_in + 5].z = _h3; _vt[_in + 5].nx = _n.x; _vt[_in + 5].ny = _n.y; _vt[_in + 5].nz = _n.z;
var _nx0 = st2, _ny0 = 0, _nz0 = _h1 - _h4;
var _nx1 = 0, _ny1 = st2, _nz1 = _h2 - _h5;
vertex_add_vntc(VB[0], _vt[_in + 0]);
vertex_add_vntc(VB[0], _vt[_in + 1]);
vertex_add_vntc(VB[0], _vt[_in + 2]);
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
vertex_add_vntc(VB[0], _vt[_in + 3]);
vertex_add_vntc(VB[0], _vt[_in + 4]);
vertex_add_vntc(VB[0], _vt[_in + 5]);
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n0x = _cx / len;
var _n0y = _cy / len;
var _n0z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h7 - _h0;
var _nx1 = 0, _ny1 = st2, _nz1 = _h3 - _h6;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n1x = _cx / len;
var _n1y = _cy / len;
var _n1z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h3 - _h11;
var _nx1 = 0, _ny1 = st2, _nz1 = _h10 - _h0;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n2x = _cx / len;
var _n2y = _cy / len;
var _n2z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
var _nx0 = st2, _ny0 = 0, _nz0 = _h8 - _h2;
var _nx1 = 0, _ny1 = st2, _nz1 = _h9 - _h1;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _n3x = _cx / len;
var _n3y = _cy / len;
var _n3z = _cz / len;
////////////////////////////////////////////////////////////////////////////////
_v0.z = _h0; _v0.nx = _n0x; _v0.ny = _n0y; _v0.nz = _n0z;
_v1.z = _h3; _v1.nx = _n3x; _v1.ny = _n3y; _v1.nz = _n3z;
_v2.z = _h1; _v2.nx = _n1x; _v2.ny = _n1y; _v2.nz = _n1z;
_v3.z = _h0; _v3.nx = _n0x; _v3.ny = _n0y; _v3.nz = _n0z;
_v4.z = _h2; _v4.nx = _n2x; _v4.ny = _n2y; _v4.nz = _n2z;
_v5.z = _h3; _v5.nx = _n3x; _v5.ny = _n3y; _v5.nz = _n3z;
vertex_position_3d(vb, _v0.x, _v0.y, _v0.z);
vertex_normal( vb, _v0.nx, _v0.ny, _v0.nz);
vertex_texcoord( vb, _v0.u, _v0.v);
vertex_color( vb, _v0.color, _v0.alpha);
vertex_position_3d(vb, _v1.x, _v1.y, _v1.z);
vertex_normal( vb, _v1.nx, _v1.ny, _v1.nz);
vertex_texcoord( vb, _v1.u, _v1.v);
vertex_color( vb, _v1.color, _v1.alpha);
vertex_position_3d(vb, _v2.x, _v2.y, _v2.z);
vertex_normal( vb, _v2.nx, _v2.ny, _v2.nz);
vertex_texcoord( vb, _v2.u, _v2.v);
vertex_color( vb, _v2.color, _v2.alpha);
vertex_position_3d(vb, _v3.x, _v3.y, _v3.z);
vertex_normal( vb, _v3.nx, _v3.ny, _v3.nz);
vertex_texcoord( vb, _v3.u, _v3.v);
vertex_color( vb, _v3.color, _v3.alpha);
vertex_position_3d(vb, _v4.x, _v4.y, _v4.z);
vertex_normal( vb, _v4.nx, _v4.ny, _v4.nz);
vertex_texcoord( vb, _v4.u, _v4.v);
vertex_color( vb, _v4.color, _v4.alpha);
vertex_position_3d(vb, _v5.x, _v5.y, _v5.z);
vertex_normal( vb, _v5.nx, _v5.ny, _v5.nz);
vertex_texcoord( vb, _v5.u, _v5.v);
vertex_color( vb, _v5.color, _v5.alpha);
_in += 6;
n++;
i = floor(n / sub);
j = n % sub;
}
} else {
repeat( sub * sub ) {
var _h0 = _h[ j * sub1 + i ];
var _h1 = _h[ j * sub1 + i + 1];
var _h2 = _h[(j + 1) * sub1 + i ];
var _h3 = _h[(j + 1) * sub1 + i + 1];
var _v0 = _vt[_in + 0];
var _v1 = _vt[_in + 1];
var _v2 = _vt[_in + 2];
var _v3 = _vt[_in + 3];
var _v4 = _vt[_in + 4];
var _v5 = _vt[_in + 5];
var _nx0 = st, _ny0 = 0, _nz0 = _h1 - _h0;
var _nx1 = 0, _ny1 = st, _nz1 = _h2 - _h0;
var _cx = _ny0 * _nz1 - _nz0 * _ny1;
var _cy = _nz0 * _nx1 - _nx0 * _nz1;
var _cz = _nx0 * _ny1 - _ny0 * _nx1;
var len = sqrt(_cx * _cx + _cy * _cy + _cz * _cz);
var _nx = _cx / len;
var _ny = _cy / len;
var _nz = _cz / len;
_v0.z = _h0; _v0.nx = _nx; _v0.ny = _ny; _v0.nz = _nz;
_v1.z = _h3; _v1.nx = _nx; _v1.ny = _ny; _v1.nz = _nz;
_v2.z = _h1; _v2.nx = _nx; _v2.ny = _ny; _v2.nz = _nz;
_v3.z = _h0; _v3.nx = _nx; _v3.ny = _ny; _v3.nz = _nz;
_v4.z = _h2; _v4.nx = _nx; _v4.ny = _ny; _v4.nz = _nz;
_v5.z = _h3; _v5.nx = _nx; _v5.ny = _ny; _v5.nz = _nz;
vertex_position_3d(vb, _v0.x, _v0.y, _v0.z);
vertex_normal( vb, _v0.nx, _v0.ny, _v0.nz);
vertex_texcoord( vb, _v0.u, _v0.v);
vertex_color( vb, _v0.color, _v0.alpha);
vertex_position_3d(vb, _v1.x, _v1.y, _v1.z);
vertex_normal( vb, _v1.nx, _v1.ny, _v1.nz);
vertex_texcoord( vb, _v1.u, _v1.v);
vertex_color( vb, _v1.color, _v1.alpha);
vertex_position_3d(vb, _v2.x, _v2.y, _v2.z);
vertex_normal( vb, _v2.nx, _v2.ny, _v2.nz);
vertex_texcoord( vb, _v2.u, _v2.v);
vertex_color( vb, _v2.color, _v2.alpha);
vertex_position_3d(vb, _v3.x, _v3.y, _v3.z);
vertex_normal( vb, _v3.nx, _v3.ny, _v3.nz);
vertex_texcoord( vb, _v3.u, _v3.v);
vertex_color( vb, _v3.color, _v3.alpha);
vertex_position_3d(vb, _v4.x, _v4.y, _v4.z);
vertex_normal( vb, _v4.nx, _v4.ny, _v4.nz);
vertex_texcoord( vb, _v4.u, _v4.v);
vertex_color( vb, _v4.color, _v4.alpha);
vertex_position_3d(vb, _v5.x, _v5.y, _v5.z);
vertex_normal( vb, _v5.nx, _v5.ny, _v5.nz);
vertex_texcoord( vb, _v5.u, _v5.v);
vertex_color( vb, _v5.color, _v5.alpha);
_in += 6;
n++;
i = floor(n / sub);
j = n % sub;
}
}
vertex_end(VB[0]);
}

View file

@ -16,10 +16,11 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
inputs[| in_mesh + 4] = nodeValue("Height array", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [] )
.setArrayDepth(2);
inputs[| in_mesh + 5] = nodeValue("Smooth", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false );
input_display_list = [
__d3d_input_list_mesh,
__d3d_input_list_transform,
["Terrain", false], in_mesh + 3, in_mesh + 1, in_mesh + 2, in_mesh + 4,
["Terrain", false], in_mesh + 3, in_mesh + 1, in_mesh + 2, in_mesh + 4, in_mesh + 5,
["Material", false], in_mesh + 0,
]
@ -36,30 +37,38 @@ function Node_3D_Mesh_Terrain(_x, _y, _group = noone) : Node_3D_Mesh(_x, _y, _gr
var _sub = _data[in_mesh + 3];
var _his = _data[in_mesh + 2];
var _hia = _data[in_mesh + 4];
var _smt = _data[in_mesh + 5];
var _h = array_create((_sub + 1) * (_sub + 1));
var object = getObject(_array_index);
if(_inT == 0 && is_surface(_his)) {
var _ind = 0;
var _pxw = surface_get_width(_his) / (_sub + 1);
var _pxh = surface_get_height(_his) / (_sub + 1);
var _sw = surface_get_width(_his);
var _sh = surface_get_height(_his);
var _pxw = _sw / (_sub + 1);
var _pxh = _sh / (_sub + 1);
var _bf = buffer_from_surface(_his, false);
for( var i = 0; i < _sub + 1; i++ )
for( var j = 0; j < _sub + 1; j++ ) {
var cc = surface_getpixel(_his, j * _pxw, i * _pxh);
var ps = clamp(round(i * _pxh), 0, _sh) * _sw + clamp(round(j * _pxw), 0, _sw);
buffer_seek(_bf, buffer_seek_start, ps * 4);
var cc = buffer_read(_bf, buffer_u32);
_h[_ind] = colorBrightness(cc);
_ind++;
}
buffer_delete(_bf);
} else if(_inT == 1 && !array_empty(_hia)) {
if(is_array(_hia[0])) _hia = array_spread(_hia);
array_copy(_h, 0, _hia, 0, min(array_length(_h), array_length(_hia)));
}
if(IS_FIRST_FRAME) object.initModel();
object.checkParameter({ subdivision: _sub });
object.checkParameter({ subdivision: _sub, smooth: _smt });
object.updateHeight(_h);
object.materials = [ _mat ];