GL Thermal rendering working for + and S thermals
--- a/src/data/shaders/2D.fs
+++ b/src/data/shaders/2D.fs
@@ -7,6 +7,7 @@
uniform float innerRadius;
uniform float startAngle;
uniform float sweep;
+uniform float shaveInside;
uniform bool arcEnabled;
uniform bool roundPoints;
@@ -20,6 +21,10 @@
discard;
if(arcEnabled){
+
+ if(abs(gl_PointCoord.x - 0.5) < shaveInside || abs(gl_PointCoord.y - 0.5) < shaveInside)
+ discard;
+
float y_dif = gl_PointCoord.y - 0.5;
if(inverted)
y_dif = y_dif * -1.0;
--- a/src/js/circuit/PCB/ElementArc.js
+++ b/src/js/circuit/PCB/ElementArc.js
@@ -66,7 +66,7 @@
gl.uniform1f(shaderProgram.invertedUniform, false);
gl.uniform1f(shaderProgram.startAngleUniform, (this.start / 180.0 * Math.PI) - Math.PI);
gl.uniform1f(shaderProgram.sweepUniform, (this.sweep / 180.0 * Math.PI));
-
+
gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
--- a/src/js/circuit/PCB/Layer.js
+++ b/src/js/circuit/PCB/Layer.js
@@ -87,12 +87,12 @@
gl.uniform4f(shaderProgram.vColorUniform, 0.0, 0.0, 0.0, 0.0);
for(i = 0; i < this.parts.length; i++)
this.parts[i].clearGL(gl, shaderProgram);
- if(pins)
- for(i = 0; i < pins.parts.length; i++)
- pins.parts[i].clearGL(gl, shaderProgram);
if(elements)
for(i = 0; i < elements.parts.length; i++)
elements.parts[i].clearGL(gl, shaderProgram);
+ if(pins)
+ for(i = 0; i < pins.parts.length; i++)
+ pins.parts[i].clearGL(gl, shaderProgram, this.number);
}
// render non clear polygons
@@ -100,6 +100,12 @@
for(i = 0; i < this.polygons.length; i++)
if(!this.polygons[i].isClear())
this.polygons[i].renderGL(gl, shaderProgram);
+
+ // Clear centers
+ gl.uniform4f(shaderProgram.vColorUniform, 0.0, 0.0, 0.0, 0.0);
+ if(pins)
+ for(i = 0; i < pins.parts.length; i++)
+ pins.parts[i].clearInnerGL(gl, shaderProgram);
}
--- a/src/js/circuit/PCB/Pin.js
+++ b/src/js/circuit/PCB/Pin.js
@@ -77,7 +77,7 @@
if(thrm){
thrm = Thermal.findThermal(thrm, layerNumber);
if(thrm)
- thrm.clear(ctx, this._cache.x, this._cache.y, this.clearance, this.thick, this.drill);
+ thrm.clear(ctx, this.pointBuffer, this.clearance, this.thick, this.drill);
}
if(!thrm){
@@ -122,18 +122,27 @@
}
- Pin.prototype.clearGL = function(gl, shaderProgram){
+ Pin.prototype.clearGL = function(gl, shaderProgram, layerNumber){
- gl.uniform1f(shaderProgram.roundPointsUniform, !this.flags.square);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
- gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
-
- gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
- gl.uniform1f(shaderProgram.pointsizeUniform, (this.thick + this.clearance) * gl.scaleFactor);
- gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
-
- gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ var thrm = this.flags.thermal;
+ if(thrm){
+ thrm = Thermal.findThermal(thrm, layerNumber);
+ if(thrm)
+ thrm.clearGL(gl, shaderProgram, this.pointBuffer, this.clearance, this.thick, this.drill);
+ }
+
+ if(!thrm){
+ gl.uniform1f(shaderProgram.roundPointsUniform, !this.flags.square);
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+ gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+ gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+ gl.uniform1f(shaderProgram.pointsizeUniform, (this.thick + this.clearance) * gl.scaleFactor);
+ gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ }
};
@@ -147,7 +156,21 @@
}
}
-
+
+ Pin.prototype.clearInnerGL = function(gl, shaderProgram){
+ gl.uniform1f(shaderProgram.roundPointsUniform, true);
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+ gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+ gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+
+ gl.uniform1f(shaderProgram.pointsizeUniform, this.id * gl.scaleFactor);
+ gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ };
+
Pin.prototype.setup3DArrayBuffer = function(gl, x, y){
var vBuffer;
--- a/src/js/circuit/PCB/Renderers/GLRenderer.js
+++ b/src/js/circuit/PCB/Renderers/GLRenderer.js
@@ -90,6 +90,7 @@
this.shaderProgram.sweepUniform = gl.getUniformLocation(this.shaderProgram, "sweep");
this.shaderProgram.arcEnabledUniform = gl.getUniformLocation(this.shaderProgram, "arcEnabled");
this.shaderProgram.invertedUniform = gl.getUniformLocation(this.shaderProgram, "inverted");
+ this.shaderProgram.shaveInsideUniform = gl.getUniformLocation(this.shaderProgram, "shaveInside");
// Texture Shader
this.texShaderProgram = GLHelper.createProgram(gl,
--- a/src/js/circuit/PCB/Thermal.js
+++ b/src/js/circuit/PCB/Thermal.js
@@ -121,6 +121,51 @@
};
+ Thermal._clearArc = function(gl, shaderProgram, pointBuffer, ang1, ang2, outerDiameter, innerDiameter, clearance){
+
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, pointBuffer);
+ gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, true);
+ gl.uniform1f(shaderProgram.arcEnabledUniform, true);
+ gl.uniform1f(shaderProgram.innerRadiusUniform, innerDiameter / outerDiameter / 2);
+ gl.uniform1f(shaderProgram.pointsizeUniform, outerDiameter * gl.scaleFactor);
+ gl.uniform1f(shaderProgram.startAngleUniform, ang1 + ang2);
+ gl.uniform1f(shaderProgram.sweepUniform, Math.PI / 2 - ang2 * 2);
+ gl.uniform1f(shaderProgram.shaveInsideUniform, clearance / outerDiameter / 4);
+ gl.drawArrays(gl.POINTS, 0, pointBuffer.numItems);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ gl.uniform1f(shaderProgram.arcEnabledUniform, false);
+ gl.uniform1f(shaderProgram.shaveInsideUniform, 0.0);
+
+ };
+
+ Thermal.prototype.clearGL = function(gl, shaderProgram, pointBuffer, clearance, outerDiameter, innerDiameter){
+ switch(this.type){
+ case 'S':
+ break;
+ case 't':
+ break;
+ case 'X':
+ break;
+ case '+':
+ var radius = (clearance + outerDiameter) / 2;
+ var clearanceAngle = clearance / radius / 4;
+ Thermal._clearArc(gl, shaderProgram, pointBuffer, 0, clearanceAngle, outerDiameter + clearance, outerDiameter, clearance);
+ Thermal._clearArc(gl, shaderProgram, pointBuffer, Math.PI * 0.5, clearanceAngle, outerDiameter + clearance, outerDiameter, clearance);
+ Thermal._clearArc(gl, shaderProgram, pointBuffer, Math.PI, clearanceAngle, outerDiameter + clearance, outerDiameter, clearance);
+ Thermal._clearArc(gl, shaderProgram, pointBuffer, Math.PI * 1.5, clearanceAngle, outerDiameter + clearance, outerDiameter, clearance);
+ break;
+ case 'O':
+ break;
+ default:
+ break;
+ }
+ };
+
return Thermal;
}
--- a/src/js/circuit/PCB/Via.js
+++ b/src/js/circuit/PCB/Via.js
@@ -71,7 +71,7 @@
gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
-
+
gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
gl.uniform4f(shaderProgram.vColorUniform, 0.59, 0.59, 0.59, 1.0);
@@ -86,20 +86,28 @@
}
- Via.prototype.clearGL = function(gl, shaderProgram){
+ Via.prototype.clearGL = function(gl, shaderProgram, layerNumber){
- gl.uniform1f(shaderProgram.roundPointsUniform, true);
-
- gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
- gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
-
- gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
-
- gl.uniform1f(shaderProgram.pointsizeUniform, (this.od + this.clearance) * gl.scaleFactor);
- gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
-
-
- gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ var thrm = this.flags.thermal;
+ if(thrm){
+ thrm = Thermal.findThermal(thrm, layerNumber);
+ if(thrm)
+ thrm.clearGL(gl, shaderProgram, this.pointBuffer, this.clearance, this.od, this.id);
+ }
+
+ if(!thrm){
+ gl.uniform1f(shaderProgram.roundPointsUniform, true);
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+ gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+ gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+
+ gl.uniform1f(shaderProgram.pointsizeUniform, (this.od + this.clearance) * gl.scaleFactor);
+ gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ }
};
@@ -113,7 +121,21 @@
}
}
-
+
+ Via.prototype.clearInnerGL = function(gl, shaderProgram){
+ gl.uniform1f(shaderProgram.roundPointsUniform, true);
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, this.pointBuffer);
+ gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, this.pointBuffer.itemSize, gl.FLOAT, false, 0, 0);
+
+ gl.uniform1f(shaderProgram.innerRadiusUniform, 0.0);
+
+ gl.uniform1f(shaderProgram.pointsizeUniform, this.id * gl.scaleFactor);
+ gl.drawArrays(gl.POINTS, 0, this.pointBuffer.numItems);
+
+ gl.uniform1f(shaderProgram.roundPointsUniform, false);
+ };
+
Via.prototype.setup3DArrayBuffer = function(gl){
var vBuffer;