Async mesh reloading for planets
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
package mindustry.maps.generators;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.geom.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
@@ -9,16 +7,6 @@ import mindustry.world.*;
|
||||
/** A planet generator that provides no weather, height, color or bases. Override generate().*/
|
||||
public class BlankPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
@Override
|
||||
public float getHeight(Vec3 position){
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
return Color.white;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addWeather(Sector sector, Rules rules){
|
||||
|
||||
|
||||
@@ -39,15 +39,13 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
public void getColor(Vec3 position, Color out){
|
||||
Block block = getBlock(position);
|
||||
|
||||
//more obvious color
|
||||
if(block == Blocks.crystallineStone) block = Blocks.crystalFloor;
|
||||
//TODO this might be too green
|
||||
//if(block == Blocks.beryllicStone) block = Blocks.arkyicStone;
|
||||
|
||||
return Tmp.c1.set(block.mapColor).a(1f - block.albedo);
|
||||
out.set(block.mapColor).a(1f - block.albedo);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -66,12 +66,12 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
@Override
|
||||
public void onSectorCaptured(Sector sector){
|
||||
sector.planet.requiresMeshReload = true;
|
||||
sector.planet.reloadMeshAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSectorLost(Sector sector){
|
||||
sector.planet.requiresMeshReload = true;
|
||||
sector.planet.reloadMeshAsync();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,26 +96,27 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
public void getColor(Vec3 position, Color out){
|
||||
//if(dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 4f, position.x, position.y + 200f, position.z)*0.14f < 0.09f){
|
||||
// return Tmp.c1.set(Team.crux.color).lerp(Team.sharded.color, 0.4f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z)).a(packAlpha(0f, 1f));
|
||||
//}
|
||||
|
||||
Block block = getBlock(position);
|
||||
//replace salt with sand color
|
||||
if(block == Blocks.salt) return Blocks.sand.mapColor;
|
||||
return Tmp.c1.set(block.mapColor).a(1f - block.albedo);
|
||||
if(block == Blocks.salt) block = Blocks.sand;
|
||||
out.set(block.mapColor).a(1f - block.albedo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasEmissive(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getEmissiveColor(Vec3 position){
|
||||
public void getEmissiveColor(Vec3 position, Color out){
|
||||
float dst = 999f, captureDst = 999f, lightScl = 0f;
|
||||
for(Sector sector : Planets.serpulo.sectors){
|
||||
|
||||
Object[] sectors = Planets.serpulo.sectors.items;
|
||||
int size = Planets.serpulo.sectors.size;
|
||||
|
||||
for(int i = 0; i < size; i ++){
|
||||
var sector = (Sector)sectors[i];
|
||||
|
||||
if(sector.hasEnemyBase() && !sector.isCaptured()){
|
||||
dst = Math.min(dst, position.dst(sector.tile.v) - (sector.preset != null ? sector.preset.difficulty/10f * 0.03f - 0.03f : 0f));
|
||||
}else if(sector.hasBase()){
|
||||
@@ -133,22 +134,23 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
float freq = 0.05f;
|
||||
if(position.dst(basePos) < 0.55f ?
|
||||
|
||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f :
|
||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.08f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.08f/* || dst <= 0.0001f*/ :
|
||||
dst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 9f, position.x, position.y + 370f, position.z)*0.06f < 0.045){
|
||||
|
||||
return Tmp.c1.set(Team.crux.color).mul(0.8f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.sharded.color, 0.2f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z));
|
||||
out.set(Team.crux.color)
|
||||
.mul(0.8f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.sharded.color, 0.2f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z)).toFloatBits();
|
||||
}else if(captureDst*metalDstScl + Simplex.noise3d(seed, 3, 0.4, 9f, position.x, position.y + 600f, position.z)*0.07f < 0.05 * lightScl){
|
||||
return Tmp.c1.set(Team.sharded.color).mul(0.7f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.crux.color, 0.3f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z));
|
||||
}
|
||||
out.set(Team.sharded.color).mul(0.7f + Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 99f, position.z) * 0.4f)
|
||||
.lerp(Team.crux.color, 0.3f*Simplex.noise3d(seed, 1, 1, 9f, position.x, position.y + 999f, position.z)).toFloatBits();
|
||||
|
||||
return Color.clear;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void genTile(Vec3 position, TileGen tile){
|
||||
tile.floor = getBlock(position);
|
||||
if(tile.floor == Blocks.darkPanel6) tile.floor = Blocks.darkPanel3;
|
||||
tile.block = tile.floor.asFloor().wall;
|
||||
|
||||
if(Ridged.noise3d(seed + 1, position.x, position.y, position.z, 2, 22) > 0.31){
|
||||
@@ -156,7 +158,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
}
|
||||
|
||||
public static double metalMag = 0.11, metalScl = 1, metalDstScl = 0.25, metalThresh = 0.1;
|
||||
static double metalDstScl = 0.25;
|
||||
|
||||
Block getBlock(Vec3 position){
|
||||
float height = rawHeight(position);
|
||||
@@ -169,7 +171,7 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
height *= 1.2f;
|
||||
height = Mathf.clamp(height);
|
||||
|
||||
float tar = Simplex.noise3d(seed, 4, 0.55f, 1f/2f, px, py + 999f, pz) * 0.3f + Tmp.v31.dst(0, 0, 1f) * 0.2f;
|
||||
float tar = Simplex.noise3d(seed, 4, 0.55f, 1f/2f, px, py + 999f, pz) * 0.3f + position.dst(0, 0, 1f) * 0.2f;
|
||||
|
||||
Block res = arr[Mathf.clamp((int)(temp * arr.length), 0, arr[0].length - 1)][Mathf.clamp((int)(height * arr[0].length), 0, arr[0].length - 1)];
|
||||
if(tar > 0.5f){
|
||||
@@ -178,16 +180,22 @@ public class SerpuloPlanetGenerator extends PlanetGenerator{
|
||||
if(position.within(basePos, 0.65f)){
|
||||
|
||||
float dst = 999f;
|
||||
for(Sector sector : Planets.serpulo.sectors){
|
||||
|
||||
Object[] sectors = Planets.serpulo.sectors.items;
|
||||
int size = Planets.serpulo.sectors.size;
|
||||
|
||||
for(int i = 0; i < size; i ++){
|
||||
var sector = (Sector)sectors[i];
|
||||
|
||||
if(sector.hasEnemyBase()){
|
||||
dst = Math.min(dst, position.dst(sector.tile.v));
|
||||
}
|
||||
}
|
||||
|
||||
float freq = 0.05f;
|
||||
float freq = 0.05f, freq2 = 0.07f;
|
||||
|
||||
if(dst*0.85f + Simplex.noise3d(seed, 3, 0.4, 5.5f, position.x, position.y + 200f, position.z)*0.015f + ((basePos.dst(position) + 0.00f) % freq < freq/2f ? 1f : 0f) * 0.07f < 0.15f){
|
||||
return Blocks.metalFloor;
|
||||
return ((basePos.dst(position) + 0.01f) % freq2 < freq2*0.65f) ? Blocks.metalFloor : Blocks.darkPanel6;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -14,7 +14,7 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class TantrosPlanetGenerator extends PlanetGenerator{
|
||||
Color c1 = Color.valueOf("5057a6"), c2 = Color.valueOf("272766"), out = new Color();
|
||||
Color c1 = Color.valueOf("5057a6"), c2 = Color.valueOf("272766");
|
||||
|
||||
Block[][] arr = {
|
||||
{Blocks.redmat, Blocks.redmat, Blocks.darksand, Blocks.bluemat, Blocks.bluemat}
|
||||
@@ -30,9 +30,9 @@ public class TantrosPlanetGenerator extends PlanetGenerator{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getColor(Vec3 position){
|
||||
public void getColor(Vec3 position, Color out){
|
||||
float depth = Simplex.noise3d(seed, 2, 0.56, 1.7f, position.x, position.y, position.z) / 2f;
|
||||
return c1.write(out).lerp(c2, Mathf.clamp(Mathf.round(depth, 0.15f))).a(1f - 0.2f);
|
||||
out.set(c1).lerp(c2, Mathf.clamp(Mathf.round(depth, 0.15f))).a(1f - 0.2f).toFloatBits();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user