mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 00:15:19 +02:00
make terrain a doubly linked list
This commit is contained in:
parent
264d39aa9b
commit
4ab8ac29b9
1 changed files with 44 additions and 38 deletions
|
@ -290,50 +290,56 @@ function addTerrainBlock() {
|
||||||
// stitch together the terrain with x/y/z NeighorID properties
|
// stitch together the terrain with x/y/z NeighorID properties
|
||||||
//////////
|
//////////
|
||||||
|
|
||||||
// link plots which are lower on the axes to this one
|
// link neighbors to this plot
|
||||||
imXNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:-16, y:0, z:0}));
|
imXNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:16, y:0, z:0}));
|
||||||
if (imXNeighborFor) {
|
imYNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:16, z:0}));
|
||||||
var properties = Entities.getEntityProperties(imXNeighborFor);
|
imZNNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16}));
|
||||||
properties.xNeighborID = polyVoxID;
|
imXPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:-16, y:0, z:0}));
|
||||||
Entities.editEntity(imXNeighborFor, properties);
|
imYPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:-16, z:0}));
|
||||||
|
imZPNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:-16}));
|
||||||
|
|
||||||
|
if (imXNNeighborFor) {
|
||||||
|
var properties = Entities.getEntityProperties(imXNNeighborFor);
|
||||||
|
properties.xNNeighborID = polyVoxID;
|
||||||
|
Entities.editEntity(imXNNeighborFor, properties);
|
||||||
|
}
|
||||||
|
if (imYNNeighborFor) {
|
||||||
|
var properties = Entities.getEntityProperties(imYNNeighborFor);
|
||||||
|
properties.yNNeighborID = polyVoxID;
|
||||||
|
Entities.editEntity(imYNNeighborFor, properties);
|
||||||
|
}
|
||||||
|
if (imZNNeighborFor) {
|
||||||
|
var properties = Entities.getEntityProperties(imZNNeighborFor);
|
||||||
|
properties.zNNeighborID = polyVoxID;
|
||||||
|
Entities.editEntity(imZNNeighborFor, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
imYNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:-16, z:0}));
|
if (imXPNeighborFor) {
|
||||||
if (imYNeighborFor) {
|
var properties = Entities.getEntityProperties(imXPNeighborFor);
|
||||||
var properties = Entities.getEntityProperties(imYNeighborFor);
|
properties.xPNeighborID = polyVoxID;
|
||||||
properties.yNeighborID = polyVoxID;
|
Entities.editEntity(imXPNeighborFor, properties);
|
||||||
Entities.editEntity(imYNeighborFor, properties);
|
|
||||||
}
|
}
|
||||||
|
if (imYPNeighborFor) {
|
||||||
imZNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:-16}));
|
var properties = Entities.getEntityProperties(imYPNeighborFor);
|
||||||
if (imZNeighborFor) {
|
properties.yPNeighborID = polyVoxID;
|
||||||
var properties = Entities.getEntityProperties(imZNeighborFor);
|
Entities.editEntity(imYPNeighborFor, properties);
|
||||||
properties.zNeighborID = polyVoxID;
|
}
|
||||||
Entities.editEntity(imZNeighborFor, properties);
|
if (imZPNeighborFor) {
|
||||||
|
var properties = Entities.getEntityProperties(imZPNeighborFor);
|
||||||
|
properties.zPNeighborID = polyVoxID;
|
||||||
|
Entities.editEntity(imZPNeighborFor, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// link this plot to plots which are higher on the axes
|
// link this plot to its neighbors
|
||||||
xNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:16, y:0, z:0}));
|
var properties = Entities.getEntityProperties(polyVoxID);
|
||||||
if (xNeighborFor) {
|
properties.xNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:-16, y:0, z:0}));
|
||||||
var properties = Entities.getEntityProperties(polyVoxID);
|
properties.yNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:-16, z:0}));
|
||||||
properties.xNeighborID = xNeighborFor;
|
properties.zNNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:-16}));
|
||||||
Entities.editEntity(polyVoxID, properties);
|
properties.xPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:16, y:0, z:0}));
|
||||||
}
|
properties.yPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:16, z:0}));
|
||||||
|
properties.zPNeighborID = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16}));
|
||||||
yNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:16, z:0}));
|
Entities.editEntity(polyVoxID, properties);
|
||||||
if (yNeighborFor) {
|
|
||||||
var properties = Entities.getEntityProperties(polyVoxID);
|
|
||||||
properties.yNeighborID = yNeighborFor;
|
|
||||||
Entities.editEntity(polyVoxID, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
zNeighborFor = lookupTerrainForLocation(Vec3.sum(baseLocation, {x:0, y:0, z:16}));
|
|
||||||
if (zNeighborFor) {
|
|
||||||
var properties = Entities.getEntityProperties(polyVoxID);
|
|
||||||
properties.zNeighborID = zNeighborFor;
|
|
||||||
Entities.editEntity(polyVoxID, properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue