Add stroke drawing functionality to the mesh debugger.
It's disabled by default, but it can be enabled by editing the code.
This commit is contained in:
parent
f04f39afd6
commit
f58d3a8512
|
@ -52,6 +52,7 @@ const SEGMENT_POINT_FILL_STYLE: string = "rgb(0, 0, 128)";
|
||||||
const LIGHT_STROKE_STYLE: string = "rgb(192, 192, 192)";
|
const LIGHT_STROKE_STYLE: string = "rgb(192, 192, 192)";
|
||||||
const LINE_STROKE_STYLE: string = "rgb(0, 128, 0)";
|
const LINE_STROKE_STYLE: string = "rgb(0, 128, 0)";
|
||||||
const CURVE_STROKE_STYLE: string = "rgb(128, 0, 0)";
|
const CURVE_STROKE_STYLE: string = "rgb(128, 0, 0)";
|
||||||
|
const SEGMENT_LINE_STROKE_STYLE: string = "rgb(128, 192, 128)";
|
||||||
const SEGMENT_CONTROL_POINT_FILL_STYLE: string = "rgb(255, 255, 255)";
|
const SEGMENT_CONTROL_POINT_FILL_STYLE: string = "rgb(255, 255, 255)";
|
||||||
const SEGMENT_CONTROL_POINT_STROKE_STYLE: string = "rgb(0, 0, 128)";
|
const SEGMENT_CONTROL_POINT_STROKE_STYLE: string = "rgb(0, 0, 128)";
|
||||||
const SEGMENT_CONTROL_POINT_HULL_STROKE_STYLE: string = "rgba(128, 128, 128, 0.5)";
|
const SEGMENT_CONTROL_POINT_HULL_STROKE_STYLE: string = "rgba(128, 128, 128, 0.5)";
|
||||||
|
@ -228,6 +229,7 @@ class MeshDebuggerView extends PathfinderView {
|
||||||
private drawControl: boolean = true;
|
private drawControl: boolean = true;
|
||||||
private drawNormals: boolean = true;
|
private drawNormals: boolean = true;
|
||||||
private drawVertices: boolean = true;
|
private drawVertices: boolean = true;
|
||||||
|
private drawSegments: boolean = false;
|
||||||
|
|
||||||
constructor(appController: MeshDebuggerAppController) {
|
constructor(appController: MeshDebuggerAppController) {
|
||||||
super();
|
super();
|
||||||
|
@ -393,7 +395,8 @@ class MeshDebuggerView extends PathfinderView {
|
||||||
2,
|
2,
|
||||||
invScaleFactor,
|
invScaleFactor,
|
||||||
this.drawControl,
|
this.drawControl,
|
||||||
this.drawNormals);
|
this.drawNormals,
|
||||||
|
this.drawSegments);
|
||||||
drawSegmentVertices(context,
|
drawSegmentVertices(context,
|
||||||
new Float32Array(meshes.segmentCurves),
|
new Float32Array(meshes.segmentCurves),
|
||||||
new Float32Array(meshes.segmentCurveNormals),
|
new Float32Array(meshes.segmentCurveNormals),
|
||||||
|
@ -403,7 +406,8 @@ class MeshDebuggerView extends PathfinderView {
|
||||||
3,
|
3,
|
||||||
invScaleFactor,
|
invScaleFactor,
|
||||||
this.drawControl,
|
this.drawControl,
|
||||||
this.drawNormals);
|
this.drawNormals,
|
||||||
|
this.drawSegments);
|
||||||
}
|
}
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
@ -455,7 +459,8 @@ function drawSegmentVertices(context: CanvasRenderingContext2D,
|
||||||
segmentSize: number,
|
segmentSize: number,
|
||||||
invScaleFactor: number,
|
invScaleFactor: number,
|
||||||
drawControl: boolean,
|
drawControl: boolean,
|
||||||
drawNormals: boolean) {
|
drawNormals: boolean,
|
||||||
|
drawSegments: boolean) {
|
||||||
for (let segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) {
|
for (let segmentIndex = 0; segmentIndex < segmentCount; segmentIndex++) {
|
||||||
const positionStartOffset = segmentSize * 2 * segmentIndex;
|
const positionStartOffset = segmentSize * 2 * segmentIndex;
|
||||||
const normalStartOffset = segmentSize * segmentIndex;
|
const normalStartOffset = segmentSize * segmentIndex;
|
||||||
|
@ -506,6 +511,17 @@ function drawSegmentVertices(context: CanvasRenderingContext2D,
|
||||||
context.restore();
|
context.restore();
|
||||||
drawSegmentControlPoint(context, controlPoint, invScaleFactor);
|
drawSegmentControlPoint(context, controlPoint, invScaleFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(pcwalton): Draw the curves too.
|
||||||
|
if (drawSegments) {
|
||||||
|
context.save();
|
||||||
|
context.strokeStyle = SEGMENT_LINE_STROKE_STYLE;
|
||||||
|
context.beginPath();
|
||||||
|
context.moveTo(position0[0], -position0[1]);
|
||||||
|
context.lineTo(position1[0], -position1[1]);
|
||||||
|
context.stroke();
|
||||||
|
context.restore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue