use video pixel buffer for raycasting

pull/95/head
jmoenig 2020-12-03 17:29:16 +01:00
rodzic 816186f17d
commit 9fcaf64300
2 zmienionych plików z 4 dodań i 11 usunięć

Wyświetl plik

@ -2104,19 +2104,12 @@ SpriteMorph.prototype.getImageData = function () {
).data;
this.imageData = {
version : this.version,
pixels : new Uint32Array(imageData.buffer.slice(0)),
full : imageData // +++ get rid of this
pixels : new Uint32Array(imageData.buffer.slice(0))
};
}
return this.imageData.pixels;
};
SpriteMorph.prototype.getFullImageData = function () {
// temporary hack for raycasting. // +++
this.getImageData();
return this.imageData.full;
};
SpriteMorph.prototype.projectionSnap = function() {
var stage = this.parentThatIsA(StageMorph),
center = this.center().subtract(stage.position())

Wyświetl plik

@ -4933,13 +4933,13 @@ Process.prototype.reportDistanceFacing = function (name) {
*/
width = Math.floor(targetBounds.width() / stage.scale); // +++
imageData = thatObj.getFullImageData(); // +++
imageData = thatObj.getImageData(); // +++
// scan the ray along the coordinates of a Bresenham line
// for the first opaque pixel
function alphaAt(imageData, width, x, y) {
var idx = (y * width * 4) + x * 4;
return imageData[idx + 3];
var idx = y * width + x;
return imageData[idx] && 0x000000FF; // alpha
}
function isOpaque(x, y) {