mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-20 17:28:14 +07:00
Non-stupid shockwave shader uniform setting
This commit is contained in:
parent
8af96999b0
commit
3847434c42
@ -472,7 +472,7 @@ public class Damage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//cap radius to prevent lag
|
//cap radius to prevent lag
|
||||||
float radius = Math.min(baseRadius, 30), rad2 = radius * radius;
|
float radius = Math.min(baseRadius, 100), rad2 = radius * radius;
|
||||||
int rays = Mathf.ceil(radius * 2 * Mathf.pi);
|
int rays = Mathf.ceil(radius * 2 * Mathf.pi);
|
||||||
double spacing = Math.PI * 2.0 / rays;
|
double spacing = Math.PI * 2.0 / rays;
|
||||||
damages.clear();
|
damages.clear();
|
||||||
|
@ -359,21 +359,15 @@ public class Shaders{
|
|||||||
public static class ShockwaveShader extends LoadShader{
|
public static class ShockwaveShader extends LoadShader{
|
||||||
static final int max = 64;
|
static final int max = 64;
|
||||||
static final int size = 5;
|
static final int size = 5;
|
||||||
static final String[] uniformNames = new String[max];
|
|
||||||
|
|
||||||
//x y radius life[1-0] lifetime
|
//x y radius life[1-0] lifetime
|
||||||
protected FloatSeq data = new FloatSeq();
|
protected FloatSeq data = new FloatSeq();
|
||||||
|
protected FloatSeq uniforms = new FloatSeq();
|
||||||
protected boolean hadAny = false;
|
protected boolean hadAny = false;
|
||||||
protected FrameBuffer buffer = new FrameBuffer();
|
protected FrameBuffer buffer = new FrameBuffer();
|
||||||
|
|
||||||
public float lifetime = 20f;
|
public float lifetime = 20f;
|
||||||
|
|
||||||
static{
|
|
||||||
for(int i = 0; i < max; i++){
|
|
||||||
uniformNames[i] = "u_shockwaves[" + i + "]";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ShockwaveShader(){
|
public ShockwaveShader(){
|
||||||
super("shockwave", "screenspace");
|
super("shockwave", "screenspace");
|
||||||
|
|
||||||
@ -429,17 +423,21 @@ public class Shaders{
|
|||||||
setUniformf("u_resolution", Core.camera.width, Core.camera.height);
|
setUniformf("u_resolution", Core.camera.width, Core.camera.height);
|
||||||
setUniformf("u_campos", Core.camera.position.x - Core.camera.width/2f, Core.camera.position.y - Core.camera.height/2f);
|
setUniformf("u_campos", Core.camera.position.x - Core.camera.width/2f, Core.camera.position.y - Core.camera.height/2f);
|
||||||
|
|
||||||
|
uniforms.clear();
|
||||||
|
|
||||||
var items = data.items;
|
var items = data.items;
|
||||||
for(int i = 0; i < count; i++){
|
for(int i = 0; i < count; i++){
|
||||||
int offset = i * size;
|
int offset = i * size;
|
||||||
|
|
||||||
setUniformf(uniformNames[i],
|
uniforms.add(
|
||||||
items[offset], items[offset + 1], //xy
|
items[offset], items[offset + 1], //xy
|
||||||
items[offset + 2] * (1f - items[offset + 3]), //radius * time
|
items[offset + 2] * (1f - items[offset + 3]), //radius * time
|
||||||
items[offset + 3] //time
|
items[offset + 3] //time
|
||||||
//lifetime ignored
|
//lifetime ignored
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setUniform4fv("u_shockwaves", uniforms.items, 0, uniforms.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ public class TypeIO{
|
|||||||
/** @return the maximum acceptable amount of plans to send over the network */
|
/** @return the maximum acceptable amount of plans to send over the network */
|
||||||
public static int getMaxPlans(Queue<BuildPlan> plans){
|
public static int getMaxPlans(Queue<BuildPlan> plans){
|
||||||
//limit to prevent buffer overflows
|
//limit to prevent buffer overflows
|
||||||
int used = Math.min(plans.size, 15);
|
int used = Math.min(plans.size, 20);
|
||||||
int totalLength = 0;
|
int totalLength = 0;
|
||||||
|
|
||||||
//prevent buffer overflow by checking config length
|
//prevent buffer overflow by checking config length
|
||||||
|
Loading…
Reference in New Issue
Block a user